FS2_Open
Open source remastering of the Freespace 2 engine
controlsconfigcommon.cpp File Reference
#include <stdio.h>
#include <stdarg.h>
#include "cfile/cfile.h"
#include "controlconfig/controlsconfig.h"
#include "globalincs/def_files.h"
#include "globalincs/systemvars.h"
#include "io/joy.h"
#include "io/key.h"
#include "localization/localize.h"
#include "parse/parselo.h"
#include <map>
#include <string>

Go to the source code of this file.

Macros

#define ADD_ENUM_TO_KEY_MAP(Enum)   mKeyNameToVal[#Enum] = (Enum);
 
#define ADD_ENUM_TO_CCTYPE_MAP(Enum)   mCCTypeNameToVal[#Enum] = (Enum);
 
#define ADD_ENUM_TO_CCTAB_MAP(Enum)   mCCTabNameToVal[#Enum] = (Enum);
 

Enumerations

enum  CC_tab { TARGET_TAB =0, SHIP_TAB =1, WEAPON_TAB =2, COMPUTER_TAB =3 }
 

Functions

void set_modifier_status ()
 
int translate_key_to_index (const char *key, bool find_override)
 
char * translate_key (char *key)
 
char * textify_scancode (int code)
 
void control_config_common_load_overrides ()
 Parses controlconfigdefault.tbl, and overrides the default control configuration for each valid entry in the .tbl. More...
 
void control_config_common_init ()
 initialize common control config stuff - call at game startup after localization has been initialized More...
 
void control_config_common_close ()
 close common control config stuff - call at game shutdown More...
 
void LoadEnumsIntoKeyMap (void)
 
void LoadEnumsIntoCCTypeMap (void)
 
void LoadEnumsIntoCCTabMap (void)
 
void LoadEnumsIntoMaps ()
 

Variables

int Failed_key_index
 
int Shift_is_modifier
 
int Ctrl_is_modifier
 
int Alt_is_modifier
 
int Axis_enabled [JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 }
 
int Axis_enabled_defaults [JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 }
 
int Invert_axis [JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 }
 
int Invert_axis_defaults [JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 }
 
config_item Control_config [CCFG_MAX+1]
 Stores the keyboard configuration. More...
 
char * Scan_code_text_german []
 
char * Joy_button_text_german []
 
char * Scan_code_text_french []
 
char * Joy_button_text_french []
 
char * Scan_code_text_polish []
 
char * Joy_button_text_polish []
 
char * Scan_code_text_english []
 This is the text that is displayed on the screen for the keys a player selects. More...
 
char * Joy_button_text_english []
 
char ** Scan_code_text = Scan_code_text_english
 
char ** Joy_button_text = Joy_button_text_english
 
SCP_vector< config_item * > Control_config_presets
 
SCP_vector< SCP_stringControl_config_preset_names
 
SCP_map< SCP_string, intmKeyNameToVal
 
SCP_map< SCP_string, CC_typemCCTypeNameToVal
 
SCP_map< SCP_string, char > mCCTabNameToVal
 

Macro Definition Documentation

#define ADD_ENUM_TO_CCTAB_MAP (   Enum)    mCCTabNameToVal[#Enum] = (Enum);
#define ADD_ENUM_TO_CCTYPE_MAP (   Enum)    mCCTypeNameToVal[#Enum] = (Enum);
#define ADD_ENUM_TO_KEY_MAP (   Enum)    mKeyNameToVal[#Enum] = (Enum);

Enumeration Type Documentation

enum CC_tab
Enumerator
TARGET_TAB 
SHIP_TAB 
WEAPON_TAB 
COMPUTER_TAB 

Definition at line 24 of file controlsconfigcommon.cpp.

Function Documentation

void control_config_common_close ( )

close common control config stuff - call at game shutdown

Definition at line 616 of file controlsconfigcommon.cpp.

void control_config_common_init ( )

initialize common control config stuff - call at game startup after localization has been initialized

Definition at line 590 of file controlsconfigcommon.cpp.

void control_config_common_load_overrides ( )

Parses controlconfigdefault.tbl, and overrides the default control configuration for each valid entry in the .tbl.

short key_default; short joy_default; char tab; bool hasXSTR; char type;

Definition at line 806 of file controlsconfigcommon.cpp.

void LoadEnumsIntoCCTabMap ( void  )

Helper function to LoadEnumsIntoMaps(), Loads the Control Tabs enumerations into mCCTabNameToVal

Definition at line 781 of file controlsconfigcommon.cpp.

void LoadEnumsIntoCCTypeMap ( void  )

Helper function to LoadEnumsIntoMaps(), Loads the Control Types enumerations into mCCTypeNameToVal

Definition at line 769 of file controlsconfigcommon.cpp.

void LoadEnumsIntoKeyMap ( void  )

Helper function to LoadEnumsIntoMaps(), Loads the Keyboard definitions/enumerations into mKeyNameToVal

Definition at line 633 of file controlsconfigcommon.cpp.

void LoadEnumsIntoMaps ( )

Loads the various control configuration maps to allow the parsing functions to appropriately map string tokns to their associated enumerations. The string tokens in the controlconfigdefaults.tbl match directly to their names in the C++ code, such as "KEY_5" in the .tbl mapping to the #define KEY_5 value

Definition at line 797 of file controlsconfigcommon.cpp.

void set_modifier_status ( )

Definition at line 409 of file controlsconfigcommon.cpp.

char* textify_scancode ( int  code)

Definition at line 552 of file controlsconfigcommon.cpp.

char* translate_key ( char *  key)

Given the system default key 'key', return the current key that is bound to that function. Both are 'key' and the return value are descriptive strings that can be displayed directly to the user. If 'key' isn't a real key, is not normally bound to anything, or there is no key currently bound to the function, NULL is returned.

Definition at line 506 of file controlsconfigcommon.cpp.

int translate_key_to_index ( const char *  key,
bool  find_override 
)

Definition at line 437 of file controlsconfigcommon.cpp.

Variable Documentation

int Alt_is_modifier

Definition at line 36 of file controlsconfigcommon.cpp.

int Axis_enabled[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 }

Definition at line 38 of file controlsconfigcommon.cpp.

int Axis_enabled_defaults[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 }

Definition at line 39 of file controlsconfigcommon.cpp.

config_item Control_config[CCFG_MAX+1]

Stores the keyboard configuration.

arrays which hold the key mappings. The array index represents a key-independent action. please use SPACES for aligning the fields of this array

Definition at line 46 of file controlsconfigcommon.cpp.

SCP_vector<SCP_string> Control_config_preset_names

Definition at line 407 of file controlsconfigcommon.cpp.

SCP_vector<config_item*> Control_config_presets

Definition at line 406 of file controlsconfigcommon.cpp.

int Ctrl_is_modifier

Definition at line 35 of file controlsconfigcommon.cpp.

int Failed_key_index

Definition at line 31 of file controlsconfigcommon.cpp.

int Invert_axis[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 }

Definition at line 40 of file controlsconfigcommon.cpp.

int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 }

Definition at line 41 of file controlsconfigcommon.cpp.

char** Joy_button_text = Joy_button_text_english

Definition at line 404 of file controlsconfigcommon.cpp.

char* Joy_button_text_english[]
Initial value:
= {
"Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6",
"Button 7", "Button 8", "Button 9", "Button 10", "Button 11", "Button 12",
"Button 13", "Button 14", "Button 15", "Button 16", "Button 17", "Button 18",
"Button 19", "Button 20", "Button 21", "Button 22", "Button 23", "Button 24",
"Button 25", "Button 26", "Button 27", "Button 28", "Button 29", "Button 30",
"Button 31", "Button 32", "Hat Back", "Hat Forward", "Hat Left", "Hat Right"
}

Definition at line 394 of file controlsconfigcommon.cpp.

char* Joy_button_text_french[]
Initial value:
= {
"Bouton 1", "Bouton 2", "Bouton 3", "Bouton 4", "Bouton 5", "Bouton 6",
"Bouton 7", "Bouton 8", "Bouton 9", "Bouton 10", "Bouton 11", "Bouton 12",
"Bouton 13", "Bouton 14", "Bouton 15", "Bouton 16", "Bouton 17", "Bouton 18",
"Bouton 19", "Bouton 20", "Bouton 21", "Bouton 22", "Bouton 23", "Bouton 24",
"Bouton 25", "Bouton 26", "Bouton 27", "Bouton 28", "Bouton 29", "Bouton 30",
"Bouton 31", "Bouton 32", "Chapeau Arri\x8Are", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite"
}

Definition at line 291 of file controlsconfigcommon.cpp.

char* Joy_button_text_german[]
Initial value:
= {
"Knopf 1", "Knopf 2", "Knopf 3", "Knopf 4", "Knopf 5", "Knopf 6",
"Knopf 7", "Knopf 8", "Knopf 9", "Knopf 10", "Knopf 11", "Knopf 12",
"Knopf 13", "Knopf 14", "Knopf 15", "Knopf 16", "Knopf 17", "Knopf 18",
"Knopf 19", "Knopf 20", "Knopf 21", "Knopf 22", "Knopf 23", "Knopf 24",
"Knopf 25", "Knopf 26", "Knopf 27", "Knopf 28", "Knopf 29", "Knopf 30",
"Knopf 31", "Knopf 32", "Hut Hinten", "Hut Vorne", "Hut Links", "Hut Rechts"
}

Definition at line 240 of file controlsconfigcommon.cpp.

char* Joy_button_text_polish[]
Initial value:
= {
"Przyc.1", "Przyc.2", "Przyc.3", "Przyc.4", "Przyc.5", "Przyc.6",
"Przyc.7", "Przyc.8", "Przyc.9", "Przyc.10", "Przyc.11", "Przyc.12",
"Przyc.13", "Przyc.14", "Przyc.15", "Przyc.16", "Przyc.17", "Przyc.18",
"Przyc.19", "Przyc.20", "Przyc.21", "Przyc.22", "Przyc.23", "Przyc.24",
"Przyc.25", "Przyc.26", "Przyc.27", "Przyc.28", "Przyc.29", "Przyc.30",
"Przyc.31", "Przyc.32", "Hat Ty\xB3", "Hat Prz\xF3\x64", "Hat Lewo", "Hat Prawo"
}

Definition at line 342 of file controlsconfigcommon.cpp.

SCP_map<SCP_string, char> mCCTabNameToVal

Definition at line 629 of file controlsconfigcommon.cpp.

SCP_map<SCP_string, CC_type> mCCTypeNameToVal

Definition at line 628 of file controlsconfigcommon.cpp.

SCP_map<SCP_string, int> mKeyNameToVal

Definition at line 627 of file controlsconfigcommon.cpp.

char** Scan_code_text = Scan_code_text_english

Definition at line 403 of file controlsconfigcommon.cpp.

char* Scan_code_text_english[]

This is the text that is displayed on the screen for the keys a player selects.

Definition at line 352 of file controlsconfigcommon.cpp.

char* Scan_code_text_french[]

Definition at line 249 of file controlsconfigcommon.cpp.

char* Scan_code_text_german[]

Definition at line 198 of file controlsconfigcommon.cpp.

char* Scan_code_text_polish[]

Definition at line 300 of file controlsconfigcommon.cpp.

int Shift_is_modifier

Definition at line 34 of file controlsconfigcommon.cpp.