github.com/holoplot/go-evdev@v0.0.0-20220721205823-d31c64b9d636/types.go (about) 1 package evdev 2 3 import ( 4 "fmt" 5 "syscall" 6 ) 7 8 // EvType is EV_KEY, EV_SW, EV_LED, EV_SND, ... 9 type EvType uint16 10 11 // EvCode describes codes within a type (eg. KEY_A, KEY_B, ...) 12 type EvCode uint16 13 14 // EvProp describes device properties (eg. INPUT_PROP_ACCELEROMETER, INPUT_PROP_BUTTONPAD, ...) 15 type EvProp uint16 16 17 // StateMap describes the current state of codes within a type, as booleans. 18 type StateMap map[EvCode]bool 19 20 // InputEvent describes an event that is generated by an InputDevice 21 type InputEvent struct { 22 Time syscall.Timeval // time in seconds since epoch at which event occurred 23 Type EvType // event type - one of ecodes.EV_* 24 Code EvCode // event code related to the event type 25 Value int32 // event value related to the event type 26 } 27 28 func (e *InputEvent) TypeName() string { 29 return TypeName(e.Type) 30 } 31 32 func (e *InputEvent) CodeName() string { 33 return CodeName(e.Type, e.Code) 34 } 35 36 func (e *InputEvent) String() string { 37 return fmt.Sprintf( 38 "type: 0x%02x [%s], code: 0x%02x [%s], value: %d", 39 e.Type, e.TypeName(), e.Code, e.CodeName(), e.Value, 40 ) 41 } 42 43 // InputID ... 44 type InputID struct { 45 BusType uint16 46 Vendor uint16 47 Product uint16 48 Version uint16 49 } 50 51 // AbsInfo describes details on ABS input types 52 type AbsInfo struct { 53 Value int32 54 Minimum int32 55 Maximum int32 56 Fuzz int32 57 Flat int32 58 Resolution int32 59 } 60 61 // InputKeymapEntry is used to retrieve and modify keymap data 62 type InputKeymapEntry struct { 63 Flags uint8 64 Len uint8 65 Index uint16 66 KeyCode uint32 67 ScanCode [32]uint8 68 } 69 70 // InputMask ... 71 type InputMask struct { 72 Type uint32 73 CodesSize uint32 74 CodesPtr uint64 75 } 76 77 // UinputUserDevice is used when creating or cloning a device 78 type UinputUserDevice struct { 79 Name [uinputMaxNameSize]byte 80 ID InputID 81 EffectsMax uint32 82 Absmax [absSize]int32 83 Absmin [absSize]int32 84 Absfuzz [absSize]int32 85 Absflat [absSize]int32 86 }