Documentation
¶
Overview ¶
Package inputactivity detects whether a person is using a device's keyboard, mouse or controllers. The decision logic lives in portable files so it can be tested without hardware; the OS-specific files only gather raw samples.
Index ¶
- Constants
- type ChatterFilter
- type Class
- type Desktop
- type Evdev
- type IdleTracker
- type InputDevice
- func (d *InputDevice) Classify() Class
- func (d *InputDevice) EventNode() (string, bool)
- func (d *InputDevice) HasAbs(code int) bool
- func (d *InputDevice) JoystickNode() (string, bool)
- func (d *InputDevice) Own() bool
- func (d *InputDevice) Skipped() bool
- func (d *InputDevice) Synthetic() bool
- func (d *InputDevice) UsbParent() string
- type SAM
- type Snapshot
- type Throttle
Constants ¶
const ( // NotifyInterval is the shortest gap between two callbacks. NotifyInterval = 200 * time.Millisecond // PollInterval is how often polled sources sample while idle rotation is // only waiting for someone to go away. PollInterval = 250 * time.Millisecond // ResponsivePollInterval is the sampling gap while a countdown is on // screen and one tap has to register. ResponsivePollInterval = 20 * time.Millisecond )
const ProcDevicesPath = "/proc/bus/input/devices"
ProcDevicesPath is the kernel's list of input devices.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatterFilter ¶
type ChatterFilter struct {
// contains filtered or unexported fields
}
ChatterFilter suppresses a device that is stuck. A person pauses or varies what they do; a gamepad keyboard interface, a pegged axis or a flapping switch repeats the same event nonstop.
type Class ¶
type Class uint8
Class is a set of kinds of input. The bit values match platforms.InputClass so a platform can convert with a plain cast.
type Desktop ¶
type Desktop struct {
// contains filtered or unexported fields
}
Desktop watches a desktop session: controllers through event nodes and keyboard plus mouse through the session's idle time on D-Bus.
func NewDesktop ¶
func NewDesktop() *Desktop
NewDesktop returns a source for a non-root desktop session.
func (*Desktop) Coverage ¶
Coverage reports keyboard and mouse only when a session idle source works, and controllers only when event nodes can be read.
type Evdev ¶
type Evdev struct {
// contains filtered or unexported fields
}
Evdev watches /dev/input/event* nodes for keyboards, mice and controllers. It only works where nothing else grabs the devices exclusively.
func NewEvdevAll ¶
func NewEvdevAll() *Evdev
NewEvdevAll returns a source watching keyboards, mice and controllers.
type IdleTracker ¶
type IdleTracker struct {
// contains filtered or unexported fields
}
IdleTracker turns a stream of "time since last input" readings into activity. Idle time only ever grows by the time between readings unless someone touched an input in between.
func NewIdleTracker ¶
func NewIdleTracker(clock clockwork.Clock) *IdleTracker
NewIdleTracker returns a tracker reading time from clock.
type InputDevice ¶
type InputDevice struct {
Name string
Phys string
Sysfs string
Uniq string
Handlers []string
// contains filtered or unexported fields
}
InputDevice is one entry of /proc/bus/input/devices.
func ParseDevices ¶
func ParseDevices(r io.Reader) []InputDevice
ParseDevices reads the /proc/bus/input/devices format. Unknown lines are ignored so a newer kernel cannot break enumeration.
func ReadDevices ¶
func ReadDevices(fs afero.Fs, name string) ([]InputDevice, error)
ReadDevices parses the device list at name on fs.
func (*InputDevice) Classify ¶
func (d *InputDevice) Classify() Class
Classify returns the single kind of input a device produces. A device with gamepad buttons is a controller even if it also exposes keys or a pointer, and a device with letter keys is a keyboard even if it has a wheel.
func (*InputDevice) EventNode ¶
func (d *InputDevice) EventNode() (string, bool)
EventNode returns the evdev node name such as "event3".
func (*InputDevice) HasAbs ¶
func (d *InputDevice) HasAbs(code int) bool
HasAbs reports whether the device advertises the absolute axis code.
func (*InputDevice) JoystickNode ¶
func (d *InputDevice) JoystickNode() (string, bool)
JoystickNode returns the legacy joystick node name such as "js0".
func (*InputDevice) Own ¶
func (d *InputDevice) Own() bool
Own reports whether the device is one Zaparoo created itself.
func (*InputDevice) Skipped ¶
func (d *InputDevice) Skipped() bool
Skipped reports whether the device must never count as a person. Only Zaparoo's own devices qualify: software that creates input devices for a real controller, such as Steam Input or ds4drv, is a person's input, and treating every uinput device as synthetic would leave that player invisible while coverage still claimed to see them. Devices that report nonstop without anyone behind them are the chatter filter's job.
func (*InputDevice) Synthetic ¶
func (d *InputDevice) Synthetic() bool
Synthetic reports whether the device was created by software through uinput rather than backed by hardware.
func (*InputDevice) UsbParent ¶
func (d *InputDevice) UsbParent() string
UsbParent returns the physical parent shared by every interface of one USB device, or "" when the device has no such notion (Bluetooth, PS/2).
type SAM ¶
type SAM struct {
// contains filtered or unexported fields
}
SAM watches input the way MiSTer_SAM does, for devices where MiSTer Main holds an exclusive grab on every /dev/input/event* node. The legacy nodes keep reporting while grabbed: joystick state through /dev/input/jsN, keyboards through their /dev/hidrawN twin and every mouse through /dev/input/mice.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot remembers the last value of each button and axis of a polled device so a change can be told from a held position.
type Throttle ¶
type Throttle struct {
// contains filtered or unexported fields
}
Throttle forwards at most one call per interval.
func NewThrottle ¶
NewThrottle returns a Throttle that calls fn no more often than interval.