From 10aa2e5106d0e668c08a4c161fdfd6450aa7f755 Mon Sep 17 00:00:00 2001 From: Kp Date: Thu, 22 Dec 2016 05:21:16 +0000 Subject: [PATCH] Move some kconfig symbols into namespace dsx --- common/main/kconfig.h | 20 +++++++++++--------- similar/main/kconfig.cpp | 37 +++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/common/main/kconfig.h b/common/main/kconfig.h index b444af638..71b011216 100644 --- a/common/main/kconfig.h +++ b/common/main/kconfig.h @@ -88,12 +88,19 @@ extern control_info Controls; #define CONTROL_USING_JOYSTICK 1 #define CONTROL_USING_MOUSE 2 #define MOUSEFS_DELTA_RANGE 512 +#ifdef dsx +namespace dsx { #if defined(DXX_BUILD_DESCENT_I) -#define MAX_DXX_REBIRTH_CONTROLS 30 -#define MAX_CONTROLS 50 +constexpr unsigned MAX_CONTROLS = 50; #elif defined(DXX_BUILD_DESCENT_II) -#define MAX_DXX_REBIRTH_CONTROLS 30 -#define MAX_CONTROLS 60 // there are actually 48, so this leaves room for more +constexpr unsigned MAX_CONTROLS = 60; // there are actually 48, so this leaves room for more +#endif +extern const array, 3> DefaultKeySettings; +} +namespace dcx { +constexpr unsigned MAX_DXX_REBIRTH_CONTROLS = 30; +extern const array DefaultKeySettingsRebirth; +} #endif extern void kconfig_read_controls(const d_event &event, int automap_flag); @@ -110,11 +117,6 @@ enum class kconfig_type void kconfig(kconfig_type n); -#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II) -extern const array, 3> DefaultKeySettings; -extern const array DefaultKeySettingsRebirth; -#endif - extern void kc_set_controls(); //set the cruise speed to zero diff --git a/similar/main/kconfig.cpp b/similar/main/kconfig.cpp index 6eb7813c8..1fed947b3 100644 --- a/similar/main/kconfig.cpp +++ b/similar/main/kconfig.cpp @@ -125,26 +125,38 @@ fix Cruise_speed=0; #define INFO_Y (188) +namespace dcx { + +const array DefaultKeySettingsRebirth{{ 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 }}; + +namespace { + +struct kc_mitem { + uint8_t value; // what key,button,etc +}; + +} + +} + +namespace dsx { + namespace { struct kc_item { const short x, y; // x, y pos of label const short xinput; // x pos of input field - const short w2; // length of input field - const short u,d,l,r; // neighboring field ids for cursor navigation - const ubyte type; - const int state_bit; + const int8_t w2; // length of input field + const uint8_t u,d,l,r; // neighboring field ids for cursor navigation + const uint8_t type; + const uint8_t state_bit; union { - ubyte control_info::state_controls_t::*ci_state_ptr; - ubyte control_info::state_controls_t::*ci_count_ptr; + uint8_t control_info::state_controls_t::*const ci_state_ptr; + uint8_t control_info::state_controls_t::*const ci_count_ptr; }; }; -struct kc_mitem { - ubyte value; // what key,button,etc -}; - struct kc_menu : embed_window_pointer_t { const char *litems; @@ -175,7 +187,6 @@ const array, 3> DefaultKeySettings{{ {{0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0}}, #endif }}; -const array DefaultKeySettingsRebirth{{ 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 constexpr kc_item kc_keyboard[] = { @@ -638,6 +649,8 @@ constexpr const char *kcl_rebirth = ; static array kcm_rebirth; +} + static void kc_drawinput( const kc_item &item, kc_mitem& mitem, int is_current, const char *label ); static void kc_change_key( kc_menu &menu,const d_event &event, kc_mitem& mitem ); #if DXX_MAX_BUTTONS_PER_JOYSTICK || DXX_MAX_HATS_PER_JOYSTICK @@ -1103,7 +1116,7 @@ static void reset_mitem_values(array &m, const array &c) m[i].value = c[i]; } -static void step_citem_past_empty_cell(unsigned &citem, const kc_item *items, const short kc_item::*next) +static void step_citem_past_empty_cell(unsigned &citem, const kc_item *const items, const uint8_t kc_item::*const next) { do { citem = items[citem].*next;