From 11af9cfdc69275a41f15070113cc27db8c983f4d Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Fri, 11 Oct 2013 03:37:53 -0400 Subject: [PATCH] SDL2 port - stage 2 --- Makefile | 3 +- include/controlsconfig.h | 4 +- include/gropengl.h | 1 + include/joy.h | 8 +- include/key.h | 6 +- src/controlconfig/controlsconfig.cpp | 111 ++- src/controlconfig/controlsconfigcommon.cpp | 413 +++++++--- src/cutscene/cutscenes.cpp | 30 +- src/debugconsole/console.cpp | 16 +- src/fonttool/fontkern.cpp | 38 +- src/freespace2/freespace.cpp | 46 +- src/freespace2/unixmain.cpp | 3 +- src/gamehelp/gameplayhelp.cpp | 16 +- src/graphics/2d.cpp | 1 + src/graphics/gropengl.cpp | 39 +- src/hud/hudconfig.cpp | 6 +- src/hud/hudmessage.cpp | 26 +- src/hud/hudsquadmsg.cpp | 14 +- src/io/joy-sdl.cpp | 399 ++++----- src/io/joy_ff-sdl.cpp | 897 +++++++++++++++++++++ src/io/key.cpp | 65 +- src/lighting/lighting.cpp | 6 +- src/menuui/barracks.cpp | 30 +- src/menuui/credits.cpp | 14 +- src/menuui/mainhallmenu.cpp | 10 +- src/menuui/mainhalltemp.cpp | 12 +- src/menuui/optionsmenu.cpp | 26 +- src/menuui/optionsmenumulti.cpp | 6 +- src/menuui/playermenu.cpp | 24 +- src/menuui/readyroom.cpp | 34 +- src/menuui/snazzyui.cpp | 7 +- src/menuui/techmenu.cpp | 36 +- src/mission/missiongoals.cpp | 10 +- src/mission/missiongrid.cpp | 12 +- src/mission/missionhotkey.cpp | 52 +- src/mission/missionload.cpp | 24 +- src/missionui/chatbox.cpp | 4 +- src/missionui/missionbrief.cpp | 40 +- src/missionui/missioncmdbrief.cpp | 16 +- src/missionui/missiondebrief.cpp | 22 +- src/missionui/missionloopbrief.cpp | 2 +- src/missionui/missionpause.cpp | 20 +- src/missionui/missionscreencommon.cpp | 22 +- src/missionui/redalert.cpp | 4 +- src/model/modelinterp.cpp | 12 +- src/model/modelread.cpp | 22 +- src/movie/mveplayer.cpp | 2 +- src/nebedit/nebedit.cpp | 38 +- src/network/multi_dogfight.cpp | 2 +- src/network/multi_ingame.cpp | 6 +- src/network/multi_oo.cpp | 10 +- src/network/multi_pause.cpp | 4 +- src/network/multi_pinfo.cpp | 2 +- src/network/multi_pmsg.cpp | 18 +- src/network/multi_voice.cpp | 6 +- src/network/multiteamselect.cpp | 6 +- src/network/multiui.cpp | 42 +- src/network/multiutil.cpp | 19 +- src/osapi/os_unix.cpp | 72 +- src/physics/physics.cpp | 4 +- src/platform/unix.cpp | 24 +- src/playerman/managepilot.cpp | 160 +++- src/playerman/playercontrol.cpp | 6 +- src/pofview/pofviewview.cpp | 30 +- src/popup/popup.cpp | 16 +- src/popup/popupdead.cpp | 18 +- src/stats/medals.cpp | 4 +- src/ui/button.cpp | 4 +- src/ui/checkbox.cpp | 4 +- src/ui/inputbox.cpp | 52 +- src/ui/listbox.cpp | 22 +- src/ui/radio.cpp | 4 +- src/ui/scroll.cpp | 8 +- src/ui/slider.cpp | 12 +- src/ui/window.cpp | 2 +- 75 files changed, 2210 insertions(+), 996 deletions(-) create mode 100644 src/io/joy_ff-sdl.cpp diff --git a/Makefile b/Makefile index 1c0a5ab..59b0dab 100644 --- a/Makefile +++ b/Makefile @@ -99,6 +99,7 @@ CODE_SOURCES =./src/anim/animplay.cpp \ ./src/io/key.cpp \ ./src/io/keycontrol.cpp \ ./src/io/joy-sdl.cpp \ + ./src/io/joy_ff-sdl.cpp \ ./src/io/mouse.cpp \ ./src/io/timer.cpp \ ./src/jumpnode/jumpnode.cpp \ @@ -314,7 +315,7 @@ ifeq ($(strip $(MACOSX)),true) endif $(FS_BINARY): $(CODE_BINARY) $(FS_OBJECTS) - $(CC) -o $(FS_BINARY) $(LDFLAGS) $(FS_OBJECTS) $(CODE_BINARY) + $(CC) -o $(FS_BINARY) $(FS_OBJECTS) $(CODE_BINARY) $(LDFLAGS) cryptstring: $(CC) -o cryptstring $(CFLAGS) src/cryptstring/cryptstring.cpp diff --git a/include/controlsconfig.h b/include/controlsconfig.h index 289e0c0..8785d40 100644 --- a/include/controlsconfig.h +++ b/include/controlsconfig.h @@ -292,12 +292,12 @@ #define CC_TYPE_CONTINUOUS 1 typedef struct config_item { - short key_default; // default key bound to action + int key_default; // default key bound to action short joy_default; // default joystick button bound to action char tab; // what tab (catagory) it belongs in const char *text; // describes the action in the config screen char type; // manner control should be checked in - short key_id; // actual key bound to action + int key_id; // actual key bound to action short joy_id; // joystick button bound to action int used; // has control been used yet in mission? If so, this is the timestamp } config_item; diff --git a/include/gropengl.h b/include/gropengl.h index 50a8c25..ef90ad2 100644 --- a/include/gropengl.h +++ b/include/gropengl.h @@ -54,6 +54,7 @@ void gr_opengl_init(); void gr_opengl_cleanup(); +void gr_opengl_force_windowed(); void gr_opengl_bitmap(int x, int y); void gr_opengl_bitmap_ex(int x, int y, int w, int h, int sx, int sy); diff --git a/include/joy.h b/include/joy.h index e062d30..64ec21c 100644 --- a/include/joy.h +++ b/include/joy.h @@ -93,10 +93,11 @@ #define JOY_AXIS_UNDEFINED -10000 typedef struct Joy_info { - int axis_valid[JOY_NUM_AXES]; + int num_axes; int axis_min[JOY_NUM_AXES]; int axis_center[JOY_NUM_AXES]; int axis_max[JOY_NUM_AXES]; + int axis_current[JOY_NUM_AXES]; } Joy_info; extern int Joy_sensitivity; @@ -117,8 +118,9 @@ void joy_set_cen(); void joy_cheap_cal(); int joystick_read_raw_axis( int num_axes, int * axis ); void joy_get_delta(int *dx, int *dy); -int joy_get_scaled_reading(int raw, int axn); -int joy_get_unscaled_reading(int raw, int axn); +int joy_get_scaled_reading(int axn); +int joy_get_unscaled_reading(int axn); +bool joy_axis_valid(int axis); #endif /* __JOY_H__ */ diff --git a/include/key.h b/include/key.h index 6ad09f9..0a9c061 100644 --- a/include/key.h +++ b/include/key.h @@ -108,7 +108,7 @@ void key_flush(); // Routines/data you can access: float key_down_timef(int keycode); -int key_to_ascii(int keycode); +int key_to_ascii(int keycode, bool force_up = false); int key_inkey(); // global flag that will enable/disable the backspace key from stopping execution @@ -132,9 +132,9 @@ extern int Key_normal_game; #define KEY_CTRLED 0x4000 #define KEY_DEBUGGED 0x8000 #define KEY_DEBUGGED1 0x0800 // Cheat bit in release version of game. -#define KEY_MASK 0x01FF +#define KEY_MASK (SDLK_SCANCODE_MASK|0x01FF) -#define KEY_DEBUG_KEY 0x29 // KEY_LAPOSTRO (shifted = tilde, near upper-left of keyboard) +#define KEY_DEBUG_KEY SDLK_BACKQUOTE // KEY_LAPOSTRO (shifted = tilde, near upper-left of keyboard) #endif diff --git a/src/controlconfig/controlsconfig.cpp b/src/controlconfig/controlsconfig.cpp index 7d3027a..e913d9a 100644 --- a/src/controlconfig/controlsconfig.cpp +++ b/src/controlconfig/controlsconfig.cpp @@ -480,10 +480,10 @@ char *Mouse_button_text[NUM_MOUSE_TEXT]; char *Mouse_axis_text[NUM_MOUSE_AXIS_TEXT]; char *Invert_text[NUM_INVERT_TEXT]; -ubyte System_keys[NUM_SYSTEM_KEYS] = { - KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, - KEY_F11, KEY_F12, KEY_PRINT_SCRN -}; +//ubyte System_keys[NUM_SYSTEM_KEYS] = { +// SDLK_ESCAPE, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, +// SDLK_F11, SDLK_F12, SDLK_PRINTSCREEN +//}; int Control_check_count = 0; @@ -773,13 +773,13 @@ void control_config_conflict_check() for (i=0; iindex[0] = i; ptr->list[0] = Control_config[i]; - Control_config[i].key_id = (short) key; + Control_config[i].key_id = key; } void control_config_bind_joy(int i, int joy) @@ -1078,7 +1078,7 @@ int control_config_remove_binding() Control_config[z].joy_id = (short) -1; if ((Selected_item != 1) && (Control_config[z].key_id >= 0)) // if not just joy button selected (1) - Control_config[z].key_id = (short) -1; + Control_config[z].key_id = -1; control_config_conflict_check(); control_config_list_prepare(); @@ -1160,7 +1160,7 @@ int control_config_clear_other() j++; if (Control_config[i].key_id == Control_config[z].key_id) - Control_config[i].key_id = (short) -1; + Control_config[i].key_id = -1; if (Control_config[i].joy_id == Control_config[z].joy_id) Control_config[i].joy_id = (short) -1; } @@ -1207,8 +1207,6 @@ int control_config_clear_all() return 0; } -extern Joy_info joystick; - int control_config_axis_default(int axis) { Assert(axis >= 0); @@ -1217,7 +1215,7 @@ int control_config_axis_default(int axis) if (Axis_map_to_defaults[axis] < 0) return -1; - if (!joystick.axis_valid[Axis_map_to_defaults[axis]]) + if ( !joy_axis_valid(Axis_map_to_defaults[axis]) ) return -1; } @@ -1395,7 +1393,7 @@ void control_config_do_bind() } CC_Buttons[gr_screen.res][CANCEL_BUTTON].button.enable(); - CC_Buttons[gr_screen.res][CANCEL_BUTTON].button.set_hotkey(KEY_ESC); + CC_Buttons[gr_screen.res][CANCEL_BUTTON].button.set_hotkey(SDLK_ESCAPE); for (i=0; i= 0) && (k <= 0) && !keyd_pressed[Last_key] ) + if ( (Last_key >= 0) && (k <= 0) && !key_pressed(Last_key) ) k = Last_key; if ((k > 0) && !Config_allowed[k & KEY_MASK]) { @@ -1933,7 +1931,7 @@ void control_config_do_frame(float frametime) Ui_window.set_ignore_gadgets(0); } - if (k == KEY_ESC) { + if (k == SDLK_ESCAPE) { control_config_do_cancel(); } else { @@ -2011,7 +2009,7 @@ void control_config_do_frame(float frametime) if (!z) { z = Cc_lines[Selected_line].cc_index; k = Control_config[z].key_id; - if ( (k == KEY_LALT) || (k == KEY_RALT) || (k == KEY_LSHIFT) || (k == KEY_RSHIFT) ) { + if ( (k == SDLK_LALT) || (k == SDLK_RALT) || (k == SDLK_LSHIFT) || (k == SDLK_RSHIFT) ) { CC_Buttons[gr_screen.res][ALT_TOGGLE].button.enable(0); CC_Buttons[gr_screen.res][SHIFT_TOGGLE].button.enable(0); } @@ -2039,15 +2037,15 @@ void control_config_do_frame(float frametime) } switch (k) { - case KEY_DOWN: // select next line + case SDLK_DOWN: // select next line control_config_scroll_line_down(); break; - case KEY_UP: // select previous line + case SDLK_UP: // select previous line control_config_scroll_line_up(); break; - case KEY_SHIFTED | KEY_TAB: // activate previous tab + case KEY_SHIFTED | SDLK_TAB: // activate previous tab Tab--; if (Tab < 0) Tab = NUM_TABS - 1; @@ -2057,7 +2055,7 @@ void control_config_do_frame(float frametime) gamesnd_play_iface(SND_SCREEN_MODE_PRESSED); break; - case KEY_TAB: // activate next tab + case SDLK_TAB: // activate next tab Tab++; if (Tab >= NUM_TABS) Tab = 0; @@ -2067,7 +2065,7 @@ void control_config_do_frame(float frametime) gamesnd_play_iface(SND_SCREEN_MODE_PRESSED); break; - case KEY_LEFT: + case SDLK_LEFT: Selected_item--; if (Selected_item == -2) { Selected_item = 1; @@ -2081,7 +2079,7 @@ void control_config_do_frame(float frametime) gamesnd_play_iface(SND_SCROLL); break; - case KEY_RIGHT: + case SDLK_RIGHT: Selected_item++; if ((Selected_item == 1) && (Cc_lines[Selected_line].jw < 1)) Selected_item = -1; @@ -2093,11 +2091,11 @@ void control_config_do_frame(float frametime) gamesnd_play_iface(SND_SCROLL); break; - case KEY_BACKSP: // undo + case SDLK_BACKSPACE: // undo control_config_undo_last(); break; - case KEY_ESC: + case SDLK_ESCAPE: control_config_cancel_exit(); break; } // end switch @@ -2481,16 +2479,11 @@ int check_control(int id, int key) } // check what current modifiers are pressed - mask = 0; - if (keyd_pressed[KEY_LSHIFT] || key_down_count(KEY_LSHIFT) || keyd_pressed[KEY_RSHIFT] || key_down_count(KEY_RSHIFT)) - mask |= KEY_SHIFTED; - - if (keyd_pressed[KEY_LALT] || key_down_count(KEY_LALT) || keyd_pressed[KEY_RALT] || key_down_count(KEY_RALT)) - mask |= KEY_ALTED; + mask = key_get_shift_status(); z = Control_config[id].key_id; if (z >= 0) { - if ( (z != KEY_LALT) && (z != KEY_RALT) && (z != KEY_LSHIFT) && (z != KEY_RSHIFT) ) { + if ( (z != SDLK_LALT) && (z != SDLK_RALT) && (z != SDLK_LSHIFT) && (z != SDLK_RSHIFT) ) { // if current modifiers don't match action's modifiers, don't register control active. if ((z & (KEY_SHIFTED | KEY_ALTED)) != mask) return 0; @@ -2498,7 +2491,7 @@ int check_control(int id, int key) z &= KEY_MASK; - if (keyd_pressed[z] || key_down_count(z)) { + if (key_pressed(z) || key_down_count(z)) { if ( !hud_squadmsg_read_key(z) ) { control_used(id); return 1; @@ -2520,30 +2513,26 @@ int check_control(int id, int key) // get heading, pitch, bank, throttle abs. and throttle rel. values. void control_get_axes_readings(int *h, int *p, int *b, int *ta, int *tr) { - int axes_values[JOY_NUM_AXES]; - - joystick_read_raw_axis(JOY_NUM_AXES, axes_values); - // joy_get_scaled_reading will return a value represents the joystick pos from -1 to +1 (fixed point) *h = 0; if (Axis_map_to[0] >= 0) - *h = joy_get_scaled_reading(axes_values[Axis_map_to[0]], Axis_map_to[0]); + *h = joy_get_scaled_reading(Axis_map_to[0]); *p = 0; if (Axis_map_to[1] >= 0) - *p = joy_get_scaled_reading(axes_values[Axis_map_to[1]], Axis_map_to[1]); + *p = joy_get_scaled_reading(Axis_map_to[1]); *b = 0; if (Axis_map_to[2] >= 0) - *b = joy_get_scaled_reading(axes_values[Axis_map_to[2]], Axis_map_to[2]); + *b = joy_get_scaled_reading(Axis_map_to[2]); *ta = 0; if (Axis_map_to[3] >= 0) - *ta = joy_get_unscaled_reading(axes_values[Axis_map_to[3]], Axis_map_to[3]); + *ta = joy_get_unscaled_reading(Axis_map_to[3]); *tr = 0; if (Axis_map_to[4] >= 0) - *tr = joy_get_scaled_reading(axes_values[Axis_map_to[4]], Axis_map_to[4]); + *tr = joy_get_scaled_reading(Axis_map_to[4]); if (Invert_axis[0]) *h = -(*h); diff --git a/src/controlconfig/controlsconfigcommon.cpp b/src/controlconfig/controlsconfigcommon.cpp index 4a7c3b8..300b58b 100644 --- a/src/controlconfig/controlsconfigcommon.cpp +++ b/src/controlconfig/controlsconfigcommon.cpp @@ -250,7 +250,7 @@ * mouse button down but not up again yet. * * 89 11/24/97 10:20p Lawrance - * Add key 'KEY_N' to target next ship on monitoring view + * Add key 'SDLK_n' to target next ship on monitoring view * * 88 11/24/97 6:15p Lawrance * fix button scroll problem @@ -410,159 +410,163 @@ int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 }; //XSTR:OFF config_item Control_config[CCFG_MAX + 1] = { // targeting a ship - { KEY_T, -1, TARGET_TAB, "Target Next Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_T, -1, TARGET_TAB, "Target Previous Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_H, 2, TARGET_TAB, "Target Next Closest Hostile Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_H, -1, TARGET_TAB, "Target Previous Closest Hostile Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_H, -1, TARGET_TAB, "Toggle Auto Targeting", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_F, -1, TARGET_TAB, "Target Next Closest Friendly Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_F, -1, TARGET_TAB, "Target Previous Closest Friendly Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_Y, 4, TARGET_TAB, "Target Ship in Reticle", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_G, -1, TARGET_TAB, "Target Target's Nearest Attacker", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_Y, -1, TARGET_TAB, "Target Last Ship to Send Transmission", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_T, -1, TARGET_TAB, "Turn Off Auto-Targeting", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_t, -1, TARGET_TAB, "Target Next Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_t, -1, TARGET_TAB, "Target Previous Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_h, 2, TARGET_TAB, "Target Next Closest Hostile Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_h, -1, TARGET_TAB, "Target Previous Closest Hostile Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | SDLK_h, -1, TARGET_TAB, "Toggle Auto Targeting", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_f, -1, TARGET_TAB, "Target Next Closest Friendly Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_f, -1, TARGET_TAB, "Target Previous Closest Friendly Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_y, 4, TARGET_TAB, "Target Ship in Reticle", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_g, -1, TARGET_TAB, "Target Target's Nearest Attacker", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | SDLK_y, -1, TARGET_TAB, "Target Last Ship to Send Transmission", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | SDLK_t, -1, TARGET_TAB, "Turn Off Auto-Targeting", CC_TYPE_TRIGGER, -1, -1, 0 }, // targeting a ship's subsystem - { KEY_V, -1, TARGET_TAB, "Target Subsystem in Reticle", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_S, -1, TARGET_TAB, "Target Next Subsystem", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_S, -1, TARGET_TAB, "Target Previous Subsystem", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_S, -1, TARGET_TAB, "Turn Off Auto-Targeting of Subsystems", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_v, -1, TARGET_TAB, "Target Subsystem in Reticle", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_s, -1, TARGET_TAB, "Target Next Subsystem", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_s, -1, TARGET_TAB, "Target Previous Subsystem", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | SDLK_s, -1, TARGET_TAB, "Turn Off Auto-Targeting of Subsystems", CC_TYPE_TRIGGER, -1, -1, 0 }, // matching speed - { KEY_M, -1, COMPUTER_TAB, "Match Target Speed", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_M, -1, COMPUTER_TAB, "Toggle Auto Speed Matching", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_m, -1, COMPUTER_TAB, "Match Target Speed", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | SDLK_m, -1, COMPUTER_TAB, "Toggle Auto Speed Matching", CC_TYPE_TRIGGER, -1, -1, 0 }, // weapons - { KEY_LCTRL, 0, WEAPON_TAB, "Fire Primary Weapon", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_SPACEBAR, 1, WEAPON_TAB, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PERIOD, -1, WEAPON_TAB, "Cycle Forward Primary Weapon", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_COMMA, -1, WEAPON_TAB, "Cycle Backward Primary Weapon", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Bank", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Firing Rate", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_X, 3, WEAPON_TAB, "Launch Countermeasure", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_LCTRL, 0, WEAPON_TAB, "Fire Primary Weapon", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_SPACE, 1, WEAPON_TAB, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_PERIOD, -1, WEAPON_TAB, "Cycle Forward Primary Weapon", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_COMMA, -1, WEAPON_TAB, "Cycle Backward Primary Weapon", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_SLASH, -1, WEAPON_TAB, "Cycle Secondary Weapon Bank", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_SLASH, -1, WEAPON_TAB, "Cycle Secondary Weapon Firing Rate", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_x, 3, WEAPON_TAB, "Launch Countermeasure", CC_TYPE_TRIGGER, -1, -1, 0 }, // controls - { KEY_A, -1, SHIP_TAB, "Forward Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_Z, -1, SHIP_TAB, "Reverse Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PAD7, -1, SHIP_TAB, "Bank Left", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PAD9, -1, SHIP_TAB, "Bank Right", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PAD8, -1, SHIP_TAB, "Pitch Forward", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PAD2, -1, SHIP_TAB, "Pitch Backward", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PAD4, -1, SHIP_TAB, "Turn Left", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PAD6, -1, SHIP_TAB, "Turn Right", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_a, -1, SHIP_TAB, "Forward Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_z, -1, SHIP_TAB, "Reverse Thrust", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_7, -1, SHIP_TAB, "Bank Left", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_9, -1, SHIP_TAB, "Bank Right", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_8, -1, SHIP_TAB, "Pitch Forward", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_2, -1, SHIP_TAB, "Pitch Backward", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_4, -1, SHIP_TAB, "Turn Left", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_6, -1, SHIP_TAB, "Turn Right", CC_TYPE_CONTINUOUS, -1, -1, 0 }, // throttle controls - { KEY_BACKSP, -1, SHIP_TAB, "Set Throttle to Zero", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SLASH, -1, SHIP_TAB, "Set Throttle to Max", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_LBRACKET, -1, SHIP_TAB, "Set Throttle to One-Third", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_RBRACKET, -1, SHIP_TAB, "Set Throttle to Two-Thirds", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_EQUAL, -1, SHIP_TAB, "Increase Throttle 5 Percent", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_MINUS, -1, SHIP_TAB, "Decrease Throttle 5 Percent", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_BACKSPACE, -1, SHIP_TAB, "Set Throttle to Zero", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_BACKSLASH, -1, SHIP_TAB, "Set Throttle to Max", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_LEFTBRACKET, -1, SHIP_TAB, "Set Throttle to One-Third", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_RIGHTBRACKET, -1, SHIP_TAB, "Set Throttle to Two-Thirds", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_EQUALS, -1, SHIP_TAB, "Increase Throttle 5 Percent", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_MINUS, -1, SHIP_TAB, "Decrease Throttle 5 Percent", CC_TYPE_TRIGGER, -1, -1, 0 }, // squadmate messaging - { KEY_SHIFTED | KEY_A, -1, COMPUTER_TAB, "Attack My Target", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_Z, -1, COMPUTER_TAB, "Disarm My Target", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_D, -1, COMPUTER_TAB, "Disable My Target", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_V, -1, COMPUTER_TAB, "Attack my Subsystem", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_X, -1, COMPUTER_TAB, "Capture My Target", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Engage Enemy", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_W, -1, COMPUTER_TAB, "Form on my Wing", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_I, -1, COMPUTER_TAB, "Ignore my Target", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_P, -1, COMPUTER_TAB, "Protect my Target", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_C, -1, COMPUTER_TAB, "Cover me", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_J, -1, COMPUTER_TAB, "Return to base", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_R, -1, COMPUTER_TAB, "Rearm me", CC_TYPE_TRIGGER, -1, -1, 0 }, - - { KEY_R, 6, TARGET_TAB, "Target Closest Attacking Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_a, -1, COMPUTER_TAB, "Attack My Target", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_z, -1, COMPUTER_TAB, "Disarm My Target", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_d, -1, COMPUTER_TAB, "Disable My Target", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_v, -1, COMPUTER_TAB, "Attack my Subsystem", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_x, -1, COMPUTER_TAB, "Capture My Target", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_e, -1, COMPUTER_TAB, "Engage Enemy", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_w, -1, COMPUTER_TAB, "Form on my Wing", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_i, -1, COMPUTER_TAB, "Ignore my Target", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_p, -1, COMPUTER_TAB, "Protect my Target", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_c, -1, COMPUTER_TAB, "Cover me", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_j, -1, COMPUTER_TAB, "Return to base", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_r, -1, COMPUTER_TAB, "Rearm me", CC_TYPE_TRIGGER, -1, -1, 0 }, + + { SDLK_r, 6, TARGET_TAB, "Target Closest Attacking Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, // Views - { KEY_PADMULTIPLY, -1, COMPUTER_TAB, "Chase View", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_PADPERIOD, -1, COMPUTER_TAB, "External View", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_PADENTER, -1, COMPUTER_TAB, "Toggle External Camera Lock", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_PAD0, -1, COMPUTER_TAB, "Free Look View", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PADDIVIDE, -1, COMPUTER_TAB, "Current Target View", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_PADPLUS, -1, COMPUTER_TAB, "Increase View Distance", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PADMINUS, -1, COMPUTER_TAB, "Decrease View Distance", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_PAD5, -1, COMPUTER_TAB, "Center View", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_MULTIPLY, -1, COMPUTER_TAB, "Chase View", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_KP_PERIOD, -1, COMPUTER_TAB, "External View", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_KP_ENTER, -1, COMPUTER_TAB, "Toggle External Camera Lock", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_KP_0, -1, COMPUTER_TAB, "Free Look View", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_DIVIDE, -1, COMPUTER_TAB, "Current Target View", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_KP_PLUS, -1, COMPUTER_TAB, "Increase View Distance", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_MINUS, -1, COMPUTER_TAB, "Decrease View Distance", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_KP_5, -1, COMPUTER_TAB, "Center View", CC_TYPE_CONTINUOUS, -1, -1, 0 }, { -1, 33, COMPUTER_TAB, "View Up", CC_TYPE_CONTINUOUS, -1, -1, 0 }, { -1, 32, COMPUTER_TAB, "View Rear", CC_TYPE_CONTINUOUS, -1, -1, 0 }, { -1, 34, COMPUTER_TAB, "View Left", CC_TYPE_CONTINUOUS, -1, -1, 0 }, { -1, 35, COMPUTER_TAB, "View Right", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_RAPOSTRO, -1, COMPUTER_TAB, "Cycle Radar Range", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_C, -1, COMPUTER_TAB, "Communications Menu", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_QUOTE, -1, COMPUTER_TAB, "Cycle Radar Range", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_c, -1, COMPUTER_TAB, "Communications Menu", CC_TYPE_TRIGGER, -1, -1, 0 }, { -1, -1, -1, "Show Objectives", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_J, -1, COMPUTER_TAB, "Enter Subspace (End Mission)", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_J, -1, TARGET_TAB, "Target Target's Target", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_TAB, 5, SHIP_TAB, "Afterburner", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { KEY_ALTED | SDLK_j, -1, COMPUTER_TAB, "Enter Subspace (End Mission)", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_j, -1, TARGET_TAB, "Target Target's Target", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_TAB, 5, SHIP_TAB, "Afterburner", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_INSERT, -1, COMPUTER_TAB, "Increase Weapon Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_DELETE, -1, COMPUTER_TAB, "Decrease Weapon Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_HOME, -1, COMPUTER_TAB, "Increase Shield Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_END, -1, COMPUTER_TAB, "Decrease Shield Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_PAGEUP, -1, COMPUTER_TAB, "Increase Engine Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_PAGEDOWN, -1, COMPUTER_TAB, "Decrease Engine Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_D, -1, COMPUTER_TAB, "Equalize Energy Settings", CC_TYPE_TRIGGER, -1, -1, 0 }, - - { KEY_Q, 7, COMPUTER_TAB, "Equalize Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_UP, -1, COMPUTER_TAB, "Augment Forward Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_DOWN, -1, COMPUTER_TAB, "Augment Rear Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_LEFT, -1, COMPUTER_TAB, "Augment Left Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_RIGHT, -1, COMPUTER_TAB, "Augment Right Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Laser->Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Shield->Laser", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_INSERT, -1, COMPUTER_TAB, "Increase Weapon Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_DELETE, -1, COMPUTER_TAB, "Decrease Weapon Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_HOME, -1, COMPUTER_TAB, "Increase Shield Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_END, -1, COMPUTER_TAB, "Decrease Shield Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_PAGEUP, -1, COMPUTER_TAB, "Increase Engine Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_PAGEDOWN, -1, COMPUTER_TAB, "Decrease Engine Energy", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | SDLK_d, -1, COMPUTER_TAB, "Equalize Energy Settings", CC_TYPE_TRIGGER, -1, -1, 0 }, + + { SDLK_q, 7, COMPUTER_TAB, "Equalize Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_UP, -1, COMPUTER_TAB, "Augment Forward Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_DOWN, -1, COMPUTER_TAB, "Augment Rear Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_LEFT, -1, COMPUTER_TAB, "Augment Left Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_RIGHT, -1, COMPUTER_TAB, "Augment Right Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_SCROLLLOCK, -1, COMPUTER_TAB, "Transfer Energy Laser->Shield", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_SCROLLLOCK, -1, COMPUTER_TAB, "Transfer Energy Shield->Laser", CC_TYPE_TRIGGER, -1, -1, 0 }, { -1, -1, -1, "Show Damage Popup Window", CC_TYPE_TRIGGER, -1, -1, 0 }, { -1, -1, SHIP_TAB, "Bank When Pressed", CC_TYPE_CONTINUOUS, -1, -1, 0 }, { -1, -1, -1, "Show NavMap", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_E, -1, COMPUTER_TAB, "Add or Remove Escort", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Clear Escort List", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_E, -1, TARGET_TAB, "Target Next Escort Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_ALTED | KEY_R, -1, TARGET_TAB, "Target Closest Repair Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | SDLK_e, -1, COMPUTER_TAB, "Add or Remove Escort", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | KEY_SHIFTED | SDLK_e, -1, COMPUTER_TAB, "Clear Escort List", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_e, -1, TARGET_TAB, "Target Next Escort Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_ALTED | SDLK_r, -1, TARGET_TAB, "Target Closest Repair Ship", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_U, -1, TARGET_TAB, "Target Next Uninspected Cargo", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_U, -1, TARGET_TAB, "Target Previous Uninspected Cargo", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_N, -1, TARGET_TAB, "Target Newest Ship In Area", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_K, -1, TARGET_TAB, "Target Next Live Turret", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_K, -1, TARGET_TAB, "Target Previous Live Turret", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_u, -1, TARGET_TAB, "Target Next Uninspected Cargo", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_u, -1, TARGET_TAB, "Target Previous Uninspected Cargo", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_n, -1, TARGET_TAB, "Target Newest Ship In Area", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_k, -1, TARGET_TAB, "Target Next Live Turret", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_k, -1, TARGET_TAB, "Target Previous Live Turret", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_B, -1, TARGET_TAB, "Target Next Hostile Bomb or Bomber", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_B, -1, TARGET_TAB, "Target Previous Hostile Bomb or Bomber", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_b, -1, TARGET_TAB, "Target Next Hostile Bomb or Bomber", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_b, -1, TARGET_TAB, "Target Previous Hostile Bomb or Bomber", CC_TYPE_TRIGGER, -1, -1, 0 }, // multiplayer messaging keys - { KEY_1, -1, COMPUTER_TAB, "(Multiplayer) Message All", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_2, -1, COMPUTER_TAB, "(Multiplayer) Message Friendly", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_3, -1, COMPUTER_TAB, "(Multiplayer) Message Hostile", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_4, -1, COMPUTER_TAB, "(Multiplayer) Message Target", CC_TYPE_CONTINUOUS, -1, -1, 0 }, - { KEY_ALTED | KEY_X, -1, COMPUTER_TAB, "(Multiplayer) Observer zoom to target", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_1, -1, COMPUTER_TAB, "(Multiplayer) Message All", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_2, -1, COMPUTER_TAB, "(Multiplayer) Message Friendly", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_3, -1, COMPUTER_TAB, "(Multiplayer) Message Hostile", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { SDLK_4, -1, COMPUTER_TAB, "(Multiplayer) Message Target", CC_TYPE_CONTINUOUS, -1, -1, 0 }, + { KEY_ALTED | SDLK_x, -1, COMPUTER_TAB, "(Multiplayer) Observer zoom to target", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, "Increase time compression", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, "Decrease time compression", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_PERIOD, -1, COMPUTER_TAB, "Increase time compression", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_COMMA, -1, COMPUTER_TAB, "Decrease time compression", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_L, -1, COMPUTER_TAB, "Toggle high HUD contrast", CC_TYPE_TRIGGER, -1, -1, 0 }, + { SDLK_l, -1, COMPUTER_TAB, "Toggle high HUD contrast", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_N, -1, COMPUTER_TAB, "(Multiplayer) Toggle network info", CC_TYPE_TRIGGER, -1, -1, 0 }, - { KEY_SHIFTED | KEY_END, -1, COMPUTER_TAB, "(Multiplayer) Self destruct", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_n, -1, COMPUTER_TAB, "(Multiplayer) Toggle network info", CC_TYPE_TRIGGER, -1, -1, 0 }, + { KEY_SHIFTED | SDLK_END, -1, COMPUTER_TAB, "(Multiplayer) Self destruct", CC_TYPE_TRIGGER, -1, -1, 0 }, { -1, -1, -1, "", CC_TYPE_TRIGGER, -1, -1, 0 } }; - -const char *Scan_code_text_german[] = { - "", "Esc", "1", "2", "3", "4", "5", "6", +/* #ifndef MAKE_FS1 "7", "8", "9", "0", "Akzent '", "\xE1", "R\x81""cktaste", "Tab", #else "7", "8", "9", "0", "?", "Akzent '", "R\x81""cktaste", "Tab", #endif - "Q", "W", "E", "R", "T", "Z", "U", "I", - "O", "P", "\x9A", "+", "Eingabe", "Strg Links", "A", "S", - - "D", "F", "G", "H", "J", "K", "L", "\x99", #ifndef MAKE_FS1 "\xAE", "`", "Shift", "#", "Y", "X", "C", "V", #else "\x8E", "`", "Shift", "#", "Y", "X", "C", "V", #endif +*/ +/* +const char *Scan_code_text_german[] = { + "", "Esc", "1", "2", "3", "4", "5", "6", + "7", "8", "9", "0", "Akzent '", "\xE1", "R\x81""cktaste", "Tab", + "Q", "W", "E", "R", "T", "Z", "U", "I", + "O", "P", "\x9A", "+", "Eingabe", "Strg Links", "A", "S", + + "D", "F", "G", "H", "J", "K", "L", "\x99", + "\xAE", "`", "Shift", "#", "Y", "X", "C", "V", "B", "N", "M", ",", ".", "-", "Shift", "Num *", "Alt", "Leertaste", "Hochstell", "F1", "F2", "F3", "F4", "F5", @@ -596,6 +600,49 @@ const char *Scan_code_text_german[] = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; +*/ +const char *Scan_code_text_german[] = { + "", "", "", "", "A", "B", "C", "D", "E", + "F", "G", "H", "I", "J", "K", "L", "M", + "N", "O", "P", "Q", "R", "S", "T", "U", + "V", "W", "X", "Z", "Y", "1", "2", "3", + "4", "5", "6", "7", "8", "9", "0", "Eingabe", + "Esc", "R\x81""cktaste", "Tab", "Leertaste", "Akzent '", "\xE1", "\x9A", "+", + "#", "", "\x99", "\xAE", "`", ",", ".", "-", + "Hochstell", "F1", "F2", "F3", "F4", "F5", "F6", "F7", + "F8", "F9", "F10", "F11", "F12", "Druck", "Rollen", "Pause", + "Einfg", "Pos 1", "Bild Hoch", "Entf", "Ende", "Bild Runter", "Pfeil Rechts", "Pfeil Links", + "Pfeil Runter", "Pfeil Hoch", "", "Num /", "Num *", "Num -", "Num +", "Num Eingabe", + "Num 1", "Num 2", "Num 3", "Num 4", "Num 5", "Num 6", "Num 7", "Num 8", + "Num 9", "Num 0", "Num ,", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "Strg Links", + "Shift", "Alt", "", "Strg Rechts", "Shift", "Alt", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "" +}; const char *Joy_button_text_german[] = { "Knopf 1", "Knopf 2", "Knopf 3", "Knopf 4", "Knopf 5", "Knopf 6", @@ -606,6 +653,7 @@ const char *Joy_button_text_german[] = { "Knopf 31", "Knopf 32", "Hut Hinten", "Hut Vorne", "Hut Links", "Hut Rechts" }; +/* const char *Scan_code_text_french[] = { "", "\x90""chap", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Fl\x82""che Ret.", "Tab", @@ -647,6 +695,49 @@ const char *Scan_code_text_french[] = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; +*/ +const char *Scan_code_text_french[] = { + "", "", "", "", "A", "B", "C", "D", "E", + "F", "G", "H", "I", "J", "K", "L", "M", + "N", "O", "P", "Q", "R", "S", "T", "U", + "V", "W", "X", "Y", "Z", "1", "2", "3", + "4", "5", "6", "7", "8", "9", "0", "Entr\x82""e", + "\x90""chap", "Fl\x82""che Ret.", "Tab", "Espace", "-", "=", "[", "]", + "\\", "", ";", "'", "`", ",", ".", "/", + "Verr. Maj.", "F1", "F2", "F3", "F4", "F5", "F6", "F7", + "F8", "F9", "F10", "F11", "F12", "Impr \x82""cran", "Arret defil", "Pause", + "Inser", "Orig.", "Page Haut", "Suppr", "Fin", "Page Bas", "Fl\x82""che Droite", "Fl\x82""che Gauche", + "Fl\x82""che Bas", "Fl\x82""che Haut", "", "Pav\x82 /", "Pav\x82 *", "Pav\x82 -", "Pav\x82 +", "Pav\x82 Entr", + "Pav\x82 1", "Pav\x82 2", "Pav\x82 3", "Pav\x82 4", "Pav\x82 5", "Pav\x82 6", "Pav\x82 7", "Pav\x82 8", + "Pav\x82 9", "Pav\x82 0", "Pav\x82 .", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "Ctrl Gauche", + "Maj.", "Alt", "", "Ctrl Droite", "Maj.", "Alt", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "" +}; const char *Joy_button_text_french[] = { "Bouton 1", "Bouton 2", "Bouton 3", "Bouton 4", "Bouton 5", "Bouton 6", @@ -654,10 +745,11 @@ const char *Joy_button_text_french[] = { "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ère", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite" + "Bouton 31", "Bouton 32", "Chapeau Arri\xE8re", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite" }; // This is the text that is displayed on the screen for the keys a player selects +/* const char *Scan_code_text_english[] = { "", "Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Backspace", "Tab", @@ -699,6 +791,49 @@ const char *Scan_code_text_english[] = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; +*/ +const char *Scan_code_text_english[] = { + "", "", "", "", "A", "B", "C", "D", "E", + "F", "G", "H", "I", "J", "K", "L", "M", + "N", "O", "P", "Q", "R", "S", "T", "U", + "V", "W", "X", "Y", "Z", "1", "2", "3", + "4", "5", "6", "7", "8", "9", "0", "Enter", + "Esc", "Backspace", "Tab", "Spacebar", "-", "=", "[", "]", + "\\", "", ";", "'", "`", ",", ".", "/", + "Caps Lock", "F1", "F2", "F3", "F4", "F5", "F6", "F7", + "F8", "F9", "F10", "F11", "F12", "Print Scrn", "Scroll Lock", "Pause", + "Insert", "Home", "Page Up", "Delete", "End", "Page Down", "Right Arrow", "Left Arrow", + "Down Arrow", "Up Arrow", "", "Pad /", "Pad *", "Pad -", "Pad +", "Pad Enter", + "Pad 1", "Pad 2", "Pad 3", "Pad 4", "Pad 5", "Pad 6", "Pad 7", "Pad 8", + "Pad 9", "Pad 0", "Pad .", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "Left Ctrl", + "Shift", "Alt", "", "Right Ctrl", "Shift", "Alt", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "" +}; const char *Joy_button_text_english[] = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6", @@ -708,7 +843,7 @@ const char *Joy_button_text_english[] = { "Button 25", "Button 26", "Button 27", "Button 28", "Button 29", "Button 30", "Button 31", "Button 32", "Hat Back", "Hat Forward", "Hat Left", "Hat Right" }; - +/* const char *Scan_code_text_polish[] = { "", "Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Backspace", "Tab", @@ -750,6 +885,49 @@ const char *Scan_code_text_polish[] = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", }; +*/ +const char *Scan_code_text_polish[] = { + "", "", "", "", "A", "B", "C", "D", "E", + "F", "G", "H", "I", "J", "K", "L", "M", + "N", "O", "P", "Q", "R", "S", "T", "U", + "V", "W", "X", "Y", "Z", "1", "2", "3", + "4", "5", "6", "7", "8", "9", "0", "Enter", + "Esc", "Backspace", "Tab", "Spacja", "-", "=", "[", "]", + "\\", "", ";", "'", "`", ",", ".", "/", + "CapsLock", "F1", "F2", "F3", "F4", "F5", "F6", "F7", + "F8", "F9", "F10", "F11", "F12", "PrntScr", "Scrlock", "Pause", + "Insert", "Home", "Page Up", "Delete", "End", "Page Down", "Kursor Prawo", "Kursor Lewo", + "Kursor D\xF3\xB3", "Kursor G\xF3ra", "", "Num /", "Num *", "Num -", "Num +", "Num Enter", + "Num 1", "Num 2", "Num 3", "Num 4", "Num 5", "Num 6", "Num 7", "Num 8", + "Num 9", "Num 0", "Num .", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "Lewy Ctrl", + "LShift", "Alt", "", "Prawy Ctrl", "PShift", "Alt", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "" +}; const char *Joy_button_text_polish[] = { "Przyc.1", "Przyc.2", "Przyc.3", "Przyc.4", "Przyc.5", "Przyc.6", @@ -763,6 +941,7 @@ const char *Joy_button_text_polish[] = { const char **Scan_code_text = Scan_code_text_english; const char **Joy_button_text = Joy_button_text_english; + void set_modifier_status() { int i; @@ -919,7 +1098,9 @@ const char *textify_scancode(int code) } } - strcat(text, Scan_code_text[code & KEY_MASK]); + code = SDL_GetScancodeFromKey(code & KEY_MASK); + + strcat(text, Scan_code_text[code]); return text; } //XSTR:ON @@ -932,10 +1113,10 @@ void control_config_common_init() Joy_button_text = Joy_button_text_german; // swap init bindings for y and z keys - Control_config[TARGET_SHIP_IN_RETICLE].key_default = KEY_Z; - Control_config[TARGET_LAST_TRANMISSION_SENDER].key_default = KEY_ALTED | KEY_Z; - Control_config[REVERSE_THRUST].key_default = KEY_Y; - Control_config[DISARM_MESSAGE].key_default = KEY_SHIFTED | KEY_Y; + // Control_config[TARGET_SHIP_IN_RETICLE].key_default = SDLK_z; + // Control_config[TARGET_LAST_TRANMISSION_SENDER].key_default = KEY_ALTED | SDLK_z; + // Control_config[REVERSE_THRUST].key_default = SDLK_y; + // Control_config[DISARM_MESSAGE].key_default = KEY_SHIFTED | SDLK_y; } else if(Lcl_fr){ Scan_code_text = Scan_code_text_french; Joy_button_text = Joy_button_text_french; diff --git a/src/cutscene/cutscenes.cpp b/src/cutscene/cutscenes.cpp index 7147abf..0093050 100644 --- a/src/cutscene/cutscenes.cpp +++ b/src/cutscene/cutscenes.cpp @@ -633,16 +633,16 @@ void cutscenes_screen_init() } #endif - Buttons[gr_screen.res][EXIT_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER); - Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(KEY_PAGEUP); - Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(KEY_PAGEDOWN); + Buttons[gr_screen.res][EXIT_BUTTON].button.set_hotkey(KEY_CTRLED | SDLK_RETURN); + Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(SDLK_PAGEUP); + Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(SDLK_PAGEDOWN); List_region.create(&Ui_window, "", Cutscene_list_coords[gr_screen.res][0], Cutscene_list_coords[gr_screen.res][1], Cutscene_list_coords[gr_screen.res][2], Cutscene_list_coords[gr_screen.res][3], 0, 1); List_region.hide(); // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed - Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(KEY_PAGEUP); - Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(KEY_PAGEDOWN); + Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(SDLK_PAGEUP); + Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(SDLK_PAGEDOWN); Background_bitmap = bm_load(Cutscene_bitmap_name[gr_screen.res]); Scroll_offset = Selected_line = 0; @@ -681,37 +681,37 @@ void cutscenes_screen_do_frame() k = Ui_window.process(); switch (k) { - case KEY_DOWN: // select next line + case SDLK_DOWN: // select next line cutscenes_screen_scroll_line_down(); break; - case KEY_UP: // select previous line + case SDLK_UP: // select previous line cutscenes_screen_scroll_line_up(); break; - case KEY_TAB: - case KEY_CTRLED | KEY_DOWN: + case SDLK_TAB: + case KEY_CTRLED | SDLK_DOWN: cutscenes_screen_button_pressed(CREDITS_BUTTON); break; - case KEY_SHIFTED | KEY_TAB: - case KEY_CTRLED | KEY_UP: + case KEY_SHIFTED | SDLK_TAB: + case KEY_CTRLED | SDLK_UP: cutscenes_screen_button_pressed(SIMULATOR_BUTTON); break; - case KEY_ENTER: + case SDLK_RETURN: cutscenes_screen_play(); break; - case KEY_ESC: // cancel + case SDLK_ESCAPE: // cancel gameseq_post_event(GS_EVENT_MAIN_MENU); game_flush(); break; - case KEY_F1: // show help overlay + case SDLK_F1: // show help overlay break; - case KEY_F2: // goto options screen + case SDLK_F2: // goto options screen gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; } // end switch diff --git a/src/debugconsole/console.cpp b/src/debugconsole/console.cpp index 19cd30d..25cce1b 100644 --- a/src/debugconsole/console.cpp +++ b/src/debugconsole/console.cpp @@ -671,17 +671,17 @@ void debug_console( void (*_func)() ) int k = key_inkey(); switch( k ) { - case KEY_SHIFTED+KEY_ENTER: - case KEY_ESC: + case KEY_SHIFTED+SDLK_RETURN: + case SDLK_ESCAPE: done=1; break; - case KEY_BACKSP: + case SDLK_BACKSPACE: if ( command_line_pos > 0 ) { command_line[--command_line_pos] = 0; } break; - case KEY_F3: + case SDLK_F3: if ( last_oldcommand > -1 ) { strcpy( command_line, oldcommand_line[last_oldcommand] ); command_line_pos = strlen(command_line); @@ -689,7 +689,7 @@ void debug_console( void (*_func)() ) } break; - case KEY_UP: + case SDLK_UP: command_scroll--; if (command_scroll<0) command_scroll = last_oldcommand; @@ -701,7 +701,7 @@ void debug_console( void (*_func)() ) } break; - case KEY_DOWN: + case SDLK_DOWN: command_scroll++; if (command_scroll>last_oldcommand) command_scroll = 0; @@ -714,7 +714,7 @@ void debug_console( void (*_func)() ) } break; - case KEY_ENTER: { + case SDLK_RETURN: { debug_output( '\n' ); debug_draw(); @@ -790,7 +790,7 @@ void debug_help() debug_draw(); k = key_getch(); s = scroll_times; - if ( k == KEY_B ) { + if ( k == SDLK_b ) { i -= ((DROWS-3)*2); if ( i <= 0 ) i = -1; diff --git a/src/fonttool/fontkern.cpp b/src/fonttool/fontkern.cpp index e7d377d..e2d802b 100644 --- a/src/fonttool/fontkern.cpp +++ b/src/fonttool/fontkern.cpp @@ -351,7 +351,7 @@ void fonttool_edit_kerning(char *fname1, char *argv[]) os_init_registry_stuff(Osreg_company_name, Osreg_app_name,NULL); #endif ptr = os_config_read_string(NULL, NOX("Videocard"), NULL); - if((ptr == NULL) || !stricmp(ptr, "Aucune accélération 3D") || !stricmp(ptr, "Keine 3D-Beschleunigerkarte") || !stricmp(ptr, "No 3D acceleration")){ + if((ptr == NULL) || !stricmp(ptr, "Aucune acc�l�ration 3D") || !stricmp(ptr, "Keine 3D-Beschleunigerkarte") || !stricmp(ptr, "No 3D acceleration")){ #ifndef PLAT_UNIX MessageBox((HWND)os_get_window(), "Warning, Freespace 2 requires Glide or Direct3D hardware accleration. You will not be able to run Freespace 2 without it", "Warning", MB_OK); #endif @@ -400,82 +400,82 @@ void fonttool_edit_kerning(char *fname1, char *argv[]) os_poll(); k = key_inkey(); switch(k) { - case KEY_F5: + case SDLK_F5: fonttool_read( fname1, &tmpfont ); fonttool_copy_kern( &tmpfont, &KernFont ); break; - case KEY_F6: + case SDLK_F6: fonttool_remove_kerning( &KernFont ); break; - case KEY_F10: + case SDLK_F10: fonttool_dump( fname1, &KernFont ); done=1; break; - case KEY_COMMA: + case SDLK_COMMA: if ( alpha > 1 ) { alpha--; gr_init_alphacolor(&ac,cr*16,cg*16,cb*16,alpha*16,AC_TYPE_HUD); } break; - case KEY_PERIOD: + case SDLK_PERIOD: if ( alpha < 17 ) { alpha++; gr_init_alphacolor(&ac,cr*16,cg*16,cb*16,alpha*16,AC_TYPE_HUD); } break; - case KEY_R: + case SDLK_r: if ( cr == 16 ) cr = 1; else cr = 16; gr_init_alphacolor(&ac,cr*16,cg*16,cb*16,alpha*16,AC_TYPE_HUD); break; - case KEY_G: + case SDLK_g: if ( cg == 16 ) cg = 1; else cg = 16; gr_init_alphacolor(&ac,cr*16,cg*16,cb*16,alpha*16,AC_TYPE_HUD); break; - case KEY_B: + case SDLK_b: if ( cb == 16 ) cb = 1; else cb = 16; gr_init_alphacolor(&ac,cr*16,cg*16,cb*16,alpha*16,AC_TYPE_HUD); break; - case KEY_PAD6: + case SDLK_KP_6: x = fonttool_get_kerning( &KernFont, c1, c2, NULL ); fonttool_set_kerning( &KernFont, c1, c2, x+1 ); break; - case KEY_PAD4: + case SDLK_KP_4: x = fonttool_get_kerning( &KernFont, c1, c2, NULL ); fonttool_set_kerning( &KernFont, c1, c2, x-1 ); break; - case KEY_PAD5: + case SDLK_KP_5: fonttool_set_kerning( &KernFont, c1, c2, 0 ); break; - case KEY_PAD7: + case SDLK_KP_7: if ( c1 < KernFont.first_ascii + KernFont.num_chars-1 ) c1++; break; - case KEY_PAD1: + case SDLK_KP_1: if ( c1 > KernFont.first_ascii ) c1--; break; - case KEY_PAD9: + case SDLK_KP_9: if ( c2 < KernFont.first_ascii + KernFont.num_chars-1 ) c2++; mprintf(( "C2 = %d\n", c2 )); break; - case KEY_PAD3: + case SDLK_KP_3: if ( c2 > KernFont.first_ascii ) c2--; mprintf(( "C2 = %d\n", c2 )); break; - case KEY_PAD2: + case SDLK_KP_2: if ( current_pair < 0 ) current_pair = last_good_pair; else @@ -489,7 +489,7 @@ void fonttool_edit_kerning(char *fname1, char *argv[]) } break; - case KEY_PAD8: + case SDLK_KP_8: if ( current_pair < 0 ) current_pair = last_good_pair; else @@ -503,7 +503,7 @@ void fonttool_edit_kerning(char *fname1, char *argv[]) } break; - case KEY_ESC: + case SDLK_ESCAPE: done=1; break; } diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index 20ac0d3..f26d931 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -2522,7 +2522,7 @@ void game_init() } if(!Is_standalone){ - if(!stricmp(ptr, "Aucune accélération 3D") || !stricmp(ptr, "Keine 3D-Beschleunigerkarte") || !stricmp(ptr, "No 3D acceleration")){ + if(!stricmp(ptr, "Aucune acc�l�ration 3D") || !stricmp(ptr, "Keine 3D-Beschleunigerkarte") || !stricmp(ptr, "No 3D acceleration")){ #ifndef PLAT_UNIX MessageBox((HWND)os_get_window(), XSTR("Warning, Freespace 2 requires Glide or Direct3D hardware accleration. You will not be able to run Freespace 2 without it.", 1448), XSTR("Warning", 1449), MB_OK); #else @@ -3980,7 +3980,7 @@ void game_render_frame( vector * eye_pos, matrix * eye_orient ) #ifdef JOHNS_DEBUG_CODE void john_debug_stuff(vector *eye_pos, matrix *eye_orient) { - //if ( keyd_pressed[KEY_LSHIFT] ) + //if ( key_pressed(SDLK_LSHIFT) ) { ship_subsys *tsys = Players[Player_num].targeted_subobject; if ( tsys ) { @@ -4102,7 +4102,7 @@ void game_maybe_dump_frame() return; } - if( Debug_dump_trigger && !keyd_pressed[KEY_Q] ){ + if( Debug_dump_trigger && !key_pressed(SDLK_q) ){ return; } @@ -4917,8 +4917,8 @@ int game_check_key() k = game_poll(); // convert keypad enter to normal enter - if ((k & KEY_MASK) == KEY_PADENTER) - k = (k & ~KEY_MASK) | KEY_ENTER; + if ((k & KEY_MASK) == SDLK_KP_ENTER) + k = (k & ~KEY_MASK) | SDLK_RETURN; return k; } @@ -5052,16 +5052,16 @@ int game_poll() // if ( k ) nprintf(( "General", "Key = %x\n", k )); switch (k) { - case KEY_DEBUGGED + KEY_BACKSP: + case KEY_DEBUGGED + SDLK_BACKSPACE: Int3(); break; - case KEY_F1: + case SDLK_F1: launch_context_help(); k = 0; break; - case KEY_F2: + case SDLK_F2: // if (state != GS_STATE_INITIAL_PLAYER_SELECT) { // don't allow f2 while warping out in multiplayer @@ -5088,7 +5088,7 @@ int game_poll() break; // hotkey selection screen -- only valid from briefing and beyond. - case KEY_F3: + case SDLK_F3: #if !(defined(FS2_DEMO) || defined(FS1_DEMO)) if ( (state == GS_STATE_TEAM_SELECT) || (state == GS_STATE_BRIEFING) || (state == GS_STATE_SHIP_SELECT) || (state == GS_STATE_WEAPON_SELECT) || (state == GS_STATE_GAME_PLAY) || (state == GS_STATE_GAME_PAUSED) ) { gameseq_post_event( GS_EVENT_HOTKEY_SCREEN ); @@ -5097,15 +5097,15 @@ int game_poll() #endif break; - case KEY_DEBUGGED + KEY_F3: + case KEY_DEBUGGED + SDLK_F3: gameseq_post_event( GS_EVENT_TOGGLE_FULLSCREEN ); break; - case KEY_DEBUGGED + KEY_F4: + case KEY_DEBUGGED + SDLK_F4: gameseq_post_event( GS_EVENT_TOGGLE_GLIDE ); break; - case KEY_F4: + case SDLK_F4: if(Game_mode & GM_MULTIPLAYER){ if((state == GS_STATE_GAME_PLAY) || (state == GS_STATE_MULTI_PAUSED)){ gameseq_post_event( GS_EVENT_MISSION_LOG_SCROLLBACK ); @@ -5119,7 +5119,7 @@ int game_poll() } break; - case KEY_ESC | KEY_SHIFTED: + case SDLK_ESCAPE | KEY_SHIFTED: // make sure to quit properly out of multiplayer if(Game_mode & GM_MULTIPLAYER){ multi_quit_game(PROMPT_NONE); @@ -5130,10 +5130,10 @@ int game_poll() break; - case KEY_DEBUGGED + KEY_P: + case KEY_DEBUGGED + SDLK_p: break; - case KEY_PRINT_SCRN: + case SDLK_PRINTSCREEN: { static int counter = 0; char tmp_name[127]; @@ -5151,7 +5151,7 @@ int game_poll() k = 0; break; - case KEY_SHIFTED | KEY_ENTER: { + case KEY_SHIFTED | SDLK_RETURN: { #if !defined(NDEBUG) @@ -7665,25 +7665,25 @@ void game_show_event_debug(float frametime) k = game_check_key(); if (k) switch (k) { - case KEY_UP: - case KEY_PAD8: + case SDLK_UP: + case SDLK_KP_8: scroll_offset--; if (scroll_offset < 0) scroll_offset = 0; break; - case KEY_DOWN: - case KEY_PAD2: + case SDLK_DOWN: + case SDLK_KP_2: scroll_offset++; break; - case KEY_PAGEUP: + case SDLK_PAGEUP: scroll_offset -= 20; if (scroll_offset < 0) scroll_offset = 0; break; - case KEY_PAGEDOWN: + case SDLK_PAGEDOWN: scroll_offset += 20; // not font-independent, hard-coded since I counted the lines! break; @@ -7870,7 +7870,7 @@ void Time_model( int modelnum ) ta.h += 0.1f; int k = key_inkey(); - if ( k == KEY_ESC ) { + if ( k == SDLK_ESCAPE ) { exit(1); } } diff --git a/src/freespace2/unixmain.cpp b/src/freespace2/unixmain.cpp index 549ecda..3dcc4ea 100644 --- a/src/freespace2/unixmain.cpp +++ b/src/freespace2/unixmain.cpp @@ -15,6 +15,7 @@ char full_path[1024]; void vm_dump(); + int main(int argc, char **argv) { char userdir[MAX_PATH] = { 0 }; @@ -26,7 +27,7 @@ int main(int argc, char **argv) // create user game directory snprintf(userdir, MAX_PATH, "%s/%s/", detect_home(), Osreg_user_dir); _mkdir(userdir); - + char *argptr = NULL; int i; int len = 0; diff --git a/src/gamehelp/gameplayhelp.cpp b/src/gamehelp/gameplayhelp.cpp index e0293e1..279c5bf 100644 --- a/src/gamehelp/gameplayhelp.cpp +++ b/src/gamehelp/gameplayhelp.cpp @@ -374,9 +374,9 @@ void gameplay_help_init() } // setup hotkeys so lights flash when keys are pressed - Buttons[gr_screen.res][CONTINUE_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER); - Buttons[gr_screen.res][PREVIOUS_PAGE_BUTTON].button.set_hotkey(KEY_LEFT); - Buttons[gr_screen.res][NEXT_PAGE_BUTTON].button.set_hotkey(KEY_RIGHT); + Buttons[gr_screen.res][CONTINUE_BUTTON].button.set_hotkey(KEY_CTRLED | SDLK_RETURN); + Buttons[gr_screen.res][PREVIOUS_PAGE_BUTTON].button.set_hotkey(SDLK_LEFT); + Buttons[gr_screen.res][NEXT_PAGE_BUTTON].button.set_hotkey(SDLK_RIGHT); Background_bitmap = bm_load(Game_help_filename[gr_screen.res]); @@ -420,18 +420,18 @@ void gameplay_help_leave() void gameplay_help_process_key(int k) { switch ( k ) { - case KEY_ESC: + case SDLK_ESCAPE: gameplay_help_leave(); break; - case KEY_ENTER: - case KEY_SPACEBAR: - case KEY_TAB: + case SDLK_RETURN: + case SDLK_SPACE: + case SDLK_TAB: //gameplay_help_goto_next_screen(); Buttons[gr_screen.res][NEXT_PAGE_BUTTON].button.press_button(); break; - case KEY_SHIFTED | KEY_TAB: + case KEY_SHIFTED | SDLK_TAB: Buttons[gr_screen.res][PREVIOUS_PAGE_BUTTON].button.press_button(); // gameplay_help_goto_prev_screen(); break; diff --git a/src/graphics/2d.cpp b/src/graphics/2d.cpp index ef5e17f..f9119c7 100644 --- a/src/graphics/2d.cpp +++ b/src/graphics/2d.cpp @@ -1074,6 +1074,7 @@ void gr_force_windowed() break; #endif case GR_OPENGL: + gr_opengl_force_windowed(); break; default: Int3(); // Invalid graphics mode diff --git a/src/graphics/gropengl.cpp b/src/graphics/gropengl.cpp index fea69c9..fb0ad5d 100644 --- a/src/graphics/gropengl.cpp +++ b/src/graphics/gropengl.cpp @@ -2889,6 +2889,11 @@ void gr_opengl_unlock() { } +void gr_opengl_force_windowed() +{ + SDL_SetWindowFullscreen(GL_window, 0); +} + void opengl_zbias(int bias) { if (bias) { @@ -2910,9 +2915,7 @@ void gr_opengl_init() mprintf(( "Initializing opengl graphics device...\n" )); Inited = 1; -#ifdef PLAT_UNIX - if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0) - { + if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0) { fprintf (stderr, "Couldn't init SDL: %s", SDL_GetError()); exit (1); } @@ -2926,19 +2929,19 @@ void gr_opengl_init() int flags = SDL_WINDOW_OPENGL; if (!Cmdline_window && ( (os_config_read_uint( NULL, "Fullscreen", 1 ) == 1) || Cmdline_fullscreen )) - flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; -/* + flags |= SDL_WINDOW_FULLSCREEN; + // grab mouse/key unless told otherwise, ignore when we are going fullscreen - if ( !((flags & SDL_FULLSCREEN) || Cmdline_no_grab) ) { - SDL_WM_GrabInput(SDL_GRAB_ON); + if ( !((flags & SDL_WINDOW_FULLSCREEN) || Cmdline_no_grab) ) { + SDL_SetWindowGrab(GL_window, SDL_TRUE); } - FSAA = os_config_read_uint( NULL, "FSAA", 1 ); + FSAA = os_config_read_uint( NULL, "FSAA", 2 ); if ( FSAA ) { SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, FSAA ); } - +/* if (SDL_SetVideoMode (gr_screen.max_w, gr_screen.max_h,0,flags) == NULL) { mprintf(( "Couldn't set FSAA video mode: %s\n", SDL_GetError () )); @@ -2954,17 +2957,16 @@ void gr_opengl_init() */ GL_window = SDL_CreateWindow(Osreg_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - 0, 0, flags); + gr_screen.max_w, gr_screen.max_h, flags); GL_context = SDL_GL_CreateContext(GL_window); - // mprintf(( "Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel )); // mprintf(( "\n" )); mprintf(( "Vendor : %s\n", glGetString(GL_VENDOR) )); mprintf(( "Renderer : %s\n", glGetString(GL_RENDERER) )); mprintf(( "Version : %s\n", glGetString(GL_VERSION) )); - +/* #ifndef NDEBUG // print out extensions - taken from FS2_Open (credits: phreak, taylor) mprintf(( "Extensions : \n")); @@ -2993,14 +2995,14 @@ void gr_opengl_init() mprintf(( "\n" )); #endif - +*/ int value; int rgb_size[3]; int bpp = 15; rgb_size[0]=5; rgb_size[1]=5; rgb_size[2]=5; -/* + SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value ); mprintf(( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value )); SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value ); @@ -3018,14 +3020,13 @@ void gr_opengl_init() SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value ); mprintf(( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", FSAA, value )); } -*/ + + mprintf(("\n")); + // SDL_ShowCursor(0); -// SDL_WM_SetCaption (Osreg_title, NULL); - /* might as well put this here */ -// SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); +// SDL_SetRelativeMouseMode(SDL_TRUE); -#endif GL_use_luminance_alpha = os_config_read_uint(NOX("OpenGL"), NOX("UseLuminanceAlpha"), 0); diff --git a/src/hud/hudconfig.cpp b/src/hud/hudconfig.cpp index 54e92f1..91f49b9 100644 --- a/src/hud/hudconfig.cpp +++ b/src/hud/hudconfig.cpp @@ -1429,13 +1429,13 @@ void hud_cycle_gauge_status() void hud_config_handle_keypresses(int k) { switch(k) { - case KEY_ESC: + case SDLK_ESCAPE: hud_config_cancel(); break; - case KEY_CTRLED+KEY_ENTER: + case KEY_CTRLED+SDLK_RETURN: hud_config_commit(); break; - case KEY_TAB: + case SDLK_TAB: gamesnd_play_iface(SND_USER_SELECT); hud_cycle_gauge_status(); break; diff --git a/src/hud/hudmessage.cpp b/src/hud/hudmessage.cpp index adbad13..856e599 100644 --- a/src/hud/hudmessage.cpp +++ b/src/hud/hudmessage.cpp @@ -1380,8 +1380,8 @@ void hud_scrollback_init() #endif // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed - Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(KEY_UP); - Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(KEY_DOWN); + Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(SDLK_UP); + Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(SDLK_DOWN); Background_bitmap = bm_load(Hud_mission_log_fname[gr_screen.res]); #ifdef MAKE_FS1 @@ -1428,8 +1428,8 @@ void hud_scrollback_do_frame(float frametime) k = Ui_window.process(); switch (k) { - case KEY_RIGHT: - case KEY_TAB: + case SDLK_RIGHT: + case SDLK_TAB: if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) { Scrollback_mode = SCROLLBACK_MODE_MSGS_LOG; Scroll_max = hud_query_scrollback_size(); @@ -1448,8 +1448,8 @@ void hud_scrollback_do_frame(float frametime) break; - case KEY_LEFT: - case KEY_SHIFTED | KEY_TAB: + case SDLK_LEFT: + case KEY_SHIFTED | SDLK_TAB: if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) { Scrollback_mode = SCROLLBACK_MODE_EVENT_LOG; Scroll_max = Num_log_lines * gr_get_font_height(); @@ -1468,24 +1468,24 @@ void hud_scrollback_do_frame(float frametime) break; - case KEY_PAGEUP: + case SDLK_PAGEUP: hud_page_scroll_list(1); break; - case KEY_PAGEDOWN: + case SDLK_PAGEDOWN: hud_page_scroll_list(0); break; - case KEY_ENTER: - case KEY_CTRLED | KEY_ENTER: - case KEY_ESC: + case SDLK_RETURN: + case KEY_CTRLED | SDLK_RETURN: + case SDLK_ESCAPE: hud_scrollback_exit(); break; - case KEY_F1: // show help overlay + case SDLK_F1: // show help overlay break; - case KEY_F2: // goto options screen + case SDLK_F2: // goto options screen gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; } // end switch diff --git a/src/hud/hudsquadmsg.cpp b/src/hud/hudsquadmsg.cpp index ff4ceed..01aa996 100644 --- a/src/hud/hudsquadmsg.cpp +++ b/src/hud/hudsquadmsg.cpp @@ -378,8 +378,8 @@ int num_keys_saved = 0; // number of keys that are saved. // next array is the array of MAX_KEYS_USED size which are the keys to use for messaging mode -int keys_used[] = { KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, - KEY_PAGEUP, KEY_PAGEDOWN }; +int keys_used[] = { SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_0, + SDLK_PAGEUP, SDLK_PAGEDOWN }; #define ID1 1 #define ID2 2 @@ -850,7 +850,7 @@ int hud_squadmsg_read_key( int k ) // after messaging is over. Return true for a while. if ( !timestamp_elapsed(Msg_eat_key_timestamp) ) { for (i = 0; i < num_keys_used; i++ ) { - if ( keyd_pressed[keys_used[i]] ) + if ( key_pressed(keys_used[i]) ) return 1; } } @@ -866,7 +866,7 @@ int hud_squadmsg_read_key( int k ) key_found = 1; } - if ( keyd_pressed[k] ) { + if ( key_pressed(k) ) { key_found = 1; } @@ -905,13 +905,13 @@ int hud_squadmsg_get_key() // use a timestamp to prevent top level key code from possibly reprocessing this key Msg_eat_key_timestamp = timestamp(MSG_KEY_EAT_TIME); - if ( k == KEY_PAGEDOWN ) { // pageup and pagedown scroll the menu -- deal with these seperately!! + if ( k == SDLK_PAGEDOWN ) { // pageup and pagedown scroll the menu -- deal with these seperately!! hud_squadmsg_page_down(); return -1; - } else if ( k == KEY_PAGEUP ) { + } else if ( k == SDLK_PAGEUP ) { hud_squadmsg_page_up(); return -1; - } else if ( k == KEY_ESC ) { + } else if ( k == SDLK_ESCAPE ) { hud_squadmsg_toggle(); return -1; } else if ( (i < Num_menu_items) && (Squad_msg_mode == SM_MODE_REINFORCEMENTS) ) // return any key if selecting reinforcement diff --git a/src/io/joy-sdl.cpp b/src/io/joy-sdl.cpp index 198b728..dd4064e 100644 --- a/src/io/joy-sdl.cpp +++ b/src/io/joy-sdl.cpp @@ -18,13 +18,10 @@ #include "SDL.h" static int Joy_inited = 0; -int joy_num_sticks = 0; int Dead_zone_size = 10; int Cur_joystick = -1; int Joy_sensitivity = 9; -int joy_pollrate = 1000 / 18; // poll at 18Hz - static int Joy_last_x_reading = 0; static int Joy_last_y_reading = 0; @@ -37,21 +34,28 @@ typedef struct joy_button_info { uint last_down_check; // timestamp in milliseconds of last } joy_button_info; -Joy_info joystick; +static Joy_info joystick; -int JOYSTICKID1 = 0; // DDOI - temporary -static SDL_Joystick *sdljoy; +SDL_Joystick *sdljoy; +static SDL_JoystickID joy_id = -1; joy_button_info joy_buttons[JOY_TOTAL_BUTTONS]; +int joystick_get_id() +{ + return joy_id; +} + void joy_close() { if (!Joy_inited) return; + joy_ff_shutdown(); + Joy_inited = 0; - joy_num_sticks = 0; + joy_id = -1; if (SDL_JoystickGetAttached(sdljoy)) { SDL_JoystickClose(sdljoy); @@ -67,10 +71,6 @@ void joy_get_caps() SDL_Joystick *joy; int j, max_count; - for (j=0; j < JOY_NUM_AXES; j++) { - joystick.axis_valid[j] = 0; - } - max_count = SDL_NumJoysticks(); for (j = 0; j < max_count; j++) { @@ -79,30 +79,30 @@ void joy_get_caps() if (joy) { // nprintf (("JOYSTICK", "Joystick #%d: %s\n", j - JOYSTICKID1 + 1, SDL_JoystickName(j))); mprintf(("Joystick #%d: %s %s\n", j + 1, SDL_JoystickName(joy), (j == Cur_joystick) ? "*" : " ")); - mprintf((" Axes: %d", SDL_JoystickNumAxes(joy))); - mprintf((" Buttons: %d", SDL_JoystickNumButtons(joy))); - mprintf((" Hats: %d", SDL_JoystickNumHats(joy))); - mprintf((" Balls: %d", SDL_JoystickNumBalls(joy))); - mprintf((" Haptic: %s", SDL_JoystickIsHaptic(joy) ? "Yes" : "No")); - mprintf((" Gamepad: %s", (SDL_IsGameController(j) == SDL_TRUE) ? "Yes" : "No")); - - if (j == Cur_joystick) { - for (int i = 0; i < SDL_JoystickNumAxes(joy); i++) { - joystick.axis_valid[i] = 1; - } - } + mprintf((" Axes: %d\n", SDL_JoystickNumAxes(joy))); + mprintf((" Buttons: %d\n", SDL_JoystickNumButtons(joy))); + mprintf((" Hats: %d\n", SDL_JoystickNumHats(joy))); + mprintf((" Balls: %d\n", SDL_JoystickNumBalls(joy))); + mprintf((" Haptic: %s\n", SDL_JoystickIsHaptic(joy) ? "Yes" : "No")); SDL_JoystickClose (joy); } } + + mprintf(("\n")); } int joy_down(int btn) { int tmp; - if ( joy_num_sticks < 1 ) return 0; - if ( (btn < 0) || (btn >= JOY_TOTAL_BUTTONS )) return 0; + if ( !Joy_inited ) { + return 0; + } + + if ( (btn < 0) || (btn >= JOY_TOTAL_BUTTONS)) { + return 0; + } tmp = joy_buttons[btn].state; @@ -113,8 +113,13 @@ int joy_down_count(int btn, int reset_count) { int tmp; - if ( joy_num_sticks < 1 ) return 0; - if ( (btn < 0) || (btn >= JOY_TOTAL_BUTTONS)) return 0; + if ( !Joy_inited ) { + return 0; + } + + if ( (btn < 0) || (btn >= JOY_TOTAL_BUTTONS)) { + return 0; + } tmp = joy_buttons[btn].down_count; if ( reset_count ) { @@ -127,21 +132,24 @@ int joy_down_count(int btn, int reset_count) float joy_down_time(int btn) { float rval; - unsigned int now; + unsigned int now, delta; joy_button_info *bi; - if ( joy_num_sticks < 1 ) return 0.0f; - if ( (btn < 0) || (btn >= JOY_TOTAL_BUTTONS)) return 0.0f; + if ( !Joy_inited ) { + return 0.0f; + } + + if ( (btn < 0) || (btn >= JOY_TOTAL_BUTTONS)) { + return 0.0f; + } + bi = &joy_buttons[btn]; now = timer_get_milliseconds(); - - if ( bi->down_time == 0 && joy_down(btn) ) { - bi->down_time += joy_pollrate; - } + delta = now - bi->last_down_check; if ( (now - bi->last_down_check) > 0) - rval = i2fl(bi->down_time) / (now - bi->last_down_check); + rval = i2fl((now - bi->down_time)) / delta; else rval = 0.0f; @@ -161,7 +169,7 @@ void joy_mark_button(int btn, int state) int i; joy_button_info *bi; - if (joy_num_sticks < 1) { + if ( !Joy_inited ) { return; } @@ -177,24 +185,24 @@ void joy_mark_button(int btn, int state) bi->state = 1; bi->down_time = timer_get_milliseconds(); + + // toggle off other positions if hat + if (btn >= JOY_HATBACK) { + for (i = JOY_HATBACK; i < (JOY_HATBACK+JOY_NUM_HAT_POS); i++) { + if (btn != i) { + joy_buttons[i].state = 0; + } + } + } } else { // button released // bi->up_count++; bi->state = 0; - } - - // special handling if hat, since only one position can register active - if (btn >= JOY_HATFORWARD) { - // special case, hat at center pos, force reset all - if (state == 0) { - btn = 0; - } - for (i = JOY_HATFORWARD; i < JOY_NUM_HAT_POS; i++) { - // for all pos but current, or special case, reset to released state - if (btn != i) { - // joy_buttons[i].up_count++; + // special hat handling - make sure all hat pos are off + if (btn == JOY_HATBACK) { + for (i = JOY_HATBACK; i < (JOY_HATBACK+JOY_NUM_HAT_POS); i++) { joy_buttons[i].state = 0; } } @@ -206,7 +214,9 @@ void joy_flush() int i; joy_button_info *bi; - if ( joy_num_sticks < 1 ) return; + if ( !Joy_inited ) { + return; + } for ( i = 0; i < JOY_TOTAL_BUTTONS; i++) { bi = &joy_buttons[i]; @@ -218,10 +228,18 @@ void joy_flush() } } -int joy_get_unscaled_reading(int raw, int axn) +int joy_get_unscaled_reading(int axn) { int rng; + if ( !Joy_inited ) { + return 0; + } + + if (axn >= joystick.num_axes) { + return 0; + } + // Make sure it's calibrated properly. if (joystick.axis_center[axn] - joystick.axis_min[axn] < 5) return 0; @@ -229,6 +247,8 @@ int joy_get_unscaled_reading(int raw, int axn) if (joystick.axis_max[axn] - joystick.axis_center[axn] < 5) return 0; + int raw = joystick.axis_current[axn]; + rng = joystick.axis_max[axn] - joystick.axis_min[axn]; raw -= joystick.axis_min[axn]; // adjust for linear range starting at 0 @@ -251,19 +271,29 @@ int joy_get_unscaled_reading(int raw, int axn) // the joystick pos from -1 to +1 for the specified axis number 'axn', and // the raw value 'raw' // -int joy_get_scaled_reading(int raw, int axn) +int joy_get_scaled_reading(int axn) { - int x, d, dead_zone, rng; + int x, d, dead_zone, rng, raw; float percent, sensitivity_percent, non_sensitivity_percent; + if ( !Joy_inited ) { + return 0; + } + + if (axn >= joystick.num_axes) { + return 0; + } + // Make sure it's calibrated properly. - if (joystick.axis_center[axn] - joystick.axis_min[axn] < 5) + if (joystick.axis_center[axn] - joystick.axis_min[axn] < 5) { return 0; + } - if (joystick.axis_max[axn] - joystick.axis_center[axn] < 5) + if (joystick.axis_max[axn] - joystick.axis_center[axn] < 5) { return 0; + } - raw -= joystick.axis_center[axn]; + raw = joystick.axis_current[axn] - joystick.axis_center[axn]; dead_zone = (joystick.axis_max[axn] - joystick.axis_min[axn]) * Dead_zone_size / 100; @@ -275,8 +305,9 @@ int joy_get_scaled_reading(int raw, int axn) rng = joystick.axis_max[axn] - joystick.axis_center[axn] - dead_zone; d = raw - dead_zone; - } else + } else { return 0; + } if (d > rng) d = rng; @@ -297,8 +328,9 @@ int joy_get_scaled_reading(int raw, int axn) //nprintf(("AI", "d=%6i, sens=%3i, percent=%6.3f, val=%6i, ratio=%6.3f\n", d, Joy_sensitivity, percent, (raw<0) ? -x : x, (float) d/x)); - if (raw < 0) + if (raw < 0) { return -x; + } return x; } @@ -316,121 +348,41 @@ int joy_get_scaled_reading(int raw, int axn) // int joy_get_pos(int *x, int *y, int *z, int *rx) { - int axis[JOY_NUM_AXES]; - if (x) *x = 0; if (y) *y = 0; if (z) *z = 0; if (rx) *rx = 0; - if (joy_num_sticks < 1) return 0; - - joystick_read_raw_axis( 6, axis ); - - // joy_get_scaled_reading will return a value represents the joystick pos from -1 to +1 - if (x && joystick.axis_valid[0]) - *x = joy_get_scaled_reading(axis[0], 0); - if (y && joystick.axis_valid[1]) - *y = joy_get_scaled_reading(axis[1], 1); - if (z && joystick.axis_valid[2]) - *z = joy_get_unscaled_reading(axis[2], 2); - if (rx && joystick.axis_valid[3]) - *rx = joy_get_scaled_reading(axis[3], 3); + if ( !Joy_inited ) { + return 0; + } - if (x) + // joy_get_scaled_reading will return a value represents the joystick + // pos from -1 to +1 + if (x && joystick.num_axes > 0) { + *x = joy_get_scaled_reading(0); Joy_last_x_reading = *x; + } - if (y) + if (y && joystick.num_axes > 1) { + *y = joy_get_scaled_reading(1); Joy_last_y_reading = *y; - - return 1; -} -/* -void joy_process(int time_delta) -{ - int i; - - if (!Joy_inited) - return; - if (sdljoy == NULL) - return; - - int buttons = SDL_JoystickNumButtons(sdljoy); - int hat = SDL_JoystickGetHat(sdljoy, 0); - - for (i=0; i < JOY_TOTAL_BUTTONS; i++) { - int state = 0; - - if (i < JOY_NUM_BUTTONS) { - if (i < buttons) { - state = SDL_JoystickGetButton(sdljoy, i); - } - } else { - switch (i) { - case JOY_HATBACK: - state = (hat & SDL_HAT_DOWN) ? 1 : 0; - break; - case JOY_HATFORWARD: - state = (hat & SDL_HAT_UP) ? 1 : 0; - break; - case JOY_HATLEFT: - state = (hat & SDL_HAT_LEFT) ? 1 : 0; - break; - case JOY_HATRIGHT: - state = (hat & SDL_HAT_RIGHT) ? 1 : 0; - break; - default: - break; - } - } - - if (state != joy_buttons[i].actual_state) { - // Button position physically changed. - joy_buttons[i].actual_state = state; - - if ( state ) { - // went from up to down - joy_buttons[i].down_count++; - joy_buttons[i].down_time = 0; - - joy_buttons[i].state = 1; - } else { - // went from down to up - if ( joy_buttons[i].state ) { - joy_buttons[i].up_count++; - } - - joy_buttons[i].state = 0; - } - } else { - // Didn't move... increment time down if down. - if (joy_buttons[i].state) { - //joy_buttons[i].down_time += joy_pollrate; - joy_buttons[i].down_time += time_delta; - } - } } -} -void joy_read() -{ - static Uint32 lasttic = 0; - Uint32 curtic = SDL_GetTicks(); - Uint32 delta = curtic - lasttic; - - while (delta >= (uint)joy_pollrate) { - joy_process(delta); + if (z && joystick.num_axes > 2) { + *z = joy_get_unscaled_reading(2); + } - lasttic += joy_pollrate; + if (rx && joystick.num_axes > 3) { + *rx = joy_get_scaled_reading(3); + } - delta = curtic - lasttic; - } + return 1; } -*/ int joy_init() { - int i, n; + int i, num_sticks; if (Joy_inited) { return 0; @@ -441,16 +393,16 @@ int joy_init() return 0; } - n = SDL_NumJoysticks(); + num_sticks = SDL_NumJoysticks(); - if (n < 1) { + if (num_sticks < 1) { mprintf(("No joysticks found\n")); return 0; } Cur_joystick = os_config_read_uint (NULL, "CurrentJoystick", 0); - if (Cur_joystick >= n) { + if (Cur_joystick >= num_sticks) { Cur_joystick = 0; } @@ -463,43 +415,54 @@ int joy_init() return 0; } - joy_flush (); + Joy_inited = 1; + + joy_id = SDL_JoystickInstanceID(sdljoy); + + joystick.num_axes = SDL_JoystickNumAxes(sdljoy); - joy_num_sticks = n; + joy_flush(); // Fake a calibration - if (joy_num_sticks > 0) { - // joy_set_cen(); - for (i = 0; i < JOY_NUM_AXES; i++) { - joystick.axis_center[i] = 32768; - joystick.axis_min[i] = 0; - joystick.axis_max[i] = 65536; - } + joy_set_cen(); + + for (i = 0; i < JOY_NUM_AXES; i++) { + joystick.axis_min[i] = 0; + joystick.axis_max[i] = 65536; + joystick.axis_current[i] = 32768; } - Joy_inited = 1; + joy_ff_init(); - return joy_num_sticks; + return num_sticks; } void joy_set_cen() { - joystick_read_raw_axis( 2, joystick.axis_center ); + if ( !Joy_inited ) { + return; + } + + for (int i = 0; i < JOY_NUM_AXES; i++) { + // if (i < joystick.num_axes) { + // joystick.axis_center[i] = SDL_JoystickGetAxis(sdljoy, i) + 32768; + // } else { + joystick.axis_center[i] = 32768; + // } + } } int joystick_read_raw_axis(int num_axes, int *axis) { int i; - int num; - if (sdljoy == NULL) + if ( !Joy_inited ) { return 0; - - num = SDL_JoystickNumAxes(sdljoy); + } for (i = 0; i < num_axes; i++) { - if (i < num) { - axis[i] = SDL_JoystickGetAxis(sdljoy, i) + 32768; + if (i < joystick.num_axes) { + axis[i] = joystick.axis_current[i]; } else { axis[i] = 32768; } @@ -508,72 +471,56 @@ int joystick_read_raw_axis(int num_axes, int *axis) return 1; } -void joy_ff_adjust_handling(int speed) +bool joy_axis_valid(int axis) { -// STUB_FUNCTION; + return (axis < joystick.num_axes); } -void joy_ff_afterburn_off() +void joystick_update_axis(int axis, int value) { -// STUB_FUNCTION; -} - -void joy_ff_afterburn_on() -{ -// STUB_FUNCTION; -} - -void joy_ff_deathroll() -{ -// STUB_FUNCTION; + if (axis < JOY_NUM_AXES) { + joystick.axis_current[axis] = value + 32768; + } } -void joy_ff_docked() +DCF(joytest, "Test joystick") { -// STUB_FUNCTION; -} + if (Dc_command) { + while (!key_pressed(SDLK_ESCAPE)) { + int x, y, axis[JOY_NUM_AXES]; -void joy_ff_explode() -{ -// STUB_FUNCTION; -} + if ( !Joy_inited ) + return; -void joy_ff_fly_by(int mag) -{ -// STUB_FUNCTION; -} + joystick_read_raw_axis(JOY_NUM_AXES, axis); -void joy_ff_mission_init(vector v) -{ -// STUB_FUNCTION; -} + x = joy_get_scaled_reading(0); + y = joy_get_scaled_reading(1); -void joy_ff_play_dir_effect(float x, float y) -{ -// STUB_FUNCTION; + mprintf(("X=%5d Y=%5d Calibrated X=%6d Y=%6d\n", axis[0], axis[1], x, y)); + Sleep(100); + } + } } -void joy_ff_play_primary_shoot(int gain) +DCF(joytest2, "Test joystick (extended)") { -// STUB_FUNCTION; -} + if (Dc_command) { + while (!key_pressed(SDLK_ESCAPE)) { + int x, y, z, r, axis[JOY_NUM_AXES]; -void joy_ff_play_reload_effect() -{ -// STUB_FUNCTION; -} + if ( !Joy_inited ) + return; -void joy_ff_play_secondary_shoot(int gain) -{ -// STUB_FUNCTION; -} + joystick_read_raw_axis(JOY_NUM_AXES, axis); -void joy_ff_play_vector_effect(vector *v, float scaler) -{ -// STUB_FUNCTION; -} + x = joy_get_scaled_reading(0); + y = joy_get_scaled_reading(1); + z = joy_get_unscaled_reading(2); + r = joy_get_scaled_reading(3); -void joy_ff_stop_effects() -{ - joy_ff_afterburn_off(); + mprintf(("X=%5d Y=%5d Z=%5d Rx=%5d Ry=%5d Rz=%5d Cal X=%6d Y=%6d Z=%6d R=%6d\n", axis[0], axis[1], axis[2], axis[3], axis[4], axis[5], x, y, z, r)); + Sleep(100); + } + } } diff --git a/src/io/joy_ff-sdl.cpp b/src/io/joy_ff-sdl.cpp new file mode 100644 index 0000000..f7326b8 --- /dev/null +++ b/src/io/joy_ff-sdl.cpp @@ -0,0 +1,897 @@ +/* + * Copyright (C) Volition, Inc. 1999. All rights reserved. + * + * All source code herein is the property of Volition, Inc. You may not sell + * or otherwise commercially exploit the source or things you created based on the + * source. + * +*/ + + +#include "pstypes.h" +#include "vecmat.h" +#include "osregistry.h" +#include "joy_ff.h" +#include "osapi.h" + + +static int Joy_ff_enabled = 0; +static SDL_Haptic *haptic = NULL; +static int joy_ff_handling_scaler = 0; +static int Joy_ff_directional_hit_effect_enabled = 1; +static int Joy_rumble = 0; + +typedef struct { + SDL_HapticEffect eff; + int id; + int loaded; +} haptic_effect_t; + +static haptic_effect_t pHitEffect1; +static haptic_effect_t pHitEffect2; +static haptic_effect_t pAfterburn1; +static haptic_effect_t pAfterburn2; +static haptic_effect_t pShootEffect; +static haptic_effect_t pSecShootEffect; +static haptic_effect_t pSpring; +static haptic_effect_t pDock; +//static haptic_effect_t pDeathroll1; +//static haptic_effect_t pDeathroll2; +//static haptic_effect_t pExplode; + +static void joy_ff_create_effects(); +static int joy_ff_effect_playing(haptic_effect_t *eff); +static void joy_ff_start_effect(haptic_effect_t *eff, const char *name); + +extern SDL_Joystick *sdljoy; + + +int joy_ff_init() +{ + int ff_enabled = 0; + + ff_enabled = os_config_read_uint(NULL, "EnableJoystickFF", 1); + + if ( !ff_enabled ) { + return 0; + } + +// mprintf(("Initializing Haptic...\n")); + + if (SDL_InitSubSystem(SDL_INIT_HAPTIC) < 0) { + return -1; + } + + if ( !SDL_JoystickIsHaptic(sdljoy) ) { + SDL_QuitSubSystem(SDL_INIT_HAPTIC); + return -1; + } + + haptic = SDL_HapticOpenFromJoystick(sdljoy); + + if (haptic == NULL) { + mprintf(("ERROR: Unable to open haptic joystick\n")); + SDL_QuitSubSystem(SDL_INIT_HAPTIC); + return -1; + } + + if ( SDL_HapticRumbleSupported(haptic) ) { + SDL_HapticRumbleInit(haptic); + Joy_rumble = 1; + } + + mprintf(("Haptic device:\n")); + mprintf((" Rumble: %s\n", Joy_rumble ? "Yes" : "No")); + mprintf((" Axes: %d\n", SDL_HapticNumAxes(haptic))); + mprintf((" Max effects: %d\n", SDL_HapticNumEffects(haptic))); + mprintf((" Simultaneous effects: %d\n", SDL_HapticNumEffectsPlaying(haptic))); + + joy_ff_create_effects(); + + mprintf(("\n")); + + Joy_ff_enabled = 1; + + Joy_ff_directional_hit_effect_enabled = os_config_read_uint(NULL, "EnableHitEffect", 1); + + return 0; +} + +void joy_ff_shutdown() +{ + if ( !Joy_ff_enabled ) { + return; + } + + Joy_rumble = 0; + + SDL_HapticClose(haptic); + haptic = NULL; + + SDL_QuitSubSystem(SDL_INIT_HAPTIC); + + Joy_ff_enabled = 0; +} + +static void joy_ff_create_effects() +{ + // clear all SDL errors + SDL_ClearError(); + + unsigned int supported = 0; + + supported = SDL_HapticQuery(haptic); + + if ( !(supported & SDL_HAPTIC_CONSTANT) ) { + mprintf((" Constant Force: not supported\n")); + } + + if ( !(supported & SDL_HAPTIC_SINE) ) { + mprintf((" Sine Wave: not supported\n")); + Warning(LOCATION, "Sine Wave: not supported"); + } + + if ( !(supported & SDL_HAPTIC_SAWTOOTHDOWN) ) { + mprintf((" Sawtooth Down: not supported\n")); + } + + if ( !(supported & SDL_HAPTIC_SPRING) ) { + mprintf((" Spring: not supported\n")); + // Error(LOCATION, "Spring: not supported"); + } +/* + if ( !(supported & SDL_HAPTIC_SQUARE) ) { + mprintf((" Square: not supported\n")); + } +*/ + if ( !(supported & SDL_HAPTIC_TRIANGLE) ) { + mprintf((" Triangle: not supported\n")); + } + + + if (supported & SDL_HAPTIC_CONSTANT) { + // pHitEffect1 + memset(&pHitEffect1, 0, sizeof(haptic_effect_t)); + + pHitEffect1.eff.type = SDL_HAPTIC_CONSTANT; + pHitEffect1.eff.constant.direction.type = SDL_HAPTIC_POLAR; + pHitEffect1.eff.constant.direction.dir[0] = 0; + pHitEffect1.eff.constant.length = 300; + pHitEffect1.eff.constant.level = 0x7FFF; + pHitEffect1.eff.constant.attack_length = 0; + pHitEffect1.eff.constant.attack_level = 0x7FFF; + pHitEffect1.eff.constant.fade_length = 120; + pHitEffect1.eff.constant.fade_level = 1; + + pHitEffect1.id = SDL_HapticNewEffect(haptic, &pHitEffect1.eff); + + if (pHitEffect1.id < 0) { + mprintf((" Hit effect 1 failed to load:\n %s\n", SDL_GetError())); + } else { + pHitEffect1.loaded = 1; + } + } + + if (supported & SDL_HAPTIC_SINE) { + // pHitEffect2 + memset(&pHitEffect2, 0, sizeof(haptic_effect_t)); + + pHitEffect2.eff.type = SDL_HAPTIC_SINE; + pHitEffect2.eff.periodic.direction.type = SDL_HAPTIC_POLAR; + pHitEffect2.eff.periodic.direction.dir[0] = 9000; + pHitEffect2.eff.periodic.length = 300; + pHitEffect2.eff.periodic.period = 100; + pHitEffect2.eff.periodic.magnitude = 0x7FFF; + pHitEffect2.eff.periodic.attack_length = 100; + pHitEffect2.eff.periodic.fade_length = 100; + + pHitEffect2.id = SDL_HapticNewEffect(haptic, &pHitEffect2.eff); + + if (pHitEffect2.id < 0) { + mprintf((" Hit effect 2 failed to load:\n %s\n", SDL_GetError())); + } else { + pHitEffect2.loaded = 1; + } + } + + if (supported & SDL_HAPTIC_SAWTOOTHDOWN) { + // pShootEffect + memset(&pShootEffect, 0, sizeof(haptic_effect_t)); + + pShootEffect.eff.type = SDL_HAPTIC_SAWTOOTHDOWN; + pShootEffect.eff.periodic.direction.type = SDL_HAPTIC_POLAR; + pShootEffect.eff.periodic.direction.dir[0] = 0; + pShootEffect.eff.periodic.length = 160; + pShootEffect.eff.periodic.period = 20; + pShootEffect.eff.periodic.magnitude = 0x7FFF; + pShootEffect.eff.periodic.fade_length = 120; + + pShootEffect.id = SDL_HapticNewEffect(haptic, &pShootEffect.eff); + + if (pShootEffect.id < 0) { + mprintf((" Fire primary effect failed to load:\n %s\n", SDL_GetError())); + } else { + pShootEffect.loaded = 1; + } + } + + if (supported & SDL_HAPTIC_CONSTANT) { + // pSecShootEffect + memset(&pSecShootEffect, 0, sizeof(haptic_effect_t)); + + pSecShootEffect.eff.type = SDL_HAPTIC_CONSTANT; + pSecShootEffect.eff.constant.direction.type = SDL_HAPTIC_POLAR; + pSecShootEffect.eff.constant.direction.dir[0] = 0; + pSecShootEffect.eff.constant.length = 200; + pSecShootEffect.eff.constant.level = 0x7FFF; + pSecShootEffect.eff.constant.attack_length = 50; + pSecShootEffect.eff.constant.attack_level = 0x7FFF; + pSecShootEffect.eff.constant.fade_length = 100; + pSecShootEffect.eff.constant.fade_level = 1; + + pSecShootEffect.id = SDL_HapticNewEffect(haptic, &pSecShootEffect.eff); + + if (pSecShootEffect.id < 0) { + mprintf((" Fire secondary effect failed to load:\n %s\n", SDL_GetError())); + } else { + pSecShootEffect.loaded = 1; + } + } + + if (supported & SDL_HAPTIC_SPRING) { + // pSpring + memset(&pSpring, 0, sizeof(haptic_effect_t)); + + pSpring.eff.type = SDL_HAPTIC_SPRING; + pSpring.eff.condition.length = SDL_HAPTIC_INFINITY; + + for (int i = 0; i < SDL_HapticNumAxes(haptic); i++) { + pSpring.eff.condition.right_sat[i] = 0x7FFF; + pSpring.eff.condition.left_sat[i] = 0x7FFF; + pSpring.eff.condition.right_coeff[i] = 0x147; + pSpring.eff.condition.left_coeff[i] = 0x147; + } + + pSpring.id = SDL_HapticNewEffect(haptic, &pSpring.eff); + + if (pSpring.id < 0) { + mprintf((" Spring effect failed to load:\n %s\n", SDL_GetError())); + } else { + pSpring.loaded = 1; + joy_ff_start_effect(&pSpring, "Spring"); + } + } + + if (supported & SDL_HAPTIC_SINE) { + // pAfterburn1 + memset(&pAfterburn1, 0, sizeof(haptic_effect_t)); + + pAfterburn1.eff.type = SDL_HAPTIC_SINE; + pAfterburn1.eff.periodic.direction.type = SDL_HAPTIC_POLAR; + pAfterburn1.eff.periodic.direction.dir[0] = 0; + pAfterburn1.eff.periodic.length = SDL_HAPTIC_INFINITY; + pAfterburn1.eff.periodic.period = 20; + pAfterburn1.eff.periodic.magnitude = 0x6665; + + pAfterburn1.id = SDL_HapticNewEffect(haptic, &pAfterburn1.eff); + + if (pAfterburn1.id < 0) { + mprintf((" Afterburn effect 1 failed to load:\n %s\n", SDL_GetError())); + } else { + pAfterburn1.loaded = 1; + } + + // pAfterburn2 + memset(&pAfterburn2, 0, sizeof(haptic_effect_t)); + + pAfterburn2.eff.type = SDL_HAPTIC_SINE; + pAfterburn2.eff.periodic.direction.type = SDL_HAPTIC_POLAR; + pAfterburn2.eff.periodic.direction.dir[0] = 9000; + pAfterburn2.eff.periodic.length = 125; + pAfterburn2.eff.periodic.period = 100; + pAfterburn2.eff.periodic.magnitude = 0x3332; + + pAfterburn2.id = SDL_HapticNewEffect(haptic, &pAfterburn2.eff); + + if (pAfterburn2.id < 0) { + mprintf((" Afterburn effect 2 failed to load:\n %s\n", SDL_GetError())); + } else { + pAfterburn2.loaded = 1; + } + } + + +// if (supported & SDL_HAPTIC_SQUARE) { + if (supported & SDL_HAPTIC_TRIANGLE) { + // pDock + memset(&pDock, 0, sizeof(haptic_effect_t)); + + // pDock.eff.type = SDL_HAPTIC_SQUARE; + pDock.eff.type = SDL_HAPTIC_TRIANGLE; + pDock.eff.periodic.direction.type = SDL_HAPTIC_POLAR; + pDock.eff.periodic.direction.dir[0] = 9000; + pDock.eff.periodic.length = 125; + pDock.eff.periodic.period = 100; + pDock.eff.periodic.magnitude = 0x3332; + + pDock.id = SDL_HapticNewEffect(haptic, &pDock.eff); + + if (pDock.id < 0) { + mprintf((" Dock effect failed to load:\n %s\n", SDL_GetError())); + } else { + pDock.loaded = 1; + } + } + +/* + if (supported & SDL_HAPTIC_SAWTOOTHDOWN) { + // pExplode + memset(&pExplode, 0, sizeof(haptic_effect_t)); + + pExplode.eff.type = SDL_HAPTIC_SAWTOOTHDOWN; + pExplode.eff.periodic.direction.type = SDL_HAPTIC_POLAR; + pExplode.eff.periodic.direction.dir[0] = 9000; + pExplode.eff.periodic.length = 500; + pExplode.eff.periodic.period = 20; + pExplode.eff.periodic.magnitude = 0x7FFF; + pExplode.eff.periodic.attack_length = 0; + pExplode.eff.periodic.fade_length = 500; + + pExplode.id = SDL_HapticNewEffect(haptic, &pExplode.eff); + + if (pExplode.id < 0) { + mprintf((" Explosion effect failed to load:\n %s\n", SDL_GetError())); + } else { + pExplode.loaded = 1; + } + } + + if (supported & SDL_HAPTIC_SINE) { + // pDeathroll1 + memset(&pDeathroll1, 0, sizeof(haptic_effect_t)); + + pDeathroll1.eff.type = SDL_HAPTIC_SINE; + pDeathroll1.eff.periodic.direction.type = SDL_HAPTIC_POLAR; + pDeathroll1.eff.periodic.direction.dir[0] = 0; + pDeathroll1.eff.periodic.length = SDL_HAPTIC_INFINITY; + pDeathroll1.eff.periodic.period = 200; + pDeathroll1.eff.periodic.magnitude = 0x7FFF; + pDeathroll1.eff.periodic.attack_length = 200; + + pDeathroll1.id = SDL_HapticNewEffect(haptic, &pDeathroll1.eff); + + if (pDeathroll1.id < 0) { + mprintf((" Deathroll effect 1 failed to load:\n %s\n", SDL_GetError())); + } else { + pDeathroll1.loaded = 1; + } + + // pDeathroll2 + memset(&pDeathroll2, 0, sizeof(haptic_effect_t)); + + pDeathroll2.eff.type = SDL_HAPTIC_SINE; + pDeathroll2.eff.periodic.direction.type = SDL_HAPTIC_POLAR; + pDeathroll2.eff.periodic.direction.dir[0] = 9000; + pDeathroll2.eff.periodic.length = SDL_HAPTIC_INFINITY; + pDeathroll2.eff.periodic.period = 200; + pDeathroll2.eff.periodic.magnitude = 0x7FFF; + pDeathroll2.eff.periodic.attack_length = 200; + + pDeathroll2.id = SDL_HapticNewEffect(haptic, &pDeathroll2.eff); + + if (pDeathroll2.id < 0) { + mprintf((" Deathroll effect 2 failed to load:\n %s\n", SDL_GetError())); + } else { + pDeathroll2.loaded = 1; + } + } +*/ +} + +static void joy_ff_start_effect(haptic_effect_t *eff, const char *name) +{ + if ( !eff->loaded ) { + return; + } + +// nprintf(("Joystick", "FF: Starting effect %s\n", name)); + + if ( SDL_HapticRunEffect(haptic, eff->id, 1) ) { + mprintf(("HapticERROR: Unable to run %s:\n %s\n", name, SDL_GetError())); + } +} + +void joy_ff_stop_effects() +{ + SDL_HapticStopAll(haptic); +} + +void joy_ff_mission_init(vector v) +{ + v.xyz.z = 0.0f; + + joy_ff_handling_scaler = (int) ((vm_vec_mag(&v) + 1.3f) * 5.0f); +} + +void joy_reacquire_ff() +{ +} + +void joy_unacquire_ff() +{ +} + +void joy_ff_play_vector_effect(vector *v, float scaler) +{ + vector vf; + float x, y; + +// nprintf(("Joystick", "FF: vec = { %f, %f, %f } s = %f\n", v->xyz.x, v->xyz.y, v->xyz.z, scaler)); + vm_vec_copy_scale(&vf, v, scaler); + x = vf.xyz.x; + vf.xyz.x = 0.0f; + + if (vf.xyz.y + vf.xyz.z < 0.0f) { + y = -vm_vec_mag(&vf); + } else { + y = vm_vec_mag(&vf); + } + + joy_ff_play_dir_effect(-x, -y); +} + +void joy_ff_play_dir_effect(float x, float y) +{ + int idegs, imag; + float degs; + + if ( !Joy_ff_enabled ) { + return; + } + + // allow for at least one of the effects to work + if ( !pHitEffect1.loaded && !pHitEffect2.loaded ) { + return; + } + + if (joy_ff_effect_playing(&pHitEffect1) || joy_ff_effect_playing(&pHitEffect2)) { + nprintf(("Joystick", "FF: HitEffect already playing. Skipping\n")); + return; + } + + if (Joy_ff_directional_hit_effect_enabled) { + if (x > 8000.0f) { + x = 8000.0f; + } else if (x < -8000.0f) { + x = -8000.0f; + } + + if (y > 8000.0f) { + y = 8000.0f; + } else if (y < -8000.0f) { + y = -8000.0f; + } + + imag = (int) fl_sqrt(x * x + y * y); + if (imag > 10000) { + imag = 10000; + } + + degs = (float)atan2(x, y); + idegs = (int) (degs * 18000.0f / PI) + 90; + while (idegs < 0) { + idegs += 36000; + } + + while (idegs >= 36000) { + idegs -= 36000; + } + + if (pHitEffect1.loaded) { + pHitEffect1.eff.constant.direction.dir[0] = idegs; + pHitEffect1.eff.constant.level = fl2i(0x7FFF * (imag / 10000.0f)); + + if ( SDL_HapticUpdateEffect(haptic, pHitEffect1.id, &pHitEffect1.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pHitEffect1:\n %s\n", SDL_GetError())); + } + } + + idegs += 9000; + if (idegs >= 36000) + idegs -= 36000; + + if (pHitEffect2.loaded) { + pHitEffect2.eff.periodic.direction.dir[0] = idegs; + pHitEffect2.eff.periodic.magnitude = fl2i(0x7FFF * (imag / 10000.0f)); + + if ( SDL_HapticUpdateEffect(haptic, pHitEffect2.id, &pHitEffect2.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pHitEffect2:\n %s\n", SDL_GetError())); + } + } + } + + joy_ff_start_effect(&pHitEffect1, "HitEffect1"); + joy_ff_start_effect(&pHitEffect2, "HitEffect2"); +} + +static int primary_ff_level = 10000; + +void joy_ff_play_primary_shoot(int gain) +{ + if ( !Joy_ff_enabled ) { + return; + } + + if ( !pShootEffect.loaded && !Joy_rumble ) { + return; + } + + if (gain < 1) { + gain = 1; + } else if (gain > 10000) { + gain = 10000; + } + + if (pShootEffect.loaded) { + SDL_HapticStopEffect(haptic, pShootEffect.id); + + if (gain != primary_ff_level) { + pShootEffect.eff.periodic.direction.dir[0] = 0; + pShootEffect.eff.periodic.length = 160; + pShootEffect.eff.periodic.magnitude = fl2i(0x7FFF * (gain / 10000.0f)); + pShootEffect.eff.periodic.fade_length = 120; + + if ( SDL_HapticUpdateEffect(haptic, pShootEffect.id, &pShootEffect.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pShootEffect:\n %s\n", SDL_GetError())); + } + + primary_ff_level = gain; + } + + joy_ff_start_effect(&pShootEffect, "ShootEffect"); + } else if (Joy_rumble) { + SDL_HapticRumblePlay(haptic, (gain / 10000.0f) * 0.5f, 100); + } +} + +static int secondary_ff_level = 10000; + +void joy_ff_play_secondary_shoot(int gain) +{ + if ( !Joy_ff_enabled ) { + return; + } + + if ( !pSecShootEffect.loaded && !Joy_rumble ) { + return; + } + + gain = gain * 100 + 2500; + + if (gain < 1) { + gain = 1; + } else if (gain > 10000) { + gain = 10000; + } + + if (pSecShootEffect.loaded) { + SDL_HapticStopEffect(haptic, pSecShootEffect.id); + + if (gain != secondary_ff_level) { + pSecShootEffect.eff.constant.level = fl2i(0x7FFF * (gain / 10000.0f)); + pSecShootEffect.eff.constant.length = (150000 + gain * 25) / 1000; + + if ( SDL_HapticUpdateEffect(haptic, pSecShootEffect.id, &pSecShootEffect.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pSecShootEffect:\n %s\n", SDL_GetError())); + } + + secondary_ff_level = gain; + nprintf(("Joystick", "FF: Secondary force = 0x%04x\n", pSecShootEffect.eff.constant.level)); + } + + joy_ff_start_effect(&pSecShootEffect, "SecShootEffect"); + } else if (Joy_rumble) { + SDL_HapticRumblePlay(haptic, (gain / 10000.0f) * 0.5f, (150000 + gain * 25) / 1000); + } +} + +void joy_ff_adjust_handling(int speed) +{ + int v; + short coeff = 0; + + if ( !Joy_ff_enabled ) { + return; + } + + if ( !pSpring.loaded ) { + return; + } + + v = speed * joy_ff_handling_scaler * 2 / 3; +// v += joy_ff_handling_scaler * joy_ff_handling_scaler * 6 / 7 + 250; + v += joy_ff_handling_scaler * 45 - 500; + + if (v < 0) { + v = 0; + } else if (v > 10000) { + v = 10000; + } + + coeff = fl2i(0x7FFF * (v / 10000.0f)); + + for (int i = 0; i < SDL_HapticNumAxes(haptic); i++) { + pSpring.eff.condition.right_coeff[i] = coeff; + pSpring.eff.condition.left_coeff[i] = coeff; + } + +// nprintf(("Joystick", "FF: New handling force = 0x%04x\n", coeff)); + + SDL_HapticUpdateEffect(haptic, pSpring.id, &pSpring.eff); +} + +static int joy_ff_effect_playing(haptic_effect_t *eff) +{ + if ( !eff->loaded ) { + return 0; + } else { + return (SDL_HapticGetEffectStatus(haptic, eff->id) > 0); + } +} + +void joy_ff_docked() +{ + if ( !Joy_ff_enabled ) { + return; + } + + if ( !pDock.loaded ) { + return; + } + + SDL_HapticStopEffect(haptic, pDock.id); + + pDock.eff.periodic.magnitude = 0x7fff; + + if ( SDL_HapticUpdateEffect(haptic, pDock.id, &pDock.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pDock:\n %s\n", SDL_GetError())); + } + + joy_ff_start_effect(&pDock, "Dock"); +} + +void joy_ff_play_reload_effect() +{ + if ( !Joy_ff_enabled ) { + return; + } + + if ( !pDock.loaded ) { + return; + } + + SDL_HapticStopEffect(haptic, pDock.id); + + pDock.eff.periodic.magnitude = 0x3fff; + + if ( SDL_HapticUpdateEffect(haptic, pDock.id, &pDock.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pDock:\n %s\n", SDL_GetError())); + } + + joy_ff_start_effect(&pDock, "Dock (Reload)"); +} + +static int Joy_ff_afterburning = 0; + +void joy_ff_afterburn_on() +{ + if ( !Joy_ff_enabled ) { + return; + } + + if (Joy_ff_afterburning) { + return; + } + + if ( !(pAfterburn1.loaded && pAfterburn2.loaded) ) { + return; + } + + SDL_HapticStopEffect(haptic, pAfterburn1.id); + + pAfterburn1.eff.periodic.length = SDL_HAPTIC_INFINITY; + pAfterburn1.eff.periodic.period = 20; + pAfterburn1.eff.periodic.magnitude = 0x3fff; + pAfterburn1.eff.periodic.attack_length = 0; + + if ( SDL_HapticUpdateEffect(haptic, pAfterburn1.id, &pAfterburn1.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pAfterburn1:\n %s\n", SDL_GetError())); + } + + SDL_HapticStopEffect(haptic, pAfterburn2.id); + + pAfterburn2.eff.periodic.length = SDL_HAPTIC_INFINITY; + pAfterburn2.eff.periodic.period = 100; + pAfterburn2.eff.periodic.magnitude = 0x3fff; + pAfterburn2.eff.periodic.attack_length = 0; + + if ( SDL_HapticUpdateEffect(haptic, pAfterburn2.id, &pAfterburn2.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pAfterburn2:\n %s\n", SDL_GetError())); + } + + joy_ff_start_effect(&pAfterburn1, "Afterburn1"); + joy_ff_start_effect(&pAfterburn2, "Afterburn2"); + +// nprintf(("Joystick", "FF: Afterburn started\n")); + + Joy_ff_afterburning = 1; +} + +void joy_ff_afterburn_off() +{ + if ( !Joy_ff_enabled ) { + return; + } + + if ( !Joy_ff_afterburning ) { + return; + } + + if (pAfterburn1.loaded) { + SDL_HapticStopEffect(haptic, pAfterburn1.id); + } + + if (pAfterburn2.loaded) { + SDL_HapticStopEffect(haptic, pAfterburn2.id); + } + + Joy_ff_afterburning = 0; + +// nprintf(("Joystick", "FF: Afterburn stopped\n")); +} + +void joy_ff_explode() +{ + if ( !Joy_ff_enabled ) { + return; + } +/* + if (pDeathroll1.loaded) { + SDL_HapticStopEffect(haptic, pDeathroll1.id); + } + + if (pDeathroll2.loaded) { + SDL_HapticStopEffect(haptic, pDeathroll2.id); + } + + if (pExplode.loaded) { + SDL_HapticStopEffect(haptic, pExplode.id); + } + + joy_ff_start_effect(&pExplode, "Explode"); +*/ + + if (pAfterburn1.loaded) { + SDL_HapticStopEffect(haptic, pAfterburn1.id); + } + + if (pAfterburn2.loaded) { + SDL_HapticStopEffect(haptic, pAfterburn2.id); + } + + if (pShootEffect.loaded) { + SDL_HapticStopEffect(haptic, pShootEffect.id); + + pShootEffect.eff.periodic.direction.dir[0] = 9000; + pShootEffect.eff.periodic.length = 500; + pShootEffect.eff.periodic.magnitude = 0x7FFF; + pShootEffect.eff.periodic.fade_length = 500; + + if ( SDL_HapticUpdateEffect(haptic, pShootEffect.id, &pShootEffect.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pShootEffect:\n %s\n", SDL_GetError())); + } + + joy_ff_start_effect(&pShootEffect, "ShootEffect (Explode)"); + } + + Joy_ff_afterburning = 0; +} + +void joy_ff_fly_by(int mag) +{ + int gain; + + if ( !Joy_ff_enabled ) { + return; + } + + if (Joy_ff_afterburning) { + return; + } + + if ( !(pAfterburn1.loaded && pAfterburn2.loaded) ) { + return; + } + + gain = mag * 120 + 4000; + + if (gain < 1) { + gain = 1; + } else if (gain > 10000) { + gain = 10000; + } + + SDL_HapticStopEffect(haptic, pAfterburn1.id); + + pAfterburn1.eff.periodic.length = (6000 * mag + 400000) / 1000; + pAfterburn1.eff.periodic.period = 20; + pAfterburn1.eff.periodic.magnitude = fl2i(0x7FFF * (gain / 10000.0f)); + pAfterburn1.eff.periodic.attack_length = 0; + + if ( SDL_HapticUpdateEffect(haptic, pAfterburn1.id, &pAfterburn1.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pAfterburn1:\n %s\n", SDL_GetError())); + } + + + SDL_HapticStopEffect(haptic, pAfterburn2.id); + + pAfterburn2.eff.periodic.length = (6000 * mag + 400000) / 1000; + pAfterburn2.eff.periodic.period = 100; + pAfterburn2.eff.periodic.magnitude = fl2i(0x7FFF * (gain / 10000.0f)); + pAfterburn2.eff.periodic.attack_length = 0; + + if ( SDL_HapticUpdateEffect(haptic, pAfterburn2.id, &pAfterburn2.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pAfterburn2:\n %s\n", SDL_GetError())); + } + + joy_ff_start_effect(&pAfterburn1, "Afterburn1 (Fly by)"); + joy_ff_start_effect(&pAfterburn2, "Afterburn2 (Fly by)"); +} + +void joy_ff_deathroll() +{ + if ( !Joy_ff_enabled ) { + return; + } +/* + if (pDeathroll1.loaded) { + SDL_HapticStopEffect(haptic, pDeathroll1.id); + } + + if (pDeathroll2.loaded) { + SDL_HapticStopEffect(haptic, pDeathroll2.id); + } + + joy_ff_start_effect(&pDeathroll1, "Deathroll1"); + joy_ff_start_effect(&pDeathroll2, "Deathroll2"); +*/ + + if (pAfterburn1.loaded && pAfterburn2.loaded) { + SDL_HapticStopEffect(haptic, pAfterburn1.id); + + pAfterburn1.eff.periodic.length = SDL_HAPTIC_INFINITY; + pAfterburn1.eff.periodic.period = 200; + pAfterburn1.eff.periodic.magnitude = 0x7FFF; + pAfterburn1.eff.periodic.attack_length = 200; + + if ( SDL_HapticUpdateEffect(haptic, pAfterburn1.id, &pAfterburn1.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pAfterburn1:\n %s\n", SDL_GetError())); + } + + SDL_HapticStopEffect(haptic, pAfterburn2.id); + + pAfterburn2.eff.periodic.length = SDL_HAPTIC_INFINITY; + pAfterburn2.eff.periodic.period = 200; + pAfterburn2.eff.periodic.magnitude = 0x7FFF; + pAfterburn2.eff.periodic.attack_length = 200; + + if ( SDL_HapticUpdateEffect(haptic, pAfterburn2.id, &pAfterburn2.eff) < 0 ) { + mprintf(("HapticERROR: Unable to update pAfterburn2:\n %s\n", SDL_GetError())); + } + + joy_ff_start_effect(&pAfterburn1, "Afterburn1 (Death Roll)"); + joy_ff_start_effect(&pAfterburn2, "Afterburn2 (Death Roll)"); + + Joy_ff_afterburning = 1; + } +} diff --git a/src/io/key.cpp b/src/io/key.cpp index e0a5579..01590f1 100644 --- a/src/io/key.cpp +++ b/src/io/key.cpp @@ -219,7 +219,7 @@ int Key_normal_game = 0; bool key_pressed(int keycode) { - SDL_Scancode scancode = SDL_GetScancodeFromKey(keycode); + SDL_Scancode scancode = SDL_GetScancodeFromKey(keycode & KEY_MASK); return keyd_pressed[scancode]; } @@ -246,12 +246,27 @@ void key_turn_on_numlock() // Convert a BIOS scancode to ASCII. // If scancode >= 127, returns 255, meaning there is no corresponding ASCII code. // Uses ascii_table and shifted_ascii_table to translate scancode to ASCII. -int key_to_ascii(int keycode) +int key_to_ascii(int keycode, bool force_up) { + int shifted; + + // bail on non-printable keycodes + if (keycode & SDLK_SCANCODE_MASK) { + return 255; + } + + shifted = keycode & KEY_SHIFTED; + keycode &= KEY_MASK; + + // this is definitely never come back to bite me in the ass if ( ((keycode >= SDLK_SPACE) && (keycode <= SDLK_AT)) || ((keycode >= SDLK_LEFTBRACKET) && (keycode <= SDLK_z)) ) { - return keycode; + if ( (keycode >= SDLK_a) && (shifted || force_up) ) { + return toupper(keycode); + } else { + return keycode; + } } return 255; @@ -326,21 +341,24 @@ int key_checkch() // Reads keys out of the key buffer and updates keyhead. int key_inkey() { - SDL_Scancode scancode; + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + int mod, keycode; if ( !key_inited ) return 0; - ENTER_CRITICAL_SECTION(&key_lock); - if (key_data.keytail != key_data.keyhead) { scancode = (SDL_Scancode)key_data.keybuffer[key_data.keyhead]; key_data.keyhead = add_one(key_data.keyhead); + } else { + return 0; } - LEAVE_CRITICAL_SECTION(&key_lock); + // need to strip key mod state for keycode lookup + mod = (scancode & 0xf900); + keycode = SDL_GetKeyFromScancode((SDL_Scancode)(scancode & KEY_MASK)); - return (int)SDL_GetKeyFromScancode(scancode); + return (keycode | mod); } // If not installed, uses BIOS and returns getch(); @@ -367,24 +385,25 @@ uint key_get_shift_status() { unsigned int shift_status = 0; - if ( !key_inited ) return 0; + if ( !key_inited ) + return 0; - ENTER_CRITICAL_SECTION(&key_lock); + SDL_Keymod kmod = SDL_GetModState(); - if ( keyd_pressed[SDL_SCANCODE_LSHIFT] || keyd_pressed[SDL_SCANCODE_RSHIFT] ) + if (kmod & KMOD_SHIFT) shift_status |= KEY_SHIFTED; - if ( keyd_pressed[SDL_SCANCODE_LALT] || keyd_pressed[SDL_SCANCODE_RALT] ) + if (kmod & KMOD_ALT) shift_status |= KEY_ALTED; - if ( keyd_pressed[SDL_SCANCODE_LCTRL] || keyd_pressed[SDL_SCANCODE_RCTRL] ) + if (kmod & KMOD_CTRL) shift_status |= KEY_CTRLED; #ifndef NDEBUG - if (keyd_pressed[KEY_DEBUG_KEY]) + if (key_pressed(KEY_DEBUG_KEY)) shift_status |= KEY_DEBUGGED; #else - if (keyd_pressed[KEY_DEBUG_KEY]) { + if (key_pressed(KEY_DEBUG_KEY)) { mprintf(("Cheats_enabled = %i, Key_normal_game = %i\n", Cheats_enabled, Key_normal_game)); if ((Cheats_enabled) && Key_normal_game) { mprintf(("Debug key\n")); @@ -392,7 +411,6 @@ uint key_get_shift_status() } } #endif - LEAVE_CRITICAL_SECTION(&key_lock); return shift_status; } @@ -408,7 +426,7 @@ float key_down_timef(int keycode) if ( !key_inited ) return 0.0f; - scancode = SDL_GetScancodeFromKey(keycode); + scancode = SDL_GetScancodeFromKey(keycode & KEY_MASK); if (scancode == SDL_SCANCODE_UNKNOWN) return 0.0f; @@ -452,7 +470,7 @@ int key_down_count(int keycode) if ( !key_inited ) return 0; - scancode = SDL_GetScancodeFromKey(keycode); + scancode = SDL_GetScancodeFromKey(keycode & KEY_MASK); if (scancode == SDL_SCANCODE_UNKNOWN) return 0; @@ -477,7 +495,7 @@ int key_up_count(int keycode) if ( !key_inited ) return 0; - scancode = SDL_GetScancodeFromKey(keycode); + scancode = SDL_GetScancodeFromKey(keycode & KEY_MASK); if (scancode == SDL_SCANCODE_UNKNOWN) return 0; @@ -494,7 +512,7 @@ int key_up_count(int keycode) int key_check(int keycode) { - SDL_Scancode scancode = SDL_GetScancodeFromKey(keycode); + SDL_Scancode scancode = SDL_GetScancodeFromKey(keycode & KEY_MASK); return key_data.down_check[scancode]; } @@ -505,7 +523,7 @@ int key_check(int keycode) void key_mark(SDL_Scancode scancode, int state, ushort kmod, uint latency ) { uint breakbit, temp, event_time; - ushort keycode; + ushort keycode; if ( !key_inited ) return; @@ -557,8 +575,9 @@ void key_mark(SDL_Scancode scancode, int state, ushort kmod, uint latency ) keycode |= KEY_CTRLED; #ifndef NDEBUG - if ( keyd_pressed[KEY_DEBUG_KEY] ) + if ( key_pressed(KEY_DEBUG_KEY) ) keycode |= KEY_DEBUGGED; + // if ( keycode == (KEY_BACKSP + KEY_DEBUGGED) ) { // keycode = 0; // keyd_pressed[KEY_DEBUG_KEY] = 0; @@ -566,7 +585,7 @@ void key_mark(SDL_Scancode scancode, int state, ushort kmod, uint latency ) // Int3(); // } #else - if ( keyd_pressed[KEY_DEBUG_KEY] ) { + if ( keyd_pressed(KEY_DEBUG_KEY) ) { mprintf(("Cheats_enabled = %i, Key_normal_game = %i\n", Cheats_enabled, Key_normal_game)); if (Cheats_enabled && Key_normal_game) { keycode |= KEY_DEBUGGED1; diff --git a/src/lighting/lighting.cpp b/src/lighting/lighting.cpp index 8e01105..ca375fe 100644 --- a/src/lighting/lighting.cpp +++ b/src/lighting/lighting.cpp @@ -406,7 +406,7 @@ void light_add_point( vector * pos, float rad1, float rad2, float intensity, flo if (!Lighting_flag) return; -// if ( keyd_pressed[KEY_LSHIFT] ) return; +// if ( key_pressed(SDLK_LSHIFT) ) return; if ( Num_lights >= MAX_LIGHTS ) { mprintf(( "Out of lights!\n" )); @@ -440,7 +440,7 @@ void light_add_point_unique( vector * pos, float rad1, float rad2, float intensi if (!Lighting_flag) return; -// if ( keyd_pressed[KEY_LSHIFT] ) return; +// if ( key_pressed(SDLK_LSHIFT) ) return; if ( Num_lights >= MAX_LIGHTS ) { mprintf(( "Out of lights!\n" )); @@ -474,7 +474,7 @@ void light_add_tube(vector *p0, vector *p1, float r1, float r2, float intensity, if (!Lighting_flag) return; -// if ( keyd_pressed[KEY_LSHIFT] ) return; +// if ( key_pressed(SDLK_LSHIFT) ) return; if ( Num_lights >= MAX_LIGHTS ) { mprintf(( "Out of lights!\n" )); diff --git a/src/menuui/barracks.cpp b/src/menuui/barracks.cpp index 000de08..1425312 100644 --- a/src/menuui/barracks.cpp +++ b/src/menuui/barracks.cpp @@ -597,17 +597,17 @@ void barracks_init_stats(scoring_struct *stats) // sets or clears hotkeys for pilot selection. void barracks_set_hotkeys(bool pilot_text_enter_mode) { - Buttons[gr_screen.res][B_PILOT_SCROLL_UP_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_UP : -1); - Buttons[gr_screen.res][B_PILOT_SCROLL_DOWN_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_DOWN : -1); + Buttons[gr_screen.res][B_PILOT_SCROLL_UP_BUTTON].button.set_hotkey(pilot_text_enter_mode ? SDLK_UP : -1); + Buttons[gr_screen.res][B_PILOT_SCROLL_DOWN_BUTTON].button.set_hotkey(pilot_text_enter_mode ? SDLK_DOWN : -1); - Buttons[gr_screen.res][B_PILOT_CREATE_BOTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_C : -1); - Buttons[gr_screen.res][B_PILOT_SET_ACTIVE_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_ENTER : -1); - Buttons[gr_screen.res][B_PILOT_DELETE_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_DELETE : -1); + Buttons[gr_screen.res][B_PILOT_CREATE_BOTTON].button.set_hotkey(pilot_text_enter_mode ? SDLK_c : -1); + Buttons[gr_screen.res][B_PILOT_SET_ACTIVE_BUTTON].button.set_hotkey(pilot_text_enter_mode ? SDLK_RETURN : -1); + Buttons[gr_screen.res][B_PILOT_DELETE_BUTTON].button.set_hotkey(pilot_text_enter_mode ? SDLK_DELETE : -1); - Buttons[gr_screen.res][B_PIC_PREV_PILOT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_LEFT : -1); - Buttons[gr_screen.res][B_PIC_NEXT_PILOT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_RIGHT : -1); + Buttons[gr_screen.res][B_PIC_PREV_PILOT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? SDLK_LEFT : -1); + Buttons[gr_screen.res][B_PIC_NEXT_PILOT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? SDLK_RIGHT : -1); - Buttons[gr_screen.res][B_ACCEPT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_CTRLED | KEY_ENTER : -1); + Buttons[gr_screen.res][B_ACCEPT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_CTRLED | SDLK_RETURN : -1); } // strip the possible .pcx extension off a filename @@ -1585,7 +1585,7 @@ void barracks_do_frame(float frametime) Inputbox.set_focus(); switch (k) { - case KEY_ESC: + case SDLK_ESCAPE: // cancel create pilot Num_pilots--; for (i=0; iflags & PLAYER_FLAGS_IS_MULTI) ) { credits_screen_button_pressed(CUTSCENES_BUTTON); break; } // else, react like tab key. - case KEY_CTRLED | KEY_DOWN: - case KEY_TAB: + case KEY_CTRLED | SDLK_DOWN: + case SDLK_TAB: credits_screen_button_pressed(TECH_DATABASE_BUTTON); break; @@ -824,7 +824,7 @@ void credits_do_frame(float frametime) timestamp_inc(Credits_frametime / 1000.0f); float fl_frametime = i2fl(Credits_frametime) / 1000.f; - if (keyd_pressed[KEY_LSHIFT]) { + if (key_pressed(SDLK_LSHIFT)) { Credit_position -= fl_frametime * CREDITS_SCROLL_RATE * 4.0f; } else { Credit_position -= fl_frametime * CREDITS_SCROLL_RATE; diff --git a/src/menuui/mainhallmenu.cpp b/src/menuui/mainhallmenu.cpp index 9cb75ca..7a555bd 100644 --- a/src/menuui/mainhallmenu.cpp +++ b/src/menuui/mainhallmenu.cpp @@ -1044,21 +1044,21 @@ void main_hall_do(float frametime) game_process_cheats(key); } switch(key){ - case KEY_ENTER: + case SDLK_RETURN: snazzy_action = SNAZZY_CLICKED; break; #if 0 //#ifndef NDEBUG - case KEY_1: + case SDLK_1: movie_play("endprt2b.mve", 0); break; - case KEY_2: + case SDLK_2: movie_play_two("endprt2a.mve", "endprt2b.mve", 0); break; - case KEY_3: + case SDLK_3: main_hall_campaign_cheat(); break; - case KEY_DEBUGGED + KEY_D: + case KEY_DEBUGGED + SDLK_d: demo_start_playback("test.fsd"); break; } diff --git a/src/menuui/mainhalltemp.cpp b/src/menuui/mainhalltemp.cpp index e721b5a..35721d8 100644 --- a/src/menuui/mainhalltemp.cpp +++ b/src/menuui/mainhalltemp.cpp @@ -157,15 +157,15 @@ void mht_do() // process any keypresses switch(k){ - case KEY_ESC : + case SDLK_ESCAPE : mht_exit_game(); break; - case KEY_B: + case SDLK_b: gameseq_post_event( GS_EVENT_BARRACKS_MENU ); break; - case KEY_G: + case SDLK_g: if(Player->flags & PLAYER_FLAGS_IS_MULTI){ break; } @@ -181,15 +181,15 @@ void mht_do() gameseq_post_event(GS_EVENT_START_GAME_QUICK); break; - case KEY_L: + case SDLK_l: gameseq_post_event( GS_EVENT_LOAD_MISSION_MENU ); break; - case KEY_F2: + case SDLK_F2: gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; - case KEY_M: + case SDLK_m: if (Player->flags & PLAYER_FLAGS_IS_MULTI){ main_hall_do_multi_ready(); } diff --git a/src/menuui/optionsmenu.cpp b/src/menuui/optionsmenu.cpp index 4b0d175..75a4114 100644 --- a/src/menuui/optionsmenu.cpp +++ b/src/menuui/optionsmenu.cpp @@ -1320,8 +1320,8 @@ void options_menu_init() Detail_bogus.base_create(&Ui_window, UI_KIND_ICON, 0, 0, 0, 0); Options_bogus.base_create(&Ui_window, UI_KIND_ICON, 0, 0, 0, 0); - Buttons[gr_screen.res][GAMMA_DOWN].button.set_hotkey(KEY_COMMA); - Buttons[gr_screen.res][GAMMA_UP].button.set_hotkey(KEY_PERIOD); + Buttons[gr_screen.res][GAMMA_DOWN].button.set_hotkey(SDLK_COMMA); + Buttons[gr_screen.res][GAMMA_UP].button.set_hotkey(SDLK_PERIOD); /* Skill_control.first_frame = bm_load_animation("OPa_11", &Skill_control.total_frames); @@ -1503,8 +1503,8 @@ void options_menu_do_frame(float frametime) Assert(Options_menu_inited); k = Ui_window.process() & ~KEY_DEBUGGED; switch (k) { - case KEY_SHIFTED | KEY_TAB: - case KEY_LEFT: // activate previous tab + case KEY_SHIFTED | SDLK_TAB: + case SDLK_LEFT: // activate previous tab i = Tab - 1; if (i < 0) i = NUM_TABS - 1; @@ -1512,10 +1512,10 @@ void options_menu_do_frame(float frametime) options_change_tab(i); break; - case KEY_TAB: - case KEY_RIGHT: // activate next tab + case SDLK_TAB: + case SDLK_RIGHT: // activate next tab // check to see if the multiplayer options screen wants to eat the tab kay - if ((k == KEY_TAB) && (Tab == MULTIPLAYER_TAB)) { + if ((k == SDLK_TAB) && (Tab == MULTIPLAYER_TAB)) { if (options_multi_eat_tab()) { break; } @@ -1528,7 +1528,7 @@ void options_menu_do_frame(float frametime) options_change_tab(i); break; - case KEY_C: + case SDLK_c: if (Tab == OPTIONS_TAB) { gamesnd_play_iface(SND_SWITCH_SCREENS); gameseq_post_event(GS_EVENT_CONTROL_CONFIG); @@ -1536,7 +1536,7 @@ void options_menu_do_frame(float frametime) break; - case KEY_H: + case SDLK_h: if (Tab == OPTIONS_TAB) { gamesnd_play_iface(SND_SWITCH_SCREENS); gameseq_post_event(GS_EVENT_HUD_CONFIG); @@ -1544,20 +1544,20 @@ void options_menu_do_frame(float frametime) break; - case KEY_ESC: + case SDLK_ESCAPE: // if(Tab != MULTIPLAYER_TAB){ options_cancel_exit(); // } break; - case KEY_CTRLED | KEY_ENTER: + case KEY_CTRLED | SDLK_RETURN: options_accept(); break; - case KEY_DELETE: + case SDLK_DELETE: break; - case KEY_ENTER: + case SDLK_RETURN: break; } diff --git a/src/menuui/optionsmenumulti.cpp b/src/menuui/optionsmenumulti.cpp index 7ed9243..a88e17e 100644 --- a/src/menuui/optionsmenumulti.cpp +++ b/src/menuui/optionsmenumulti.cpp @@ -1145,7 +1145,7 @@ void options_multi_protocol_do(int key) // see if he hit any interesting key presses switch(key){ - case KEY_ENTER: + case SDLK_RETURN: // add a new ip string if we're in "input" mode if(Om_input_mode){ options_multi_protocol_add_current_ip(); @@ -1174,7 +1174,7 @@ void options_multi_protocol_do(int key) } break; - case KEY_ESC: + case SDLK_ESCAPE: // if we're in input mode, cancel out if(Om_input_mode){ // clear the text control and input mode @@ -1189,7 +1189,7 @@ void options_multi_protocol_do(int key) } break; - case KEY_TAB: + case SDLK_TAB: // tab through the tracker input controls if(Om_tracker_login.has_focus()){ Om_tracker_passwd.set_focus(); diff --git a/src/menuui/playermenu.cpp b/src/menuui/playermenu.cpp index 0be3e99..22f1e0d 100644 --- a/src/menuui/playermenu.cpp +++ b/src/menuui/playermenu.cpp @@ -525,10 +525,10 @@ void player_select_init() Player_select_input_mode = 0; // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed - Player_select_buttons[gr_screen.res][SCROLL_LIST_UP_BUTTON].button.set_hotkey(KEY_UP); - Player_select_buttons[gr_screen.res][SCROLL_LIST_DOWN_BUTTON].button.set_hotkey(KEY_DOWN); - Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(KEY_ENTER); - Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button.set_hotkey(KEY_C); + Player_select_buttons[gr_screen.res][SCROLL_LIST_UP_BUTTON].button.set_hotkey(SDLK_UP); + Player_select_buttons[gr_screen.res][SCROLL_LIST_DOWN_BUTTON].button.set_hotkey(SDLK_DOWN); + Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(SDLK_RETURN); + Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button.set_hotkey(SDLK_c); // disable the single player button in the multiplayer beta #ifdef MULTIPLAYER_BETA_BUILD @@ -652,7 +652,7 @@ void player_select_do() } switch(k){ // switch between single and multiplayer modes - case KEY_TAB : + case SDLK_TAB : #if defined(DEMO) || defined(OEM_BUILD) // not for FS2_DEMO break; #else @@ -795,8 +795,8 @@ void player_select_set_input_mode(int n) Player_select_buttons[gr_screen.res][i].button.enable(!n); } - Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(n ? -1 : KEY_ENTER); - Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button.set_hotkey(n ? -1 : KEY_C); + Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(n ? -1 : SDLK_RETURN); + Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button.set_hotkey(n ? -1 : SDLK_c); // enable the player select input box if(Player_select_input_mode){ @@ -1216,16 +1216,16 @@ void player_select_process_noninput(int k) // check for keypresses switch (k) { // quit the game entirely - case KEY_ESC: + case SDLK_ESCAPE: gameseq_post_event(GS_EVENT_QUIT_GAME); break; - case KEY_ENTER | KEY_CTRLED: + case SDLK_RETURN | KEY_CTRLED: player_select_button_pressed(ACCEPT_BUTTON); break; // delete the currently highlighted pilot - case KEY_DELETE: + case SDLK_DELETE: if (Player_select_pilot >= 0) { int ret; @@ -1274,12 +1274,12 @@ void player_select_process_input(int k) // if the player is in the process of typing in a new pilot name... switch (k) { // cancel create pilot - case KEY_ESC: + case SDLK_ESCAPE: player_select_cancel_create(); break; // accept a new pilot name - case KEY_ENTER: + case SDLK_RETURN: Player_select_input_box.get_text(buf); drop_white_space(buf); z = 0; diff --git a/src/menuui/readyroom.cpp b/src/menuui/readyroom.cpp index a1dfe6e..4b3bb26 100644 --- a/src/menuui/readyroom.cpp +++ b/src/menuui/readyroom.cpp @@ -1165,9 +1165,9 @@ void sim_room_init() } // set up sim_rooms for buttons so we draw the correct animation frame when a key is pressed - Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(KEY_PAGEUP); - Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(KEY_PAGEDOWN); - Buttons[gr_screen.res][COMMIT_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER); + Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(SDLK_PAGEUP); + Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(SDLK_PAGEDOWN); + Buttons[gr_screen.res][COMMIT_BUTTON].button.set_hotkey(KEY_CTRLED | SDLK_RETURN); Background_bitmap = bm_load(Sim_filename[gr_screen.res]); @@ -1330,27 +1330,27 @@ void sim_room_do_frame(float frametime) } switch (k) { - case KEY_DOWN: // scroll list down + case SDLK_DOWN: // scroll list down sim_room_scroll_line_down(); break; - case KEY_UP: // scroll list up + case SDLK_UP: // scroll list up sim_room_scroll_line_up(); break; - case KEY_ESC: + case SDLK_ESCAPE: gameseq_post_event(GS_EVENT_MAIN_MENU); break; - case KEY_CTRLED | KEY_UP: + case KEY_CTRLED | SDLK_UP: sim_room_button_pressed(TECH_DATABASE_BUTTON); break; - case KEY_CTRLED | KEY_DOWN: + case KEY_CTRLED | SDLK_DOWN: sim_room_button_pressed(CUTSCENES_BUTTON); break; - case KEY_TAB: + case SDLK_TAB: if (Player->readyroom_listing_mode == MODE_CAMPAIGNS) Player->readyroom_listing_mode = MODE_MISSIONS; else @@ -1361,7 +1361,7 @@ void sim_room_do_frame(float frametime) sim_room_build_listing(); break; - case KEY_F2: + case SDLK_F2: gamesnd_play_iface(SND_SWITCH_SCREENS); gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; @@ -1825,10 +1825,10 @@ void campaign_room_init() #endif // set up sim_rooms for buttons so we draw the correct animation frame when a key is pressed - Cr_buttons[gr_screen.res][CR_SCROLL_UP_BUTTON].button.set_hotkey(KEY_PAGEUP); - Cr_buttons[gr_screen.res][CR_SCROLL_DOWN_BUTTON].button.set_hotkey(KEY_PAGEDOWN); - Cr_buttons[gr_screen.res][CR_RESET_BUTTON].button.set_hotkey(KEY_DELETE); - Cr_buttons[gr_screen.res][CR_COMMIT_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER); + Cr_buttons[gr_screen.res][CR_SCROLL_UP_BUTTON].button.set_hotkey(SDLK_PAGEUP); + Cr_buttons[gr_screen.res][CR_SCROLL_DOWN_BUTTON].button.set_hotkey(SDLK_PAGEDOWN); + Cr_buttons[gr_screen.res][CR_RESET_BUTTON].button.set_hotkey(SDLK_DELETE); + Cr_buttons[gr_screen.res][CR_COMMIT_BUTTON].button.set_hotkey(KEY_CTRLED | SDLK_RETURN); // Cr_buttons[gr_screen.res][CR_HELP_BUTTON].button.set_hotkey(KEY_F2); Background_bitmap = bm_load(Campaign_filename[gr_screen.res]); @@ -1952,7 +1952,7 @@ void campaign_room_do_frame(float frametime) } switch (k) { - case KEY_DOWN: // scroll list down + case SDLK_DOWN: // scroll list down if (Selected_campaign_index < Num_campaigns - 1) { set_new_campaign_line(Selected_campaign_index + 1); gamesnd_play_iface(SND_SCROLL); @@ -1962,7 +1962,7 @@ void campaign_room_do_frame(float frametime) break; - case KEY_UP: // scroll list up + case SDLK_UP: // scroll list up if (Selected_campaign_index < 0) Selected_campaign_index = 1; @@ -1975,7 +1975,7 @@ void campaign_room_do_frame(float frametime) break; - case KEY_ESC: + case SDLK_ESCAPE: gameseq_post_event(GS_EVENT_MAIN_MENU); break; } // end switch diff --git a/src/menuui/snazzyui.cpp b/src/menuui/snazzyui.cpp index ea21c3a..ac9c26c 100644 --- a/src/menuui/snazzyui.cpp +++ b/src/menuui/snazzyui.cpp @@ -211,9 +211,6 @@ #include "localize.h" -extern int ascii_table[]; -extern int shifted_ascii_table[]; - static int Snazzy_mouse_left_was_down; void snazzy_flush() @@ -292,7 +289,7 @@ int snazzy_menu_do(ubyte *data, int mask_w, int mask_h, int num_regions, MENU_RE } switch ( k ) { - case KEY_ESC: + case SDLK_ESCAPE: choice = ESC_PRESSED; break; @@ -301,7 +298,7 @@ int snazzy_menu_do(ubyte *data, int mask_w, int mask_h, int num_regions, MENU_RE for (i=0; i= NUM_TABS) { i = 0; @@ -1931,27 +1931,27 @@ void techroom_do_frame(float frametime) techroom_change_tab(i); break; - case KEY_CTRLED | KEY_DOWN: + case KEY_CTRLED | SDLK_DOWN: if ( !(Player->flags & PLAYER_FLAGS_IS_MULTI) ) { techroom_button_pressed(SIMULATOR_TAB); break; } // fall through - case KEY_CTRLED | KEY_UP: + case KEY_CTRLED | SDLK_UP: techroom_button_pressed(CREDITS_TAB); break; /* - case KEY_UP: + case SDLK_UP: tech_prev_entry(); break; - case KEY_DOWN: + case SDLK_DOWN: tech_next_entry(); break; */ - case KEY_CTRLED | KEY_ENTER: - case KEY_ESC: + case KEY_CTRLED | SDLK_RETURN: + case SDLK_ESCAPE: gameseq_post_event(GS_EVENT_MAIN_MENU); break; } diff --git a/src/mission/missiongoals.cpp b/src/mission/missiongoals.cpp index 1361af2..e591557 100644 --- a/src/mission/missiongoals.cpp +++ b/src/mission/missiongoals.cpp @@ -815,8 +815,8 @@ void mission_show_goals_init() } // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed - Goal_buttons[GOAL_SCREEN_BUTTON_SCROLL_UP].button.set_hotkey(KEY_UP); - Goal_buttons[GOAL_SCREEN_BUTTON_SCROLL_DOWN].button.set_hotkey(KEY_DOWN); + Goal_buttons[GOAL_SCREEN_BUTTON_SCROLL_UP].button.set_hotkey(SDLK_UP); + Goal_buttons[GOAL_SCREEN_BUTTON_SCROLL_DOWN].button.set_hotkey(SDLK_DOWN); Goals_screen_bg_bitmap = bm_load("ObjectivesBG"); Goal_complete_bitmap = bm_load("ObjComp"); @@ -859,15 +859,15 @@ void mission_show_goals_do_frame(float frametime) k = Goals_screen_ui_window.process(); switch (k) { - case KEY_ESC: + case SDLK_ESCAPE: mission_goal_exit(); break; - case KEY_DOWN: + case SDLK_DOWN: goal_screen_scroll_down(); break; - case KEY_UP: + case SDLK_UP: goal_screen_scroll_up(); break; diff --git a/src/mission/missiongrid.cpp b/src/mission/missiongrid.cpp index b64274c..2cb7d04 100644 --- a/src/mission/missiongrid.cpp +++ b/src/mission/missiongrid.cpp @@ -83,7 +83,7 @@ void grid_read_camera_controls( control_info * ci, float frametime ) } // From keyboard... - kh = key_down_timef(KEY_PAD6) - key_down_timef(KEY_PAD4); + kh = key_down_timef(SDLK_KP_6) - key_down_timef(SDLK_KP_4); if (kh == 0.0f) ci->heading = 0.0f; else if (kh > 0.0f) { @@ -94,7 +94,7 @@ void grid_read_camera_controls( control_info * ci, float frametime ) ci->heading = 0.0f; ci->heading += kh; - kh = key_down_timef(KEY_PAD8) - key_down_timef(KEY_PAD2); + kh = key_down_timef(SDLK_KP_8) - key_down_timef(SDLK_KP_2); if (kh == 0.0f) ci->pitch = 0.0f; else if (kh > 0.0f) { @@ -105,10 +105,10 @@ void grid_read_camera_controls( control_info * ci, float frametime ) ci->pitch = 0.0f; ci->pitch += kh; - ci->bank = (key_down_timef(KEY_PAD7) - key_down_timef(KEY_PAD9)); - ci->forward = (key_down_timef(KEY_A) - key_down_timef(KEY_Z)); - ci->sideways = (key_down_timef(KEY_PAD3) - key_down_timef(KEY_PAD1)); - ci->vertical = (key_down_timef(KEY_PADMINUS) - key_down_timef(KEY_PADPLUS)); + ci->bank = (key_down_timef(SDLK_KP_7) - key_down_timef(SDLK_KP_9)); + ci->forward = (key_down_timef(SDLK_a) - key_down_timef(SDLK_z)); + ci->sideways = (key_down_timef(SDLK_KP_3) - key_down_timef(SDLK_KP_1)); + ci->vertical = (key_down_timef(SDLK_KP_MINUS) - key_down_timef(SDLK_KP_PLUS)); } // Project the viewer's position onto the grid plane. If more than threshold distance diff --git a/src/mission/missionhotkey.cpp b/src/mission/missionhotkey.cpp index 0927393..1d1242f 100644 --- a/src/mission/missionhotkey.cpp +++ b/src/mission/missionhotkey.cpp @@ -201,14 +201,14 @@ #include "beam.h" static int Key_sets[MAX_KEYED_TARGETS] = { - KEY_F5, - KEY_F6, - KEY_F7, - KEY_F8, - KEY_F9, - KEY_F10, - KEY_F11, - KEY_F12 + SDLK_F5, + SDLK_F6, + SDLK_F7, + SDLK_F8, + SDLK_F9, + SDLK_F10, + SDLK_F11, + SDLK_F12 }; ///////////////////////////// @@ -1169,8 +1169,8 @@ void mission_hotkey_init() } // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed - Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(KEY_PAGEUP); - Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(KEY_PAGEDOWN); + Buttons[gr_screen.res][SCROLL_UP_BUTTON].button.set_hotkey(SDLK_PAGEUP); + Buttons[gr_screen.res][SCROLL_DOWN_BUTTON].button.set_hotkey(SDLK_PAGEDOWN); // ensure help overlay is off help_overlay_set_state(HOTKEY_OVERLAY,0); @@ -1254,55 +1254,55 @@ void mission_hotkey_do_frame(float frametime) } switch (k) { - case KEY_DOWN: // scroll list down + case SDLK_DOWN: // scroll list down hotkey_scroll_line_down(); break; - case KEY_UP: // scroll list up + case SDLK_UP: // scroll list up hotkey_scroll_line_up(); break; - case KEY_PAGEDOWN: // scroll list down + case SDLK_PAGEDOWN: // scroll list down hotkey_scroll_screen_down(); break; - case KEY_PAGEUP: // scroll list up + case SDLK_PAGEUP: // scroll list up hotkey_scroll_screen_up(); break; - case KEY_CTRLED | KEY_ENTER: + case KEY_CTRLED | SDLK_RETURN: save_hotkeys(); // fall through to next state -- allender changed this behavior since ESC should always cancel, no? - case KEY_ESC: + case SDLK_ESCAPE: mission_hotkey_exit(); break; - case KEY_TAB: - case KEY_ENTER: - case KEY_PADENTER: + case SDLK_TAB: + case SDLK_RETURN: + case SDLK_KP_ENTER: expand_wing(); break; - case KEY_EQUAL: - case KEY_PADPLUS: + case SDLK_EQUALS: + case SDLK_KP_PLUS: add_hotkey(Cur_hotkey); break; - case KEY_MINUS: - case KEY_PADMINUS: + case SDLK_MINUS: + case SDLK_KP_MINUS: remove_hotkey(); break; - case KEY_F2: + case SDLK_F2: gameseq_post_event(GS_EVENT_OPTIONS_MENU); break; - case KEY_CTRLED | KEY_R: + case KEY_CTRLED | SDLK_r: reset_hotkeys(); break; - case KEY_CTRLED | KEY_C: + case KEY_CTRLED | SDLK_c: clear_hotkeys(); break; } // end switch diff --git a/src/mission/missionload.cpp b/src/mission/missionload.cpp index c65f8d6..9a54094 100644 --- a/src/mission/missionload.cpp +++ b/src/mission/missionload.cpp @@ -214,8 +214,6 @@ extern mission The_mission; // need to send this info to the briefing -extern int shifted_ascii_table[]; -extern int ascii_table[]; // ----------------------------------------------- // For recording most recent missions played @@ -375,7 +373,7 @@ void mission_load_menu_init() mlm_ok.create( &mlm_window, NOX("Ok"), 125, 420, 80, 40 ); mlm_cancel.create( &mlm_window, NOX("Cancel"), 250, 420, 80, 40 ); - mlm_cancel.set_hotkey( KEY_ESC ); + mlm_cancel.set_hotkey( SDLK_ESCAPE ); mlm_mission_list.create( &mlm_window, 450, 150, 150, 200, mlm_nfiles, mlm_missions ); @@ -417,21 +415,21 @@ void mission_load_menu_do() switch ( key_in & KEY_MASK ) { - case KEY_UP: - case KEY_DOWN: - case KEY_HOME: - case KEY_END: - case KEY_PAGEUP: - case KEY_PAGEDOWN: - case KEY_ENTER: + case SDLK_UP: + case SDLK_DOWN: + case SDLK_HOME: + case SDLK_END: + case SDLK_PAGEUP: + case SDLK_PAGEDOWN: + case SDLK_RETURN: break; - case KEY_RIGHT: - case KEY_LEFT: + case SDLK_RIGHT: + case SDLK_LEFT: ml_change_listbox(); break; - case KEY_ESC: + case SDLK_ESCAPE: gameseq_post_event(GS_EVENT_MAIN_MENU); break; diff --git a/src/missionui/chatbox.cpp b/src/missionui/chatbox.cpp index 79dbe62..358ec62 100644 --- a/src/missionui/chatbox.cpp +++ b/src/missionui/chatbox.cpp @@ -839,13 +839,13 @@ int chatbox_process(int key_in) // look for special keypresses switch(key_out){ // line recall up one - case KEY_UP: + case SDLK_UP: chatbox_recall_up(); key_out = 0; break; // line recall down one - case KEY_DOWN: + case SDLK_DOWN: chatbox_recall_down(); key_out = 0; break; diff --git a/src/missionui/missionbrief.cpp b/src/missionui/missionbrief.cpp index afdf0aa..a486643 100644 --- a/src/missionui/missionbrief.cpp +++ b/src/missionui/missionbrief.cpp @@ -1008,12 +1008,12 @@ void brief_buttons_init() Closeup_close_button.link_hotspot(Closeup_button_hotspot); // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed - Brief_buttons[gr_screen.res][BRIEF_BUTTON_LAST_STAGE].button.set_hotkey(KEY_SHIFTED|KEY_RIGHT); - Brief_buttons[gr_screen.res][BRIEF_BUTTON_NEXT_STAGE].button.set_hotkey(KEY_RIGHT); - Brief_buttons[gr_screen.res][BRIEF_BUTTON_PREV_STAGE].button.set_hotkey(KEY_LEFT); - Brief_buttons[gr_screen.res][BRIEF_BUTTON_FIRST_STAGE].button.set_hotkey(KEY_SHIFTED|KEY_LEFT); - Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_UP].button.set_hotkey(KEY_UP); - Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_DOWN].button.set_hotkey(KEY_DOWN); + Brief_buttons[gr_screen.res][BRIEF_BUTTON_LAST_STAGE].button.set_hotkey(KEY_SHIFTED|SDLK_RIGHT); + Brief_buttons[gr_screen.res][BRIEF_BUTTON_NEXT_STAGE].button.set_hotkey(SDLK_RIGHT); + Brief_buttons[gr_screen.res][BRIEF_BUTTON_PREV_STAGE].button.set_hotkey(SDLK_LEFT); + Brief_buttons[gr_screen.res][BRIEF_BUTTON_FIRST_STAGE].button.set_hotkey(KEY_SHIFTED|SDLK_LEFT); + Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_UP].button.set_hotkey(SDLK_UP); + Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_DOWN].button.set_hotkey(SDLK_DOWN); Closeup_close_button.disable(); Closeup_close_button.hide(); @@ -1909,7 +1909,7 @@ void brief_do_frame(float frametime) switch(k) { #ifndef NDEBUG - case KEY_CTRLED | KEY_PAGEUP: { + case KEY_CTRLED | SDLK_PAGEUP: { if (Closeup_icon->ship_class) { Closeup_icon->ship_class--; @@ -1925,7 +1925,7 @@ void brief_do_frame(float frametime) break; } - case KEY_CTRLED | KEY_PAGEDOWN: { + case KEY_CTRLED | SDLK_PAGEDOWN: { if (Closeup_icon->ship_class < Num_ship_types - 1) { Closeup_icon->ship_class++; @@ -1941,66 +1941,66 @@ void brief_do_frame(float frametime) break; } - case KEY_A: + case SDLK_a: Closeup_cam_pos.xyz.z += 1; cam_change = 1; break; - case KEY_A + KEY_SHIFTED: + case SDLK_a + KEY_SHIFTED: Closeup_cam_pos.xyz.z += 10; cam_change = 1; break; - case KEY_Z: + case SDLK_z: Closeup_cam_pos.xyz.z -= 1; cam_change = 1; break; - case KEY_Z + KEY_SHIFTED: + case SDLK_z + KEY_SHIFTED: Closeup_cam_pos.xyz.z -= 10; cam_change = 1; break; - case KEY_Y: + case SDLK_y: Closeup_cam_pos.xyz.y += 1; cam_change = 1; break; - case KEY_Y + KEY_SHIFTED: + case SDLK_y + KEY_SHIFTED: Closeup_cam_pos.xyz.y += 10; cam_change = 1; break; - case KEY_H: + case SDLK_h: Closeup_cam_pos.xyz.y -= 1; cam_change = 1; break; - case KEY_H + KEY_SHIFTED: + case SDLK_h + KEY_SHIFTED: Closeup_cam_pos.xyz.y -= 10; cam_change = 1; break; - case KEY_COMMA: + case SDLK_COMMA: Closeup_zoom -= 0.1f; if ( Closeup_zoom < 0.1 ) Closeup_zoom = 0.1f; cam_change = 1; break; - case KEY_COMMA+KEY_SHIFTED: + case SDLK_COMMA+KEY_SHIFTED: Closeup_zoom -= 0.5f; if ( Closeup_zoom < 0.1 ) Closeup_zoom = 0.1f; cam_change = 1; break; - case KEY_PERIOD: + case SDLK_PERIOD: Closeup_zoom += 0.1f; cam_change = 1; break; - case KEY_PERIOD+KEY_SHIFTED: + case SDLK_PERIOD+KEY_SHIFTED: Closeup_zoom += 0.5f; cam_change = 1; break; diff --git a/src/missionui/missioncmdbrief.cpp b/src/missionui/missioncmdbrief.cpp index 380853a..1cd8591 100644 --- a/src/missionui/missioncmdbrief.cpp +++ b/src/missionui/missioncmdbrief.cpp @@ -730,13 +730,13 @@ void cmd_brief_init(int team) #endif // set up readyrooms for buttons so we draw the correct animation frame when a key is pressed - Cmd_brief_buttons[gr_screen.res][FIRST_STAGE_BUTTON].button.set_hotkey(KEY_SHIFTED | KEY_LEFT); - Cmd_brief_buttons[gr_screen.res][LAST_STAGE_BUTTON].button.set_hotkey(KEY_SHIFTED | KEY_RIGHT); - Cmd_brief_buttons[gr_screen.res][PREV_STAGE_BUTTON].button.set_hotkey(KEY_LEFT); - Cmd_brief_buttons[gr_screen.res][NEXT_STAGE_BUTTON].button.set_hotkey(KEY_RIGHT); - Cmd_brief_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(KEY_CTRLED | KEY_ENTER); - Cmd_brief_buttons[gr_screen.res][HELP_BUTTON].button.set_hotkey(KEY_F1); - Cmd_brief_buttons[gr_screen.res][OPTIONS_BUTTON].button.set_hotkey(KEY_F2); + Cmd_brief_buttons[gr_screen.res][FIRST_STAGE_BUTTON].button.set_hotkey(KEY_SHIFTED | SDLK_LEFT); + Cmd_brief_buttons[gr_screen.res][LAST_STAGE_BUTTON].button.set_hotkey(KEY_SHIFTED | SDLK_RIGHT); + Cmd_brief_buttons[gr_screen.res][PREV_STAGE_BUTTON].button.set_hotkey(SDLK_LEFT); + Cmd_brief_buttons[gr_screen.res][NEXT_STAGE_BUTTON].button.set_hotkey(SDLK_RIGHT); + Cmd_brief_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(KEY_CTRLED | SDLK_RETURN); + Cmd_brief_buttons[gr_screen.res][HELP_BUTTON].button.set_hotkey(SDLK_F1); + Cmd_brief_buttons[gr_screen.res][OPTIONS_BUTTON].button.set_hotkey(SDLK_F2); // load in help overlay bitmap help_overlay_load(CMD_BRIEF_OVERLAY); @@ -824,7 +824,7 @@ void cmd_brief_do_frame(float frametime) } switch (k) { - case KEY_ESC: + case SDLK_ESCAPE: common_music_close(); gameseq_post_event(GS_EVENT_MAIN_MENU); break; diff --git a/src/missionui/missiondebrief.cpp b/src/missionui/missiondebrief.cpp index 96c1945..975ab2f 100644 --- a/src/missionui/missiondebrief.cpp +++ b/src/missionui/missiondebrief.cpp @@ -1254,13 +1254,13 @@ void debrief_buttons_init() #endif // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed - Buttons[gr_screen.res][NEXT_STAGE].button.set_hotkey(KEY_RIGHT); - Buttons[gr_screen.res][PREV_STAGE].button.set_hotkey(KEY_LEFT); - Buttons[gr_screen.res][LAST_STAGE].button.set_hotkey(KEY_SHIFTED | KEY_RIGHT); - Buttons[gr_screen.res][FIRST_STAGE].button.set_hotkey(KEY_SHIFTED | KEY_LEFT); - Buttons[gr_screen.res][TEXT_SCROLL_UP].button.set_hotkey(KEY_UP); - Buttons[gr_screen.res][TEXT_SCROLL_DOWN].button.set_hotkey(KEY_DOWN); - Buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(KEY_CTRLED+KEY_ENTER); + Buttons[gr_screen.res][NEXT_STAGE].button.set_hotkey(SDLK_RIGHT); + Buttons[gr_screen.res][PREV_STAGE].button.set_hotkey(SDLK_LEFT); + Buttons[gr_screen.res][LAST_STAGE].button.set_hotkey(KEY_SHIFTED | SDLK_RIGHT); + Buttons[gr_screen.res][FIRST_STAGE].button.set_hotkey(KEY_SHIFTED | SDLK_LEFT); + Buttons[gr_screen.res][TEXT_SCROLL_UP].button.set_hotkey(SDLK_UP); + Buttons[gr_screen.res][TEXT_SCROLL_DOWN].button.set_hotkey(SDLK_DOWN); + Buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(KEY_CTRLED+SDLK_RETURN); // if in multiplayer, disable the button for all players except the host // also disable for squad war matches @@ -2629,15 +2629,15 @@ void debrief_close() void debrief_do_keys(int new_k) { switch (new_k) { - case KEY_TAB: + case SDLK_TAB: debrief_next_tab(); break; - case KEY_SHIFTED | KEY_TAB: + case KEY_SHIFTED | SDLK_TAB: debrief_prev_tab(); break; - case KEY_ESC: { + case SDLK_ESCAPE: { int pf_flags; int choice; @@ -2792,7 +2792,7 @@ void debrief_do_frame(float frametime) // esc pressed? os_poll(); int keypress = game_check_key(); - if(keypress == KEY_ESC){ + if(keypress == SDLK_ESCAPE){ // popup to leave multi_quit_game(PROMPT_CLIENT); } diff --git a/src/missionui/missionloopbrief.cpp b/src/missionui/missionloopbrief.cpp index 74c6adf..d779009 100644 --- a/src/missionui/missionloopbrief.cpp +++ b/src/missionui/missionloopbrief.cpp @@ -234,7 +234,7 @@ void loop_brief_do() k = Loop_brief_window.process(); switch (k) { - case KEY_ESC: + case SDLK_ESCAPE: gameseq_post_event(GS_EVENT_MAIN_MENU); break; } diff --git a/src/missionui/missionpause.cpp b/src/missionui/missionpause.cpp index 8ddbb02..d098bf2 100644 --- a/src/missionui/missionpause.cpp +++ b/src/missionui/missionpause.cpp @@ -208,8 +208,8 @@ void pause_do(int multi) else { k = Pause_win.process() & ~KEY_DEBUGGED; switch (k) { - case KEY_ESC: - case KEY_PAUSE: + case SDLK_ESCAPE: + case SDLK_PAUSE: gameseq_post_event(GS_EVENT_PREVIOUS_STATE); break; } // end switch @@ -277,13 +277,13 @@ void pause_debug_init() Pause_single_step.create( &Pause_win, NOX("Single Step "), 200, 290, game_single_step ); Pause_continue.create( &Pause_win, NOX("Leave Pause"), 200, 350, 200, 40 ); - Pause_single_step.set_hotkey( KEY_S ); - Pause_physics.set_hotkey( KEY_P ); - Pause_ai.set_hotkey( KEY_A ); - Pause_ai_render.set_hotkey( KEY_R ); - Pause_firing.set_hotkey( KEY_F ); - Pause_external_view_mode_check.set_hotkey( KEY_E ); - Pause_continue.set_hotkey( KEY_ESC ); + Pause_single_step.set_hotkey( SDLK_s ); + Pause_physics.set_hotkey( SDLK_p ); + Pause_ai.set_hotkey( SDLK_a ); + Pause_ai_render.set_hotkey( SDLK_r ); + Pause_firing.set_hotkey( SDLK_f ); + Pause_external_view_mode_check.set_hotkey( SDLK_e ); + Pause_continue.set_hotkey( SDLK_ESCAPE ); Pause_continue.set_focus(); } @@ -326,7 +326,7 @@ void pause_debug_do() } } - if ( Pause_continue.pressed() || (key == KEY_PAUSE) ) { // Changed, MK, 11/9/97, only Pause break pause. + if ( Pause_continue.pressed() || (key == SDLK_PAUSE) ) { // Changed, MK, 11/9/97, only Pause break pause. gameseq_post_event(GS_EVENT_PREVIOUS_STATE); } diff --git a/src/missionui/missionscreencommon.cpp b/src/missionui/missionscreencommon.cpp index 3e75fb2..285ce9f 100644 --- a/src/missionui/missionscreencommon.cpp +++ b/src/missionui/missionscreencommon.cpp @@ -561,9 +561,9 @@ void common_buttons_init(UI_WINDOW *ui_window) common_reset_buttons(); - Common_buttons[Current_screen-1][gr_screen.res][COMMON_COMMIT_BUTTON].button.set_hotkey(KEY_CTRLED+KEY_ENTER); - Common_buttons[Current_screen-1][gr_screen.res][COMMON_HELP_BUTTON].button.set_hotkey(KEY_F1); - Common_buttons[Current_screen-1][gr_screen.res][COMMON_OPTIONS_BUTTON].button.set_hotkey(KEY_F2); + Common_buttons[Current_screen-1][gr_screen.res][COMMON_COMMIT_BUTTON].button.set_hotkey(KEY_CTRLED+SDLK_RETURN); + Common_buttons[Current_screen-1][gr_screen.res][COMMON_HELP_BUTTON].button.set_hotkey(SDLK_F1); + Common_buttons[Current_screen-1][gr_screen.res][COMMON_OPTIONS_BUTTON].button.set_hotkey(SDLK_F2); // for scramble or training missions, disable the ship/weapon selection regions if ( brief_only_allow_briefing() ) { @@ -1006,7 +1006,7 @@ void common_check_keys(int k) { switch (k) { - case KEY_ESC: { + case SDLK_ESCAPE: { if ( Current_screen == ON_BRIEFING_SELECT ) { if ( brief_get_closeup_icon() != NULL ) { @@ -1035,17 +1035,17 @@ void common_check_keys(int k) break; } - case KEY_CTRLED + KEY_ENTER: + case KEY_CTRLED + SDLK_RETURN: Commit_pressed = 1; break; - case KEY_B: + case SDLK_b: if ( Current_screen != ON_BRIEFING_SELECT && !Background_playing ) { Next_screen = ON_BRIEFING_SELECT; } break; - case KEY_W: + case SDLK_w: if ( brief_only_allow_briefing() ) { gamesnd_play_iface(SND_GENERAL_FAIL); break; @@ -1065,7 +1065,7 @@ void common_check_keys(int k) break; - case KEY_S: + case SDLK_s: if ( brief_only_allow_briefing() ) { gamesnd_play_iface(SND_GENERAL_FAIL); @@ -1082,7 +1082,7 @@ void common_check_keys(int k) break; - case KEY_SHIFTED+KEY_TAB: + case KEY_SHIFTED+SDLK_TAB: if ( brief_only_allow_briefing() ) { gamesnd_play_iface(SND_GENERAL_FAIL); @@ -1118,7 +1118,7 @@ void common_check_keys(int k) break; - case KEY_TAB: + case SDLK_TAB: if ( brief_only_allow_briefing() ) { gamesnd_play_iface(SND_GENERAL_FAIL); @@ -1154,7 +1154,7 @@ void common_check_keys(int k) break; - case KEY_P: + case SDLK_p: if ( Anim_paused ) Anim_paused = 0; else diff --git a/src/missionui/redalert.cpp b/src/missionui/redalert.cpp index e55e650..86181ad 100644 --- a/src/missionui/redalert.cpp +++ b/src/missionui/redalert.cpp @@ -471,7 +471,7 @@ void red_alert_init() #endif // set up red alert hotkeys - Buttons[gr_screen.res][RA_CONTINUE].button.set_hotkey(KEY_CTRLED | KEY_ENTER); + Buttons[gr_screen.res][RA_CONTINUE].button.set_hotkey(KEY_CTRLED | SDLK_RETURN); // load in background image and flashing red alert animation Background_bitmap = bm_load(Red_alert_fname[gr_screen.res]); @@ -536,7 +536,7 @@ void red_alert_do_frame(float frametime) k = Ui_window.process() & ~KEY_DEBUGGED; switch (k) { - case KEY_ESC: + case SDLK_ESCAPE: // gameseq_post_event(GS_EVENT_ENTER_GAME); gameseq_post_event(GS_EVENT_MAIN_MENU); break; diff --git a/src/model/modelinterp.cpp b/src/model/modelinterp.cpp index 72a3e38..7224843 100644 --- a/src/model/modelinterp.cpp +++ b/src/model/modelinterp.cpp @@ -1364,7 +1364,7 @@ void interp_render_lightning( polymodel *pm, bsp_info * sm ) if (!Interp_lightning) return; -// if ( keyd_pressed[KEY_LSHIFT] ) return; +// if ( key_pressed(SDLK_LSHIFT) ) return; // if ( rad < 3.0f ) return; for (i=0; inum_arcs; i++ ) { @@ -1466,7 +1466,7 @@ void model_interp_subcall(polymodel * pm, int mn, int detail_level) int interp_box_offscreen( vector *min, vector *max ) { - if ( keyd_pressed[KEY_LSHIFT] ) { + if ( key_pressed(SDLK_LSHIFT) ) { return IBOX_ALL_ON; } @@ -2115,7 +2115,7 @@ void model_try_cache_render(int model_num, matrix *orient, vector * pos, uint fl // mprintf(( "Detail level %d\n", tmp_detail_level )); // } -// if ( keyd_pressed[KEY_LSHIFT] ) { +// if ( key_pressed(SDLK_LSHIFT) ) { // mc->cached_valid = 0; // model_really_render(model_num, orient, pos, flags, objnum ); // return; @@ -2176,7 +2176,7 @@ void model_try_cache_render(int model_num, matrix *orient, vector * pos, uint fl goto RedrawIt; } -// if ( keyd_pressed[KEY_LSHIFT] ) { +// if ( key_pressed(SDLK_LSHIFT) ) { // goto RedrawIt; // } @@ -2302,12 +2302,12 @@ void model_try_cache_render(int model_num, matrix *orient, vector * pos, uint fl g3_draw_poly(4, vertlist, TMAP_FLAG_TEXTURED ); Tmap_scan_read = 0; - // if ( keyd_pressed[KEY_LSHIFT] ) { + // if ( key_pressed(SDLK_LSHIFT) ) { // gr_set_color( 255, 0, 0 ); // gr_pixel( fl2i(v[0].sx), fl2i(v[0].sy) ); // } - //if ( keyd_pressed[KEY_RSHIFT] ) { + //if ( key_pressed(SDLK_RSHIFT) ) { // gr_line( fl2i(v[0].sx), fl2i(v[0].sy), fl2i(v[1].sx), fl2i(v[1].sy) ); // gr_line( fl2i(v[1].sx), fl2i(v[1].sy), fl2i(v[2].sx), fl2i(v[2].sy) ); // gr_line( fl2i(v[2].sx), fl2i(v[2].sy), fl2i(v[3].sx), fl2i(v[3].sy) ); diff --git a/src/model/modelread.cpp b/src/model/modelread.cpp index d5c2b5e..4430e8d 100644 --- a/src/model/modelread.cpp +++ b/src/model/modelread.cpp @@ -1175,11 +1175,11 @@ void print_family_tree( polymodel *obj, int modelnum, const char * ident, int is mprintf(( " %s", obj->submodel[modelnum].name )); sprintf( temp, " " ); } else if ( islast ) { - mprintf(( "%sÀÄ%s", ident, obj->submodel[modelnum].name )); + mprintf(( "%s��%s", ident, obj->submodel[modelnum].name )); sprintf( temp, "%s ", ident ); } else { - mprintf(( "%sÃÄ%s", ident, obj->submodel[modelnum].name )); - sprintf( temp, "%s³ ", ident ); + mprintf(( "%s��%s", ident, obj->submodel[modelnum].name )); + sprintf( temp, "%s� ", ident ); } mprintf(( "\n" )); @@ -3003,8 +3003,8 @@ int model_rotate_gun(int model_num, model_subsystem *turret, matrix *orient, ang vm_interp_angle(&turret1->h,desired_angles.h,step_size); vm_interp_angle(&turret2->p,desired_angles.p,step_size); -// turret1->h -= step_size*(key_down_timef(KEY_1)-key_down_timef(KEY_2) ); -// turret2->p += step_size*(key_down_timef(KEY_3)-key_down_timef(KEY_4) ); +// turret1->h -= step_size*(key_down_timef(SDLK_1)-key_down_timef(SDLK_2) ); +// turret2->p += step_size*(key_down_timef(SDLK_3)-key_down_timef(SDLK_4) ); return 1; @@ -3223,12 +3223,12 @@ void model_clear_instance(int model_num) interp_clear_instance(); -// if ( keyd_pressed[KEY_1] ) pm->lights[0].value = 1.0f/255.0f; -// if ( keyd_pressed[KEY_2] ) pm->lights[1].value = 1.0f/255.0f; -// if ( keyd_pressed[KEY_3] ) pm->lights[2].value = 1.0f/255.0f; -// if ( keyd_pressed[KEY_4] ) pm->lights[3].value = 1.0f/255.0f; -// if ( keyd_pressed[KEY_5] ) pm->lights[4].value = 1.0f/255.0f; -// if ( keyd_pressed[KEY_6] ) pm->lights[5].value = 1.0f/255.0f; +// if ( key_pressed(SDLK_1) ) pm->lights[0].value = 1.0f/255.0f; +// if ( key_pressed(SDLK_2) ) pm->lights[1].value = 1.0f/255.0f; +// if ( key_pressed(SDLK_3) ) pm->lights[2].value = 1.0f/255.0f; +// if ( key_pressed(SDLK_4) ) pm->lights[3].value = 1.0f/255.0f; +// if ( key_pressed(SDLK_5) ) pm->lights[4].value = 1.0f/255.0f; +// if ( key_pressed(SDLK_6) ) pm->lights[5].value = 1.0f/255.0f; } diff --git a/src/movie/mveplayer.cpp b/src/movie/mveplayer.cpp index 30a47a9..08c211a 100644 --- a/src/movie/mveplayer.cpp +++ b/src/movie/mveplayer.cpp @@ -624,7 +624,7 @@ void mve_video_display() } int k = key_inkey(); - if ( k == KEY_ESC ) { + if ( k == SDLK_ESCAPE ) { mve_playing = 0; } diff --git a/src/nebedit/nebedit.cpp b/src/nebedit/nebedit.cpp index 0fb6aed..f0ceaeb 100644 --- a/src/nebedit/nebedit.cpp +++ b/src/nebedit/nebedit.cpp @@ -346,7 +346,7 @@ void draw_tri_2d( int i, int j, int k ) // gr_set_color( 0, 0, 0 ); gr_tmapper(3, verts, TMAP_FLAG_RAMP | TMAP_FLAG_GOURAUD | TMAP_FLAG_NEBULA ); - if ( !keyd_pressed[KEY_LSHIFT] ) { + if ( !key_pressed(SDLK_LSHIFT) ) { gr_set_color(100,100,100); gr_line( x[i], y[i], x[j], y[j] ); gr_line( x[j], y[j], x[k], y[k] ); @@ -627,7 +627,7 @@ void controls_read_all(control_info * ci, float sim_time ) } // From keyboard... - kh = (key_down_timef(KEY_PAD6) - key_down_timef(KEY_PAD4))/8.0f; + kh = (key_down_timef(SDLK_KP_6) - key_down_timef(SDLK_KP_4))/8.0f; if (kh == 0.0f) ci->heading = 0.0f; else if (kh > 0.0f) { @@ -638,7 +638,7 @@ void controls_read_all(control_info * ci, float sim_time ) ci->heading = 0.0f; ci->heading += kh; - kh = (key_down_timef(KEY_PAD8) - key_down_timef(KEY_PAD2))/8.0f; + kh = (key_down_timef(SDLK_KP_8) - key_down_timef(SDLK_KP_2))/8.0f; if (kh == 0.0f) ci->pitch = 0.0f; else if (kh > 0.0f) { @@ -649,10 +649,10 @@ void controls_read_all(control_info * ci, float sim_time ) ci->pitch = 0.0f; ci->pitch += kh; - ci->bank = (key_down_timef(KEY_PAD7) - key_down_timef(KEY_PAD9))*.75f; - ci->forward = key_down_timef(KEY_A) - key_down_timef(KEY_Z); - ci->sideways = key_down_timef(KEY_PAD3) - key_down_timef(KEY_PAD1); - ci->vertical = key_down_timef(KEY_PADPLUS) - key_down_timef(KEY_PADENTER); + ci->bank = (key_down_timef(SDLK_KP_7) - key_down_timef(SDLK_KP_9))*.75f; + ci->forward = key_down_timef(SDLK_a) - key_down_timef(SDLK_z); + ci->sideways = key_down_timef(SDLK_KP_3) - key_down_timef(SDLK_KP_1); + ci->vertical = key_down_timef(SDLK_KP_PLUS) - key_down_timef(SDLK_KP_ENTER); } int check_keys() @@ -661,18 +661,18 @@ int check_keys() while( (k = key_inkey()) != 0 ) { //mprintf(( "Key = %x\n", k )); - if ( k == KEY_ESC ) { + if ( k == SDLK_ESCAPE ) { return 1; } switch( k ) { - case KEY_ENTER: + case SDLK_RETURN: Sel_mode = FALSE; Vert_mode = !Vert_mode; Which_vert = 0; break; - case KEY_DELETE: + case SDLK_DELETE: if (Sel_mode) break; if (Vert_mode==1) delete_face(Current_face); else if (Vert_mode==0) { @@ -680,26 +680,26 @@ int check_keys() } break; - case KEY_MINUS: + case SDLK_MINUS: scale_factor -= 0.05f; mprintf(( "Scale = %.1f\n", scale_factor )); break; - case KEY_EQUAL: + case SDLK_EQUALS: scale_factor += 0.05f; mprintf(( "Scale = %.1f\n", scale_factor )); break; - case KEY_INSERT: + case SDLK_INSERT: Sel_mode = !Sel_mode; break; - case KEY_SPACEBAR: + case SDLK_SPACE: View_mode = !View_mode; break; - case KEY_COMMA: + case SDLK_COMMA: if (Sel_mode) { int i; for (i=0;ilowest_ping)/1000.0f; lag /= 2.0f; // Our ping time is round trip, we only account for 1/2 the trip. @@ -447,7 +447,7 @@ void multi_oo_interpolate(object *objp, interp_info *current, interp_info *last) physics_sim_rot(actual_orient, &objp->phys_info, flFrametime ); } - if(keyd_pressed[LAG_OFF_KEY]){ + if(key_pressed(LAG_OFF_KEY)){ // Make orient go quickly to actual_orient /* diff --git a/src/network/multi_pause.cpp b/src/network/multi_pause.cpp index 3ef7050..79c229c 100644 --- a/src/network/multi_pause.cpp +++ b/src/network/multi_pause.cpp @@ -461,8 +461,8 @@ void multi_pause_do() k = Multi_paused_window->process(k); switch (k) { - case KEY_ESC: - case KEY_PAUSE: + case SDLK_ESCAPE: + case SDLK_PAUSE: multi_pause_request(0); break; } diff --git a/src/network/multi_pinfo.cpp b/src/network/multi_pinfo.cpp index 5876ae9..606d898 100644 --- a/src/network/multi_pinfo.cpp +++ b/src/network/multi_pinfo.cpp @@ -487,7 +487,7 @@ void multi_pinfo_popup_do() // process the window k = Multi_pinfo_window.process(); switch(k){ - case KEY_ESC : + case SDLK_ESCAPE : Multi_pinfo_popup_done = 1; break; } diff --git a/src/network/multi_pmsg.cpp b/src/network/multi_pmsg.cpp index 4bee51f..947febf 100644 --- a/src/network/multi_pmsg.cpp +++ b/src/network/multi_pmsg.cpp @@ -338,30 +338,30 @@ int multi_msg_text_process(int k) switch(k){ // cancel the message - case KEY_ESC: + case SDLK_ESCAPE: multi_msg_text_flush(); break; // send the message - case KEY_ENTER: + case SDLK_RETURN: multi_msg_eval_text_msg(); multi_msg_text_flush(); break; // backspace - case KEY_BACKSP: + case SDLK_BACKSPACE: if(strlen(Multi_msg_text) > 0){ Multi_msg_text[strlen(Multi_msg_text)-1] = '\0'; } break; // ignore these individual keys - case KEY_LSHIFT + KEY_SHIFTED: - case KEY_RSHIFT + KEY_SHIFTED: - case KEY_LALT + KEY_SHIFTED: - case KEY_RALT + KEY_SHIFTED: - case KEY_LCTRL + KEY_SHIFTED: - case KEY_RCTRL + KEY_SHIFTED: + case SDLK_LSHIFT + KEY_SHIFTED: + case SDLK_RSHIFT + KEY_SHIFTED: + case SDLK_LALT + KEY_SHIFTED: + case SDLK_RALT + KEY_SHIFTED: + case SDLK_LCTRL + KEY_SHIFTED: + case SDLK_RCTRL + KEY_SHIFTED: break; // stick other printable characters onto the text diff --git a/src/network/multi_voice.cpp b/src/network/multi_voice.cpp index 5e4ed60..7e2a502 100644 --- a/src/network/multi_voice.cpp +++ b/src/network/multi_voice.cpp @@ -344,7 +344,7 @@ typedef struct voice_stream { voice_stream Multi_voice_stream[MULTI_VOICE_MAX_STREAMS]; // voice streams themselves // player-side data -#define MULTI_VOICE_KEY KEY_LAPOSTRO // key used for realtime voice +#define MULTI_VOICE_KEY SDLK_BACKQUOTE // key used for realtime voice int Multi_voice_keydown = 0; // is the record key currently being pressed int Multi_voice_recording = 0; // flag indicating if we're currently recording or not int Multi_voice_token = 0; // if we currently have a token or not @@ -953,12 +953,12 @@ int multi_voice_keydown() // if we're pre-game, we should just be checking the keyboard bitflags if(!(Game_mode & GM_IN_MISSION)){ - return (keyd_pressed[MULTI_VOICE_KEY] && !(keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT])) ? 1 : 0; + return (key_pressed(MULTI_VOICE_KEY) && !(key_pressed(SDLK_LSHIFT) || key_pressed(SDLK_RSHIFT))) ? 1 : 0; } // in-mission, paused - treat just like any other "chattable" screen. if(gameseq_get_state() == GS_STATE_MULTI_PAUSED){ - return (keyd_pressed[MULTI_VOICE_KEY] && !(keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT])) ? 1 : 0; + return (key_pressed(MULTI_VOICE_KEY) && !(key_pressed(SDLK_LSHIFT) || key_pressed(SDLK_RSHIFT))) ? 1 : 0; } // ingame, unpaused, rely on the multi-messaging system (ingame) diff --git a/src/network/multiteamselect.cpp b/src/network/multiteamselect.cpp index 0d9ad7d..e980a37 100644 --- a/src/network/multiteamselect.cpp +++ b/src/network/multiteamselect.cpp @@ -768,19 +768,19 @@ void multi_ts_do() // process any keypresses switch(k){ - case KEY_ESC : + case SDLK_ESCAPE : gamesnd_play_iface(SND_USER_SELECT); multi_quit_game(PROMPT_ALL); break; // cycle to the weapon select screen - case KEY_TAB : + case SDLK_TAB : gamesnd_play_iface(SND_USER_SELECT); Next_screen = ON_WEAPON_SELECT; gameseq_post_event(GS_EVENT_WEAPON_SELECTION); break; - case KEY_ENTER|KEY_CTRLED: + case SDLK_RETURN|KEY_CTRLED: multi_ts_commit_pressed(); break; } diff --git a/src/network/multiui.cpp b/src/network/multiui.cpp index 14789eb..5db071c 100644 --- a/src/network/multiui.cpp +++ b/src/network/multiui.cpp @@ -1524,7 +1524,7 @@ void multi_join_game_do_frame() // process any keypresses switch(k){ - case KEY_ESC : + case SDLK_ESCAPE : if(help_overlay_active(MULTI_JOIN_OVERLAY)){ help_overlay_set_state(MULTI_JOIN_OVERLAY,0); } else { @@ -1534,19 +1534,19 @@ void multi_join_game_do_frame() break; // page up the game list - case KEY_PAGEUP: + case SDLK_PAGEUP: multi_join_list_page_up(); #ifndef MAKE_FS1 Multi_join_slider.force_currentItem(Multi_join_list_start); #endif break; - case KEY_T: + case SDLK_t: multi_pinfo_popup(Net_player); break; // page down the game list - case KEY_PAGEDOWN: + case SDLK_PAGEDOWN: multi_join_list_page_down(); #ifndef MAKE_FS1 Multi_join_slider.force_currentItem(Multi_join_list_start); @@ -1554,18 +1554,18 @@ void multi_join_game_do_frame() break; // send out a ping-all - case KEY_P : + case SDLK_p : multi_join_ping_all(); Multi_join_ping_stamp = timestamp(MULTI_JOIN_PING_TIME); break; // shortcut to start a game - case KEY_S : + case SDLK_s : multi_join_create_game(); break; // scroll the game list up - case KEY_UP: + case SDLK_UP: multi_join_list_scroll_up(); #ifndef MAKE_FS1 Multi_join_slider.force_currentItem(Multi_join_list_start); @@ -1573,7 +1573,7 @@ void multi_join_game_do_frame() break; // scroll the game list down - case KEY_DOWN: + case SDLK_DOWN: multi_join_list_scroll_down(); #ifndef MAKE_FS1 Multi_join_slider.force_currentItem(Multi_join_list_start); @@ -2992,7 +2992,7 @@ void multi_start_game_do() // process any keypresses switch(k){ - case KEY_ESC : + case SDLK_ESCAPE : if(help_overlay_active(MULTI_START_OVERLAY)){ help_overlay_set_state(MULTI_START_OVERLAY,0); } else { @@ -3002,8 +3002,8 @@ void multi_start_game_do() break; // same as ACCEPT - case KEY_LCTRL + KEY_ENTER : - case KEY_RCTRL + KEY_ENTER : + case SDLK_LCTRL + SDLK_RETURN : + case SDLK_RCTRL + SDLK_RETURN : gamesnd_play_iface(SND_COMMIT_PRESSED); gameseq_post_event(GS_EVENT_MULTI_HOST_SETUP); break; @@ -4211,7 +4211,7 @@ void multi_create_game_init() Multi_create_list_select_button.hide(); // set hotkeys for a couple of things. - Multi_create_buttons[gr_screen.res][MC_ACCEPT].button.set_hotkey(KEY_CTRLED+KEY_ENTER); + Multi_create_buttons[gr_screen.res][MC_ACCEPT].button.set_hotkey(KEY_CTRLED+SDLK_RETURN); // init some master tracker stuff Multi_create_frame_count = 0; @@ -4304,7 +4304,7 @@ void multi_create_game_do() switch(k){ // same as the cancel button - case KEY_ESC: + case SDLK_ESCAPE: if(help_overlay_active(MULTI_CREATE_OVERLAY)){ help_overlay_set_state(MULTI_CREATE_OVERLAY,0); } else { @@ -6486,11 +6486,11 @@ void multi_host_options_do() // process any keypresses switch(k){ - case KEY_ESC : + case SDLK_ESCAPE : gameseq_post_event(GS_EVENT_MULTI_HOST_SETUP); break; // same as ACCEPT - case KEY_CTRLED + KEY_ENTER : + case KEY_CTRLED + SDLK_RETURN : gamesnd_play_iface(SND_COMMIT_PRESSED); multi_ho_accept_hit(); break; @@ -7271,7 +7271,7 @@ void multi_game_client_setup_init() Multi_jw_plist_select_button.hide(); // set hotkeys - Multi_jw_buttons[gr_screen.res][MJW_CANCEL].button.set_hotkey(KEY_ESC); + Multi_jw_buttons[gr_screen.res][MJW_CANCEL].button.set_hotkey(SDLK_ESCAPE); // remove campaign flags Game_mode &= ~(GM_CAMPAIGN_MODE); @@ -8173,7 +8173,7 @@ void multi_sync_common_init() Multi_sync_plist_button.hide(); // set up hotkeys for certain common functions - Multi_sync_buttons[gr_screen.res][MS_CANCEL].button.set_hotkey(KEY_ESC); + Multi_sync_buttons[gr_screen.res][MS_CANCEL].button.set_hotkey(SDLK_ESCAPE); } void multi_sync_common_do() @@ -8189,7 +8189,7 @@ void multi_sync_common_do() // process any keypresses switch(k){ - case KEY_ESC : + case SDLK_ESCAPE : // Sync_test = 1; gamesnd_play_iface(SND_USER_SELECT); multi_quit_game(PROMPT_ALL); @@ -9124,7 +9124,7 @@ void multi_sync_create_launch_button() Multi_sync_buttons[gr_screen.res][MS_LAUNCH].button.link_hotspot(Multi_sync_buttons[gr_screen.res][MS_LAUNCH].hotspot); // hotkey - Multi_sync_buttons[gr_screen.res][MS_LAUNCH].button.set_hotkey(KEY_CTRLED+KEY_ENTER); + Multi_sync_buttons[gr_screen.res][MS_LAUNCH].button.set_hotkey(KEY_CTRLED+SDLK_RETURN); #ifndef MAKE_FS1 // create the text for the button @@ -9726,7 +9726,7 @@ void multi_passwd_init() Multi_pwd_passwd.set_focus(); // link the enter key to ACCEPT - Multi_pwd_buttons[gr_screen.res][MPWD_COMMIT].button.set_hotkey(KEY_ENTER); + Multi_pwd_buttons[gr_screen.res][MPWD_COMMIT].button.set_hotkey(SDLK_RETURN); Multi_passwd_done = -1; Multi_passwd_running = 1; @@ -9780,7 +9780,7 @@ void multi_passwd_do(char *passwd) // process any keypresses switch(k){ - case KEY_ESC : + case SDLK_ESCAPE : // set this to indicate the user has cancelled for one reason or another Multi_passwd_done = 0; break; diff --git a/src/network/multiutil.cpp b/src/network/multiutil.cpp index a4f80c1..6a6b691 100644 --- a/src/network/multiutil.cpp +++ b/src/network/multiutil.cpp @@ -297,9 +297,6 @@ extern int MSG_WINDOW_X_START; // used to position multiplayer text messages extern int MSG_WINDOW_Y_START; extern int MSG_WINDOW_HEIGHT; -extern int ascii_table[]; -extern int shifted_ascii_table[]; - // if a client doesn't receive an update for an object after this many seconds, query server // as to the objects status. #define MULTI_CLIENT_OBJ_TIMEOUT 10 @@ -2746,26 +2743,26 @@ int multi_process_restricted_keys(int k) switch(Multi_join_restr_mode){ // normal restricted join, Y or N case MULTI_JOIN_RESTR_MODE_1: - key1 = KEY_Y; - key2 = KEY_N; + key1 = SDLK_y; + key2 = SDLK_n; break; // team vs team, team 0 only has ships case MULTI_JOIN_RESTR_MODE_2: - key1 = KEY_Y; - key2 = KEY_N; + key1 = SDLK_y; + key2 = SDLK_n; break; // team vs team, team 1 only has ships case MULTI_JOIN_RESTR_MODE_3: - key1 = KEY_Y; - key2 = KEY_N; + key1 = SDLK_y; + key2 = SDLK_n; break; // team vs team, both teams have ships case MULTI_JOIN_RESTR_MODE_4: - key1 = KEY_1; - key2 = KEY_2; + key1 = SDLK_1; + key2 = SDLK_2; break; // illegal mode diff --git a/src/osapi/os_unix.cpp b/src/osapi/os_unix.cpp index 4bffead..9b1895b 100644 --- a/src/osapi/os_unix.cpp +++ b/src/osapi/os_unix.cpp @@ -293,7 +293,10 @@ void os_deinit() SDL_Quit(); } -//extern int SDLtoFS2[SDLK_LAST]; +extern void joy_mark_button(int btn, int state); +extern int joystick_get_id(); +extern void joystick_update_axis(int axis, int value); + void os_poll() { SDL_Event e; @@ -338,6 +341,7 @@ void os_poll() break; } */ +printf("KEYDOWN => scan: %d, sym: %d, name: \"%s\"\n", e.key.keysym.scancode, e.key.keysym.sym, SDL_GetKeyName(e.key.keysym.sym)); key_mark(e.key.keysym.scancode, 1, e.key.keysym.mod, 0); break; @@ -356,45 +360,49 @@ void os_poll() break; */ case SDL_JOYAXISMOTION: - // e.jaxis.; + if (e.jaxis.which == joystick_get_id()) { + joystick_update_axis(e.jaxis.axis, e.jaxis.value); + } break; case SDL_JOYBUTTONDOWN: - joy_mark_button((int)e.jbutton.button, 1); - break; - case SDL_JOYBUTTONUP: - joy_mark_button((int)e.jbutton.button, 0); + if (e.jbutton.which == joystick_get_id()) { + state = (e.jbutton.state == SDL_PRESSED) ? 1 : 0; + joy_mark_button((int)e.jbutton.button, state); + } break; case SDL_JOYHATMOTION: - button = JOY_HATFORWARD; - state = 1; - - // can only handle one hat - if (e.jhat.hat == 0) { - switch (e.jhat.value) { - case SDL_HAT_UP: - button = JOY_HATFORWARD; - break; - case SDL_HAT_DOWN: - button = JOY_HATBACK; - break; - case SDL_HAT_LEFT: - button = JOY_HATLEFT; - break; - case SDL_HAT_RIGHT: - button = JOY_HATRIGHT; - break; - default: - // special case - will toggle all hat positions off - button = JOY_HATFORWARD; - state = 0; - break; - + if (e.jhat.which == joystick_get_id()) { + // can only handle one hat + if (e.jhat.hat == 0) { + switch (e.jhat.value) { + case SDL_HAT_UP: + button = JOY_HATFORWARD; + state = 1; + break; + case SDL_HAT_DOWN: + button = JOY_HATBACK; + state = 1; + break; + case SDL_HAT_LEFT: + button = JOY_HATLEFT; + state = 1; + break; + case SDL_HAT_RIGHT: + button = JOY_HATRIGHT; + state = 1; + break; + default: + // special case - will toggle all hat positions off + button = JOY_HATBACK; + state = 0; + break; + } + + joy_mark_button(button, state); } - - joy_mark_button(button, state); } break; diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 8f11814..1032c7f 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -857,8 +857,8 @@ void physics_read_flying_controls( matrix * orient, physics_info * pi, control_i float velocity_ramp (float v_in, float v_goal, float time_const, float t); -// if ( keyd_pressed[KEY_LSHIFT] ) { -// keyd_pressed[KEY_LSHIFT] = 0; +// if ( key_pressed(SDLK_LSHIFT) ) { +// // key_pressed(SDLK_LSHIFT) = 0; // Int3(); // } diff --git a/src/platform/unix.cpp b/src/platform/unix.cpp index 7f88b80..e1555c4 100644 --- a/src/platform/unix.cpp +++ b/src/platform/unix.cpp @@ -311,26 +311,42 @@ void outwnd_close() // STUB_FUNCTION; } */ + +extern void gr_force_windowed(); + void Warning( const char * filename, int line, const char * format, ... ) { char tmp[MAX_LINE_WIDTH*4] = { 0 }; + char tmp2[MAX_LINE_WIDTH*4] = { 0 }; va_list args; - va_start (args, format); - vsnprintf (tmp, sizeof(tmp), format, args); + va_start(args, format); + vsnprintf(tmp, sizeof(tmp), format, args); va_end(args); - fprintf (stderr, "Warning: (%s:%d): %s\n", filename, line, tmp); +// fprintf (stderr, "Warning: (%s:%d): %s\n", filename, line, tmp); + snprintf(tmp2, sizeof(tmp2), "Warning: %s\n\nFile:%s\nLine: %d", tmp, filename, line); + + gr_force_windowed(); + + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning!", tmp2, NULL); } void Error( const char * filename, int line, const char * format, ... ) { char tmp[MAX_LINE_WIDTH*4] = { 0 }; + char tmp2[MAX_LINE_WIDTH*4] = { 0 }; va_list args; va_start (args, format); vsnprintf (tmp, sizeof(tmp), format, args); va_end(args); - fprintf (stderr, "Error: (%s:%d): %s\n", filename, line, tmp); +// fprintf (stderr, "Error: (%s:%d): %s\n", filename, line, tmp); + snprintf(tmp2, sizeof(tmp2), "Error: %s\n\nFile:%s\nLine: %d", tmp, filename, line); + + gr_force_windowed(); + + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error!", tmp2, NULL); + exit (1); } diff --git a/src/playerman/managepilot.cpp b/src/playerman/managepilot.cpp index 9e038a3..b84288b 100644 --- a/src/playerman/managepilot.cpp +++ b/src/playerman/managepilot.cpp @@ -234,6 +234,7 @@ #include "mouse.h" #include "cutscenes.h" #include "bmpman.h" +#include "key.h" // update this when altering data that is read/written to .PLR file #ifndef MAKE_FS1 @@ -294,6 +295,9 @@ void write_stats_block(CFILE *file, scoring_struct *stats); void read_multiplayer_options(player *p,CFILE *file); void write_multiplayer_options(player *p,CFILE *file); +static SDL_Keycode keycode_translate_from(short keycode); +static short keycode_translate_to(SDL_Keycode keycode); + // internal function to delete a player file. Called after a pilot is obsoleted, and when a pilot is deleted // used in barracks and player_select void delete_pilot_file( const char *pilot_name, int single ) @@ -653,7 +657,7 @@ int read_pilot_file(const char *callsign, int single, player *p) if (key_value == 255) key_value = -1; - Control_config[i].key_id = (short) key_value; + Control_config[i].key_id = keycode_translate_from((short)key_value); key_value = cfread_short(file); // NOTE: next two lines are only here for transitioning from 255 to -1 as undefined key items @@ -978,9 +982,11 @@ int write_pilot_file_core(player *p) // --------------------------------------------- // write the keyboard/joystick configuration // --------------------------------------------- + short key_id = 0; cfwrite_ubyte( CCFG_MAX, file ); for (i=0; ipitch += kh; - ci->sideways = (key_down_timef(KEY_PAD3) - key_down_timef(KEY_PAD1)); - ci->vertical = (key_down_timef(KEY_PADPLUS) - key_down_timef(KEY_PADENTER)); + ci->sideways = (key_down_timef(SDLK_KP_3) - key_down_timef(SDLK_KP_1)); + ci->vertical = (key_down_timef(SDLK_KP_PLUS) - key_down_timef(SDLK_KP_ENTER)); do_thrust_keys(ci); } @@ -1045,7 +1045,7 @@ void read_keyboard_controls( control_info * ci, float frame_time, physics_info * // for debugging, check to see if the debug key is down -- if so, make fire the debug laser instead #ifndef NDEBUG - if ( keyd_pressed[KEY_DEBUG_KEY] ) { + if ( key_pressed(KEY_DEBUG_KEY) ) { ci->fire_debug_count = ci->fire_primary_count; ci->fire_primary_count = 0; } diff --git a/src/pofview/pofviewview.cpp b/src/pofview/pofviewview.cpp index 1e0eb5a..bd8f41c 100644 --- a/src/pofview/pofviewview.cpp +++ b/src/pofview/pofviewview.cpp @@ -166,44 +166,44 @@ void CPofViewView::MoveViewer(float FrameTime, BOOL is_active, int key ) } switch(key) { - case KEY_1: + case SDLK_1: if ( n_detail_levels >= 1){ m_current_detail_level = 1; } break; - case KEY_2: + case SDLK_2: if ( n_detail_levels >= 2){ m_current_detail_level = 2; } break; - case KEY_3: + case SDLK_3: if ( n_detail_levels >= 3){ m_current_detail_level = 3; } break; - case KEY_4: + case SDLK_4: if ( n_detail_levels >= 4){ m_current_detail_level = 4; } break; - case KEY_5: + case SDLK_5: if ( n_detail_levels >= 5){ m_current_detail_level = 5; } break; - case KEY_6: + case SDLK_6: if ( n_detail_levels >= 6){ m_current_detail_level = 6; } break; - case KEY_MINUS: + case SDLK_MINUS: // Scales the engines thrusters by this much model_thrust -= 0.1f; if ( model_thrust < 0.0f ){ model_thrust = 0.0f; } break; - case KEY_EQUAL: + case SDLK_EQUALS: // Scales the engines thrusters by this much model_thrust += 0.1f; if ( model_thrust > 1.0f ){ @@ -226,14 +226,14 @@ void CPofViewView::MoveViewer(float FrameTime, BOOL is_active, int key ) ci->heading = temp; ci->pitch = temp1; - if ( keyd_pressed[KEY_BACKSP] ) { + if ( key_pressed(SDLK_BACKSPACE) ) { model_afterburner = 1; } else { model_afterburner = 0; } - kh = (key_down_timef(KEY_PAD6) - key_down_timef(KEY_PAD4)) / 32.0f; + kh = (key_down_timef(SDLK_KP_6) - key_down_timef(SDLK_KP_4)) / 32.0f; if (kh == 0.0f){ ci->heading = 0.0f; } else if (kh > 0.0f) { @@ -247,7 +247,7 @@ void CPofViewView::MoveViewer(float FrameTime, BOOL is_active, int key ) } ci->heading += kh; - kh = (key_down_timef(KEY_PAD8) - key_down_timef(KEY_PAD2)) / 32.0f; + kh = (key_down_timef(SDLK_KP_8) - key_down_timef(SDLK_KP_2)) / 32.0f; if (kh == 0.0f){ ci->pitch = 0.0f; } else if (kh > 0.0f) { @@ -261,10 +261,10 @@ void CPofViewView::MoveViewer(float FrameTime, BOOL is_active, int key ) } ci->pitch += kh; - ci->bank = (key_down_timef(KEY_PAD7) - key_down_timef(KEY_PAD9)) / 8.0f; - ci->forward = (key_down_timef(KEY_A) - key_down_timef(KEY_Z)) * c_scale; - ci->sideways = (key_down_timef(KEY_PAD3) - key_down_timef(KEY_PAD1)) * c_scale; - ci->vertical = (key_down_timef(KEY_PADMINUS) - key_down_timef(KEY_PADPLUS)) * c_scale; + ci->bank = (key_down_timef(SDLK_KP_7) - key_down_timef(SDLK_KP_9)) / 8.0f; + ci->forward = (key_down_timef(SDLK_a) - key_down_timef(SDLK_z)) * c_scale; + ci->sideways = (key_down_timef(SDLK_KP_3) - key_down_timef(SDLK_KP_1)) * c_scale; + ci->vertical = (key_down_timef(SDLK_KP_MINUS) - key_down_timef(SDLK_KP_PLUS)) * c_scale; } else { memset( ci, 0, sizeof(control_info) ); } diff --git a/src/popup/popup.cpp b/src/popup/popup.cpp index e54d6ad..8dd2d65 100644 --- a/src/popup/popup.cpp +++ b/src/popup/popup.cpp @@ -531,21 +531,21 @@ int popup_process_keys(popup_info *pi, int k, int flags) switch(k) { - case KEY_ENTER: + case SDLK_RETURN: // select the current default choice return Popup_default_choice; break; - case KEY_ESC: + case SDLK_ESCAPE: // only process the escape key if this flag is not set if(!(flags & PF_IGNORE_ESC)){ return POPUP_ABORT; } break; - case KEY_DOWN: - case KEY_PAD2: - case KEY_TAB: + case SDLK_DOWN: + case SDLK_KP_2: + case SDLK_TAB: popup_play_default_change_sound(pi); Popup_default_choice++; if ( Popup_default_choice >= pi->nchoices ) { @@ -553,9 +553,9 @@ int popup_process_keys(popup_info *pi, int k, int flags) } break; - case KEY_UP: - case KEY_PAD8: - case KEY_SHIFTED+KEY_TAB: + case SDLK_UP: + case SDLK_KP_8: + case KEY_SHIFTED+SDLK_TAB: popup_play_default_change_sound(pi); Popup_default_choice--; if ( Popup_default_choice < 0 ) { diff --git a/src/popup/popupdead.cpp b/src/popup/popupdead.cpp index 42aa59d..70b5481 100644 --- a/src/popup/popupdead.cpp +++ b/src/popup/popupdead.cpp @@ -395,11 +395,11 @@ int popupdead_process_keys(int k) switch(k) { - case KEY_ENTER: + case SDLK_RETURN: return Popupdead_default_choice; // select the current default choice break; - case KEY_ESC: + case SDLK_ESCAPE: if (Popupdead_skip_active) { return 0; // 0 mimics a "do not skip" } else { @@ -407,9 +407,9 @@ int popupdead_process_keys(int k) } break; - case KEY_DOWN: - case KEY_PAD2: - case KEY_TAB: + case SDLK_DOWN: + case SDLK_KP_2: + case SDLK_TAB: popupdead_play_default_change_sound(); Popupdead_default_choice++; if ( Popupdead_default_choice >= Popupdead_num_choices ) { @@ -417,9 +417,9 @@ int popupdead_process_keys(int k) } break; - case KEY_UP: - case KEY_PAD8: - case KEY_SHIFTED+KEY_TAB: + case SDLK_UP: + case SDLK_KP_8: + case KEY_SHIFTED+SDLK_TAB: popupdead_play_default_change_sound(); Popupdead_default_choice--; if ( Popupdead_default_choice < 0 ) { @@ -427,7 +427,7 @@ int popupdead_process_keys(int k) } break; - case KEY_PAUSE: + case SDLK_PAUSE: game_process_pause_key(); break; diff --git a/src/stats/medals.cpp b/src/stats/medals.cpp index 261ca2c..4924674 100644 --- a/src/stats/medals.cpp +++ b/src/stats/medals.cpp @@ -845,7 +845,7 @@ int medal_main_do() k = Medals_window.process(); // process an exit command - if ((k == KEY_ESC) && (Medals_mode == MM_NORMAL)) { + if ((k == SDLK_ESCAPE) && (Medals_mode == MM_NORMAL)) { gameseq_post_event(GS_EVENT_PREVIOUS_STATE); } @@ -858,7 +858,7 @@ int medal_main_do() } // check to see if a button was pressed - if( (k == (KEY_CTRLED|KEY_ENTER)) || (Medals_buttons[gr_screen.res][MEDALS_EXIT].button.pressed()) ) { + if( (k == (KEY_CTRLED|SDLK_RETURN)) || (Medals_buttons[gr_screen.res][MEDALS_EXIT].button.pressed()) ) { gamesnd_play_iface(SND_COMMIT_PRESSED); if(Medals_mode == MM_NORMAL){ gameseq_post_event(GS_EVENT_PREVIOUS_STATE); diff --git a/src/ui/button.cpp b/src/ui/button.cpp index ec78bb9..af5d093 100644 --- a/src/ui/button.cpp +++ b/src/ui/button.cpp @@ -236,7 +236,7 @@ void UI_BUTTON::create(UI_WINDOW *wnd, const char *_text, int _x, int _y, int _w m_press_linger = 1; first_callback = 1; - hotkey_if_focus = KEY_SPACEBAR; + hotkey_if_focus = SDLK_SPACE; if (ignore_focus){ m_flags |= BF_IGNORE_FOCUS; @@ -460,7 +460,7 @@ void UI_BUTTON::process(int focus) if (my_wnd->keypress == hotkey_if_focus) m_flags |= BF_DOWN | BF_CLICKED; - if ( (hotkey_if_focus == KEY_SPACEBAR) && (my_wnd->keypress == KEY_ENTER) ) + if ( (hotkey_if_focus == SDLK_SPACE) && (my_wnd->keypress == SDLK_RETURN) ) m_flags |= BF_DOWN | BF_CLICKED; } } diff --git a/src/ui/checkbox.cpp b/src/ui/checkbox.cpp index b8d40d0..b10c081 100644 --- a/src/ui/checkbox.cpp +++ b/src/ui/checkbox.cpp @@ -215,11 +215,11 @@ void UI_CHECKBOX::process(int focus) my_wnd->last_keypress = 0; } - if ( focus && ((my_wnd->keypress == KEY_SPACEBAR) || (my_wnd->keypress == KEY_ENTER)) ) + if ( focus && ((my_wnd->keypress == SDLK_SPACE) || (my_wnd->keypress == SDLK_RETURN)) ) position = 2; if (focus) - if ( (oldposition == 2) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER]) ) + if ( (oldposition == 2) && (key_pressed(SDLK_SPACE) || key_pressed(SDLK_RETURN)) ) position = 2; pressed_down = 0; diff --git a/src/ui/inputbox.cpp b/src/ui/inputbox.cpp index e4e97da..b2ac7a9 100644 --- a/src/ui/inputbox.cpp +++ b/src/ui/inputbox.cpp @@ -218,38 +218,38 @@ int is_letter(char c) int keypad_to_ascii(int c) { switch(c){ - case KEY_PAD0: - return key_to_ascii(KEY_0); + case SDLK_KP_0: + return key_to_ascii(SDLK_0); break; - case KEY_PAD1: - return key_to_ascii(KEY_1); + case SDLK_KP_1: + return key_to_ascii(SDLK_1); break; - case KEY_PAD2: - return key_to_ascii(KEY_2); + case SDLK_KP_2: + return key_to_ascii(SDLK_2); break; - case KEY_PAD3: - return key_to_ascii(KEY_3); + case SDLK_KP_3: + return key_to_ascii(SDLK_3); break; - case KEY_PAD4: - return key_to_ascii(KEY_4); + case SDLK_KP_4: + return key_to_ascii(SDLK_4); break; - case KEY_PAD5: - return key_to_ascii(KEY_5); + case SDLK_KP_5: + return key_to_ascii(SDLK_5); break; - case KEY_PAD6: - return key_to_ascii(KEY_6); + case SDLK_KP_6: + return key_to_ascii(SDLK_6); break; - case KEY_PAD7: - return key_to_ascii(KEY_7); + case SDLK_KP_7: + return key_to_ascii(SDLK_7); break; - case KEY_PAD8: - return key_to_ascii(KEY_8); + case SDLK_KP_8: + return key_to_ascii(SDLK_8); break; - case KEY_PAD9: - return key_to_ascii(KEY_9); + case SDLK_KP_9: + return key_to_ascii(SDLK_9); break; - case KEY_PADPERIOD: - return key_to_ascii(KEY_PERIOD); + case SDLK_KP_PERIOD: + return key_to_ascii(SDLK_PERIOD); break; default : return -1; @@ -558,8 +558,8 @@ void UI_INPUTBOX::process(int focus) case 0: break; - //case KEY_LEFT: - case KEY_BACKSP: + //case SDLK_LEFT: + case SDLK_BACKSPACE: if (position > 0) position--; @@ -575,7 +575,7 @@ void UI_INPUTBOX::process(int focus) break; - case KEY_ENTER: + case SDLK_RETURN: pressed_down = 1; locked = 0; changed_flag = 1; @@ -586,7 +586,7 @@ void UI_INPUTBOX::process(int focus) // should_reset = 1; break; - case KEY_ESC: + case SDLK_ESCAPE: if (flags & UI_INPUTBOX_FLAG_ESC_CLR){ if (position > 0) { set_text(""); diff --git a/src/ui/listbox.cpp b/src/ui/listbox.cpp index 167ddfe..455d4c8 100644 --- a/src/ui/listbox.cpp +++ b/src/ui/listbox.cpp @@ -369,46 +369,46 @@ void UI_LISTBOX::process(int focus) kf = 0; switch (my_wnd->keypress) { - case KEY_ENTER: + case SDLK_RETURN: selected_item = current_item; break; - case KEY_SPACEBAR: + case SDLK_SPACE: toggled_item = current_item; break; - case KEY_UP: + case SDLK_UP: current_item--; kf = 1; break; - case KEY_DOWN: + case SDLK_DOWN: current_item++; kf = 1; break; - case KEY_HOME: + case SDLK_HOME: current_item = 0; kf = 1; break; - case KEY_END: + case SDLK_END: current_item=num_items - 1; kf = 1; break; - case KEY_PAGEUP: + case SDLK_PAGEUP: current_item -= num_items_displayed; kf = 1; break; - case KEY_PAGEDOWN: + case SDLK_PAGEDOWN: current_item += num_items_displayed; kf = 1; break; default: // enter the key in the key buffer - if (my_wnd->keypress == KEY_BACKSP) { + if (my_wnd->keypress == SDLK_BACKSPACE) { key_buffer_count = 0; } else if (key_buffer_count < MAX_KEY_BUFFER) { @@ -424,8 +424,10 @@ void UI_LISTBOX::process(int focus) current_text = get_string(i); for (j=0; jlast_keypress = 0; } - if ( focus && ((my_wnd->keypress == KEY_SPACEBAR) || (my_wnd->keypress == KEY_ENTER)) ) + if ( focus && ((my_wnd->keypress == SDLK_SPACE) || (my_wnd->keypress == SDLK_RETURN)) ) position = 2; if (focus) - if ( (oldposition == 2) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER]) ) + if ( (oldposition == 2) && (key_pressed(SDLK_SPACE) || key_pressed(SDLK_RETURN)) ) position = 2; pressed_down = 0; diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp index 1c996b4..339528b 100644 --- a/src/ui/scroll.cpp +++ b/src/ui/scroll.cpp @@ -163,11 +163,11 @@ void UI_SCROLLBAR::create(UI_WINDOW *wnd, int _x, int _y, int _h, int _start, in up_button.create( wnd, up, _x, _y, bw, bw, 1 ); up_button.set_parent(this); - up_button.set_hotkey_if_focus(KEY_UP); + up_button.set_hotkey_if_focus(SDLK_UP); down_button.create( wnd, down, _x, _y + _h - bw, bw, bw, 1 ); down_button.set_parent(this); - down_button.set_hotkey_if_focus(KEY_DOWN); + down_button.set_hotkey_if_focus(SDLK_DOWN); horz = 0; start = _start; @@ -272,7 +272,7 @@ void UI_SCROLLBAR::process(int focus) set_focus(); } /* - if ( (up_button.position != 0) || (focus && keyd_pressed[KEY_UP]) ) { + if ( (up_button.position != 0) || (focus && key_pressed(SDLK_UP)) ) { if ( (timer_get_milliseconds() > last_scrolled + 50) || up_button.just_pressed() ) { if ( up_button.just_pressed() ) { last_scrolled = timer_get_milliseconds() + 300; @@ -300,7 +300,7 @@ void UI_SCROLLBAR::process(int focus) set_focus(); } -/* if ( down_button.position || (keyfocus && keyd_pressed[KEY_DOWN]) ) { +/* if ( down_button.position || (keyfocus && key_pressed(SDLK_DOWN)) ) { if ( (timer_get_milliseconds() > last_scrolled + 50) || down_button.just_pressed() ) { if ( down_button.just_pressed() ) last_scrolled = timer_get_milliseconds() + 300; diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp index e58e793..3b17252 100644 --- a/src/ui/slider.cpp +++ b/src/ui/slider.cpp @@ -592,9 +592,9 @@ void UI_SLIDER::process(int focus) mouse_locked = 0; } - if ( (left_button.position!=0) || (keyfocus && keyd_pressed[KEY_LEFT]) || ( OnMe && B1_PRESSED && ui_mouse.x < marker_x) || (mouse_locked && ui_mouse.x < marker_x ) ) { - if ( (timer_get_milliseconds() > last_scrolled+50) || left_button.just_pressed() || B1_JUST_PRESSED || mouse_locked || my_wnd->keypress == KEY_LEFT) { - if ( left_button.just_pressed() || B1_JUST_PRESSED || mouse_locked || my_wnd->keypress == KEY_LEFT ) { + if ( (left_button.position!=0) || (keyfocus && key_pressed(SDLK_LEFT)) || ( OnMe && B1_PRESSED && ui_mouse.x < marker_x) || (mouse_locked && ui_mouse.x < marker_x ) ) { + if ( (timer_get_milliseconds() > last_scrolled+50) || left_button.just_pressed() || B1_JUST_PRESSED || mouse_locked || my_wnd->keypress == SDLK_LEFT) { + if ( left_button.just_pressed() || B1_JUST_PRESSED || mouse_locked || my_wnd->keypress == SDLK_LEFT ) { last_scrolled = timer_get_milliseconds() + 300; } else last_scrolled = timer_get_milliseconds(); @@ -604,9 +604,9 @@ void UI_SLIDER::process(int focus) } } - if ( (right_button.position!=0) || (keyfocus && keyd_pressed[KEY_RIGHT]) || ( OnMe && B1_PRESSED && ui_mouse.x > (marker_x+marker_w)) || (mouse_locked && ui_mouse.x > marker_x+marker_w) ) { - if ( (timer_get_milliseconds() > last_scrolled+50) || right_button.just_pressed() || B1_JUST_PRESSED || mouse_locked || my_wnd->keypress == KEY_RIGHT) { - if ( right_button.just_pressed() || B1_JUST_PRESSED || mouse_locked || my_wnd->keypress == KEY_RIGHT) + if ( (right_button.position!=0) || (keyfocus && key_pressed(SDLK_RIGHT)) || ( OnMe && B1_PRESSED && ui_mouse.x > (marker_x+marker_w)) || (mouse_locked && ui_mouse.x > marker_x+marker_w) ) { + if ( (timer_get_milliseconds() > last_scrolled+50) || right_button.just_pressed() || B1_JUST_PRESSED || mouse_locked || my_wnd->keypress == SDLK_RIGHT) { + if ( right_button.just_pressed() || B1_JUST_PRESSED || mouse_locked || my_wnd->keypress == SDLK_RIGHT) last_scrolled = timer_get_milliseconds() + 300; else last_scrolled = timer_get_milliseconds(); diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 08c0299..b655b7a 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -788,7 +788,7 @@ void UI_WINDOW::draw_xstrs() void UI_WINDOW::do_dump_check() { #if 0 - if ( keypress == KEY_SHIFTED+KEY_CTRLED+KEY_ALTED+KEY_F12 ) { + if ( keypress == KEY_SHIFTED+KEY_CTRLED+KEY_ALTED+SDLK_F12 ) { FILE *fp; last_keypress = keypress = 0; -- 2.39.2