InputHandlers

From Spheriki

Jump to: navigation, search

Input Handlers

Keyboard, Joystick and Mouse can be used to send input to Sphere. Sphere can make the MapEngine handle movement input automatically through Bind functions, or you can read the status of the input and handle them yourself.

The Keyboard and Joystick controls can be configured using Sphere's config.exe utility or directly in the Sphere Editor, just choose menu option "Project" and then "Configure Sphere".

Sphere Default Input Configuration

Sphere defines AttachPlayerInput(person_entity, player_index)

     - makes the 'person_entity' respond to the input
       Currenty player_index has to be from zero to four (max four players)
       Note: AttachInput is equivalent to AttachPlayerInput(person_entity, 0)
Sphere Configuration
Sphere Configuration

The keys for these automatic bindings can be configured using Sphere's config.exe utility or directly in the Sphere Editor, just choose menu option "Project" and then "Configure Sphere".

Sphere also defines BindJoystickButton(joystick, button, onbuttondown, onbuttonup), and BindKey(key, onkeydown, onkeyup), GetJoystickX(joy), GetJoystickY(joy) IsMouseButtonPressed(button) and GetMouseX(), GetMouseY()

Custom Input Handlers

A key handler would not only allow reassignment of keys, it would also allow the finer points of key event control without worrying about the underlying programming. For example: Full key press events (instead of just ONKEYDOWN and ONKEYUP you can also manipulate the retriggering of those keys and have ONKEYPRESS[1] events) can be handled without worrying about GetKey or sphere's millisecond timing. It can also work for joystick buttons and movements and handle the mouse (for example: Sphere native commands dont handle double click or dragging).

Other input management systems: NeoLogiX has done some work on n_handler.js and cmdhandler [2], and Sarenji has a fully (keyboard and mouse) working techdemo called ActionHandler.rar, download here

Personal tools