cl_input.c File Reference

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"
Include dependency graph for cl_input.c:

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_tin_debug
cvar_tcl_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

Detailed Description

Client input handling - bindable commands.

Note:
Continuous button event tracking is complicated by the fact that two different input sources (say, mouse button 1 and the control key) can both press the same button, but the button should only be released when both of the pressing key have been released.

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 Documentation

#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().


Function Documentation

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  ) 
static void CL_HudRadarDown_f ( void   )  [static]
Todo:
only call/register it when we are on the battlescape

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]
Todo:
only call/register it when we are on the battlescape

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   ) 
void IN_Init ( void   ) 
static void IN_KeyDown ( kbutton_t b  )  [static]
static void IN_KeyUp ( kbutton_t b  )  [static]
static void IN_Parse ( void   )  [static]

Called every frame to parse the input.

Note:
The geoscape zooming code is in UI_MouseWheel too
See also:
CL_Frame

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   ) 
See also:
CL_SendCommand

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]

Definition at line 242 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_ShiftDownUp_f ( void   )  [static]

Definition at line 246 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_ShiftLeftDown_f ( void   )  [static]

Definition at line 218 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_ShiftLeftUp_f ( void   )  [static]

Definition at line 222 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_ShiftRightDown_f ( void   )  [static]

Definition at line 226 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_ShiftRightUp_f ( void   )  [static]

Definition at line 230 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_ShiftUpDown_f ( void   )  [static]

Definition at line 234 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_ShiftUpUp_f ( void   )  [static]

Definition at line 238 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_TranslateKey ( SDL_keysym *  keysym,
unsigned int *  ascii,
unsigned short *  unicode 
) [static]
static void IN_TurnDownDown_f ( void   )  [static]

Definition at line 210 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_TurnDownUp_f ( void   )  [static]

Definition at line 214 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_TurnLeftDown_f ( void   )  [static]

Definition at line 186 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_TurnLeftUp_f ( void   )  [static]

Definition at line 190 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_TurnRightDown_f ( void   )  [static]

Definition at line 194 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_TurnRightUp_f ( void   )  [static]

Definition at line 198 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_TurnUpDown_f ( void   )  [static]

Definition at line 202 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_TurnUpUp_f ( void   )  [static]

Definition at line 206 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_ZoomInDown_f ( void   )  [static]

Definition at line 250 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_ZoomInUp_f ( void   )  [static]

Definition at line 254 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().

static void IN_ZoomOutDown_f ( void   )  [static]

Definition at line 258 of file cl_input.c.

References IN_KeyDown().

Referenced by IN_Init().

static void IN_ZoomOutUp_f ( void   )  [static]

Definition at line 262 of file cl_input.c.

References IN_KeyUp().

Referenced by IN_Init().


Variable Documentation

int down

Definition at line 63 of file cl_input.c.

Referenced by Check_SidePointsDown(), and IN_SendKeyEvents().

cvar_t* in_debug [static]

Definition at line 69 of file cl_input.c.

Definition at line 94 of file cl_input.c.

Definition at line 90 of file cl_input.c.

Definition at line 89 of file cl_input.c.

Definition at line 89 of file cl_input.c.

Definition at line 90 of file cl_input.c.

Definition at line 92 of file cl_input.c.

Definition at line 89 of file cl_input.c.

Definition at line 89 of file cl_input.c.

kbutton_t in_turnup [static]

Definition at line 92 of file cl_input.c.

kbutton_t in_zoomin [static]

Definition at line 91 of file cl_input.c.

Definition at line 91 of file cl_input.c.

unsigned int key
struct { ... } keyq[MAX_KEYQ] [static]
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
int mousePosY
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().


Generated by  doxygen 1.6.2