Skip to content
Permalink
Browse files

Set default keys for input on first run.

We use the following key input if the config `vbam.ini` does not exist:

input  | keyboard
A      | A
B      | S
L      | Q
R      | W
SELECT | Z
START  | X

We also set a joystick default, using the XBOX 360 controller as a
base.

- Fix #463.
  • Loading branch information
denisfa authored and rkitover committed Jul 5, 2019
1 parent 9bc8f33 commit 3dc738b5c558e68c3b148a5a0e155793aa9eb076
Showing with 20 additions and 12 deletions.
  1. +15 −11 src/wx/opts.cpp
  2. +2 −0 src/wx/opts.h
  3. +3 −1 src/wx/wxvbam.cpp
@@ -144,17 +144,17 @@ const wxString joynames[NUM_KEYS] = {

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(wxT('A')), WJKB(wxT('S')), WJKB(wxT('Q')), WJKB(wxT('W')),
WJKB(wxT('Z')), WJKB(wxT('X')),
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, WXJB_BUTTON, 1), WJKB(1, WXJB_BUTTON, 1), WJKB(4, WXJB_BUTTON, 1), WJKB(5, WXJB_BUTTON, 1),
WJKB(6, WXJB_BUTTON, 1), WJKB(7, 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)
@@ -346,13 +346,6 @@ opts_t::opts_t()
bilinear = true;
default_stick = 1;

for (int i = 0; i < NUM_KEYS; i++) {
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);
autofire_rate = 1;
print_auto_page = true;
@@ -368,6 +361,17 @@ bool opt_lt(const opt_desc& opt1, const opt_desc& opt2)
return wxStrcmp(opt1.opt, opt2.opt) < 0;
}

// set default input keys
void set_default_keys()
{
for (int i = 0; i < NUM_KEYS; i++) {
if (defkeys_keyboard[i].key)
gopts.joykey_bindings[0][i].push_back(defkeys_keyboard[i]);
if (defkeys_joystick[i].joy)
gopts.joykey_bindings[0][i].push_back(defkeys_joystick[i]);
}
}

// FIXME: simulate MakeInstanceFilename(vbam.ini) using subkeys (Slave%d/*)
void load_opts()
{
@@ -115,6 +115,8 @@ extern const int num_opts;
extern const wxAcceleratorEntry default_accels[];
extern const int num_def_accels;

// call to setup default keys.
void set_default_keys();
// call to load config (once)
// will write defaults for options not present and delete bad opts
// will also initialize opts[] array translations
@@ -165,6 +165,8 @@ wxString wxvbamApp::GetConfigurationPath()
break;
}
}
// use default keys for input.
set_default_keys();
}

return data_path;
@@ -488,7 +490,7 @@ void wxvbamApp::OnInitCmdLine(wxCmdLineParser& cl)
N_("Print configuration path and exit"),
wxCMD_LINE_VAL_NONE, 0 },
{ wxCMD_LINE_SWITCH, t("f"), t("fullscreen"),
N_("Start in full-screen mode"),
N_("Start in full-screen mode"),
wxCMD_LINE_VAL_NONE, 0 },
#if !defined(NO_LINK) && !defined(__WXMSW__)
{ wxCMD_LINE_SWITCH, t("s"), t("delete-shared-state"),

0 comments on commit 3dc738b

Please sign in to comment.
You can’t perform that action at this time.