Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Evdev
Description
The main module for working with devices and events.
Synopsis
- data Device
- newDevice :: RawFilePath -> IO Device
- nextEvent :: Device -> IO Event
- evdevDir :: RawFilePath
- deviceName :: Device -> IO ByteString
- devicePath :: Device -> ByteString
- deviceProperties :: Device -> IO [DeviceProperty]
- deviceEventTypes :: Device -> IO [EventType]
- deviceHasEvent :: Device -> EventData -> IO Bool
- deviceFd :: Device -> IO Fd
- devicePhys :: Device -> IO (Maybe ByteString)
- deviceUniq :: Device -> IO (Maybe ByteString)
- deviceProduct :: Device -> IO Int
- deviceVendor :: Device -> IO Int
- deviceBustype :: Device -> IO Int
- deviceVersion :: Device -> IO Int
- deviceAbsAxis :: Device -> AbsoluteAxis -> IO (Maybe AbsInfo)
- data AbsInfo = AbsInfo {
- absValue :: Int32
- absMinimum :: Int32
- absMaximum :: Int32
- absFuzz :: Int32
- absFlat :: Int32
- absResolution :: Int32
- grabDevice :: Device -> IO ()
- ungrabDevice :: Device -> IO ()
- data Event = Event {}
- data EventData
- = SyncEvent SyncEvent
- | KeyEvent Key KeyEvent
- | RelativeEvent RelativeAxis EventValue
- | AbsoluteEvent AbsoluteAxis EventValue
- | MiscEvent MiscEvent EventValue
- | SwitchEvent SwitchEvent EventValue
- | LEDEvent LEDEvent EventValue
- | SoundEvent SoundEvent EventValue
- | RepeatEvent RepeatEvent EventValue
- | ForceFeedbackEvent EventCode EventValue
- | PowerEvent EventCode EventValue
- | ForceFeedbackStatusEvent EventCode EventValue
- | UnknownEvent Word16 EventCode EventValue
- data KeyEvent
- newtype EventCode = EventCode Word16
- newtype EventValue = EventValue Int32
- newDeviceFromFd :: Fd -> IO Device
- nextEventMay :: Device -> IO (Maybe Event)
- data LEDValue
- setDeviceLED :: Device -> LEDEvent -> LEDValue -> IO ()
- data CEvent = CEvent {}
- toCEvent :: Event -> CEvent
- fromCEvent :: CEvent -> Event
- toCEventData :: EventData -> (Word16, Word16, Int32)
- fromCEventData :: (Word16, Word16, Int32) -> EventData
- data CTimeVal = CTimeVal {}
- toCTimeVal :: DiffTime -> CTimeVal
- fromCTimeVal :: CTimeVal -> DiffTime
Devices
An input device.
newDevice :: RawFilePath -> IO Device Source #
Create a device from a valid path - usually /dev/input/eventX for some numeric X.
Use newDeviceFromFd
if you need more control over how the device is created.
evdevDir :: RawFilePath Source #
The usual directory containing devices ("/dev/input").
Properties
deviceName :: Device -> IO ByteString Source #
devicePath :: Device -> ByteString Source #
deviceProperties :: Device -> IO [DeviceProperty] Source #
devicePhys :: Device -> IO (Maybe ByteString) Source #
deviceUniq :: Device -> IO (Maybe ByteString) Source #
deviceAbsAxis :: Device -> AbsoluteAxis -> IO (Maybe AbsInfo) Source #
Constructors
AbsInfo | |
Fields
|
Grabbing
grabDevice :: Device -> IO () Source #
Prevent other clients (including kernel-internal ones) from receiving events. Often a bad idea.
ungrabDevice :: Device -> IO () Source #
Release a grabbed device.
Events
An input event, including the timestamp.
An input event, without the timestamp.
Each constructor corresponds to one event type, except for UnknownEvent
.
Constructors
SyncEvent SyncEvent | |
KeyEvent Key KeyEvent | |
RelativeEvent RelativeAxis EventValue | |
AbsoluteEvent AbsoluteAxis EventValue | |
MiscEvent MiscEvent EventValue | |
SwitchEvent SwitchEvent EventValue | |
LEDEvent LEDEvent EventValue | |
SoundEvent SoundEvent EventValue | |
RepeatEvent RepeatEvent EventValue | |
ForceFeedbackEvent EventCode EventValue | |
PowerEvent EventCode EventValue | |
ForceFeedbackStatusEvent EventCode EventValue | |
UnknownEvent Word16 EventCode EventValue | We include this primarily so that |
Instances
Read EventData Source # | |
Show EventData Source # | |
Eq EventData Source # | |
Ord EventData Source # | |
The status of a key.
Instances
Bounded KeyEvent Source # | |
Enum KeyEvent Source # | |
Read KeyEvent Source # | |
Show KeyEvent Source # | |
Eq KeyEvent Source # | |
Ord KeyEvent Source # | |
Defined in Evdev |
A direct representation of the code field of the C input_event, for when there is no obvious meaningful sum type.
Instances
Enum EventCode Source # | |
Defined in Evdev Methods succ :: EventCode -> EventCode # pred :: EventCode -> EventCode # fromEnum :: EventCode -> Int # enumFrom :: EventCode -> [EventCode] # enumFromThen :: EventCode -> EventCode -> [EventCode] # enumFromTo :: EventCode -> EventCode -> [EventCode] # enumFromThenTo :: EventCode -> EventCode -> EventCode -> [EventCode] # | |
Read EventCode Source # | |
Show EventCode Source # | |
Eq EventCode Source # | |
Ord EventCode Source # | |
newtype EventValue Source #
A direct representation of the value field of the C input_event, for when there is no obvious meaningful sum type.
Constructors
EventValue Int32 |
Instances
Lower-level
newDeviceFromFd :: Fd -> IO Device Source #
Generalisation of newDevice
, in case one needs control over the file descriptor,
e.g. in order to set a particular FileMode
, OpenMode
, or OpenFileFlags
.
Note that:
newDevice path = newDeviceFromFd =<< openFd path ReadOnly Nothing defaultFileFlags
WARNING: Don't attempt to reuse the Fd
- it will be closed when the Device
is garbage collected.
nextEventMay :: Device -> IO (Maybe Event) Source #
Get the next event from the device, if one is available.
Designed for use with devices created from a non-blocking file descriptor. Otherwise equal to fmap Just . nextEvent
.
LEDs values
Instances
Bounded LEDValue Source # | |
Enum LEDValue Source # | |
Read LEDValue Source # | |
Show LEDValue Source # | |
Eq LEDValue Source # | |
Ord LEDValue Source # | |
Defined in Evdev.LowLevel |
C-style types
These correspond more directly to C's input_event and timeval. They are used internally, but may be useful for advanced users.
Constructors
CEvent | |
Fields
|
fromCEvent :: CEvent -> Event Source #
toCTimeVal :: DiffTime -> CTimeVal Source #
fromCTimeVal :: CTimeVal -> DiffTime Source #