diff --git a/targets/mega65/configdb.c b/targets/mega65/configdb.c index c2a14190..cd7bbb39 100644 --- a/targets/mega65/configdb.c +++ b/targets/mega65/configdb.c @@ -133,6 +133,7 @@ static const struct xemutools_configdef_num_st num_options[] = { { "sidmask", 15, "Enabled SIDs of the four, in form of a bitmask", &configdb.sidmask, 0, 15 }, { "audiobuffersize", AUDIO_BUFFER_SAMPLES_DEFAULT, "Audio buffer size in BYTES", &configdb.audiobuffersize, AUDIO_BUFFER_SAMPLES_MIN, AUDIO_BUFFER_SAMPLES_MAX }, { "coloureffect", 0, "Colour effect to be applied to the SDL output (0=none, 1=grayscale, 2=green-monitor, ...)", &configdb.colour_effect, 0, 255 }, + { "joyport", 2, "Default joystick port to emulate (1 or 2)", &configdb.joyport, 1, 2 }, { NULL } }; diff --git a/targets/mega65/configdb.h b/targets/mega65/configdb.h index 02c6707d..90cf2f5c 100644 --- a/targets/mega65/configdb.h +++ b/targets/mega65/configdb.h @@ -114,6 +114,7 @@ struct configdb_st { char *winpos; int ramcheckread; char *init_attic; + int joyport; }; extern struct configdb_st configdb; diff --git a/targets/mega65/input_devices.c b/targets/mega65/input_devices.c index e061e649..75d4d5fc 100644 --- a/targets/mega65/input_devices.c +++ b/targets/mega65/input_devices.c @@ -369,6 +369,7 @@ void clear_emu_events ( void ) void input_toggle_joy_emu ( void ) { c64_toggle_joy_emu(); + configdb.joyport = joystick_emu; OSD(-1, -1, "Joystick emulation on port #%d", joystick_emu); } @@ -482,7 +483,6 @@ int emu_callback_key ( int pos, SDL_Scancode key, int pressed, int handled ) #endif ; DEBUGKBD("KBD: HWA: pos = %d sdl_key = %d, pressed = %d, handled = %d" NL, pos, key, pressed, handled); - static int old_joystick_emu_port; // used to remember emulated joy port, as with mouse grab, we need to switch to port-1, and we want to restore user's one on leaving grab mode if (pressed) { // check if we have the ALT-TAB trap triggered (TAB is pressed now, and ALT is hold) if (key == SDL_SCANCODE_TAB && (modkeys & MODKEY_CTRL)) { @@ -514,7 +514,6 @@ int emu_callback_key ( int pos, SDL_Scancode key, int pressed, int handled ) input_toggle_joy_emu(); } else if (((modkeys & (MODKEY_LSHIFT | MODKEY_RSHIFT)) == (MODKEY_LSHIFT | MODKEY_RSHIFT)) && set_mouse_grab(SDL_FALSE, 0)) { DEBUGPRINT("UI: mouse grab cancelled" NL); - joystick_emu = old_joystick_emu_port; } } else { if (pos == RESTORE_KEY_POS) @@ -523,8 +522,6 @@ int emu_callback_key ( int pos, SDL_Scancode key, int pressed, int handled ) if ((handled == SDL_BUTTON_LEFT) && set_mouse_grab(SDL_TRUE, 0)) { OSD(-1, -1, " Mouse grab activated. Press \n both SHIFTs together to cancel."); DEBUGPRINT("UI: mouse grab activated" NL); - old_joystick_emu_port = joystick_emu; - joystick_emu = 1; } if (handled == SDL_BUTTON_RIGHT) { ui_enter(); diff --git a/targets/mega65/mega65.c b/targets/mega65/mega65.c index e1afa4be..e2ced55b 100644 --- a/targets/mega65/mega65.c +++ b/targets/mega65/mega65.c @@ -341,7 +341,7 @@ static void mega65_init ( void ) #ifdef HID_KBD_MAP_CFG_SUPPORT hid_keymap_from_config_file(configdb.keymap); #endif - joystick_emu = 2; // use joystick port #2 by default + joystick_emu = configdb.joyport; nmi_level = 0; // *** FPGA switches ... do {