Difference between revisions of "Gasync"
(→Test programs) |
(→Windows) |
||
Line 61: | Line 61: | ||
Notes: | Notes: | ||
* The libSDL events are processed synchronously. | * The libSDL events are processed synchronously. | ||
+ | * The Windows HID API does not provide access to mouse and keyboards devices. | ||
==Porting to Darwin / MAC OS X== | ==Porting to Darwin / MAC OS X== |
Revision as of 14:05, 11 May 2016
Note: this is applicable to the refactoring branch only.
The gasync (GIMX asynchronous) library is the evolution of the GE (GIMX events) library.
In addition to input devices (mice, keyboards, joysticks), gasync also handles the following components:
- serial ports (DIY USB adapter)
- high-resolution timers (delayed or periodic tasks)
- USB devices (authentication sources)
- HID devices (Logitech Wheels, GPP/Cronus/Titan One, custom input device drivers)
It also provides a waiting interface based on poll on GNU/Linux and MsgWaitForMultipleObject on Windows.
Contents
How it works
Gimx asks the kernel to be notified about events on a set of resources (file descriptors on GNU/Linux and handles on Windows).
Each resource has callbacks that are called on events like data available, write completed, or IO error.
Resources can be of various types: USB device, timer, input device, HID device, serial device, network socket (server mode), bluetooth socket. Network and bluetooth sockets are not integrated into gasync yet.
When data is available a read is performed and the data is passed to the callback. The callback then processes the data and may submit some IOs depending on various conditions.
Implementation
GNU/Linux
gpoll | ginput | gserial | gtimer | gusb | ghid | |||
poll | evdev | jsdev | X.Org Xi2 | ghid | termios | timerfd | libusb |
Notes:
- ghid is not based on hidraw because write() does not support non-blocking mode.
- Being based on libusb, ghid claims the HID interface and detaches the kernel driver. guhid is a uhid wrapper to allow connecting the device back with the kernel.
Windows
gpoll | ginput | gserial | gtimer | gusb | ghid | ||
MsgWaitForMultipleObject | Raw Input | libSDL | ghid | COM ports | Waitable Timers | libusb | HID API |
Notes:
- The libSDL events are processed synchronously.
- The Windows HID API does not provide access to mouse and keyboards devices.
Porting to Darwin / MAC OS X
gpoll | ginput | gserial | gtimer | gusb | ghid | |
poll | libSDL | ghid | termios | TODO | libusb |
Notes:
- gtimer has to provide a file descriptor to be given to gpoll.
- ginput has to provide a way to capture the inputs (like constraining the mouse cursor into a window).
- Native input events could be added alongside the libSDL events.
Test programs
The gasync/test folder contains programs that show how to use the components and that can be used to test and validate the functionalities.
ghid_test
This program enumerates the available HID devices and asks the user to select one.
It then tries to read reports and writes force feedback for some known devices (Logitech Rumble Pad, Dualshock 4, Logitech Driving Force GT).
ginput_test
This program asks the user to select an event source for mouse and keyboards devices (physical inputs or window system).
It then shows the available input devices (mice, keyboards and joysticks) and prints the events.
gserial_test
This program writes packets to a serial port and checks if the packet can be read on the same port. The tx and rx pins have to be connected together. The following command writes / reads 1000 66-byte packets on /dev/ttyUSB0 at 500 000 bps:
./gserial_test -p /dev/ttyUSB0 -b 500000 -n 1000 -s 66
gtimer_test
This program checks the accuracy of the gtimer component.
It starts a few periodic timers and prints a message if the accuracy exceeds 10% of the period.
guhid_test
This program enumerates the available HID devices and asks the user to select one.
It then configures a uhid device, read reports and writes them to the uhid device.