Main Page | Recent changes | View source | Page history

Printable version | Disclaimers | Privacy policy

Not logged in
Log in | Help
 

Input system for GLFW 3

From GLFW

The aim of this document is to collect information about the input subsystem. It is meant to be a collection of notes that are put here to highlight the issues, solutions and present idea to implement GLFW 3 input rework.

Contents

Input system internal

The main difference with the existing GLFW is that all the function that are waiting for events now needs to listen to multiple event source at the same time. The notion of event source is implemented in many different way on the different platform. However, it is always based on the principal that instead of waiting for events on the windowing event queue. However, this prevent us from listening to event on multiple queue. We thus need to introduce an intermediate object that only act as a collector of events.

The solution identified for each platfrom is described below:

Devices

Currently GLFW support properly keyboard and mouse. Joystick are supported but you don't have Mac OS X support in the main line and the API is based on polling. The rest of GLFW is event driven we want to move to that model as well. Tablet are not supported just yet unless they emulate a mouse.

Keyboard

Mouse

Joystick

Tablet

Patch exists but needs work.

Platform-specific information

Linux/X11

Event source

The concept of event source is implemented using the select system call. Support is already implemented and sort of work. It still needs investigation as it has a remaining problem when the application is killed or aborted. There seems to be an issue in the use of select that's causing a segmentation fault. The current trace point out some glibc internal function. This needs to be fixed before we are able to deliver this change to the master branch.

Device enumeration

Device enumeration is a two stage process the first stage consists in registering device already available in the system. This stage includes extracting device information and building a list of available input devices. The second stage consists in monitoring changes to the list of devices connected to the system and notifying the application about changes.

Joystick

Implementation of an event driven API to joystick is not a technical issue. It is relatively straight forward and does not need any special support as it is what is implemented as part of the input system driver. All USB joystick are supported as is. It is possible to extract the name of the joystick, the number of axis and the number of button from the driver.

TODO: Check with game port joystick whether they are reported as part of the input system or through a different device.

The enumeration of device is simple:

  1. Register a monitor on the directory /dev/input
  2. Go through the list of device connected at the current time using directory listing on /dev/input looking for generic event source devices (eventXXX)
  3. Extract device capabilities in order to define whether it is a joystick, a mouse, a keyboard or a tablet, or something completely different (like power button and so on).
  4. For all joystick add it to the list of supported device.
  5. poll for changes on the device list as part of the event loop.
    • Changes are device addition/removal.

If the inotify API is not available, update to the device list is not supported.

*BSD/X11

No progress.

Solaris/X11

No progress.

Win32

Event source

In order to be able to implement the event driven interface and to be able to wait for change on multiple event source the link below describes how it can be implemented using CreateEvent. The mechanism is very similar to select.

http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.idirectinputdevice8.idirectinputdevice8.seteventnotification%28v=VS.85%29.aspx

Joystick

Win32 support for joystick is implemented using one of the two alternative:

The later is not that interesting for us now and will only be used in later version.

The DirectInput8 API provides at least the following features:

Cocoa

Joystick support on Mac OS X relies on HID and the HID manager API. As a consequence most of the work is very similar to Linux/X11.

Retrieved from "http://wiki.glfw.org/wiki/Input_system_for_GLFW_3"

This page has been accessed 3,325 times. This page was last modified on 20 July 2011, at 14:44. Content is available under Attribution-Share Alike 3.0 Unported.


[Main Page]
Main page
Recent changes
Random page

View source
Discuss this page
Page history
What links here
Related changes

Special pages