Difference between revisions of "Gasync"

From GIMX
Jump to: navigation, search
Line 13: Line 13:
 
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).<br />
 
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).<br />
 
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.
 
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 implementation=
+
==GNU/Linux==
 
{| class="wikitable" style="text-align: center;"
 
{| class="wikitable" style="text-align: center;"
 
|-
 
|-
Line 37: Line 37:
 
* Being based on libusb, ghid claims the HID interface and detaches the kernel driver. guhid is a [https://www.kernel.org/doc/Documentation/hid/uhid.txt uhid] wrapper to allow connecting the device back with the kernel.
 
* Being based on libusb, ghid claims the HID interface and detaches the kernel driver. guhid is a [https://www.kernel.org/doc/Documentation/hid/uhid.txt uhid] wrapper to allow connecting the device back with the kernel.
  
=Windows implementation=
+
==Windows==
 
{| class="wikitable" style="text-align: center;"
 
{| class="wikitable" style="text-align: center;"
 
|-
 
|-
Line 58: Line 58:
 
Notes:
 
Notes:
 
* The libSDL events are processed synchronously.
 
* The libSDL events are processed synchronously.
 
+
==Porting to Darwin / MAC OS X==
=Porting to Darwin / MAC OS X=
 
 
{| class="wikitable" style="text-align: center;"
 
{| class="wikitable" style="text-align: center;"
 
|-
 
|-

Revision as of 09:59, 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)

It also provides a waiting interface based on poll on GNU/Linux and MsgWaitForMultipleObject on Windows.

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 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 COM ports Waitable Timers libusb HID API

Notes:

  • The libSDL events are processed synchronously.

Porting to Darwin / MAC OS X

gpoll ginput gserial gtimer gusb ghid
poll libSDL 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.