Open source remastering of the Freespace 2 engine
keycontrol.cpp File Reference
#include "globalincs/pstypes.h"
#include "globalincs/globals.h"
#include "globalincs/linklist.h"
#include "io/key.h"
#include "io/joy.h"
#include "io/timer.h"
#include "ship/ship.h"
#include "playerman/player.h"
#include "weapon/weapon.h"
#include "hud/hud.h"
#include "gamesequence/gamesequence.h"
#include "mission/missiongoals.h"
#include "hud/hudets.h"
#include "gamesnd/gamesnd.h"
#include "hud/hudsquadmsg.h"
#include "gamesnd/eventmusic.h"
#include "freespace2/freespace.h"
#include "mission/missionhotkey.h"
#include "hud/hudescort.h"
#include "hud/hudshield.h"
#include "io/keycontrol.h"
#include "ship/shiphit.h"
#include "ship/shipfx.h"
#include "mission/missionlog.h"
#include "hud/hudtargetbox.h"
#include "popup/popup.h"
#include "object/objcollide.h"
#include "object/object.h"
#include "hud/hudconfig.h"
#include "hud/hudmessage.h"
#include "network/multi_pmsg.h"
#include "starfield/supernova.h"
#include "mission/missionmessage.h"
#include "menuui/mainhallmenu.h"
#include "missionui/missionpause.h"
#include "hud/hudgauges.h"
#include "species_defs/species_defs.h"
#include "asteroid/asteroid.h"
#include "iff_defs/iff_defs.h"
#include "network/multi.h"
#include "network/multiutil.h"
#include "network/multimsgs.h"
#include "network/multi_pause.h"
#include "network/multi_observer.h"
#include "network/multi_endgame.h"
#include "autopilot/autopilot.h"
#include "cmdline/cmdline.h"
#include "object/objectshield.h"

Go to the source code of this file.


class  factor_table
struct  Cheat


#define MAX_TIME_DIVIDER   4
#define CHEAT_BUFFER_LEN   17
#define CHEATS_TABLE_LEN   6


