evdev

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2021 License: BSD-1-Clause Imports: 10 Imported by: 2

README

About evdev

evdev is a libevdev inspired Go package for working with Linux input devices. evdev works by making ioctl system calls for the Linux input and uinput subsystems. Because evdev is written in pure Go, it can be used without CGO.

evdev is used to poll events from, and send events to /dev/input/event* devices. Additionally, evdev provides the ability to create virtual uinput devices that can be used similarly.

evdev is a rewrite of the github.com/jteeuwen/evdev package. Most of the credit for this package goes to jteeuwen for the original (and amazing!) work done.

Installing

evdev can be installed in the usual Go fashion:

$ go get -u github.com/kenshaw/evdev

Using

Please see the examples directory for more examples.

Permission Issues

Reading events from input devices or creating virtual uinput devices requires $USER to have the appropriate system-level permissions. This can be accomplished by adding $USER to a group with read/write access to /dev/input/event* and uinput block devices.

Please refer to your relevant Linux distribution's documentation on adding $USER to the appropriate system group, or otherwise allowing read/write access to /dev/input/event* and uinput devices.

Note: if adding a group to the current $USER, it will be necessary to log out and log back in before the system recognizes the group membership.

Ubuntu/Debian

On Ubuntu/Debian systems, the current $USER can be added to the input group:

$ sudo adduser $USER input

Documentation

Overview

Package evdev is a pure Go implementation of the Linux evdev API.

Index

Constants

