OpenGLEAN
OpenGLEAN User Support
Home page | Introduction | Documentation | Files | Examples | Proposals | Authors | Links


OpenGLEAN Device Support Development
Summary | CVS | (discussion via home page) | (contact via home page) | (suggestion box) | License | Todo | Bugs

Input API Proposal

This proposal was originally authored for OpenGLUT.

Scope

This proposal is limited to the scope of the OpenGLEAN input handling API including keyboard, mouse and joysticks. In the context of gleandev this API proposal should only apply to joysticks. See also Device API Proposal for other input device discussion.

Motivation

There are several aspects of OpenGLEAN input handling that can be improved. GLUT evolved over time retaining backwards compatibility, introducing some degree of duplication and inconvenience. The GLUT abstraction of joysticks has been superceded by technical advances - USB, additional axes and analog (non-binary) buttons. Another limitation of the GLUT API is support for only one keyboard, one mouse and one joystick.

Window Event Callback Handlers

Keyboard

NB: Multiple keyboard support is the OS or window system responsibilty. For modern systems, depending on configuration, you either get all keyboards multiplexed to a single workstation console or you can in principle have them each available as part of a separate console. This is far and away outside of the purview of a library such as OpenGLEAN.

Support for multiple keyboards is provided by means of the current keyboard context which can be optionally queried or set by the application.

void glutKeyboardConnect (void (*func) (int state))

Parameters

void glutKeyboardKey (void (*func) (unsigned int key, int state))

Parameters

Notes

This form of keyboard handling consolidates the two GLUT API calls: glutKeyboardFunc() and glutSpecialFunc().

Mouse

NB: See the note about workstation keyboards. That applies equally well here. This subsection of the proposal should be struck, as it was written without considering extant OS technology..

Support for multiple mice is provided by means of the current mouse context which can be optionally queried or set by the application.

void glutMouseConnect (void (*func) (int state))

Parameters

    void glutMouseButton (
        void (*func) (unsigned int button, int state, int x, int y)
    )
    

Parameters

void glutMouseMotion (void (*func) (int state, int x, int y))

Parameters

Joystick

void glutJoystickConnect (void (*func) (int state))

Parameters

void glutJoystickButton (void (*func) (unsigned int button, int state))

Parameters

State Query

Keypress, mouse button and joystick button state transitions are sent to OpenGLEAN windows as GLUT_UP or GLUT_DOWN events. It is also useful to know about keys or buttons currently being held down. Analog inputs such as joystick axes are more conveniently treated as continuously changing state, rather than individual events.

int glutGetKey (unsigned int param)

Parameters

Returns GLUT_DOWN for a key held down in the current keyboard context, GLUT_UP else.

int glutGetButton (unsigned int param)

Parameters

Returns GLUT_DOWN for a mouse button held down in the current mouse context, GLUT_UP otherwise.

Parameters

Returns the x or y position of the current mouse context.

GLdouble glutGetAxis (unsigned int param)

Parameters

For digital buttons, returns 1 for joystick buttons held down in the current joystick context, 0 otherwise.

For analog buttons, returns a number in the range [0,1] with 0 for unpressed, 1 held with down completely.

For analog axes, returns a number in the range [-1,1] with 0 being neutral.

Input Context

For applications supporting multiple keyboards, mice or joysticks.

Get the current input context, in order to identify the individual device.

Set the current input context, for querying state of specific devices.

    int glutGetKeyboard (void)
    void glutSetKeyboard (int keyboard);
    

    int glutGetMouse (void)
    void glutSetMouse (int mouse);
    

    int glutGetJoystick (void)
    void glutSetJoystick (int joystick);
    




SourceForge.net Logo Supported in part by SourceForge.net.

Generated on Fri Sep 9 18:01:32 2005 for gleandev by doxygen 1.4.3
The OpenGLEAN project is hosted in part by SourceForge.