OpenGLUT Documentation
Introduction | Documentation | Examples | Proposals | Authors | Copying | Todo | Bugs | Links

OpenGLUT Input API Proposal

Note:
This is a proposal for the purpose of discussion and discussion. This API is not currently implemented in OpenGLUT.

Scope

This proposal is limited to the scope of the OpenGLUT input handling API including keyboard, mouse and joysticks.

Motivation

There are several aspects of OpenGLUT input handling that we seek to improve. GLUT evolved over time retaining backwards compatibility, introducing some degree of duplication and inconsistancy.

Features

Window Event Callback Handlers

Keyboard

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

Set the application callback for connection or disconnection of a keyboard.

Parameters

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

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

Set the application callback for a keyboard up or down event.

Parameters

Notes

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

Mouse

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

Set the application callback for a conection or disconnection of a mouse.

Parameters

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

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

Set the application callback for a mouse button event.

Parameters

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

Set the application callback for a mouse motion event.

Parameters

Joystick

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

Set the application callback for a conection or disconnection of a joystick.

Parameters

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

Set the application callback for a joystick button event.

Parameters

State Query

Keypress, mouse button and joystick button state transitions are communicated to OpenGLUT 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 treated as continuously changing state, rather than individual events.

int glutGetKey(unsigned int param)

Return GLUT_DOWN for a key held down in the current keyboard, GLUT_UP otherwise.

Parameters

int glutGetButton(unsigned int param)

Return GLUT_DOWN for a mouse button held down in the current mouse or joystick, GLUT_UP otherwise.

Parameters

int glutGetPosition(unsigned int param)

Return the x or y position of the current mouse, relative to current window.

Parameters

GLdouble glutGetAxis(unsigned int param)

Return the value of a joystick axis or button.

Parameters

Notes

Input Context

int glutGetKeyboard()
void glutSetKeyboard(int keyboard);

Get or set the current keyboard input context.

int glutGetMouse()
void glutSetMouse(int mouse);

Get or set the current mouse input context.

int glutGetJoystick()
void glutSetJoystick(int joystick);

Get or set the current joystick input context.

Version

Last updated January 22nd 2005

Feedback

Feedback, comments or suggestions can be directed either to the mail list or discussion forum.



OpenGLUT Development @ Sourceforge
Homepage | Summary | Files | CVS | Forums | Lists | Bugs | RFE

Generated on Sat Feb 5 01:47:28 2005 for OpenGLUT by doxygen 1.3.9.1
The OpenGLUT project is hosted by sourceforge.net.