diff --git a/common/main/kconfig.h b/common/main/kconfig.h index 878c376a6..45ea1f7b1 100644 --- a/common/main/kconfig.h +++ b/common/main/kconfig.h @@ -55,14 +55,12 @@ typedef struct _control_info { #if defined(DXX_BUILD_DESCENT_I) #define NUM_DXX_REBIRTH_CONTROLS 30 #define MAX_DXX_REBIRTH_CONTROLS 30 -#define NUM_KEY_CONTROLS 50 #define NUM_JOYSTICK_CONTROLS 48 #define NUM_MOUSE_CONTROLS 29 #define MAX_CONTROLS 50 #elif defined(DXX_BUILD_DESCENT_II) #define NUM_DXX_REBIRTH_CONTROLS 30 #define MAX_DXX_REBIRTH_CONTROLS 30 -#define NUM_KEY_CONTROLS 57 #define NUM_JOYSTICK_CONTROLS 56 #define NUM_MOUSE_CONTROLS 30 #define MAX_CONTROLS 60 // there are actually 48, so this leaves room for more diff --git a/similar/main/kconfig.cpp b/similar/main/kconfig.cpp index 92a2b7d15..91dee80f7 100644 --- a/similar/main/kconfig.cpp +++ b/similar/main/kconfig.cpp @@ -22,6 +22,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include #include +#include #include "dxxerror.h" #include "pstypes.h" @@ -133,7 +134,7 @@ const ubyte DefaultKeySettings[3][MAX_CONTROLS] = { const ubyte DefaultKeySettingsRebirth[MAX_DXX_REBIRTH_CONTROLS] = { 0x2,0xff,0xff,0x3,0xff,0xff,0x4,0xff,0xff,0x5,0xff,0xff,0x6,0xff,0xff,0x7,0xff,0xff,0x8,0xff,0xff,0x9,0xff,0xff,0xa,0xff,0xff,0xb,0xff,0xff }; // id, x, y, w1, w2, u, d, l, r, text, type, value -kc_item kc_keyboard[NUM_KEY_CONTROLS] = { +kc_item kc_keyboard[] = { #if defined(DXX_BUILD_DESCENT_I) { 15, 49, 86, 26, 43, 2, 49, 1,"Pitch forward", BT_KEY, 255, &Controls.key_pitch_forward_state, STATE_BIT1, NULL }, { 15, 49,115, 26, 48, 3, 0, 24,"Pitch forward", BT_KEY, 255, &Controls.key_pitch_forward_state, STATE_BIT2, NULL }, @@ -442,7 +443,7 @@ static void kc_change_invert( kc_menu *menu, kc_item * item ); static void kc_drawquestion( kc_menu *menu, kc_item *item ); #ifdef TABLE_CREATION -static int find_item_at( kc_item * items, unsigned nitems, int x, int y ) +static int find_item_at( const kc_item * items, unsigned nitems, int x, int y ) { for (unsigned i=0; i +static int find_next_item_up( const kc_item (&items)[nitems], int citem ) +{ + return find_next_item_up(items, nitems, citem); +} + +template +static int find_next_item_down( const kc_item (&items)[nitems], int citem ) +{ + return find_next_item_down(items, nitems, citem); +} + +template +static int find_next_item_right( const kc_item (&items)[nitems], int citem ) +{ + return find_next_item_right(items, nitems, citem); +} + +template +static int find_next_item_left( const kc_item (&items)[nitems], int citem ) +{ + return find_next_item_left(items, nitems, citem); +} #endif static const char *get_item_text(const kc_item *item, char (&buf)[10]) @@ -797,7 +822,7 @@ static int kconfig_key_command(window *wind, d_event *event, kc_menu *menu) return 1; case KEY_CTRLED+KEY_R: if ( menu->items==kc_keyboard ) - for (unsigned i=0; iitems[i].value=DefaultKeySettings[0][i]; if ( menu->items==kc_joystick ) @@ -845,11 +870,11 @@ static int kconfig_key_command(window *wind, d_event *event, kc_menu *menu) case KEY_F12: { static const char *const btype_text[] = { "BT_KEY", "BT_MOUSE_BUTTON", "BT_MOUSE_AXIS", "BT_JOY_BUTTON", "BT_JOY_AXIS", "BT_INVERT" }; PHYSFS_file * fp; - for (unsigned i=0; i +static void kconfig_sub(kc_item (&items)[N], const char *title) +{ + kconfig_sub(items, N, title); +} static void kc_drawitem( kc_item *item, int is_current ) { @@ -1255,7 +1285,7 @@ void kconfig(int n, const char * title) switch(n) { - case 0:kconfig_sub( kc_keyboard,NUM_KEY_CONTROLS, title); break; + case 0:kconfig_sub( kc_keyboard,title); break; case 1:kconfig_sub( kc_joystick,NUM_JOYSTICK_CONTROLS,title); break; case 2:kconfig_sub( kc_mouse, NUM_MOUSE_CONTROLS, title); break; case 3:kconfig_sub( kc_rebirth, NUM_DXX_REBIRTH_CONTROLS, title ); break; @@ -1285,7 +1315,7 @@ void kconfig_read_controls(d_event *event, int automap_flag) { case EVENT_KEY_COMMAND: case EVENT_KEY_RELEASE: - for (i = 0; i < NUM_KEY_CONTROLS; i++) + for (i = 0; i < (sizeof(kc_keyboard) / sizeof(kc_keyboard[0])); i++) { if (kc_keyboard[i].value < 255 && kc_keyboard[i].value == event_key_get_raw(event)) { @@ -1736,7 +1766,7 @@ void reset_cruise(void) void kc_set_controls() { - for (unsigned i=0; i