Split configuration for default keys.

Split for keyboard and joystick with two arrays variables for
refactoring purposes.
This commit is contained in:
Edênis Freindorfer Azevedo 2019-06-10 23:06:21 -03:00 committed by Rafael Kitover
parent d655031a8f
commit cec1dbfd36
3 changed files with 26 additions and 22 deletions

View File

@ -1654,11 +1654,11 @@ public:
else {
wxJoyKeyBinding_v a;
if (defkeys[i * 2].key)
a.push_back(defkeys[i * 2]);
if (defkeys_keyboard[i].key)
a.push_back(defkeys_keyboard[i]);
if (defkeys[i * 2 + 1].joy)
a.push_back(defkeys[i * 2 + 1]);
if (defkeys_joystick[i].joy)
a.push_back(defkeys_joystick[i]);
tc->SetValue(wxJoyKeyTextCtrl::ToString(a));
}

View File

@ -135,18 +135,22 @@ const wxString joynames[NUM_KEYS] = {
wxT("Speed"), wxT("Capture"), wxT("GS")
};
wxJoyKeyBinding defkeys[NUM_KEYS * 2] = {
WJKB(WXK_UP), WJKB(1, WXJB_AXIS_MINUS, 1), WJKB(WXK_DOWN), WJKB(1, WXJB_AXIS_PLUS, 1),
WJKB(WXK_LEFT), WJKB(0, WXJB_AXIS_MINUS, 1), WJKB(WXK_RIGHT), WJKB(0, WXJB_AXIS_PLUS, 1),
WJKB(wxT('X')), WJKB(0, WXJB_BUTTON, 1), WJKB(wxT('Z')), WJKB(1, WXJB_BUTTON, 1),
WJKB(wxT('A')), WJKB(2, WXJB_BUTTON, 1), WJKB(wxT('S')), WJKB(3, WXJB_BUTTON, 1),
WJKB(WXK_BACK), WJKB(4, WXJB_BUTTON, 1), WJKB(WXK_RETURN), WJKB(5, WXJB_BUTTON, 1),
WJKB(WXK_NUMPAD_UP), WJKB(0), WJKB(WXK_NUMPAD_DOWN), WJKB(0),
WJKB(WXK_NUMPAD_LEFT), WJKB(0), WJKB(WXK_NUMPAD_RIGHT), WJKB(0),
WJKB(WXK_NUMPAD_PAGEUP), WJKB(0), WJKB(WXK_NUMPAD_PAGEDOWN), WJKB(0),
WJKB(wxT('W')), WJKB(0), WJKB(wxT('Q')), WJKB(0),
WJKB(WXK_SPACE), WJKB(0), WJKB(0), WJKB(0),
WJKB(0), WJKB(0)
wxJoyKeyBinding defkeys_keyboard[NUM_KEYS] = {
WJKB(WXK_UP), WJKB(WXK_DOWN), WJKB(WXK_LEFT), WJKB(WXK_RIGHT),
WJKB(wxT('Z')), WJKB(wxT('X')), WJKB(wxT('A')), WJKB(wxT('S')),
WJKB(wxT('C')), WJKB(wxT('V')),
WJKB(0), WJKB(0), WJKB(0), WJKB(0),
WJKB(0), WJKB(0), WJKB(0), WJKB(0),
WJKB(WXK_SPACE), WJKB(0), WJKB(0)
};
wxJoyKeyBinding defkeys_joystick[NUM_KEYS] = {
WJKB(1, WXJB_AXIS_MINUS, 1), WJKB(1, WXJB_AXIS_PLUS, 1), WJKB(0, WXJB_AXIS_MINUS, 1), WJKB(0, WXJB_AXIS_PLUS, 1),
WJKB(0, WXJB_BUTTON, 1), WJKB(1, WXJB_BUTTON, 1), WJKB(2, WXJB_BUTTON, 1), WJKB(3, WXJB_BUTTON, 1),
WJKB(4, WXJB_BUTTON, 1), WJKB(5, WXJB_BUTTON, 1),
WJKB(0), WJKB(0), WJKB(0), WJKB(0),
WJKB(0), WJKB(0), WJKB(0), WJKB(0),
WJKB(0), WJKB(0), WJKB(0)
};
wxAcceleratorEntry_v sys_accels;
@ -336,11 +340,10 @@ opts_t::opts_t()
default_stick = 1;
for (int i = 0; i < NUM_KEYS; i++) {
if (defkeys[i * 2].key)
joykey_bindings[0][i].push_back(defkeys[i * 2]);
if (defkeys[i * 2 + 1].joy)
joykey_bindings[0][i].push_back(defkeys[i * 2 + 1]);
if (defkeys_keyboard[i].key)
joykey_bindings[0][i].push_back(defkeys_keyboard[i]);
if (defkeys_joystick[i].key)
joykey_bindings[0][i].push_back(defkeys_joystick[i]);
}
recent = new wxFileHistory(10);

View File

@ -3,7 +3,8 @@
#define NUM_KEYS 21
extern const wxString joynames[NUM_KEYS];
extern wxJoyKeyBinding defkeys[NUM_KEYS * 2]; // keyboard + joystick defaults
extern wxJoyKeyBinding defkeys_keyboard[NUM_KEYS]; // keyboard defaults
extern wxJoyKeyBinding defkeys_joystick[NUM_KEYS]; // joystick defaults
extern struct opts_t {
opts_t();