Client input handling - bindable commands. More...
#include "../client.h"
#include "cl_input.h"
#include "cl_keys.h"
#include "cl_joystick.h"
#include "../battlescape/cl_localentity.h"
#include "../cl_console.h"
#include "../battlescape/cl_actor.h"
#include "../battlescape/cl_view.h"
#include "../battlescape/cl_parse.h"
#include "../battlescape/cl_hud.h"
#include "../ui/ui_main.h"
#include "../ui/ui_input.h"
#include "../ui/node/ui_node_abstractnode.h"
#include "../../common/tracing.h"
Go to the source code of this file.
Data Structures | |
struct | kbutton_t |
Defines | |
#define | MAX_KEYQ 64 |
#define | SCROLL_BORDER 4 |
#define | MOUSE_YAW_SCALE 0.1 |
#define | MOUSE_PITCH_SCALE 0.1 |
Functions | |
static void | IN_KeyDown (kbutton_t *b) |
static void | IN_KeyUp (kbutton_t *b) |
static void | IN_TurnLeftDown_f (void) |
static void | IN_TurnLeftUp_f (void) |
static void | IN_TurnRightDown_f (void) |
static void | IN_TurnRightUp_f (void) |
static void | IN_TurnUpDown_f (void) |
static void | IN_TurnUpUp_f (void) |
static void | IN_TurnDownDown_f (void) |
static void | IN_TurnDownUp_f (void) |
static void | IN_ShiftLeftDown_f (void) |
static void | IN_ShiftLeftUp_f (void) |
static void | IN_ShiftRightDown_f (void) |
static void | IN_ShiftRightUp_f (void) |
static void | IN_ShiftUpDown_f (void) |
static void | IN_ShiftUpUp_f (void) |
static void | IN_ShiftDownDown_f (void) |
static void | IN_ShiftDownUp_f (void) |
static void | IN_ZoomInDown_f (void) |
static void | IN_ZoomInUp_f (void) |
static void | IN_ZoomOutDown_f (void) |
static void | IN_ZoomOutUp_f (void) |
static void | CL_LevelUp_f (void) |
Switch one worldlevel up. | |
static void | CL_LevelDown_f (void) |
Switch on worldlevel down. | |
static void | CL_ZoomInQuant_f (void) |
static void | CL_ZoomOutQuant_f (void) |
static void | CL_SelectDown_f (void) |
Left mouse click. | |
static void | CL_SelectUp_f (void) |
static void | CL_ActionDown_f (void) |
Mouse click. | |
static void | CL_ActionUp_f (void) |
static void | CL_TurnDown_f (void) |
Turn button is hit. | |
static void | CL_TurnUp_f (void) |
static void | CL_HudRadarDown_f (void) |
static void | CL_HudRadarUp_f (void) |
static void | CL_RightClickDown_f (void) |
Right mouse button is hit in menu. | |
static void | CL_RightClickUp_f (void) |
Right mouse button is freed in menu. | |
static void | CL_MiddleClickDown_f (void) |
Middle mouse button is hit in menu. | |
static void | CL_MiddleClickUp_f (void) |
Middle mouse button is freed in menu. | |
static void | CL_LeftClickDown_f (void) |
Left mouse button is hit in menu. | |
static void | CL_LeftClickUp_f (void) |
Left mouse button is freed in menu. | |
float | CL_GetKeyMouseState (int dir) |
static void | IN_Parse (void) |
Called every frame to parse the input. | |
static void | IN_PrintKey (const SDL_Event *event, int down) |
Debug function to print sdl key events. | |
static void | IN_TranslateKey (SDL_keysym *keysym, unsigned int *ascii, unsigned short *unicode) |
Translate the keys to ufo keys. | |
void | IN_EventEnqueue (unsigned int keyNum, unsigned short keyUnicode, qboolean keyDown) |
void | IN_Frame (void) |
Handle input events like keys presses and joystick movement as well as window events. | |
void | IN_Init (void) |
void | IN_SendKeyEvents (void) |
Variables | |
struct { | |
unsigned int key | |
unsigned short unicode | |
int down | |
} | keyq [MAX_KEYQ] |
static int | keyq_head = 0 |
static int | keyq_tail = 0 |
static cvar_t * | in_debug |
cvar_t * | cl_isometric |
int | mouseSpace |
int | mousePosX |
int | mousePosY |
static int | oldMousePosX |
static int | oldMousePosY |
static kbutton_t | in_turnleft |
static kbutton_t | in_turnright |
static kbutton_t | in_shiftleft |
static kbutton_t | in_shiftright |
static kbutton_t | in_shiftup |
static kbutton_t | in_shiftdown |
static kbutton_t | in_zoomin |
static kbutton_t | in_zoomout |
static kbutton_t | in_turnup |
static kbutton_t | in_turndown |
static kbutton_t | in_pantilt |
Client input handling - bindable commands.
When a key event issues a button command (+forward, +attack, etc), it appends its key number as a parameter to the command so it can be matched up with the release.
Key_Event(unsigned int key, unsigned short unicode, qboolean down, unsigned time);
+mlook src time
Definition in file cl_input.c.
#define MAX_KEYQ 64 |
Definition at line 58 of file cl_input.c.
Referenced by IN_EventEnqueue(), and IN_SendKeyEvents().
#define MOUSE_PITCH_SCALE 0.1 |
Definition at line 439 of file cl_input.c.
Referenced by CL_GetKeyMouseState().
#define MOUSE_YAW_SCALE 0.1 |
Definition at line 438 of file cl_input.c.
Referenced by CL_GetKeyMouseState().
#define SCROLL_BORDER 4 |
Definition at line 437 of file cl_input.c.
Referenced by CL_GetKeyMouseState().
static void CL_ActionDown_f | ( | void | ) | [static] |
Mouse click.
Definition at line 325 of file cl_input.c.
References CL_ActorActionMouse(), mouseSpace, and MS_WORLD.
Referenced by IN_Init().
static void CL_ActionUp_f | ( | void | ) | [static] |
Definition at line 332 of file cl_input.c.
References mouseSpace, MS_NULL, and MS_UI.
Referenced by IN_Init().
float CL_GetKeyMouseState | ( | int | dir | ) |
Definition at line 444 of file cl_input.c.
References MOUSE_PITCH_SCALE, MOUSE_YAW_SCALE, mousePosX, mousePosY, oldMousePosX, oldMousePosY, viddef_t::rx, viddef_t::ry, SCROLL_BORDER, kbutton_t::state, STATE_FORWARD, STATE_RIGHT, STATE_ROT, STATE_TILT, STATE_ZOOM, viddef, viddef_t::viewHeight, viddef_t::viewWidth, viddef_t::x, and viddef_t::y.
Referenced by CL_CameraMove().
static void CL_HudRadarDown_f | ( | void | ) | [static] |
Definition at line 360 of file cl_input.c.
References mn_hud, cvar_s::string, UI_IsWindowOnStack(), and UI_PushWindow().
Referenced by IN_Init().
static void CL_HudRadarUp_f | ( | void | ) | [static] |
Definition at line 370 of file cl_input.c.
References mn_hud, cvar_s::string, UI_CloseWindow(), and UI_IsWindowOnStack().
Referenced by IN_Init().
static void CL_LeftClickDown_f | ( | void | ) | [static] |
Left mouse button is hit in menu.
Definition at line 420 of file cl_input.c.
References K_MOUSE1, mousePosX, mousePosY, mouseSpace, MS_UI, and UI_MouseDown().
Referenced by IN_Init().
static void CL_LeftClickUp_f | ( | void | ) | [static] |
Left mouse button is freed in menu.
Definition at line 430 of file cl_input.c.
References K_MOUSE1, mousePosX, mousePosY, mouseSpace, MS_UI, and UI_MouseUp().
Referenced by IN_Init().
static void CL_LevelDown_f | ( | void | ) | [static] |
Switch on worldlevel down.
Definition at line 281 of file cl_input.c.
References CL_OnBattlescape(), cl_worldlevel, Cvar_SetValue(), and cvar_s::integer.
Referenced by IN_Init().
static void CL_LevelUp_f | ( | void | ) | [static] |
Switch one worldlevel up.
Definition at line 271 of file cl_input.c.
References cl, CL_OnBattlescape(), cl_worldlevel, Cvar_SetValue(), and cvar_s::integer.
Referenced by IN_Init().
static void CL_MiddleClickDown_f | ( | void | ) | [static] |
Middle mouse button is hit in menu.
Definition at line 400 of file cl_input.c.
References K_MOUSE3, mousePosX, mousePosY, mouseSpace, MS_UI, and UI_MouseDown().
Referenced by IN_Init().
static void CL_MiddleClickUp_f | ( | void | ) | [static] |
Middle mouse button is freed in menu.
Definition at line 410 of file cl_input.c.
References K_MOUSE3, mousePosX, mousePosY, mouseSpace, MS_UI, and UI_MouseUp().
Referenced by IN_Init().
static void CL_RightClickDown_f | ( | void | ) | [static] |
Right mouse button is hit in menu.
Definition at line 380 of file cl_input.c.
References K_MOUSE2, mousePosX, mousePosY, mouseSpace, MS_UI, and UI_MouseDown().
Referenced by IN_Init().
static void CL_RightClickUp_f | ( | void | ) | [static] |
Right mouse button is freed in menu.
Definition at line 390 of file cl_input.c.
References K_MOUSE2, mousePosX, mousePosY, mouseSpace, MS_UI, and UI_MouseUp().
Referenced by IN_Init().
static void CL_SelectDown_f | ( | void | ) | [static] |
Left mouse click.
Definition at line 308 of file cl_input.c.
References CL_ActorSelectMouse(), mouseSpace, and MS_WORLD.
Referenced by IN_Init().
static void CL_SelectUp_f | ( | void | ) | [static] |
Definition at line 315 of file cl_input.c.
References mouseSpace, MS_NULL, and MS_UI.
Referenced by IN_Init().
static void CL_TurnDown_f | ( | void | ) | [static] |
Turn button is hit.
Definition at line 342 of file cl_input.c.
References CL_ActorTurnMouse(), mouseSpace, MS_UI, and MS_WORLD.
Referenced by IN_Init().
static void CL_TurnUp_f | ( | void | ) | [static] |
Definition at line 350 of file cl_input.c.
References mouseSpace, MS_NULL, and MS_UI.
Referenced by IN_Init().
static void CL_ZoomInQuant_f | ( | void | ) | [static] |
Definition at line 289 of file cl_input.c.
References CL_CameraZoomIn(), mousePosX, mousePosY, mouseSpace, MS_UI, qfalse, and UI_MouseWheel().
Referenced by IN_Init().
static void CL_ZoomOutQuant_f | ( | void | ) | [static] |
Definition at line 297 of file cl_input.c.
References CL_CameraZoomOut(), mousePosX, mousePosY, mouseSpace, MS_UI, qtrue, and UI_MouseWheel().
Referenced by IN_Init().
void IN_EventEnqueue | ( | unsigned int | keyNum, | |
unsigned short | keyUnicode, | |||
qboolean | keyDown | |||
) |
Definition at line 740 of file cl_input.c.
References Com_Printf(), cvar_s::integer, Key_KeynumToString(), keyq, keyq_head, and MAX_KEYQ.
Referenced by IN_Frame(), and IN_JoystickMove().
void IN_Frame | ( | void | ) |
Handle input events like keys presses and joystick movement as well as window events.
Definition at line 759 of file cl_input.c.
References Cmd_ExecuteString(), Com_Printf(), Con_ToggleConsole_f(), Cvar_SetValue(), IN_EventEnqueue(), IN_JoystickMove(), IN_Parse(), IN_PrintKey(), IN_TranslateKey(), cvar_s::integer, K_AUX1, K_MOUSE1, K_MOUSE2, K_MOUSE3, K_MOUSE4, K_MOUSE5, K_MWHEELDOWN, K_MWHEELUP, key, cvar_s::modified, mousePosX, mousePosY, oldMousePosX, oldMousePosY, qfalse, qtrue, viddef_t::rx, viddef_t::ry, kbutton_t::state, UI_ReleaseInput(), unicode, vid_fullscreen, vid_grabmouse, vid_mode, and viddef.
Referenced by CL_Frame().
void IN_Init | ( | void | ) |
Definition at line 905 of file cl_input.c.
References _, CL_ActionDown_f(), CL_ActionUp_f(), CL_HudRadarDown_f(), CL_HudRadarUp_f(), CL_LeftClickDown_f(), CL_LeftClickUp_f(), CL_LevelDown_f(), CL_LevelUp_f(), CL_MiddleClickDown_f(), CL_MiddleClickUp_f(), CL_RightClickDown_f(), CL_RightClickUp_f(), CL_SelectDown_f(), CL_SelectUp_f(), CL_TurnDown_f(), CL_TurnUp_f(), CL_ZoomInQuant_f(), CL_ZoomOutQuant_f(), Cmd_AddCommand(), Com_Printf(), CVAR_ARCHIVE, Cvar_Get(), IN_ShiftDownDown_f(), IN_ShiftDownUp_f(), IN_ShiftLeftDown_f(), IN_ShiftLeftUp_f(), IN_ShiftRightDown_f(), IN_ShiftRightUp_f(), IN_ShiftUpDown_f(), IN_ShiftUpUp_f(), IN_StartupJoystick(), IN_TurnDownDown_f(), IN_TurnDownUp_f(), IN_TurnLeftDown_f(), IN_TurnLeftUp_f(), IN_TurnRightDown_f(), IN_TurnRightUp_f(), IN_TurnUpDown_f(), IN_TurnUpUp_f(), IN_ZoomInDown_f(), IN_ZoomInUp_f(), IN_ZoomOutDown_f(), IN_ZoomOutUp_f(), mousePosX, and mousePosY.
Referenced by CL_InitLocal().
static void IN_KeyDown | ( | kbutton_t * | b | ) | [static] |
Definition at line 101 of file cl_input.c.
References CL_Milliseconds(), Cmd_Argv(), Com_Printf(), kbutton_t::down, kbutton_t::downtime, and kbutton_t::state.
Referenced by IN_ShiftDownDown_f(), IN_ShiftLeftDown_f(), IN_ShiftRightDown_f(), IN_ShiftUpDown_f(), IN_TurnDownDown_f(), IN_TurnLeftDown_f(), IN_TurnRightDown_f(), IN_TurnUpDown_f(), IN_ZoomInDown_f(), and IN_ZoomOutDown_f().
static void IN_KeyUp | ( | kbutton_t * | b | ) | [static] |
Definition at line 144 of file cl_input.c.
References Cmd_Argv(), kbutton_t::down, kbutton_t::downtime, kbutton_t::msec, and kbutton_t::state.
Referenced by IN_ShiftDownUp_f(), IN_ShiftLeftUp_f(), IN_ShiftRightUp_f(), IN_ShiftUpUp_f(), IN_TurnDownUp_f(), IN_TurnLeftUp_f(), IN_TurnRightUp_f(), IN_TurnUpUp_f(), IN_ZoomInUp_f(), and IN_ZoomOutUp_f().
static void IN_Parse | ( | void | ) | [static] |
Called every frame to parse the input.
Definition at line 483 of file cl_input.c.
References ca_active, CL_ActorMouseTrace(), cls, mouseSpace, MS_NULL, MS_UI, MS_WORLD, client_static_s::state, UI_IsPointOnWindow(), viddef, viddef_t::viewHeight, and viddef_t::viewWidth.
Referenced by IN_Frame().
static void IN_PrintKey | ( | const SDL_Event * | event, | |
int | down | |||
) | [inline, static] |
Debug function to print sdl key events.
Definition at line 508 of file cl_input.c.
References Com_Printf(), and cvar_s::integer.
Referenced by IN_Frame().
void IN_SendKeyEvents | ( | void | ) |
Definition at line 963 of file cl_input.c.
References CL_Milliseconds(), down, key, Key_Event(), keyq, keyq_head, keyq_tail, MAX_KEYQ, and unicode.
Referenced by CL_SendCommand(), and CL_ViewLoadMedia().
static void IN_ShiftDownDown_f | ( | void | ) | [static] |
static void IN_ShiftDownUp_f | ( | void | ) | [static] |
static void IN_ShiftLeftDown_f | ( | void | ) | [static] |
static void IN_ShiftLeftUp_f | ( | void | ) | [static] |
static void IN_ShiftRightDown_f | ( | void | ) | [static] |
static void IN_ShiftRightUp_f | ( | void | ) | [static] |
static void IN_ShiftUpDown_f | ( | void | ) | [static] |
static void IN_ShiftUpUp_f | ( | void | ) | [static] |
static void IN_TranslateKey | ( | SDL_keysym * | keysym, | |
unsigned int * | ascii, | |||
unsigned short * | unicode | |||
) | [static] |
Translate the keys to ufo keys.
Definition at line 524 of file cl_input.c.
References Com_Printf(), cvar_s::integer, K_ALT, K_BACKSPACE, K_BREAK, K_CAPSLOCK, K_COMPOSE, K_CTRL, K_DEL, K_DOWNARROW, K_END, K_ENTER, K_ESCAPE, K_EURO, K_F1, K_F10, K_F11, K_F12, K_F13, K_F14, K_F15, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8, K_F9, K_HELP, K_HOME, K_INS, K_KP_5, K_KP_DEL, K_KP_DOWNARROW, K_KP_END, K_KP_ENTER, K_KP_HOME, K_KP_INS, K_KP_LEFTARROW, K_KP_MINUS, K_KP_NUMLOCK, K_KP_PGDN, K_KP_PGUP, K_KP_PLUS, K_KP_RIGHTARROW, K_KP_SLASH, K_KP_UPARROW, K_LEFTARROW, K_MENU, K_MODE, K_PAUSE, K_PGDN, K_PGUP, K_POWER, K_PRINT, K_RIGHTARROW, K_SCROLLOCK, K_SHIFT, K_SPACE, K_SUPER, K_SYSREQ, K_TAB, K_UNDO, and K_UPARROW.
Referenced by IN_Frame().
static void IN_TurnDownDown_f | ( | void | ) | [static] |
static void IN_TurnDownUp_f | ( | void | ) | [static] |
static void IN_TurnLeftDown_f | ( | void | ) | [static] |
static void IN_TurnLeftUp_f | ( | void | ) | [static] |
static void IN_TurnRightDown_f | ( | void | ) | [static] |
static void IN_TurnRightUp_f | ( | void | ) | [static] |
static void IN_TurnUpDown_f | ( | void | ) | [static] |
static void IN_TurnUpUp_f | ( | void | ) | [static] |
static void IN_ZoomInDown_f | ( | void | ) | [static] |
static void IN_ZoomInUp_f | ( | void | ) | [static] |
static void IN_ZoomOutDown_f | ( | void | ) | [static] |
static void IN_ZoomOutUp_f | ( | void | ) | [static] |
Definition at line 70 of file cl_input.c.
Referenced by CL_ActorMouseTrace(), CL_CameraMove(), CL_ViewCalcFieldOfViewX(), and SEQ_SetCamera().
int down |
Definition at line 63 of file cl_input.c.
Referenced by Check_SidePointsDown(), and IN_SendKeyEvents().
Definition at line 69 of file cl_input.c.
kbutton_t in_pantilt [static] |
Definition at line 94 of file cl_input.c.
kbutton_t in_shiftdown [static] |
Definition at line 90 of file cl_input.c.
kbutton_t in_shiftleft [static] |
Definition at line 89 of file cl_input.c.
kbutton_t in_shiftright [static] |
Definition at line 89 of file cl_input.c.
kbutton_t in_shiftup [static] |
Definition at line 90 of file cl_input.c.
kbutton_t in_turndown [static] |
Definition at line 92 of file cl_input.c.
kbutton_t in_turnleft [static] |
Definition at line 89 of file cl_input.c.
kbutton_t in_turnright [static] |
Definition at line 89 of file cl_input.c.
Definition at line 92 of file cl_input.c.
Definition at line 91 of file cl_input.c.
kbutton_t in_zoomout [static] |
Definition at line 91 of file cl_input.c.
unsigned int key |
Definition at line 61 of file cl_input.c.
Referenced by CL_ParseMapParticle(), CON_FlushIn(), EntityKeyValues::erase(), field(), IN_Frame(), IN_SendKeyEvents(), Info_Print(), lua_getfield(), lua_setfield(), primaryexp(), recfield(), Sys_ConsoleInput(), Sys_TTYDeleteCharacter(), UI_Tooltip(), and UnparseEntities().
struct { ... } keyq[MAX_KEYQ] [static] |
Referenced by IN_EventEnqueue(), and IN_SendKeyEvents().
int keyq_head = 0 [static] |
Definition at line 66 of file cl_input.c.
Referenced by IN_EventEnqueue(), and IN_SendKeyEvents().
int keyq_tail = 0 [static] |
Definition at line 67 of file cl_input.c.
Referenced by IN_SendKeyEvents().
int mousePosX |
Definition at line 73 of file cl_input.c.
Referenced by CL_ActorMouseTrace(), CL_GetKeyMouseState(), CL_LeftClickDown_f(), CL_LeftClickUp_f(), CL_MiddleClickDown_f(), CL_MiddleClickUp_f(), CL_RightClickDown_f(), CL_RightClickUp_f(), CL_ZoomInQuant_f(), CL_ZoomOutQuant_f(), HUD_DrawMouseCursorText(), HUD_UpdateCursor(), IN_Frame(), IN_Init(), IN_JoystickMove(), SCR_DrawCursor(), UI_BaseMapNodeDraw(), UI_CheckMouseMove(), UI_ContainerNodeDNDMove(), UI_DNDDrop(), UI_Draw(), UI_DrawCursor(), UI_EditorNodeDrawOverWindow(), UI_EditorNodeMouseDown(), UI_MapNodeCapturedMouseMove(), UI_PushDropDownWindow_f(), UI_TabNodeDraw(), UI_TodoNodeDrawOverWindow(), and UI_VScrollbarNodeDraw().
int mousePosY |
Definition at line 73 of file cl_input.c.
Referenced by CL_ActorMouseTrace(), CL_GetKeyMouseState(), CL_LeftClickDown_f(), CL_LeftClickUp_f(), CL_MiddleClickDown_f(), CL_MiddleClickUp_f(), CL_RightClickDown_f(), CL_RightClickUp_f(), CL_ZoomInQuant_f(), CL_ZoomOutQuant_f(), HUD_DrawMouseCursorText(), HUD_UpdateCursor(), IN_Frame(), IN_Init(), IN_JoystickMove(), SCR_DrawCursor(), UI_BaseMapNodeDraw(), UI_CheckMouseMove(), UI_ContainerNodeDNDMove(), UI_DNDDrop(), UI_Draw(), UI_DrawCursor(), UI_EditorNodeDrawOverWindow(), UI_EditorNodeMouseDown(), UI_MapNodeCapturedMouseMove(), UI_PushDropDownWindow_f(), UI_SpinnerNodeDraw(), UI_TabNodeDraw(), UI_TodoNodeDrawOverWindow(), UI_VScrollbarNodeAction(), and UI_VScrollbarNodeDraw().
int mouseSpace |
Definition at line 72 of file cl_input.c.
Referenced by CL_ActionDown_f(), CL_ActionUp_f(), CL_ActorActionMouse(), CL_ActorSelectMouse(), CL_ActorShoot(), CL_ActorStartMove(), CL_ActorTurnMouse(), CL_ActorUseHeadgear_f(), CL_AddTargeting(), CL_LeftClickDown_f(), CL_LeftClickUp_f(), CL_MiddleClickDown_f(), CL_MiddleClickUp_f(), CL_RightClickDown_f(), CL_RightClickUp_f(), CL_SelectDown_f(), CL_SelectUp_f(), CL_TurnDown_f(), CL_TurnUp_f(), CL_ZoomInQuant_f(), CL_ZoomOutQuant_f(), HUD_UpdateActor(), IN_Parse(), Key_Event(), SCR_DrawCursor(), and UI_FocusNextActionNode().
int oldMousePosX [static] |
Definition at line 74 of file cl_input.c.
Referenced by CL_GetKeyMouseState(), and IN_Frame().
int oldMousePosY [static] |
Definition at line 74 of file cl_input.c.
Referenced by CL_GetKeyMouseState(), and IN_Frame().
unsigned short unicode |
Definition at line 62 of file cl_input.c.
Referenced by IN_Frame(), and IN_SendKeyEvents().