View Source
const (
	// DefaultPollSize is the default number of events to poll.
	DefaultPollSize = 64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsoluteType added in v0.1.1

type AbsoluteType int

AbsoluteType is the absolute axis event type.

Absolute events describe absolute changes in a property. For example, a touchpad may emit coordinates for a touch location. A few codes have special meanings:

AbsoluteDistance is used to describe the distance of a tool from an interaction surface. This event should only be emitted while the tool is hovering, meaning in close proximity to the device and while the value of the BtnTouch code is 0. If the input device may be used freely in three dimensions, consider AbsoluteZ instead.

AbsoluteMT<name> is used to describe multitouch input events.

const (
	AbsoluteX             AbsoluteType = 0x00
	AbsoluteY             AbsoluteType = 0x01
	AbsoluteZ             AbsoluteType = 0x02
	AbsoluteRX            AbsoluteType = 0x03
	AbsoluteRY            AbsoluteType = 0x04
	AbsoluteRZ            AbsoluteType = 0x05
	AbsoluteThrottle      AbsoluteType = 0x06
	AbsoluteRudder        AbsoluteType = 0x07
	AbsoluteWheel         AbsoluteType = 0x08
	AbsoluteGas           AbsoluteType = 0x09
	AbsoluteBrake         AbsoluteType = 0x0a
	AbsoluteHat0X         AbsoluteType = 0x10
	AbsoluteHat0Y         AbsoluteType = 0x11
	AbsoluteHat1X         AbsoluteType = 0x12
	AbsoluteHat1Y         AbsoluteType = 0x13
	AbsoluteHat2X         AbsoluteType = 0x14
	AbsoluteHat2Y         AbsoluteType = 0x15
	AbsoluteHat3X         AbsoluteType = 0x16
	AbsoluteHat3Y         AbsoluteType = 0x17
	AbsolutePressure      AbsoluteType = 0x18
	AbsoluteDistance      AbsoluteType = 0x19
	AbsoluteTiltX         AbsoluteType = 0x1a
	AbsoluteTiltY         AbsoluteType = 0x1b
	AbsoluteToolWidth     AbsoluteType = 0x1c
	AbsoluteVolume        AbsoluteType = 0x20
	AbsoluteMisc          AbsoluteType = 0x28
	AbsoluteMTSlot        AbsoluteType = 0x2f // MT slot being modified
	AbsoluteMTTouchMajor  AbsoluteType = 0x30 // Major axis of touching ellipse
	AbsoluteMTTouchMinor  AbsoluteType = 0x31 // Minor axis (omit if circular)
	AbsoluteMTWidthMajor  AbsoluteType = 0x32 // Major axis of approaching ellipse
	AbsoluteMTWidthMinor  AbsoluteType = 0x33 // Minor axis (omit if circular)
	AbsoluteMTOrientation AbsoluteType = 0x34 // Ellipse orientation
	AbsoluteMTPositionX   AbsoluteType = 0x35 // Center X touch position
	AbsoluteMTPositionY   AbsoluteType = 0x36 // Center Y touch position
	AbsoluteMTToolType    AbsoluteType = 0x37 // Type of touching device
	AbsoluteMTBlobID      AbsoluteType = 0x38 // Group a set of packets as a blob
	AbsoluteMTTrackingID  AbsoluteType = 0x39 // Unique ID of initiated contact
	AbsoluteMTPressure    AbsoluteType = 0x3a // Pressure on contact area
	AbsoluteMTDistance    AbsoluteType = 0x3b // Contact hover distance
	AbsoluteMTToolX       AbsoluteType = 0x3c // Center X tool position
	AbsoluteMTToolY       AbsoluteType = 0x3d // Center Y tool position

)

Absolute axis event types.

func (AbsoluteType) String added in v0.1.1

func (i AbsoluteType) String() string

type Axis added in v0.1.1

type Axis struct {
	// Val is the axis value.
	Val int32

	// Min is the axis minimum.
	Min int32

	// Max is the axis maximum.
	Max int32

	// Fuzz is the axis fuzz factor.
	Fuzz int32

	// Flat is the axis' flat section size.
	Flat int32

	// Res is the axis resolution.
	Res int32
}

Axis provides information for a specific absolute axis. This applies to devices which support EventAbsolute events.

type BusType added in v0.1.1

type BusType uint16

BusType is the device bus type.

const (
	BusPCI          BusType = 0x01
	BusISAPNP       BusType = 0x02
	BusUSB          BusType = 0x03
	BusHIL          BusType = 0x04
	BusBluetooth    BusType = 0x05
	BusVirtual      BusType = 0x06
	BusISA          BusType = 0x10
	BusI8042        BusType = 0x11
	BusXTKBD        BusType = 0x12
	BusRS232        BusType = 0x13
	BusGamePort     BusType = 0x14
	BusParallelPort BusType = 0x15
	BusAmiga        BusType = 0x16
	BusADB          BusType = 0x17
	BusI2C          BusType = 0x18
	BusHost         BusType = 0x19
	BusGSC          BusType = 0x1a
	BusAtari        BusType = 0x1b
	BusSPI          BusType = 0x1c
	BusRMI          BusType = 0x1d
	BusCEC          BusType = 0x1e
	BusIntelISHTP   BusType = 0x1f
)

BusType values.

func (BusType) String added in v0.1.1

func (i BusType) String() string

type ConditionEffect

type ConditionEffect struct {
	SaturationRight uint16
	SaturationLeft  uint16
	CoeffRight      int16
	CoeffLeft       int16
	Deadband        uint16
	Center          int16
}

ConditionEffect wraps the data for a condition force feedback effect.

type ConstantEffect

type ConstantEffect struct {
	Level    int16
	Envelope EffectEnvelope
}

ConstantEffect wraps the data for a constant force feedback effect.

type Effect

type Effect struct {
	Type      EffectType
	ID        int16
	Direction EffectDirType
	Trigger   EffectTrigger
	Replay    EffectReplay
	// contains filtered or unexported fields
}

Effect describes a force feedback effect.

Supported effects are as follows:

  • EffectRumble rumble effects

  • EffectPeriodic periodic effects (using waveform):

  • EffectSquare square waveform

  • EffectTriangle triangle waveform

  • EffectSine sine waveform

  • EffectSawUp sawtooth up waveform

  • EffectSawDown sawtooth down waveform

  • EffectCustom custom waveform

  • EffectConstant renders constant force effects

  • EffectSpring simulates the presence of a spring

  • EffectFriction simulates friction

  • EffectDamper simulates damper effects

  • EffectInertia simulates inertia

  • EffectRamp simulates ramp effects

    Supported adjustments:

  • EffectPropGain gain adjust

  • EffectPropAutoCenter auto center adjust

Note: In most cases you should use EffectPeriodic instead of EffectRumble. All devices that support EffectRumble support EffectPeriodic (square, triangle, sine) and the other way around.

Note: The exact layout of EffectCustom waveforms is undefined for the time being as no driver supports it yet.

Note: All duration values are expressed in milliseconds. Values above 32767 ms (0x7fff) should not be used and have unspecified results.

func NewEffect added in v0.1.1

func NewEffect(typ EffectType, opts ...EffectOption) *Effect

NewEffect wraps creating an effect.

func (*Effect) Data

func (e *Effect) Data() interface{}

Data returns the event data structure as a concrete type. Its type depends on the value of Effect.Type and can be any of:

EffectConstant -> ConstantEffect
EffectPeriodic -> PeriodicEffect
EffectRamp     -> RampEffect
EffectRumble   -> RumbleEffect
EffectSpring   -> [2]ConditionEffect
EffectDamper   -> [2]ConditionEffect

This returns nil if the type was not recognized.

func (*Effect) SetData

func (e *Effect) SetData(v interface{})

SetData sets the event data structure.

type EffectDirType added in v0.1.1

type EffectDirType uint16

EffectDirType is the force feedback effect direction type.

const (
	EffectDirDown  EffectDirType = 0x0000 // 0 degrees
	EffectDirLeft  EffectDirType = 0x4000 // 90 degrees
	EffectDirUp    EffectDirType = 0x8000 // 180 degrees
	EffectDirRight EffectDirType = 0xc000 // 270 degrees
)

Force feedback effect directions.

func (EffectDirType) String added in v0.1.1

func (i EffectDirType) String() string

type EffectEnvelope added in v0.1.1

type EffectEnvelope struct {
	AttackLength uint16
	AttackLevel  uint16
	FadeLength   uint16
	FadeLevel    uint16
}

EffectEnvelope ...

type EffectOption added in v0.1.1

type EffectOption func(*Effect)

EffectOption is an effect option.

func EffectDirection added in v0.1.1

func EffectDirection(dir EffectDirType) EffectOption

EffectDirection is an effect option to set the effect's direction.

func EffectID added in v0.1.1

func EffectID(id int) EffectOption

EffectID is an effect option to set the effect's ID.

type EffectPropType added in v0.1.1

type EffectPropType int

EffectPropType is the force feedback effect property type.

const (
	EffectPropGain       EffectPropType = 0x60
	EffectPropAutoCenter EffectPropType = 0x61
)

Force feedback effect event types.

func (EffectPropType) String added in v0.1.1

func (i EffectPropType) String() string

type EffectReplay added in v0.1.1

type EffectReplay struct {
	Length uint16
	Delay  uint16
}

EffectReplay ...

type EffectStatusType added in v0.1.1

type EffectStatusType int

EffectStatusType is the force feedback effect status event type.

const (
	EffectStatusStopped EffectStatusType = 0x00
	EffectStatusPlaying EffectStatusType = 0x01
)

Force feedback status event values.

func (EffectStatusType) String added in v0.1.1

func (i EffectStatusType) String() string

type EffectTrigger added in v0.1.1

type EffectTrigger struct {
	Button   uint16
	Interval uint16
}

EffectTrigger ...

type EffectType added in v0.1.1

type EffectType int

EffectType is the force feedback effect type.

const (
	EffectRumble   EffectType = 0x50
	EffectPeriodic EffectType = 0x51
	EffectConstant EffectType = 0x52
	EffectSpring   EffectType = 0x53
	EffectFriction EffectType = 0x54
	EffectDamper   EffectType = 0x55
	EffectInertia  EffectType = 0x56
	EffectRamp     EffectType = 0x57

	// periodic effect types
	EffectSquare   EffectType = 0x58
	EffectTriangle EffectType = 0x59
	EffectSine     EffectType = 0x5a
	EffectSawUp    EffectType = 0x5b
	EffectSawDown  EffectType = 0x5c
	EffectCustom   EffectType = 0x5d
)

Force feedback effect event types.

func (EffectType) String added in v0.1.1

func (i EffectType) String() string

type Evdev added in v0.1.1

type Evdev struct {
	// contains filtered or unexported fields
}

Evdev represents an evdev device.

func Open

func Open(fd *os.File) *Evdev

Open creates a device from an open file descriptor.

func OpenFile added in v0.1.1

func OpenFile(path string) (*Evdev, error)

OpenFile opens device from the file path (ie, /dev/input/event*).

func (*Evdev) AbsoluteTypes added in v0.1.1

func (d *Evdev) AbsoluteTypes() map[AbsoluteType]Axis

AbsoluteTypes returns a map of the supported absolute axis types.

This is only applicable to devices with EventAbsolute event support.

func (*Evdev) Close added in v0.1.1

func (d *Evdev) Close() error

Close closes the underlying device file descriptor.

func (*Evdev) EffectAutoCenterSet added in v0.1.1

func (d *Evdev) EffectAutoCenterSet(factor int)

EffectAutoCenterSet changes the force feedback autocenter factor. The specified factor should be in the range 0-100. A value of 0 means: no autocenter.

This is only applicable to devices with EventForceFeedback event support.

func (*Evdev) EffectGainSet added in v0.1.1

func (d *Evdev) EffectGainSet(gain int)

EffectGainSet changes the force feedback gain.

Not all devices have the same effect strength. Therefore, users should set a gain factor depending on how strong they want effects to be. This setting is persistent across access to the driver.

The specified gain should be in the range 0-100. This is only applicable to devices with EventForceFeedback event support.

func (*Evdev) EffectMax added in v0.1.1

func (d *Evdev) EffectMax() int

EffectMax retrieves the maximum number of force feedback effects supported by the device.

This is only applicable to devices with EventForceFeedback event support.

func (*Evdev) EffectPlay added in v0.1.1

func (d *Evdev) EffectPlay(id EffectType)

EffectPlay plays a previously uploaded effect.

func (*Evdev) EffectSet added in v0.1.1

func (d *Evdev) EffectSet(effect *Effect) error

EffectSet sends the Force Feedback effect to the device. The number of effects sent should not exceed the length of the device's EffectTypes.

After this call completes, the effect.ID field will contain the effect's ID. The effect's ID must be used when playing or stopping the effect. It is also possible to reupload the same effect with the same ID later on with new parameters.

This allows us to update a running effect, without first stopping it.

This is only applicable to devices with EventForceFeedback event support.

func (*Evdev) EffectStatusTypes added in v0.1.1

func (d *Evdev) EffectStatusTypes() map[EffectStatusType]bool

EffectStatusTypes returns the effects events supported by the device.

This is only applicable to devices with EventEffectStatus event support.

func (*Evdev) EffectStop added in v0.1.1

func (d *Evdev) EffectStop(id EffectType)

EffectStop stops a previously uploaded effect from playing.

func (*Evdev) EffectTypes added in v0.1.1

func (d *Evdev) EffectTypes() map[EffectType]bool

EffectTypes returns the force feedback effects supported by the device.

This is only applicable to devices with EventEffect event support.

func (*Evdev) EffectUnset added in v0.1.1

func (d *Evdev) EffectUnset(effect *Effect) error

EffectUnset deletes the given effects from the device. This makes room for new effects in the device's memory. Note that this also stops the effect if it was playing.

This is only applicable to devices with EventForceFeedback event support.

func (*Evdev) EventTypes added in v0.1.1

func (d *Evdev) EventTypes() map[EventType]bool

EventTypes returns the device's supported event types.

func (*Evdev) ID added in v0.1.1

func (d *Evdev) ID() ID

ID returns a device's identity information.

func (*Evdev) IsJoystick added in v0.1.1

func (d *Evdev) IsJoystick() bool

IsJoystick returns true if the device qualifies as a joystick.

func (*Evdev) IsKeyboard added in v0.1.1

func (d *Evdev) IsKeyboard() bool

IsKeyboard returns true if the device qualifies as a keyboard.

func (*Evdev) IsMouse added in v0.1.1

func (d *Evdev) IsMouse() bool

IsMouse returns true if the device qualifies as a mouse.

func (*Evdev) KeyMap added in v0.1.1

func (d *Evdev) KeyMap(key KeyType) KeyMap

KeyMap retrieves the key mapping for the given key.

func (*Evdev) KeyMapSet added in v0.1.1

func (d *Evdev) KeyMapSet(m KeyMap) error

KeyMapSet sets a key map.

This allows us to rewire physical keys -- ie, pressing M, will input N into the input system.

Some input drivers support variable mappings between the keys held down (which are interpreted by the keyboard scan and reported as scancodes) and the events sent to the input layer.

You can change which key is associated with each scancode using this call. The value of the scancode is the first element in the integer array (list[n][0]), and the resulting input event key number (keycode) is the second element in the array. (list[n][1]).

Be aware that the KeyMap functions may not work on every keyboard. This is only applicable to devices with EventKey event support.

func (*Evdev) KeyTypes added in v0.1.1

func (d *Evdev) KeyTypes() map[KeyType]bool

KeyTypes returns the key events supported by the device.

This is only applicable to devices with EventKey event support.

func (*Evdev) LEDTypes added in v0.1.1

func (d *Evdev) LEDTypes() map[LEDType]bool

LEDTypes returns the led events supported by the device.

This is only applicable to devices with EventLED event support.

func (*Evdev) Lock added in v0.1.1

func (d *Evdev) Lock() error

Lock attempts to gain exclusive access to the device.

This means that we are the only ones receiving events from the device; other processes will not.

This ability should be handled with care, especially when trying to lock keyboard access. If this is executed while we are running in something like X, this call will prevent X from receiving any and all keyboard events. All of them will only be sent to our own process. If we do not properly handle these key events, we may lock ourselves out of the system and a hard reset is required to restore it.

func (*Evdev) MiscTypes added in v0.1.1

func (d *Evdev) MiscTypes() map[MiscType]bool

MiscTypes returns the misc events supported by the device.

This is only applicable to devices with EventMisc event support.

func (*Evdev) Name added in v0.1.1

func (d *Evdev) Name() string

Name returns the name of the device.

func (*Evdev) Path added in v0.1.1

func (d *Evdev) Path() string

Path returns the physical path of the device. For example:

usb-00:01.2-2.1/input0

To understand what this string is showing, you need to break it down into parts. `usb` means this is a physical topology from the USB system.

`00:01.2` is the PCI bus information for the USB host controller (in this case, bus 0, slot 1, function 2).

`2.1` shows the path from the root hub to the device. In this case, the upstream hub is plugged in to the second port on the root hub, and that device is plugged in to the first port on the upstream hub.

`input0` means this is the first event interface on the device. Most devices have only one, but multimedia keyboards may present the normal keyboard on one interface and the multimedia function keys on a second interface.

func (*Evdev) Poll added in v0.1.1

func (d *Evdev) Poll(ctxt context.Context) <-chan *EventEnvelope

Poll polls the device for incoming events.

Change the buffer size by specifying PollSize.

Polling continues to run until the context is closed.

func (*Evdev) PowerTypes added in v0.1.1

func (d *Evdev) PowerTypes() map[PowerType]bool

PowerTypes returns the power events supported by the device.

This is only applicable to devices with EventPower event support.

func (*Evdev) Properties added in v0.1.1

func (d *Evdev) Properties() map[PropertyType]bool

Properties returns the device properties.

func (*Evdev) RelativeTypes added in v0.1.1

func (d *Evdev) RelativeTypes() map[RelativeType]bool

RelativeTypes returns a map of the supported relative axis types.

This is only applicable to devices with EventRelative event support.

func (*Evdev) RepeatState added in v0.1.1

func (d *Evdev) RepeatState() (uint, uint)

RepeatState returns the current, global repeat state. This applies only to devices which have the EventRepeat capability defined. This can be determined through `Device.EventTypes()`.

Refer to Device.SetRepeatState for an explanation on what the returned values mean.

This is only applicable to devices with EventRepeat event support.

func (*Evdev) RepeatStateSet added in v0.1.1

func (d *Evdev) RepeatStateSet(initial, subsequent uint) bool

RepeatStateSet sets the repeat state for the given device.

The values indicate (in milliseconds) the delay before the device starts repeating and the delay between subsequent repeats. This might apply to a keyboard where the user presses and holds a key.

E.g.: We see an initial character immediately, then another @initial milliseconds later and after that, once every @subsequent milliseconds, until the key is released.

This returns false if the operation failed.

This is only applicable to devices with EventRepeat event support.

func (*Evdev) Send added in v0.1.1

func (d *Evdev) Send(ev Event) error

Send sends an event to the device.

func (*Evdev) Serial added in v0.1.1

func (d *Evdev) Serial() string

Serial returns the unique serial for the device.

Most devices do not have this and will return an empty string.

func (*Evdev) SoundTypes added in v0.1.1

func (d *Evdev) SoundTypes() map[SoundType]bool

SoundTypes returns the sound events supported by the device.

This is only applicable to devices with EventSound event support.

func (*Evdev) SwitchTypes added in v0.1.1

func (d *Evdev) SwitchTypes() map[SwitchType]bool

SwitchTypes returns the switch events supported by the device.

This is only applicable to devices with EventSwitch event support.

func (*Evdev) SyncTypes added in v0.1.1

func (d *Evdev) SyncTypes() map[SyncType]bool

SyncTypes returns the sync events supported by the device.

This is only applicable to devices with EventSync event support.

func (*Evdev) Unlock added in v0.1.1

func (d *Evdev) Unlock() error

Unlock releases a lock, previously obtained through Lock.

func (*Evdev) Version added in v0.1.1

func (d *Evdev) Version() (int, int, int)

Version returns the major, minor, and revision of the device driver.

type Event

type Event struct {
	Time  syscall.Timeval
	Type  EventType
	Code  uint16
	Value int32
}

Event represents a event.

type EventEnvelope added in v0.1.1

type EventEnvelope struct {
	Event
	Type interface{}
}

EventEnvelope wraps a event.

type EventType added in v0.1.1

type EventType uint16

EventType is the event type.

const (
	EventSync         EventType = 0x00 // Synchronization events.
	EventKey          EventType = 0x01 // Key and button events.
	EventRelative     EventType = 0x02 // Relative axis events (such as a mouse).
	EventAbsolute     EventType = 0x03 // Absolute axis events (such as a joystick).
	EventMisc         EventType = 0x04 // Misc events.
	EventSwitch       EventType = 0x05 // Used to describe stateful binary switches.
	EventLED          EventType = 0x11 // LEDs and similar indications.
	EventSound        EventType = 0x12 // Sound output events.
	EventRepeat       EventType = 0x14 // Repeat key events.
	EventEffect       EventType = 0x15 // Force feedback effect events.
	EventPower        EventType = 0x16 // Power management events.
	EventEffectStatus EventType = 0x17 // Effect status events.

)

Event types.

func (EventType) String added in v0.1.1

func (i EventType) String() string

type ID added in v0.1.1

type ID struct {
	BusType BusType
	Vendor  uint16
	Product uint16
	Version uint16
}

ID represents the device identity.

BusType is the bus type reported by the device (Bluetooth, USB, ...).

The vendor, product and version fields are the device identifiers.

Most modern devices (ie PCI, USB, Bluetooth, ...) devices will correctly provide the vendor and product information, however legacy devices (such as serial mice, keyboards, etc.) will typically not have this information available. As such, these values are only meaningful in the context of interacting with a known, specific device.

type KeyMap added in v0.1.1

type KeyMap struct {
	Flags uint8     // They specify how the kernel should handle a keymap request.
	Len   uint8     // Length of the scancode that resides in Scancode buffer.
	Index uint16    // Index in the keymap, may be used instead of scancode
	Key   uint32    // Key code assigned to this scancode
	Code  [32]uint8 // Scancode represented in machine-endian form.
}

KeyMap is used to retrieve and modify keymap data. Users have option of performing lookup either by @scancode itself or by @index in a keymap entry. Device.KeyMap() will also return scancode or index (depending on which element was used to perform lookup).

type KeyType added in v0.1.1

type KeyType uint32

KeyType is the key event type.

Events take the form Key<name> or Btn<name>. For example, KeyA is used to represent the 'A' key on a keyboard. When a key is depressed, an event with the key's code is emitted with value 1. When the key is released, an event is emitted with value 0. Some hardware send events when a key is repeated. These events have a value of 2. In general, Key<name> is used for keyboard keys, and Btn<name> is used for other types of momentary switch events.

A few codes have special meanings:

  • BtnTool<name>: These codes are used in conjunction with input trackpads, tablets, and touchscreens. These devices may be used with fingers, pens, or other tools. When an event occurs and a tool is used, the corresponding BtnTool<name> code should be set to a value of 1. When the tool is no longer interacting with the input device, the BtnTool<name> code should be reset to 0. All trackpads, tablets, and touchscreens should use at least one BtnTool<name> code when events are generated.

  • BtnTouch: BtnTouch is used for touch contact. While an input tool is determined to be within meaningful physical contact, the value of this property must be set to 1. Meaningful physical contact may mean any contact, or it may mean contact conditioned by an implementation defined property. For example, a touchpad may set the value to 1 only when the touch pressure rises above a certain value. BtnTouch may be combined with BtnTool<name> codes. For example, a pen tablet may set BtnToolPen to 1 and BtnTouch to 0 while the pen is hovering over but not touching the tablet surface.

  • BtnToolFinger, BtnToolDoubleTap, BtnToolTrippleTap, BtnToolQuadTap: These codes denote one, two, three, and four finger interaction on a trackpad or touchscreen. For example, if the user uses two fingers and moves them on the touchpad in an effort to scroll content on screen, BtnToolDoubleTap should be set to value 1 for the duration of the motion. Note that all BtnTool<name> codes and the BtnTouch code are orthogonal in purpose. A trackpad event generated by finger touches should generate events for one code from each group. At most only one of these BtnTool<name> codes should have a value of 1 during any synchronization frame.

const (
	KeyReserved          KeyType = 0
	KeyEscape            KeyType = 1
	Key1                 KeyType = 2
	Key2                 KeyType = 3
	Key3                 KeyType = 4
	Key4                 KeyType = 5
	Key5                 KeyType = 6
	Key6                 KeyType = 7
	Key7                 KeyType = 8
	Key8                 KeyType = 9
	Key9                 KeyType = 10
	Key0                 KeyType = 11
	KeyMinus             KeyType = 12
	KeyEqual             KeyType = 13
	KeyBackSpace         KeyType = 14
	KeyTab               KeyType = 15
	KeyQ                 KeyType = 16
	KeyW                 KeyType = 17
	KeyE                 KeyType = 18
	KeyR                 KeyType = 19
	KeyT                 KeyType = 20
	KeyY                 KeyType = 21
	KeyU                 KeyType = 22
	KeyI                 KeyType = 23
	KeyO                 KeyType = 24
	KeyP                 KeyType = 25
	KeyLeftBrace         KeyType = 26
	KeyRightBrace        KeyType = 27
	KeyEnter             KeyType = 28
	KeyLeftCtrl          KeyType = 29
	KeyA                 KeyType = 30
	KeyS                 KeyType = 31
	KeyD                 KeyType = 32
	KeyF                 KeyType = 33
	KeyG                 KeyType = 34
	KeyH                 KeyType = 35
	KeyJ                 KeyType = 36
	KeyK                 KeyType = 37
	KeyL                 KeyType = 38
	KeySemiColon         KeyType = 39
	KeyApostrophe        KeyType = 40
	KeyGrave             KeyType = 41
	KeyLeftShift         KeyType = 42
	KeyBackSlash         KeyType = 43
	KeyZ                 KeyType = 44
	KeyX                 KeyType = 45
	KeyC                 KeyType = 46
	KeyV                 KeyType = 47
	KeyB                 KeyType = 48
	KeyN                 KeyType = 49
	KeyM                 KeyType = 50
	KeyComma             KeyType = 51
	KeyDot               KeyType = 52
	KeySlash             KeyType = 53
	KeyRightShift        KeyType = 54
	KeyKeypadAsterisk    KeyType = 55
	KeyLeftAlt           KeyType = 56
	KeySpace             KeyType = 57
	KeyCapsLock          KeyType = 58
	KeyF1                KeyType = 59
	KeyF2                KeyType = 60
	KeyF3                KeyType = 61
	KeyF4                KeyType = 62
	KeyF5                KeyType = 63
	KeyF6                KeyType = 64
	KeyF7                KeyType = 65
	KeyF8                KeyType = 66
	KeyF9                KeyType = 67
	KeyF10               KeyType = 68
	KeyNumLock           KeyType = 69
	KeyScrollLock        KeyType = 70
	KeyKeypad7           KeyType = 71
	KeyKeypad8           KeyType = 72
	KeyKeypad9           KeyType = 73
	KeyKeypadMinus       KeyType = 74
	KeyKeypad4           KeyType = 75
	KeyKeypad5           KeyType = 76
	KeyKeypad6           KeyType = 77
	KeyKeypadPlus        KeyType = 78
	KeyKeypad1           KeyType = 79
	KeyKeypad2           KeyType = 80
	KeyKeypad3           KeyType = 81
	KeyKeypad0           KeyType = 82
	KeyKeypadDot         KeyType = 83
	KeyZenkakuHankaku    KeyType = 85
	Key102ND             KeyType = 86
	KeyF11               KeyType = 87
	KeyF12               KeyType = 88
	KeyRO                KeyType = 89
	KeyKatakana          KeyType = 90
	KeyHiragana          KeyType = 91
	KeyHenkan            KeyType = 92
	KeyKatakanaHiragana  KeyType = 93
	KeyMuhenkan          KeyType = 94
	KeyKeypadJPComma     KeyType = 95
	KeyKeypadEnter       KeyType = 96
	KeyRightCtrl         KeyType = 97
	KeyKeypadSlash       KeyType = 98
	KeySysRQ             KeyType = 99
	KeyRightAlt          KeyType = 100
	KeyLineFeed          KeyType = 101
	KeyHome              KeyType = 102
	KeyUp                KeyType = 103
	KeyPageUp            KeyType = 104
	KeyLeft              KeyType = 105
	KeyRight             KeyType = 106
	KeyEnd               KeyType = 107
	KeyDown              KeyType = 108
	KeyPageDown          KeyType = 109
	KeyInsert            KeyType = 110
	KeyDelete            KeyType = 111
	KeyMacro             KeyType = 112
	KeyMute              KeyType = 113
	KeyVolumeDown        KeyType = 114
	KeyVolumeUp          KeyType = 115
	KeyPower             KeyType = 116 // SC System Power Down
	KeyKeypadEqual       KeyType = 117
	KeyKeypadPlusMinus   KeyType = 118
	KeyPause             KeyType = 119
	KeyScale             KeyType = 120 // AL Compiz Scale (Expose)
	KeyKeypadComma       KeyType = 121
	KeyHangul            KeyType = 122
	KeyHanja             KeyType = 123
	KeyYen               KeyType = 124
	KeyLeftMeta          KeyType = 125
	KeyRightMeta         KeyType = 126
	KeyCompose           KeyType = 127
	KeyStop              KeyType = 128 // AC Stop
	KeyAgain             KeyType = 129
	KeyProps             KeyType = 130 // AC Properties
	KeyUndo              KeyType = 131 // AC Undo
	KeyFront             KeyType = 132
	KeyCopy              KeyType = 133 // AC Copy
	KeyOpen              KeyType = 134 // AC Open
	KeyPaste             KeyType = 135 // AC Paste
	KeyFind              KeyType = 136 // AC Search
	KeyCut               KeyType = 137 // AC Cut
	KeyHelp              KeyType = 138 // AL Integrated Help Center
	KeyMenu              KeyType = 139 // Menu (show menu)
	KeyCalc              KeyType = 140 // AL Calculator
	KeySetup             KeyType = 141
	KeySleep             KeyType = 142 // SC System Sleep
	KeyWakeup            KeyType = 143 // System Wake Up
	KeyFile              KeyType = 144 // AL Local Machine Browser
	KeySendFile          KeyType = 145
	KeyDeleteFile        KeyType = 146
	KeyXfer              KeyType = 147
	KeyProg1             KeyType = 148
	KeyProg2             KeyType = 149
	KeyWWW               KeyType = 150 // AL Internet Browser
	KeyMSDOS             KeyType = 151
	KeyScreenlock        KeyType = 152
	KeyDirection         KeyType = 153
	KeyCycleWindows      KeyType = 154
	KeyMail              KeyType = 155
	KeyBookmarks         KeyType = 156 // AC Bookmarks
	KeyComputer          KeyType = 157
	KeyBack              KeyType = 158 // AC Back
	KeyForward           KeyType = 159 // AC Forward
	KeyCloseCD           KeyType = 160
	KeyEjectCD           KeyType = 161
	KeyEjectCloseCD      KeyType = 162
	KeyNextSong          KeyType = 163
	KeyPlayPause         KeyType = 164
	KeyPreviousSong      KeyType = 165
	KeyStopCD            KeyType = 166
	KeyRecord            KeyType = 167
	KeyRewind            KeyType = 168
	KeyPhone             KeyType = 169 // Media Select Telephone
	KeyISO               KeyType = 170
	KeyConfig            KeyType = 171 // AL Consumer Control Configuration
	KeyHomepage          KeyType = 172 // AC Home
	KeyRefresh           KeyType = 173 // AC Refresh
	KeyExit              KeyType = 174 // AC Exit
	KeyMove              KeyType = 175
	KeyEdit              KeyType = 176
	KeyScrollUp          KeyType = 177
	KeyScrollDown        KeyType = 178
	KeyKeypadLeftParen   KeyType = 179
	KeyKeypadRightParen  KeyType = 180
	KeyNew               KeyType = 181 // AC New
	KeyRedo              KeyType = 182 // AC Redo/Repeat
	KeyF13               KeyType = 183
	KeyF14               KeyType = 184
	KeyF15               KeyType = 185
	KeyF16               KeyType = 186
	KeyF17               KeyType = 187
	KeyF18               KeyType = 188
	KeyF19               KeyType = 189
	KeyF20               KeyType = 190
	KeyF21               KeyType = 191
	KeyF22               KeyType = 192
	KeyF23               KeyType = 193
	KeyF24               KeyType = 194
	KeyPlayCD            KeyType = 200
	KeyPauseCD           KeyType = 201
	KeyProg3             KeyType = 202
	KeyProg4             KeyType = 203
	KeyDashboard         KeyType = 204 // AL Dashboard
	KeySuspend           KeyType = 205
	KeyClose             KeyType = 206 // AC Close
	KeyPlay              KeyType = 207
	KeyFastForward       KeyType = 208
	KeyBassBoost         KeyType = 209
	KeyPrint             KeyType = 210 // AC Print
	KeyHP                KeyType = 211
	KeyCamera            KeyType = 212
	KeySound             KeyType = 213
	KeyQuestion          KeyType = 214
	KeyEmail             KeyType = 215
	KeyChat              KeyType = 216
	KeySearch            KeyType = 217
	KeyConnect           KeyType = 218
	KeyFinance           KeyType = 219 // AL Checkbook/Finance
	KeySport             KeyType = 220
	KeyShop              KeyType = 221
	KeyAltErase          KeyType = 222
	KeyCancel            KeyType = 223 // AC Cancel
	KeyBrightnessDown    KeyType = 224
	KeyBrightnessUp      KeyType = 225
	KeyMedia             KeyType = 226
	KeySwitchVideoMode   KeyType = 227 // Cycle between available video  outputs (Monitor/LCD/TV-out/etc)
	KeyKbdIllumToggle    KeyType = 228
	KeyKbdIllumDown      KeyType = 229
	KeyKbdIllumUp        KeyType = 230
	KeySend              KeyType = 231 // AC Send
	KeyReply             KeyType = 232 // AC Reply
	KeyForwardMail       KeyType = 233 // AC Forward Msg
	KeySave              KeyType = 234 // AC Save
	KeyDocuments         KeyType = 235
	KeyBattery           KeyType = 236
	KeyBluetooth         KeyType = 237
	KeyWLAN              KeyType = 238
	KeyUWB               KeyType = 239
	KeyUnknown           KeyType = 240
	KeyVideoNext         KeyType = 241 // drive next video source
	KeyVideoPrevious     KeyType = 242 // drive previous video source
	KeyBrightnessCycle   KeyType = 243 // brightness up, after max is min
	KeyBrightnessZero    KeyType = 244 // brightness off, use ambient
	KeyDisplayOff        KeyType = 245 // display device to off state
	KeyWiMax             KeyType = 246
	KeyRFKill            KeyType = 247 // Key that controls all radios
	KeyMicMute           KeyType = 248 // Mute / unmute the microphone
	KeyOk                KeyType = 0x160
	KeySelect            KeyType = 0x161
	KeyGoto              KeyType = 0x162
	KeyClear             KeyType = 0x163
	KeyPower2            KeyType = 0x164
	KeyOption            KeyType = 0x165
	KeyInfo              KeyType = 0x166 // AL OEM Features/Tips/Tutorial
	KeyTime              KeyType = 0x167
	KeyVendor            KeyType = 0x168
	KeyArchive           KeyType = 0x169
	KeyProgram           KeyType = 0x16a // Media Select Program Guide
	KeyChannel           KeyType = 0x16b
	KeyFavorites         KeyType = 0x16c
	KeyEPG               KeyType = 0x16d
	KeyPVR               KeyType = 0x16e // Media Select Home
	KeyMHP               KeyType = 0x16f
	KeyLanguage          KeyType = 0x170
	KeyTitle             KeyType = 0x171
	KeySubtitle          KeyType = 0x172
	KeyAngle             KeyType = 0x173
	KeyZoom              KeyType = 0x174
	KeyMode              KeyType = 0x175
	KeyKeyboard          KeyType = 0x176
	KeyScreen            KeyType = 0x177
	KeyPC                KeyType = 0x178 // Media Select Computer
	KeyTV                KeyType = 0x179 // Media Select TV
	KeyTV2               KeyType = 0x17a // Media Select Cable
	KeyVCR               KeyType = 0x17b // Media Select VCR
	KeyVCR2              KeyType = 0x17c // VCR Plus
	KeySAT               KeyType = 0x17d // Media Select Satellite
	KeySAT2              KeyType = 0x17e
	KeyCD                KeyType = 0x17f // Media Select CD
	KeyTape              KeyType = 0x180 // Media Select Tape
	KeyRadio             KeyType = 0x181
	KeyTuner             KeyType = 0x182 // Media Select Tuner
	KeyPlayer            KeyType = 0x183
	KeyText              KeyType = 0x184
	KeyDVD               KeyType = 0x185 // Media Select DVD
	KeyAUX               KeyType = 0x186
	KeyMP3               KeyType = 0x187
	KeyAudio             KeyType = 0x188 // AL Audio Browser
	KeyVideo             KeyType = 0x189 // AL Movie Browser
	KeyDirectory         KeyType = 0x18a
	KeyList              KeyType = 0x18b
	KeyMemo              KeyType = 0x18c // Media Select Messages
	KeyCalender          KeyType = 0x18d
	KeyRed               KeyType = 0x18e
	KeyGreen             KeyType = 0x18f
	KeyYellow            KeyType = 0x190
	KeyBlue              KeyType = 0x191
	KeyChannelUp         KeyType = 0x192 // Channel Increment
	KeyChannelDown       KeyType = 0x193 // Channel Decrement
	KeyFirst             KeyType = 0x194
	KeyLast              KeyType = 0x195 // Recall Last
	KeyAB                KeyType = 0x196
	KeyNext              KeyType = 0x197
	KeyRestart           KeyType = 0x198
	KeySlow              KeyType = 0x199
	KeyShuffle           KeyType = 0x19a
	KeyBreak             KeyType = 0x19b
	KeyPrevious          KeyType = 0x19c
	KeyDigits            KeyType = 0x19d
	KeyTeen              KeyType = 0x19e
	KeyTwen              KeyType = 0x19f
	KeyVideoPhone        KeyType = 0x1a0 // Media Select Video Phone
	KeyGames             KeyType = 0x1a1 // Media Select Games
	KeyZoomIn            KeyType = 0x1a2 // AC Zoom In
	KeyZoomOut           KeyType = 0x1a3 // AC Zoom Out
	KeyZoomReset         KeyType = 0x1a4 // AC Zoom
	KeyWordProcessor     KeyType = 0x1a5 // AL Word Processor
	KeyEditor            KeyType = 0x1a6 // AL Text Editor
	KeySpreadsheet       KeyType = 0x1a7 // AL Spreadsheet
	KeyGraphicsEditor    KeyType = 0x1a8 // AL Graphics Editor
	KeyPresentation      KeyType = 0x1a9 // AL Presentation App
	KeyDatabase          KeyType = 0x1aa // AL Database App
	KeyNews              KeyType = 0x1ab // AL Newsreader
	KeyVoiceMail         KeyType = 0x1ac // AL Voicemail
	KeyAddressBook       KeyType = 0x1ad // AL Contacts/Address Book
	KeyMessenger         KeyType = 0x1ae // AL Instant Messaging
	KeyDisplayToggle     KeyType = 0x1af // Turn display (LCD) on and off
	KeySpellCheck        KeyType = 0x1b0 // AL Spell Check
	KeyLogoff            KeyType = 0x1b1 // AL Logoff
	KeyDollar            KeyType = 0x1b2
	KeyEuro              KeyType = 0x1b3
	KeyFrameBack         KeyType = 0x1b4 // Consumer - transport controls
	KeyframeForward      KeyType = 0x1b5
	KeyContextMenu       KeyType = 0x1b6 // GenDesc - system context menu
	KeyMediaRepeat       KeyType = 0x1b7 // Consumer - transport control
	Key10ChannelsUp      KeyType = 0x1b8 // 10 channels up (10+)
	Key10ChannelsDown    KeyType = 0x1b9 // 10 channels down (10-)
	KeyImages            KeyType = 0x1ba // AL Image Browser
	KeyDelEOL            KeyType = 0x1c0
	KeyDelEOS            KeyType = 0x1c1
	KeyInsLine           KeyType = 0x1c2
	KeyDelLine           KeyType = 0x1c3
	KeyFunc              KeyType = 0x1d0
	KeyFuncEsc           KeyType = 0x1d1
	KeyFuncF1            KeyType = 0x1d2
	KeyFuncF2            KeyType = 0x1d3
	KeyFuncF3            KeyType = 0x1d4
	KeyFuncF4            KeyType = 0x1d5
	KeyFuncF5            KeyType = 0x1d6
	KeyFuncF6            KeyType = 0x1d7
	KeyFuncF7            KeyType = 0x1d8
	KeyFuncF8            KeyType = 0x1d9
	KeyFuncF9            KeyType = 0x1da
	KeyFuncF10           KeyType = 0x1db
	KeyFuncF11           KeyType = 0x1dc
	KeyFuncF12           KeyType = 0x1dd
	KeyFunc1             KeyType = 0x1de
	KeyFunc2             KeyType = 0x1df
	KeyFuncD             KeyType = 0x1e0
	KeyFuncE             KeyType = 0x1e1
	KeyFuncF             KeyType = 0x1e2
	KeyFuncS             KeyType = 0x1e3
	KeyFuncB             KeyType = 0x1e4
	KeyBrailleDot1       KeyType = 0x1f1
	KeyBrailleDot2       KeyType = 0x1f2
	KeyBrailleDot3       KeyType = 0x1f3
	KeyBrailleDot4       KeyType = 0x1f4
	KeyBrailleDot5       KeyType = 0x1f5
	KeyBrailleDot6       KeyType = 0x1f6
	KeyBrailleDot7       KeyType = 0x1f7
	KeyBrailleDot8       KeyType = 0x1f8
	KeyBrailleDot9       KeyType = 0x1f9
	KeyBrailleDot10      KeyType = 0x1fa
	KeyNumeric0          KeyType = 0x200 // used by phones, remote controls,
	KeyNumeric1          KeyType = 0x201 // and other keypads
	KeyNumeric2          KeyType = 0x202
	KeyNumeric3          KeyType = 0x203
	KeyNumeric4          KeyType = 0x204
	KeyNumeric5          KeyType = 0x205
	KeyNumeric6          KeyType = 0x206
	KeyNumeric7          KeyType = 0x207
	KeyNumeric8          KeyType = 0x208
	KeyNumeric9          KeyType = 0x209
	KeyNumericStar       KeyType = 0x20a
	KeyNumericPound      KeyType = 0x20b
	KeyNumericA          KeyType = 0x20c // Phone key A - HUT Telephony 0xb9
	KeyNumericB          KeyType = 0x20d
	KeyNumericC          KeyType = 0x20e
	KeyNumericD          KeyType = 0x20f
	KeyCameraFocus       KeyType = 0x210
	KeyWPSButton         KeyType = 0x211 // WiFi Protected Setup key
	KeyTouchpadToggle    KeyType = 0x212 // Request switch touchpad on or off
	KeyTouchpadOn        KeyType = 0x213
	KeyTouchpadOff       KeyType = 0x214
	KeyCameraZoomIn      KeyType = 0x215
	KeyCameraZoomOut     KeyType = 0x216
	KeyCameraUp          KeyType = 0x217
	KeyCameraDown        KeyType = 0x218
	KeyCameraLeft        KeyType = 0x219
	KeyCameraRight       KeyType = 0x21a
	KeyAttendantOn       KeyType = 0x21b
	KeyAttendantOff      KeyType = 0x21c
	KeyAttendantToggle   KeyType = 0x21d // Attendant call on or off
	KeyLightsToggle      KeyType = 0x21e // Reading light on or off
	KeyAlsToggle         KeyType = 0x230 // Ambient light sensor
	KeyButtonConfig      KeyType = 0x240 // AL Button Configuration
	KeyTaskManager       KeyType = 0x241 // AL Task/Project Manager
	KeyJournal           KeyType = 0x242 // AL Log/Journal/Timecard
	KeyControlPanel      KeyType = 0x243 // AL Control Panel
	KeyAppSelect         KeyType = 0x244 // AL Select Task/Application
	KeyScreensaver       KeyType = 0x245 // AL Screen Saver
	KeyVoiceCommand      KeyType = 0x246 // Listening Voice Command
	KeyAssistant         KeyType = 0x247 // AL Context-aware desktop assistant
	KeyBrightnessMin     KeyType = 0x250 // Set Brightness to Minimum
	KeyBrightnessMax     KeyType = 0x251 // Set Brightness to Maximum
	KeyKbdInputPrev      KeyType = 0x260
	KeyKbdInputNext      KeyType = 0x261
	KeyKbdInputPrevGroup KeyType = 0x262
	KeyKbdInputNextGroup KeyType = 0x263
	KeyKbdInputAccept    KeyType = 0x264
	KeyKbdInputCancel    KeyType = 0x265
	KeyRightUp           KeyType = 0x266
	KeyRightDown         KeyType = 0x267
	KeyLeftUp            KeyType = 0x268
	KeyLeftDown          KeyType = 0x269
	KeyRootMenu          KeyType = 0x26a // Show Device's Root Menu
	KeyMediaTopMenu      KeyType = 0x26b
	KeyNumeric11         KeyType = 0x26c
	KeyNumeric12         KeyType = 0x26d
	KeyAudioDesc         KeyType = 0x26e
	Key3dMode            KeyType = 0x26f
	KeyNextFavorite      KeyType = 0x270
	KeyStopRecord        KeyType = 0x271
	KeyPauseRecord       KeyType = 0x272
)

Keys event types.

const (
	Btn0    KeyType = 0x100
	Btn1    KeyType = 0x101
	Btn2    KeyType = 0x102
	Btn3    KeyType = 0x103
	Btn4    KeyType = 0x104
	Btn5    KeyType = 0x105
	Btn6    KeyType = 0x106
	Btn7    KeyType = 0x107
	Btn8    KeyType = 0x108
	Btn9    KeyType = 0x109
	BtnMisc KeyType = 0x100

	BtnLeft    KeyType = 0x110
	BtnRight   KeyType = 0x111
	BtnMiddle  KeyType = 0x112
	BtnSide    KeyType = 0x113
	BtnExtra   KeyType = 0x114
	BtnForward KeyType = 0x115
	BtnBack    KeyType = 0x116
	BtnTask    KeyType = 0x117
	BtnMouse   KeyType = 0x110

	BtnTrigger  KeyType = 0x120
	BtnThumb    KeyType = 0x121
	BtnThumb2   KeyType = 0x122
	BtnTop      KeyType = 0x123
	BtnTop2     KeyType = 0x124
	BtnPinkie   KeyType = 0x125
	BtnBase     KeyType = 0x126
	BtnBase2    KeyType = 0x127
	BtnBase3    KeyType = 0x128
	BtnBase4    KeyType = 0x129
	BtnBase5    KeyType = 0x12a
	BtnBase6    KeyType = 0x12b
	BtnDead     KeyType = 0x12f
	BtnJoystick KeyType = 0x120

	BtnA       KeyType = 0x130
	BtnB       KeyType = 0x131
	BtnC       KeyType = 0x132
	BtnX       KeyType = 0x133
	BtnY       KeyType = 0x134
	BtnZ       KeyType = 0x135
	BtnTL      KeyType = 0x136
	BtnTR      KeyType = 0x137
	BtnTL2     KeyType = 0x138
	BtnTR2     KeyType = 0x139
	BtnSelect  KeyType = 0x13a
	BtnStart   KeyType = 0x13b
	BtnMode    KeyType = 0x13c
	BtnThumbL  KeyType = 0x13d
	BtnThumbR  KeyType = 0x13e
	BtnGamepad KeyType = 0x130

	BtnToolPen        KeyType = 0x140
	BtnTooLRubber     KeyType = 0x141
	BtnToolBrush      KeyType = 0x142
	BtnToolPencil     KeyType = 0x143
	BtnToolAirbrush   KeyType = 0x144
	BtnToolFinger     KeyType = 0x145
	BtnToolMouse      KeyType = 0x146
	BtnToolLens       KeyType = 0x147
	BtnToolQuintTap   KeyType = 0x148 // Five fingers on trackpad
	BtnTouch          KeyType = 0x14a
	BtnStylus         KeyType = 0x14b
	BtnStylus2        KeyType = 0x14c
	BtnToolDoubleTap  KeyType = 0x14d
	BtnToolTrippleTap KeyType = 0x14e
	BtnToolQuadTap    KeyType = 0x14f // Four fingers on trackpad
	BtnDigi           KeyType = 0x140

	BtnGearDown KeyType = 0x150
	BtnGearUp   KeyType = 0x151
	BtnWheel    KeyType = 0x150

	BtnTriggerHappy1  KeyType = 0x2c0
	BtnTriggerHappy2  KeyType = 0x2c1
	BtnTriggerHappy3  KeyType = 0x2c2
	BtnTriggerHappy4  KeyType = 0x2c3
	BtnTriggerHappy5  KeyType = 0x2c4
	BtnTriggerHappy6  KeyType = 0x2c5
	BtnTriggerHappy7  KeyType = 0x2c6
	BtnTriggerHappy8  KeyType = 0x2c7
	BtnTriggerHappy9  KeyType = 0x2c8
	BtnTriggerHappy10 KeyType = 0x2c9
	BtnTriggerHappy11 KeyType = 0x2ca
	BtnTriggerHappy12 KeyType = 0x2cb
	BtnTriggerHappy13 KeyType = 0x2cc
	BtnTriggerHappy14 KeyType = 0x2cd
	BtnTriggerHappy15 KeyType = 0x2ce
	BtnTriggerHappy16 KeyType = 0x2cf
	BtnTriggerHappy17 KeyType = 0x2d0
	BtnTriggerHappy18 KeyType = 0x2d1
	BtnTriggerHappy19 KeyType = 0x2d2
	BtnTriggerHappy20 KeyType = 0x2d3
	BtnTriggerHappy21 KeyType = 0x2d4
	BtnTriggerHappy22 KeyType = 0x2d5
	BtnTriggerHappy23 KeyType = 0x2d6
	BtnTriggerHappy24 KeyType = 0x2d7
	BtnTriggerHappy25 KeyType = 0x2d8
	BtnTriggerHappy26 KeyType = 0x2d9
	BtnTriggerHappy27 KeyType = 0x2da
	BtnTriggerHappy28 KeyType = 0x2db
	BtnTriggerHappy29 KeyType = 0x2dc
	BtnTriggerHappy30 KeyType = 0x2dd
	BtnTriggerHappy31 KeyType = 0x2de
	BtnTriggerHappy32 KeyType = 0x2df
	BtnTriggerHappy33 KeyType = 0x2e0
	BtnTriggerHappy34 KeyType = 0x2e1
	BtnTriggerHappy35 KeyType = 0x2e2
	BtnTriggerHappy36 KeyType = 0x2e3
	BtnTriggerHappy37 KeyType = 0x2e4
	BtnTriggerHappy38 KeyType = 0x2e5
	BtnTriggerHappy39 KeyType = 0x2e6
	BtnTriggerHappy40 KeyType = 0x2e7
	BtnTriggerHappy   KeyType = 0x2c0
)

Mouse and gamepad buttons event types.

func (KeyType) String added in v0.1.1

func (i KeyType) String() string

type LEDType added in v0.1.1

type LEDType int

LEDType is the type used to set and query the state of a device's LEDs.

const (
	LEDNumLock    LEDType = 0x00
	LEDCapsLock   LEDType = 0x01
	LEDScrollLock LEDType = 0x02
	LEDCompose    LEDType = 0x03
	LEDKana       LEDType = 0x04
	LEDSleep      LEDType = 0x05
	LEDSuspend    LEDType = 0x06
	LEDMute       LEDType = 0x07
	LEDMisc       LEDType = 0x08
	LEDMail       LEDType = 0x09
	LEDCharging   LEDType = 0x0a
)

LEDs.

func (LEDType) String added in v0.1.1

func (i LEDType) String() string

type MTToolType added in v0.1.1

type MTToolType int

MTToolType is the multitouch tool type.

const (
	MTToolFinger MTToolType = 0
	MTToolPen    MTToolType = 1
)

Multitouch tool values.

func (MTToolType) String added in v0.1.1

func (i MTToolType) String() string

type MiscType added in v0.1.1

type MiscType int

MiscType is the used for other event types that do not fall under other categories.

MiscTimestamp has a special meaning. It is used to report the number of microseconds since the last reset. This event should be coded as an uint32 value, which is allowed to wrap around with no special consequence. It is assumed that the time difference between two consecutive events is reliable on a reasonable time scale (hours). A reset to zero can happen, in which case the time since the last event is unknown. If the device does not provide this information, the driver must not provide it to user space.

const (
	MiscSerial    MiscType = 0x00
	MiscPulseLED  MiscType = 0x01
	MiscGesture   MiscType = 0x02
	MiscRaw       MiscType = 0x03
	MiscScan      MiscType = 0x04
	MiscTimestamp MiscType = 0x05
)

Misc event types.

func (MiscType) String added in v0.1.1

func (i MiscType) String() string

type PeriodicEffect

type PeriodicEffect struct {
	Waveform  uint16
	Period    uint16
	Magnitude int16
	Offset    int16
	Phase     uint16
	Envelope  EffectEnvelope
	// contains filtered or unexported fields
}

PeriodicEffect wraps the data for a periodic (waveform) force feedback effect.

waveforms: Square, Triangle, Sine, Sawtooth or a custom waveform.

func (*PeriodicEffect) Data

func (e *PeriodicEffect) Data() []int16

Data returns custom waveform information. This comes in the form of a signed 16-bit slice.

The exact layout of a custom waveform is undefined for the time being as no driver supports it yet.

func (*PeriodicEffect) SetData

func (e *PeriodicEffect) SetData(v []int16)

SetData sets custom waveform information.

The exact layout of a custom waveform is undefined for the time being as no driver supports it yet.

type PowerType added in v0.1.1

type PowerType int

PowerType is the power event type.

Power events are a special type of event used specifically for power mangement. Its usage is not well defined. To be addressed later.

NOTE: these values have been invented for this package. They're not used, nor are they defined anywhere.

const (
	PowerOff     PowerType = 0x00
	PowerOn      PowerType = 0x01
	PowerStandby PowerType = 0x02
)

Power types.

func (PowerType) String added in v0.1.1

func (i PowerType) String() string

type PropertyType added in v0.1.1

type PropertyType int

PropertyType is the input device property type, for determining input device properties and quirks.

Normally, userspace sets up an input device based on the data it emits, i.e., the event types. In the case of two devices emitting the same event types, additional information can be provided in the form of device properties.

The PropertyPointer property indicates that the device is not transposed on the screen and thus requires use of an on-screen pointer to trace user's movements. Typical pointer devices: touchpads, tablets, mice; non-pointer device: touchscreen.

If neither PropertyDirect or PropertyPointer are set, the property is considered undefined and the device type should be deduced in the traditional way, using emitted event types.

The PropertyDirect property indicates that device coordinates should be directly mapped to screen coordinates (not taking into account trivial transformations, such as scaling, flipping and rotating). Non-direct input devices require non-trivial transformation, such as absolute to relative transformation for touchpads. Typical direct input devices: touchscreens, drawing tablets; non-direct devices: touchpads, mice.

If neither PropertyDirect or PropertyPointer are set, the property is considered undefined and the device type should be deduced in the traditional way, using emitted event types.

For touchpads where the button is placed beneath the surface, such that pressing down on the pad causes a button click, this property should be set. Common in clickpad notebooks and macbooks from 2009 and onwards.

Originally, the buttonpad property was coded into the bcm5974 driver version field under the name integrated button. For backwards compatibility, both methods need to be checked in userspace.

Some touchpads, most common between 2008 and 2011, can detect the presence of multiple contacts without resolving the individual positions; only the number of contacts and a rectangular shape is known. For such touchpads, the semi-mt property should be set.

Depending on the device, the rectangle may enclose all touches, like a bounding box, or just some of them, for instance the two most recent touches. The diversity makes the rectangle of limited use, but some gestures can normally be extracted from it.

If PropertySemiMT is not set, the device is assumed to be a true multi-touch device.

const (
	PropertyPointer       PropertyType = 0x00
	PropertyDirect        PropertyType = 0x01
	PropertyButtonPad     PropertyType = 0x02
	PropertySemiMT        PropertyType = 0x03
	PropertyTopButtonPad  PropertyType = 0x04
	PropertyPointingStick PropertyType = 0x05
	PropertyAccelerometer PropertyType = 0x06
)

Input property types.

func (PropertyType) String added in v0.1.1

func (i PropertyType) String() string

type RampEffect

type RampEffect struct {
	LevelStart int16
	LevelEnd   int16
	Envelope   EffectEnvelope
}

RampEffect wraps the data for a ramp force feedback effect.

type RelativeType added in v0.1.1

type RelativeType int

RelativeType is the relative axis event type.

Relative events describe relative changes in a property. For example, a mouse may move to the left by a certain number of units, but its absolute position in space is unknown. If the absolute position is known, EventAbsolute codes should be used instead of EventRelative codes.

RelativeWheel and RelativeHWheel are used for vertical and horizontal scroll wheels, respectively.

const (
	RelativeX      RelativeType = 0x00
	RelativeY      RelativeType = 0x01
	RelativeZ      RelativeType = 0x02
	RelativeRX     RelativeType = 0x03
	RelativeRY     RelativeType = 0x04
	RelativeRZ     RelativeType = 0x05
	RelativeHWheel RelativeType = 0x06
	RelativeDial   RelativeType = 0x07
	RelativeWheel  RelativeType = 0x08
	RelativeMisc   RelativeType = 0x09
)

Relative axis event types.

func (RelativeType) String added in v0.1.1

func (i RelativeType) String() string

type RepeatType added in v0.1.1

type RepeatType int

RepeatType is the repeat event type.

Repeat events are used for specifying autorepeating events.

const (
	RepeatDelay  RepeatType = 0x00
	RepeatPeriod RepeatType = 0x01
)

Repeat event types.

func (RepeatType) String added in v0.1.1

func (i RepeatType) String() string

type RumbleEffect

type RumbleEffect struct {
	MagnitudeStrong uint16
	MagnitudeWeak   uint16
}

RumbleEffect wraps the data for a rumble force feedback effect.

The rumble effect is the most basic effect, causing the device to vibrate. The API contains support for two motors, a strong one and a weak one, which can be controlled independently.

type SoundType added in v0.1.1

type SoundType int

SoundType events are used for sending sound commands to simple sound output devices.

const (
	SoundClick SoundType = 0x00
	SoundBell  SoundType = 0x01
	SoundTone  SoundType = 0x02
)

Sound event types.

func (SoundType) String added in v0.1.1

func (i SoundType) String() string

type SwitchType added in v0.1.1

type SwitchType int

SwitchType is the switch event type.

Switch events describe stateful binary switches. For example, the SwitchLid code is used to denote when a laptop lid is closed.

Upon binding to a device or resuming from suspend, a driver must report the current switch state. This ensures that the device, kernel, and userspace state is in sync.

Upon resume, if the switch state is the same as before suspend, then the input subsystem will filter out the duplicate switch state reports. The driver does not need to keep the state of the switch at any time.

const (
	SwitchLid                SwitchType = 0x00 // lid shut
	SwitchTabletMode         SwitchType = 0x01 // tablet mode
	SwitchHeadphoneInsert    SwitchType = 0x02 // inserted
	SwitchRFKillAll          SwitchType = 0x03 // rfkill master switch, type "any"; radio enabled
	SwitchMicrophoneInsert   SwitchType = 0x04 // inserted
	SwitchDock               SwitchType = 0x05 // plugged into dock
	SwitchLineoutInsert      SwitchType = 0x06 // inserted
	SwitchJackPhysicalInsert SwitchType = 0x07 // mechanical switch set
	SwitchVideoOutInsert     SwitchType = 0x08 // inserted
	SwitchCameraLensCover    SwitchType = 0x09 // lens covered
	SwitchKeypadSlide        SwitchType = 0x0a // keypad slide out
	SwitchFrontProximity     SwitchType = 0x0b // front proximity sensor active
	SwitchRotateLock         SwitchType = 0x0c // rotate locked/disabled
	SwitchLineInInsert       SwitchType = 0x0d // inserted

)

Switch types.

func (SwitchType) String added in v0.1.1

func (i SwitchType) String() string

type SyncType added in v0.1.1

type SyncType int

SyncType is the synchronization event type.

Synchronization event values are undefined. Their usage is defined only by when they are sent in the evdev event stream.

SyncReport is used to synchronize and separate events into packets of input data changes occurring at the same moment in time. For example, motion of a mouse may set the RelativeX and RelativeY values for one motion, then emit a SyncReport. The next motion will emit more RelativeX and RelativeY values and send another SyncReport.

SyncConfig: to be determined.

SyncMTReport is used to synchronize and separate touch events. See the multi-touch-protocol.txt document for more information.

SyncDropped is used to indicate buffer overrun in the evdev client's event queue. Client should ignore all events up to and including next SyncReport event and query the device (using EVIOCG* ioctls) to obtain its current state.

const (
	SyncReport     SyncType = 0
	SyncConfig     SyncType = 1
	SyncMTReport   SyncType = 2
	SyncDropped    SyncType = 3
	SyncDisconnect SyncType = 4 //Not from linux, generated when device file disappears

)

Sync event types.

func (SyncType) String added in v0.1.1

func (i SyncType) String() string

type UserInput added in v0.1.1

type UserInput struct {
	// contains filtered or unexported fields
}

UserInput wraps sending and receiving events to a user input (uinput) device.

func NewUserInput added in v0.1.1

func NewUserInput(perm os.FileMode, opts ...UserInputOption) (*UserInput, error)

NewUserInput creates a new user input (uinput) device with the specified permissions.

func (*UserInput) Close added in v0.1.1

func (u *UserInput) Close() error

Close closes the user input (uinput) device.

func (*UserInput) Path added in v0.1.1

func (u *UserInput) Path() string

Path returns the path of the device.

type UserInputOption added in v0.1.1

type UserInputOption func(*UserInput)

UserInputOption is a user input (uinput) device option.

func WithAbsoluteTypes added in v0.1.1

func WithAbsoluteTypes(types map[AbsoluteType]bool) UserInputOption

WithAbsoluteTypes is a user input (uinput) device option to set the device absolute event types.

func WithEffectStatusTypes added in v0.1.1

func WithEffectStatusTypes(types map[EffectStatusType]bool) UserInputOption

WithEffectStatusTypes is a user input (uinput) device option to set the device force feedback effect status event types.

func WithEffectTypes added in v0.1.1

func WithEffectTypes(types map[EffectType]bool) UserInputOption

WithEffectTypes is a user input (uinput) device option to set the device force feedback effect event types.

func WithEventTypes added in v0.1.1

func WithEventTypes(events map[EventType]bool) UserInputOption

WithEventTypes is a user input (uinput) device option to set the device event types.

func WithID added in v0.1.1

func WithID(id ID) UserInputOption

WithID is a user input (uinput) device option to set the device ID.

func WithKeyTypes added in v0.1.1

func WithKeyTypes(types map[KeyType]bool) UserInputOption

WithKeyTypes is a user input (uinput) device option to set the device key event types.

func WithLEDTypes added in v0.1.1

func WithLEDTypes(types map[LEDType]bool) UserInputOption

WithLEDTypes is a user input (uinput) device option to set the device led event types.

func WithMiscTypes added in v0.1.1

func WithMiscTypes(types map[MiscType]bool) UserInputOption

WithMiscTypes is a user input (uinput) device option to set the device misc event types.

func WithName added in v0.1.1

func WithName(name string) UserInputOption

WithName is a user input (uinput) device option to set the device name.

func WithPath added in v0.1.1

func WithPath(path string) UserInputOption

WithPath is a user input (uinput) device option to set the device path.

func WithPowerTypes added in v0.1.1

func WithPowerTypes(types map[PowerType]bool) UserInputOption

WithPowerTypes is a user input (uinput) device option to set the device power event types.

func WithPropertyTypes added in v0.1.1

func WithPropertyTypes(types map[PropertyType]bool) UserInputOption

WithPropertyTypes is a user input (uinput) device option to set the device property event types.

func WithRelativeTypes added in v0.1.1

func WithRelativeTypes(types map[RelativeType]bool) UserInputOption

WithRelativeTypes is a user input (uinput) device option to set the device relative event types.

func WithRepeatTypes added in v0.1.1

func WithRepeatTypes(types map[RepeatType]bool) UserInputOption

WithRepeatTypes is a user input (uinput) device option to set the device repeat event types.

func WithSoundTypes added in v0.1.1

func WithSoundTypes(types map[SoundType]bool) UserInputOption

WithSoundTypes is a user input (uinput) device option to set the device sound event types.

func WithSwitchTypes added in v0.1.1

func WithSwitchTypes(types map[SwitchType]bool) UserInputOption

WithSwitchTypes is a user input (uinput) device option to set the device switch event types.

func WithSyncTypes added in v0.1.1

func WithSyncTypes(types map[SyncType]bool) UserInputOption

WithSyncTypes is a user input (uinput) device option to set the device sync event types.

func WithTypes added in v0.1.1

func WithTypes(types ...interface{}) UserInputOption

WithTypes is a user input (uinput) device option to set all types supported by the device at once.

func WithTypesFromDev added in v0.1.1

func WithTypesFromDev(d *Evdev) UserInputOption

WithTypesFromDev is a user input (uinput) device option to copy the options from a input event device.

Directories

Path Synopsis
examples
ff
Command ff is a evdev example demonstrating how to send force feedback events to a input device.
Command ff is a evdev example demonstrating how to send force feedback events to a input device.
iter
Command iter is a evdev example demonstrating how to iterate input devices and read their configuration.
Command iter is a evdev example demonstrating how to iterate input devices and read their configuration.
led
Command led is a evdev example demonstrating how to send events (LED) to an input device.
Command led is a evdev example demonstrating how to send events (LED) to an input device.
poll
Command poll is a evdev example demonstrating how to poll a input device for events.
Command poll is a evdev example demonstrating how to poll a input device for events.
relay
Command relay is a evdev example demonstrating relaying events from an input device to a uinput device.
Command relay is a evdev example demonstrating relaying events from an input device to a uinput device.
uinput
Command uinput is a evdev example demonstrating creating a user input device.
Command uinput is a evdev example demonstrating creating a user input device.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL