41 #define NUM_SYSTEM_KEYS 14
42 #define NUM_BUTTONS 19
46 #define CONTROL_X_COORD 0
47 #define CONTROL_Y_COORD 1
48 #define CONTROL_W_COORD 2
49 #define CONTROL_H_COORD 3
120 #define CONFLICT_FLASH_TIME 250
124 #define LIST_BUTTONS_MAX 42
125 #define JOY_AXIS 0x80000
127 static int Num_cc_lines;
150 #define NUM_AXIS_TEXT 6
151 #define NUM_MOUSE_TEXT 5
152 #define NUM_MOUSE_AXIS_TEXT 2
153 #define NUM_INVERT_TEXT 2
161 KEY_ESC,
KEY_F1,
KEY_F2,
KEY_F3,
KEY_F4,
KEY_F5,
KEY_F6,
KEY_F7,
KEY_F8,
KEY_F9,
KEY_F10,
168 static int Binding_mode = 0;
169 static int Bind_time = 0;
170 static int Search_mode = 0;
171 static int Last_key = -1;
172 static int Selected_line = 0;
173 static int Selected_item = -1;
174 static int Scroll_offset;
175 static int Axis_override = -1;
176 static int Background_bitmap;
177 static int Conflicts_tabs[
NUM_TABS];
180 static unsigned int Defaults_cycle_pos;
194 #define COMPUTER_TAB 3
195 #define SCROLL_UP_BUTTON 4
196 #define SCROLL_DOWN_BUTTON 5
198 #define SHIFT_TOGGLE 7
199 #define INVERT_AXIS 8
200 #define CANCEL_BUTTON 9
201 #define UNDO_BUTTON 10
202 #define RESET_BUTTON 11
203 #define SEARCH_MODE 12
204 #define BIND_BUTTON 13
205 #define HELP_BUTTON 14
206 #define ACCEPT_BUTTON 15
207 #define CLEAR_OTHER_BUTTON 16
208 #define CLEAR_ALL_BUTTON 17
209 #define CLEAR_BUTTON 18
257 #define CC_NUM_TEXT 20
310 0, 0, 1, 1, 1, 1, 1, 1,
311 1, 1, 1, 1, 1, 1, 1, 1,
312 1, 1, 1, 1, 1, 1, 1, 1,
313 1, 1, 1, 1, 1, 1, 1, 1,
315 1, 1, 1, 1, 1, 1, 1, 1,
316 1, 0, 1, 1, 1, 1, 1, 1,
317 1, 1, 1, 1, 1, 1, 1, 1,
318 1, 1, 1, 0, 0, 0, 0, 0,
320 0, 0, 0, 0, 0, 0, 1, 1,
321 1, 1, 1, 1, 1, 1, 1, 1,
322 1, 1, 1, 1, 0, 0, 0, 0,
323 0, 0, 0, 0, 0, 0, 0, 0,
325 0, 0, 0, 0, 0, 0, 0, 0,
326 0, 0, 0, 0, 0, 0, 0, 0,
327 0, 0, 0, 0, 0, 0, 0, 0,
328 0, 0, 0, 0, 0, 0, 0, 0,
330 0, 0, 0, 0, 0, 0, 0, 0,
331 0, 0, 0, 0, 0, 0, 0, 0,
332 0, 0, 0, 0, 0, 0, 0, 0,
333 0, 0, 0, 0, 1, 1, 0, 0,
335 0, 0, 0, 0, 0, 0, 0, 0,
336 0, 0, 0, 0, 0, 0, 0, 0,
337 0, 0, 0, 0, 0, 1, 0, 0,
338 1, 0, 0, 0, 0, 0, 0, 0,
340 0, 0, 0, 0, 0, 0, 0, 1,
341 1, 1, 0, 1, 0, 1, 0, 1,
342 1, 1, 1, 1, 0, 0, 0, 0,
343 0, 0, 0, 0, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 0, 0, 0,
346 0, 0, 0, 0, 0, 0, 0, 0,
347 0, 0, 0, 0, 0, 0, 0, 0,
348 0, 0, 0, 0, 0, 0, 0, 0,
366 int i, d, axis = -1,
delta = 16384;
368 int dx, dy, dz, fudge = 7;
372 d = abs(axes_values[i] - Axes_origin[i]);
382 if ( (dx > fudge) || (dx < -fudge) ) {
384 }
else if ( (dy > fudge) || (dy < -fudge) ) {
386 }
else if ( (dz > fudge) || (dz < -fudge) ) {
399 Conflicts[
i].key = Conflicts[
i].joy = -1;
403 Conflicts_tabs[
i] = 0;
406 for (i=0; i<CCFG_MAX-1; i++) {
418 Conflicts[
i].key = j;
419 Conflicts[j].key =
i;
421 Conflicts_tabs[ Control_config[j].tab ] = 1;
433 Conflicts[
i].joy = j;
434 Conflicts[j].joy =
i;
436 Conflicts_tabs[ Control_config[j].tab ] = 1;
446 for (i=0; i<NUM_JOY_AXIS_ACTIONS-1; i++) {
463 Num_cc_lines = y = z = 0;
472 Cc_lines[Num_cc_lines].cc_index =
z;
473 Cc_lines[Num_cc_lines++].y =
y;
474 y += font_height + 2;
483 Cc_lines[Num_cc_lines].cc_index = j |
JOY_AXIS;
484 Cc_lines[Num_cc_lines++].y =
y;
485 y += font_height + 2;
494 if ((n < 0) || (n >= Num_cc_lines)) {
498 y = Cc_lines[
n].y - Cc_lines[Scroll_offset].y;
515 Config_item_undo = ptr;
544 Config_item_undo = ptr->
next;
558 if (!Config_item_undo) {
572 for (i=1; i<Config_item_undo->
size; i++) {
589 for (i=0; i<Config_item_undo->
size; i++) {
590 z = Config_item_undo->
index[
i];
595 ptr = &Config_item_undo->
list[
i];
658 if (Selected_line < 0) {
663 z = Cc_lines[Selected_line].cc_index;
706 int z,
i, j, total = 0;
709 if (Selected_line < 0) {
714 z = Cc_lines[Selected_line].cc_index;
861 bool cycling_presets =
false;
865 cycling_presets =
true;
868 Defaults_cycle_pos = 0;
889 if (!total && !cycling_presets) {
965 Assert(Selected_line > Scroll_offset);
982 if (Selected_line < Scroll_offset) {
983 Scroll_offset = Selected_line;
1000 Assert(Selected_line < Num_cc_lines);
1013 if (Selected_line < Num_cc_lines - 1) {
1015 Assert(Selected_line > Scroll_offset);
1032 z = Cc_lines[Selected_line].cc_index;
1049 z = Cc_lines[Selected_line].cc_index;
1062 if (Selected_line < 0) {
1132 Binding_mode = Search_mode = 0;
1145 if (Conflicts_tabs[i]) {
1180 Scroll_offset = Selected_line = 0;
1257 if (Conflicts_tabs[i]) {
1258 return XSTR(
"Conflict!", 205);
1276 Defaults_cycle_pos = 0;
1317 List_buttons[
i].
create(&Ui_window,
"", 0, 0, 60, 30, 0, 1);
1318 List_buttons[
i].
hide();
1339 Scroll_offset = Selected_line = 0;
1340 Config_item_undo = NULL;
1372 while (Config_item_undo){
1376 if (Background_bitmap){
1428 int i, j, k,
w,
x,
y,
z, line, conflict;
1430 int select_tease_line = -1;
1431 static float timer = 0.0f;
1433 static int bound_timestamp = 0;
1434 static char bound_string[40];
1442 z = Cc_lines[Selected_line].cc_index & ~JOY_AXIS;
1470 if (Axis_override >= 0) {
1524 if ( (Last_key >= 0) && (k <= 0) && !
keyd_pressed[Last_key] ) {
1536 z = Cc_lines[Selected_line].cc_index;
1550 z = Cc_lines[Selected_line].cc_index;
1571 if (i == NUM_BUTTONS) {
1574 z = Cc_lines[Selected_line].cc_index;
1596 }
else if (Search_mode) {
1657 if (j == NUM_BUTTONS) {
1663 for (
size_t buttonid=0; buttonid<
NUM_BUTTONS; buttonid++){
1677 Selected_line = Scroll_offset = 0;
1678 for (i=0; i<Num_cc_lines; i++) {
1686 Assert(Scroll_offset < Num_cc_lines);
1692 z = Cc_lines[Selected_line].cc_index &
JOY_AXIS;
1698 z = Cc_lines[Selected_line].cc_index;
1742 Scroll_offset = Selected_line = 0;
1753 Scroll_offset = Selected_line = 0;
1760 if (Selected_item == -2) {
1762 if (Cc_lines[Selected_line].
jw < 1) {
1764 if (Cc_lines[Selected_line].
kw < 1) {
1775 if ((Selected_item == 1) && (Cc_lines[Selected_line].
jw < 1)) {
1777 }
else if (!Selected_item && (Cc_lines[Selected_line].
kw < 1)) {
1779 }
else if (Selected_item > 1) {
1802 if (List_buttons[i].is_mouse_on()) {
1803 select_tease_line = i + Scroll_offset;
1806 if (List_buttons[i].pressed()) {
1807 Selected_line = i + Scroll_offset;
1810 if ((x >= Cc_lines[Selected_line].
kx) && (x < Cc_lines[Selected_line].kx + Cc_lines[Selected_line].
kw)) {
1814 if ((x >= Cc_lines[Selected_line].
jx) && (x < Cc_lines[Selected_line].jx + Cc_lines[Selected_line].
jw)) {
1821 if (List_buttons[i].double_clicked()) {
1827 if (Background_bitmap >= 0) {
1835 if (Conflicts_tabs[i]) {
1858 char conflict_str[512] =
"";
1859 strncpy(conflict_str,
XSTR(
"Conflict!", 205), 511);
1877 if (i == NUM_TABS) {
1885 if (Selected_line >= 0) {
1886 z = Cc_lines[Selected_line].cc_index;
1909 z = Cc_lines[Selected_line].cc_index;
1915 t = (
int) (timer * 3);
1922 }
else if (!(z &
JOY_AXIS) && ((Conflicts[z].
key >= 0) || (Conflicts[z].
joy >= 0))) {
1923 i = Conflicts[
z].key;
1925 i = Conflicts[
z].joy;
1929 str =
XSTR(
"Control conflicts with:", 209);
1943 }
else if (*bound_string) {
1958 line = Scroll_offset;
1960 z = Cc_lines[line].cc_index;
1964 List_buttons[line - Scroll_offset].
enable(!Binding_mode);
1966 Cc_lines[line].kw = Cc_lines[line].jw = 0;
1968 if (line == Selected_line){
1970 }
else if (line == select_tease_line) {
1977 if (Cc_lines[line].
label) {
1978 strcpy_s(buf, Cc_lines[line].label);
1983 if (!(z & JOY_AXIS)) {
1989 if ((k < 0) && (j < 0)) {
1996 if (Conflicts[z].
key >= 0) {
2004 }
else if (Selected_item == 1) {
2015 Cc_lines[line].kw =
w;
2028 if (Conflicts[z].
joy >= 0) {
2036 }
else if (!Selected_item) {
2054 if (Binding_mode && (line == Selected_line)) {
2072 }
else if (!Selected_item) {
2088 i = line - Scroll_offset;
2089 while (i < LIST_BUTTONS_MAX) {
2096 int matching_preset = -1;
2099 bool this_preset_matches =
true;
2104 this_preset_matches =
false;
2109 if (this_preset_matches) {
2110 matching_preset =
i;
2115 if (matching_preset >= 0) {
2118 sprintf(preset_str,
"Controls: custom");
2200 static int last_key = 0;
void set_highlight_action(void(*_user_function)(void))
#define SCROLL_DOWN_BUTTON
int timestamp(int delta_ms)
#define MOUSE_NUM_BUTTONS
void add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id=-1)
char * Mouse_button_text[NUM_MOUSE_TEXT]
void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr)
#define NUM_MOUSE_AXIS_TEXT
reset (or similar button) pressed
int Conflict_warning_coords[GR_NUM_RESOLUTIONS][2]
GLfloat GLfloat GLfloat GLfloat h
#define CHA_ONACTIONSTOPPED
float key_down_timef(uint scancode)
short key_id
actual key bound to action
void RemHookVar(char *name)
int multi_ignore_controls(int key)
char * Invert_text[NUM_INVERT_TEXT]
int Control_config_overlay_id
int check_control_used(int id, int key)
char * Mouse_axis_text[NUM_MOUSE_AXIS_TEXT]
#define GR_NUM_RESOLUTIONS
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
int Invert_axis_defaults[]
general failure sound for any event
void clear_key_binding(short key)
char * Conflict_background_bitmap_mask_fname[GR_NUM_RESOLUTIONS]
#define CONTROL_CONFIG_XSTR
void control_check_indicate()
#define GR_MAYBE_CLEAR_RES(bmap)
void control_config_do_cancel(int fail=0)
void control_config_conflict_check()
void help_overlay_set_state(int overlay_id, int resolution_index, int state)
void set_ignore_gadgets(int state)
void gr_set_color_fast(color *dst)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
int control_config_do_reset()
bool disabled
whether this action should be available at all
char * textify_scancode(int code)
GLenum GLuint GLenum GLsizei const GLchar * buf
const char *(* tooltip_handler)(const char *text)
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
script_state Script_system("FS2_Open Scripting")
void control_config_do_bind()
short joy_id
joystick button bound to action
config_item Control_config[]
Stores the keyboard configuration.
#define CONTROL_CONFIG_OVERLAY
ui_button_info CC_Buttons[GR_NUM_RESOLUTIONS][NUM_BUTTONS]
int control_config_undo_last()
int control_config_remove_binding()
void common_set_interface_palette(char *filename)
short joy_default
default joystick button bound to action
void draw_forced(int frame_num)
void control_config_save_axis_undo(int axis)
int Control_more_coords[GR_NUM_RESOLUTIONS][2]
int key_down_count(int scancode)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
int Control_list_key_w[GR_NUM_RESOLUTIONS]
void set_mask_bmap(char *fname)
char * Joy_axis_text[NUM_AXIS_TEXT]
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
void common_free_interface_palette()
void control_config_scroll_line_up()
int joystick_read_raw_axis(int num_axes, int *axis)
int Ignored_keys[CCFG_MAX]
int Control_list_ctrl_w[GR_NUM_RESOLUTIONS]
int control_config_clear_all()
bool continuous_ongoing
whether this action is a continuous one and is currently ongoing
void control_config_scroll_screen_down()
int Conflicts_axes[NUM_JOY_AXIS_ACTIONS]
float check_control_timef(int id)
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
void control_config_init()
config_item_undo * get_undo_block(int size)
const char * control_config_tooltip_handler(const char *str)
char tab
what tab (category) it belongs in
int control_config_handle_conflict()
void control_config_toggle_invert()
int control_config_accept()
int use_hack_to_get_around_stupid_problem_flag
void control_used(int id)
bool save_player(player *_p=NULL)
void control_config_bind_axis(int i, int axis)
config_item Control_config_backup[CCFG_MAX]
void mouse_get_delta(int *dx, int *dy, int *dz)
GLint GLint GLint GLint GLint x
int control_config_clear_other()
#define CONFLICT_FLASH_TIME
const char * XSTR(const char *str, int index)
bool hasXSTR
whether we should translate this with an XSTR
void control_config_do_frame(float frametime)
user_click (mouse selects a control)
int control_config_detect_axis()
char type
manner control should be checked in
int used
has control been used yet in mission? If so, this is the timestamp
color Color_text_error_hi
void set_hotkey(int keycode)
int RunCondition(int condition, char format='\0', void *data=NULL, class object *objp=NULL, int more_data=0)
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
color Color_text_subselected
GLboolean GLboolean GLboolean b
void control_config_list_prepare()
short key_default
default key bound to action
#define CLEAR_OTHER_BUTTON
void update_dimensions(int _x, int _y, int _w, int _h)
color Color_text_selected
float joy_down_time(int btn)
scroll pressed (and scroll)
void link_hotspot(int num)
void control_config_clear()
#define JOY_TOTAL_BUTTONS
void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus=0)
press briefing, ship selection or weapons bar (top-left)
#define UI_XSTR_COLOR_PINK
void control_config_reset_defaults(int presetnum)
ubyte System_keys[NUM_SYSTEM_KEYS]
void create(int _x, int _y, int _w, int _h, int _flags, int _f_id=-1)
int joy_get_scaled_reading(int raw, int axn)
int gr_force_fit_string(char *str, int max_str, int max_width)
A continous control that is activated as long as the key or button is held down.
void control_config_scroll_screen_up()
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
void hud_squadmsg_save_keys(int do_scroll)
char * text
describes the action in the config screen
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new featur...
ubyte keyd_pressed[NUM_KEYS]
void common_play_highlight_sound()
The total number of defined control actions (or last define + 1)
#define timestamp_elapsed(stamp)
void get_mouse_pos(int *xx, int *yy)
char * Conflict_background_bitmap_fname[GR_NUM_RESOLUTIONS]
void control_config_detect_axis_reset()
void SetHookVar(char *name, char format, void *data=NULL)
void control_config_close()
int Control_list_coords[GR_NUM_RESOLUTIONS][4]
int check_control(int id, int key)
int control_config_axis_default(int axis)
char * Joy_axis_action_text[NUM_JOY_AXIS_ACTIONS]
config_item_undo * Config_item_undo
void control_config_bind_joy(int i, int joy)
void gr_bitmap(int _x, int _y, int resize_mode)
#define UI_XSTR_COLOR_GREEN
SCP_vector< config_item * > Control_config_presets
int Axis_map_to_defaults[]
int joy_down_count(int btn, int reset_count)
void control_config_scroll_line_down()
void control_config_cancel_exit()
int cc_line_query_visible(int n)
int joy_get_unscaled_reading(int raw, int axn)
int Conflict_wnd_coords[GR_NUM_RESOLUTIONS][4]
void launch_context_help()
void gamesnd_play_iface(int n)
void _cdecl gr_printf_no_resize(int x, int y, const char *format,...)
struct ui_button_info ui_button_info
void gr_set_font(int fontnum)
SCP_vector< SCP_string > Control_config_preset_names
int mouse_down_count(int n, int reset_count)
void control_config_bind_key(int i, int key)
void control_config_clear_used_status()
int process(int key_in=-1, int process_mouse=1)
int help_overlay_get_index(const char *overlay_name)
int axis_valid[JOY_NUM_AXES]
DCF_BOOL(show_controls_info, Show_controls_info)
void _cdecl gr_printf_menu(int x, int y, const char *format,...)
int timer_get_milliseconds()
void gameseq_post_event(int event)
The total number of actions an axis may map to.
void control_config_do_search()
void control_config_toggle_modifier(int bit)
void help_overlay_maybe_blit(int overlay_id, int resolution_index)
int help_overlay_active(int overlay_id)
void control_config_button_pressed(int n)
UI_XSTR CC_text[GR_NUM_RESOLUTIONS][CC_NUM_TEXT]
int Control_list_key_x[GR_NUM_RESOLUTIONS]