evdev

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package evdev holds the Linux input event ABI that Planck's host injector, virtual gamepads and gamepad reader share: event types and codes, the input_event record, and ioctl request numbers.

Index

Constants

View Source
const (
	EvSyn     = 0x00
	EvKey     = 0x01
	EvRel     = 0x02
	EvAbs     = 0x03
	EvMsc     = 0x04
	EvFF      = 0x15
	EvUinput  = 0x0101
	SynReport = 0
	SynDrop   = 3
)
View Source
const (
	RelX           = 0x00
	RelY           = 0x01
	RelHWheel      = 0x06
	RelWheel       = 0x08
	RelWheelHiRes  = 0x0B
	RelHWheelHiRes = 0x0C
)
View Source
const (
	AbsX     = 0x00
	AbsY     = 0x01
	AbsZ     = 0x02
	AbsRX    = 0x03
	AbsRY    = 0x04
	AbsRZ    = 0x05
	AbsHat0X = 0x10
	AbsHat0Y = 0x11
	AbsHat3Y = 0x17
	AbsMax   = 0x3F
)
View Source
const (
	BtnJoystick   = 0x120
	BtnLeft       = 0x110
	BtnRight      = 0x111
	BtnMiddle     = 0x112
	BtnSide       = 0x113
	BtnExtra      = 0x114
	BtnSouth      = 0x130
	BtnEast       = 0x131
	BtnNorth      = 0x133
	BtnWest       = 0x134
	BtnTL         = 0x136
	BtnTR         = 0x137
	BtnTL2        = 0x138
	BtnTR2        = 0x139
	BtnSelect     = 0x13A
	BtnStart      = 0x13B
	BtnMode       = 0x13C
	BtnThumbL     = 0x13D
	BtnThumbR     = 0x13E
	BtnDPadUp     = 0x220
	BtnDPadDown   = 0x221
	BtnDPadLeft   = 0x222
	BtnDPadRight  = 0x223
	BtnTouch      = 0x14A
	BtnToolFinger = 0x145
	KeyMax        = 0x2FF
)
View Source
const (
	FFRumble = 0x50
	FFGain   = 0x60
)
View Source
const (
	BusUSB       = 0x03
	BusBluetooth = 0x05
	BusVirtual   = 0x06
)
View Source
const (
	InputIDSize = 8
	AbsInfoSize = 24
)
View Source
const EventSize = 2*(bits.UintSize/8) + 8

EventSize is sizeof(struct input_event): a timeval, then type, code and value.

View Source
const FFEffectSize = ffUnionOffset + ffUnionSize

FFEffectSize is sizeof(struct ff_effect): fourteen bytes of header padded to the union, whose largest member (ff_periodic_effect) ends in a pointer.

View Source
const FFRumbleOffset = ffUnionOffset

FFRumbleOffset is where struct ff_effect keeps its rumble magnitudes (strong, then weak, 16 bits each).

Variables

View Source
var EVIOCGID = IOR(evdevIoctlTyp, 0x02, InputIDSize)

EVIOCGID reads struct input_id.

View Source
var EVIOCRMFF = IOW(evdevIoctlTyp, 0x81, 4)

EVIOCRMFF erases a force-feedback effect by id.

View Source
var EVIOCSFF = IOW(evdevIoctlTyp, 0x80, FFEffectSize)

EVIOCSFF uploads a force-feedback effect.

Functions

func EVIOCGABS

func EVIOCGABS(abs int) uintptr

EVIOCGABS reads struct input_absinfo of axis abs.

func EVIOCGBIT

func EVIOCGBIT(ev, n int) uintptr

EVIOCGBIT reads the bitmap of codes of event type ev (0 for the types themselves) into a buffer of n bytes.

func EVIOCGKEY

func EVIOCGKEY(n int) uintptr

EVIOCGKEY reads the pressed keys into a buffer of n bytes.

func EVIOCGNAME

func EVIOCGNAME(n int) uintptr

EVIOCGNAME reads the device name into a buffer of n bytes.

func Encode

func Encode(dst []byte, evs ...Event) []byte

Encode appends the wire form of evs to dst.

func IO

func IO(typ, nr uint32) uintptr

func IOR

func IOR(typ, nr, size uint32) uintptr

func IOW

func IOW(typ, nr, size uint32) uintptr

func IOWR

func IOWR(typ, nr, size uint32) uintptr

func Ioctl

func Ioctl(fd int, req uintptr, arg unsafe.Pointer) error

Ioctl issues request on fd with arg, which may be nil.

func IoctlInt

func IoctlInt(fd int, req, arg uintptr) error

IoctlInt issues request on fd with an integer argument.

func TestBit

func TestBit(bm []byte, n int) bool

TestBit reports whether bit n is set in a bitmap the kernel returned.

Types

type Event

type Event struct {
	Type, Code uint16
	Value      int32
}

Event is one input_event.

func ParseEvent

func ParseEvent(b []byte) Event

ParseEvent reads the event at the start of b, which must hold EventSize bytes.

func (Event) Put

func (e Event) Put(b []byte)

Put writes e into b, which must hold EventSize bytes, with a zero time (the kernel stamps events written to uinput).

Jump to

Keyboard shortcuts

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