-
Notifications
You must be signed in to change notification settings - Fork 30
Inputs
See config.* controls.* and input* files.
Also see title.c for information on menu handling.
See input* for more information.
SDL has two main modes of using the keyboard:
-
unicode/text-input mode during typing areas such as text messaging.
-
key state - here we're treating the keyboard more as a raw controller and just looking for key press info.
At game startup we enumerate the list of keys from SDL to build up vkey_maps structure holding keys -> names.
Old directx supported a buffered keyboard handle which would buffer keystrokes so you wouldn't miss any while the player is typing a text message etc.. We simulate this in input_sdl*.
Check out KeyBoard Shortcuts for list of shortcuts.
See input_sdl.* and input.h for more information.
Most support that we had in DirectX exists.
See FAQ for information on button name mappings.
See configs.* and pilots folder.
Check out Pilot KeyMaps for list of names you can use in pilots file.
Note: This needs updating
ProcessGameKeys()
{
IsKeyPressed()
IsKeyHeld()
}
/* diff modes the player can be in */
ProcessShips()
{
ModeControl[]
{
ShipMode0()
ShipMode1()
{
control_ship()
}
ShipMode2()
{
AnyKeyReleased()
control_ship()
}
}
}
/* in game ship movement */
control_ship()
{
/* this is commented out */
/* it also interfers with the f keys */
//ReadInput()
/* users MouseState[ new_input ] */
IsKeyHeld()
/* read all key actions customized for user
again "any customizable user key" */
/* Joystick:
reads axis data */
/* reads globals holding current joystick events */
/* these were read in by ReadInput() above */
ReadJoystickInput()
{
/* move the ship based on the inputs */
DoShipAction()
{
}
}
/* Joystick:
read Buttons and POV data */
key_held()
{
KEY_ON_KEYBOARD()
KEY_HELD()
KEY_ON_MOUSE()
MOUSE_BUTTON_HELD()
MOUSE_WHEEL_UP()
MOUSE_WHEE_DOWN()
KEY_ON_JOYSTICK()
KEY_JOYSTICK()
KEY_ON_JOYSTICK_BUTTON()
KEY_JOYSTICK_BUTTON()
KEY_ON_JOYSTICK_POV()
KEY_JOYSTICK_POV()
KEY_JOYSTICK_POVDIR()
JOYSTICK_POV_HELD()
}
/* Joystick:
read Buttons and POV data */
key_pressed()
{
KEY_ON_KEYBOARD()
KEY_PRESSED()
KEY_ON_MOUSE()
MOUSE_BUTTON_PRESSED()
MOUSE_WHEEL_UP_PRESSED()
MOUSE_WHEEL_DOWN_PRESSED()
KEY_ON_JOYSTICK()
KEY_JOYSTICK()
KEY_ON_JOYSTICK_BUTTON()
KEY_JOYSTICK_BUTTON()
KEY_ON_JOYSTICK_POV()
KEY_JOYSTICK_POV()
KEY_JOYSTICK_POVDIR()
JOYSTICK_POV_PRESSED()
}
key_released() /* NEVER CALLED !! */
{
// doesn't matter
}
}
/* all new inputs are read into globals */
ReadInput()
{
/* sets old_input, new_input */
ReadMouse()
{
/* globals */
MouseInput
lpdiMouse
MouseState
//
MOUSE_WHEEL_UP()
MOUSE_WHEEL_DOWN()
// dinput
IDirectInputDevice_GetDeviceState()
IDirectInputDevice_Acquire()
}
ReadKeyboard()
{
/*globals*/
KeyState
lpdiKeyboard
/* dinput */
IDirectInputDevice_GetDeviceState()
}
PollJoystick()
{
/* globals accessed */
JoystickInput
lpdiJoystick[]
js[]
js_pov[]
JoystickInfo[]
/* direct input called */
IDirectInputDevice2_Poll()
IDirectInputDevice2_Acquire()
IDirectInputDevice_GetDeviceState()
}
}
AnyKeyPressed()
{
ReadInput()
KEY_PRESSED()
MOUSE_BUTTON_PRESSED
IsAnyJoystickButtonPressed()
}
AnyKeyReleased()
{
/* dik's */
ReadInput()
KEY_RELEASED()
MOUSE_BUTTON_RELEASED
IsAnyJoystickButtonReleased()
}
IsKeyHeld()
{
MOUSE_BUTTON_HELD()
MOUSE_WHEEL_UP()
MOUSE_WHEEL_DOWN()
KEY_HELD()
}
IsKeyPressed()
{
/* lots of DIK's */
MOUSE_BUTTON_PRESSED()
KEY_PRESSED()
}
SendGameMessage()
{
QuickText
{
SendQuickText()
{
ReadInput()
QuickText /* reset */
}
}
QuickTextWhisper
{
SendQuickTextWhisper()
{
ReadInput()
QuickTextWhisper /* reset */
}
}
}
RenderScene()
ReadInputs()
PollJoystick()
/* read joystick information into globals */
/* there is some code here that should
probably be moved some where else */
MainGame()
MainRoutines()
ProcessShips()
ReadJoystickInput()
key_pressed()
key_held()
MenuProcess()
/* read buffered keyboard
read mouse events
read joy events */
ProcessGameKeys()