enum  cheatCode {


float do_subobj_hit_stuff (object *ship_obj, object *other_obj, vec3d *hitpos, int submodel_num, float damage, bool *hull_should_apply_armor)
void mission_goal_mark_all_true (int type)
void debug_cycle_player_ship (int delta)
void debug_cycle_targeted_ship (int delta)
void debug_max_secondary_weapons (object *objp)
void debug_max_primary_weapons (object *objp)
void debug_change_song (int delta)
void hud_target_asteroid ()
void snd_stop_any_sound ()
void g3_set_view_matrix (const vec3d *view_pos, const matrix *view_matrix, float zoom)
int get_prev_weapon_looped (int current_weapon, int subtype)
int get_next_weapon_looped (int current_weapon, int subtype)
void process_debug_keys (int k)
void ppsk_hotkeys (int k)
void process_set_of_keys (int key, int count, int *list)
void process_player_ship_keys (int k)
void game_do_end_mission_popup ()
void game_process_pause_key ()
void game_process_cheats (int k)
void game_process_keys ()
int button_function_critical (int n, net_player *p=NULL)
int button_function_demo_valid (int n)
bool key_is_targeting (int n)
int button_function (int n)
void button_info_do (button_info *bi)
void button_info_set (button_info *bi, int n)
void button_info_unset (button_info *bi, int n)
int button_info_query (button_info *bi, int n)
void button_info_clear (button_info *bi)
void button_strip_noncritical_keys (button_info *bi)


factor_table ftables
char CheatBuffer [CHEAT_BUFFER_LEN+1]
int Tool_enabled = 0
bool Perspective_locked =false
bool quit_mission_popup_shown = false
int AI_watch_object
int Countermeasures_enabled
int Normal_key_set []
int Dead_key_set []
int Critical_key_set []
int Non_critical_key_set []
int Ignored_keys [CCFG_MAX]
int Normal_key_set_size = sizeof(Normal_key_set) / sizeof(int)
int Dead_key_set_size = sizeof(Dead_key_set) / sizeof(int)
int Critical_key_set_size = sizeof(Critical_key_set) / sizeof(int)
int Non_critical_key_set_size = sizeof(Non_critical_key_set) / sizeof(int)
int Framerate_delay
vec3d Eye_position
matrix Eye_matrix
int Show_cpu

Macro Definition Documentation

#define CHEAT_BUFFER_LEN   17

Definition at line 183 of file keycontrol.cpp.

#define CHEATS_TABLE_LEN   6

Definition at line 210 of file keycontrol.cpp.

#define MAX_TIME_DIVIDER   4

Definition at line 181 of file keycontrol.cpp.


Definition at line 180 of file keycontrol.cpp.

Enumeration Type Documentation

enum cheatCode

Definition at line 186 of file keycontrol.cpp.

Function Documentation

int button_function ( int  n)

Execute function corresponding to action n (BUTTON_ from KeyControl.h)

1 when action was taken

This switch handles the critical buttons

button_function_critical is also called from network

Assume the switches below will catch the key, if not, set to FALSE in default

Below, you must not use return in cases, else the check for invalid keys will fail

The key has been handled, return early before the timestamp is set

Update the last used timestamp of this key

All keys should have been handled above, if not panic

Definition at line 2218 of file keycontrol.cpp.

int button_function_critical ( int  n,
net_player p = NULL 

Definition at line 1724 of file keycontrol.cpp.

int button_function_demo_valid ( int  n)

Execute function corresponding to action n Basically, these are actions which don't affect demo playback at all

nAction number

Definition at line 2063 of file keycontrol.cpp.

void button_info_clear ( button_info bi)

Clear out the button_info struct

Definition at line 2892 of file keycontrol.cpp.

void button_info_do ( button_info bi)

Calls multiple event handlers for each active button

bicurrently active buttons

Definition at line 2836 of file keycontrol.cpp.

int button_info_query ( button_info bi,
int  n 

Definition at line 2884 of file keycontrol.cpp.

void button_info_set ( button_info bi,
int  n 

Set the bit for the corresponding action n (BUTTON_ from KeyControl.h)

Definition at line 2861 of file keycontrol.cpp.

void button_info_unset ( button_info bi,
int  n 

Unset the bit for the corresponding action n (BUTTON_ from KeyControl.h)

Definition at line 2874 of file keycontrol.cpp.

void button_strip_noncritical_keys ( button_info bi)

Strip out all noncritical keys from the button_info struct

Definition at line 2904 of file keycontrol.cpp.

void debug_change_song ( int  delta)

Definition at line 607 of file keycontrol.cpp.

void debug_cycle_player_ship ( int  delta)

Definition at line 483 of file keycontrol.cpp.

void debug_cycle_targeted_ship ( int  delta)

Cycle targeted ship to next ship in that species


Definition at line 519 of file keycontrol.cpp.

void debug_max_primary_weapons ( object objp)

Definition at line 581 of file keycontrol.cpp.

void debug_max_secondary_weapons ( object objp)

Definition at line 568 of file keycontrol.cpp.

float do_subobj_hit_stuff ( object ship_obj,
object other_obj,
vec3d hitpos,
int  submodel_num,
float  damage,
bool *  hull_should_apply_armor 

Definition at line 447 of file shiphit.cpp.

void g3_set_view_matrix ( const vec3d view_pos,
const matrix view_matrix,
float  zoom 

Set view from x,y,z, viewer matrix, and zoom. Must call one of g3_set_view_*()

Definition at line 152 of file 3dsetup.cpp.

void game_do_end_mission_popup ( )

Handler for when player hits 'ESC' during the game

Definition at line 1429 of file keycontrol.cpp.

void game_process_cheats ( int  k)

Process cheat codes

Definition at line 1487 of file keycontrol.cpp.

void game_process_keys ( )

Definition at line 1612 of file keycontrol.cpp.

void game_process_pause_key ( )

Handle pause keypress

Definition at line 1470 of file keycontrol.cpp.

int get_next_weapon_looped ( int  current_weapon,
int  subtype 

Definition at line 647 of file keycontrol.cpp.

int get_prev_weapon_looped ( int  current_weapon,
int  subtype 

Definition at line 630 of file keycontrol.cpp.

void hud_target_asteroid ( )

Definition at line 1441 of file asteroid.cpp.

bool key_is_targeting ( int  n)

Definition at line 2190 of file keycontrol.cpp.

void mission_goal_mark_all_true ( int  type)

Definition at line 1370 of file missiongoals.cpp.

void ppsk_hotkeys ( int  k)

Definition at line 1287 of file keycontrol.cpp.

void process_debug_keys ( int  k)

Definition at line 664 of file keycontrol.cpp.

void process_player_ship_keys ( int  k)

Routine to process keys used for player ship stuff (not ship movement).

Definition at line 1380 of file keycontrol.cpp.

void process_set_of_keys ( int  key,
int  count,
int list 

Check keypress 'key' against a set of valid controls and mark the match in the player's button info bitfield. Also checks joystick controls in the set.

keyScancode (plus modifiers).
countTotal size of the list
listList of Control_config struct action indices to check for

Definition at line 1368 of file keycontrol.cpp.

void snd_stop_any_sound ( )

Definition at line 1213 of file sound.cpp.

Variable Documentation

int AI_watch_object

Definition at line 199 of file aicode.cpp.

char CheatBuffer[CHEAT_BUFFER_LEN+1]

Definition at line 184 of file keycontrol.cpp.

int Countermeasures_enabled

Definition at line 23 of file cmeasure.cpp.

int Critical_key_set[]
Initial value:
= {
increase energy to engines
decrease shield recharge rate
transfer shield energy to right
increase shield recharge rate
decrease energy to engines
equalize recharge rates
cycle number of missiles fired from secondary bank
cycle to previous primary weapon
transfer energy to shield from weapons
cycle to next secondary weapon
transfer energy to weapons from shield
equalize shield energy to all quadrants
cycle to next primary weapon
decrease weapon recharge rate
transfer shield energy to left
increase weapon recharge rate
transfer shield energy to rear
transfer shield energy to front

Definition at line 378 of file keycontrol.cpp.

int Critical_key_set_size = sizeof(Critical_key_set) / sizeof(int)

Definition at line 476 of file keycontrol.cpp.

int Dead_key_set[]

Definition at line 336 of file keycontrol.cpp.

int Dead_key_set_size = sizeof(Dead_key_set) / sizeof(int)

Definition at line 475 of file keycontrol.cpp.

matrix Eye_matrix

Definition at line 26 of file 3dsetup.cpp.

vec3d Eye_position

Definition at line 27 of file 3dsetup.cpp.

int Framerate_delay

Definition at line 187 of file fredstubs.cpp.

factor_table ftables

Definition at line 171 of file keycontrol.cpp.

int Ignored_keys[CCFG_MAX]

Definition at line 471 of file keycontrol.cpp.

int Non_critical_key_set[]

Definition at line 399 of file keycontrol.cpp.

int Non_critical_key_set_size = sizeof(Non_critical_key_set) / sizeof(int)

Definition at line 477 of file keycontrol.cpp.

int Normal_key_set[]

Definition at line 223 of file keycontrol.cpp.

int Normal_key_set_size = sizeof(Normal_key_set) / sizeof(int)

Definition at line 474 of file keycontrol.cpp.

bool Perspective_locked =false

Definition at line 213 of file keycontrol.cpp.

bool quit_mission_popup_shown = false

Definition at line 214 of file keycontrol.cpp.

int Show_cpu

Definition at line 52 of file fred.cpp.

int Tool_enabled = 0

Definition at line 212 of file keycontrol.cpp.