diff options
author | 2023-01-14 15:57:22 +1100 | |
---|---|---|
committer | 2023-01-14 15:57:22 +1100 | |
commit | 2592ac32c15622249028fecfb2043eda3129e8be (patch) | |
tree | b262f0ffdfab902617d3972a2e5e00815bd8808e /src | |
parent | 33c6487b886eacad916a12637a575ad563fa9e61 (diff) |
osd: Added option to accept SDL game controller/joystick input when losing UI focus.
Diffstat (limited to 'src')
-rw-r--r-- | src/osd/modules/input/input_rawinput.cpp | 4 | ||||
-rw-r--r-- | src/osd/modules/input/input_sdl.cpp | 13 | ||||
-rw-r--r-- | src/osd/modules/lib/osdobj_common.cpp | 3 | ||||
-rw-r--r-- | src/osd/modules/lib/osdobj_common.h | 2 | ||||
-rw-r--r-- | src/osd/windows/winmain.cpp | 1 | ||||
-rw-r--r-- | src/osd/windows/winmain.h | 2 |
6 files changed, 15 insertions, 10 deletions
diff --git a/src/osd/modules/input/input_rawinput.cpp b/src/osd/modules/input/input_rawinput.cpp index 94018f9c404..c681017a061 100644 --- a/src/osd/modules/input/input_rawinput.cpp +++ b/src/osd/modules/input/input_rawinput.cpp @@ -481,9 +481,9 @@ public: for (int devnum = retrieved - 1; devnum >= 0; devnum--) add_rawinput_device(machine, rawinput_devices[devnum]); - // don't enable global inputs when debugging + // don't enable background input when debugging if (!machine.options().debug()) - m_global_inputs_enabled = downcast<windows_options &>(machine.options()).global_inputs(); + m_global_inputs_enabled = options()->background_input(); // If we added no devices, no need to register for notifications if (devicelist().empty()) diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index b54af499dbb..295935fda88 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -1859,6 +1859,11 @@ public: virtual void input_init(running_machine &machine) override { + auto &sdlopts = downcast<sdl_options const &>(*options()); + bool const sixaxis_mode = sdlopts.sixaxis(); + + if (!machine().options().debug && sdlopts.background_input()) + SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); init_joystick(); @@ -1867,8 +1872,6 @@ public: sdl_joystick_module_base::input_init(machine); - bool const sixaxis_mode = downcast<const sdl_options *>(options())->sixaxis(); - osd_printf_verbose("Joystick: Start initialization\n"); for (int physical_stick = 0; physical_stick < SDL_NumJoysticks(); physical_stick++) create_joystick_device(machine, physical_stick, sixaxis_mode); @@ -1947,11 +1950,13 @@ public: virtual void input_init(running_machine &machine) override { - SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); - auto &sdlopts = downcast<sdl_options const &>(*options()); bool const sixaxis_mode = sdlopts.sixaxis(); + if (!machine().options().debuge() && sdlopts.background_input()) + SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); + SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); + init_joystick(); if (!have_joystick()) return; diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index c6f551b63fc..9aab7f1dec0 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -29,13 +29,14 @@ const options_entry osd_options::s_option_entries[] = { - { nullptr, nullptr, core_options::option_type::HEADER, "OSD KEYBOARD MAPPING OPTIONS" }, + { nullptr, nullptr, core_options::option_type::HEADER, "OSD INPUT MAPPING OPTIONS" }, #if defined(SDLMAME_MACOSX) || defined(OSD_MAC) { OSDOPTION_UIMODEKEY, "DEL", core_options::option_type::STRING, "key to enable/disable MAME controls when emulated system has keyboard inputs" }, #else { OSDOPTION_UIMODEKEY, "auto", core_options::option_type::STRING, "key to enable/disable MAME controls when emulated system has keyboard inputs" }, #endif // SDLMAME_MACOSX { OSDOPTION_CONTROLLER_MAP_FILE ";ctrlmap", OSDOPTVAL_NONE, core_options::option_type::PATH, "game controller mapping file" }, + { OSDOPTION_BACKGROUND_INPUT, "0", core_options::option_type::BOOLEAN, "don't ignore input when losing UI focus" }, { nullptr, nullptr, core_options::option_type::HEADER, "OSD FONT OPTIONS" }, { OSD_FONT_PROVIDER, OSDOPTVAL_AUTO, core_options::option_type::STRING, "provider for UI font: " }, diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index 92a9a498c3c..bf680195fca 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -36,6 +36,7 @@ #define OSDOPTION_UIMODEKEY "uimodekey" #define OSDOPTION_CONTROLLER_MAP_FILE "controller_map" +#define OSDOPTION_BACKGROUND_INPUT "background_input" #define OSDCOMMAND_LIST_MIDI_DEVICES "listmidi" #define OSDCOMMAND_LIST_NETWORK_ADAPTERS "listnetwork" @@ -109,6 +110,7 @@ public: // keyboard mapping const char *ui_mode_key() const { return value(OSDOPTION_UIMODEKEY); } const char *controller_mapping_file() const { return value(OSDOPTION_CONTROLLER_MAP_FILE); } + bool background_input() const { return bool_value(OSDOPTION_BACKGROUND_INPUT); } // debugging options const char *debugger() const { return value(OSDOPTION_DEBUGGER); } diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index 91c78be5b20..3311031228f 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -276,7 +276,6 @@ const options_entry windows_options::s_option_entries[] = // input options { nullptr, nullptr, core_options::option_type::HEADER, "INPUT DEVICE OPTIONS" }, - { WINOPTION_GLOBAL_INPUTS, "0", core_options::option_type::BOOLEAN, "enable global inputs" }, { WINOPTION_DUAL_LIGHTGUN ";dual", "0", core_options::option_type::BOOLEAN, "enable dual lightgun input" }, { nullptr } diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 7c1689cff9f..7c148c94e5b 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -116,7 +116,6 @@ #define WINOPTION_FULLSCREENGAMMA "full_screen_gamma" // input options -#define WINOPTION_GLOBAL_INPUTS "global_inputs" #define WINOPTION_DUAL_LIGHTGUN "dual_lightgun" //============================================================ @@ -228,7 +227,6 @@ public: float full_screen_gamma() const { return float_value(WINOPTION_FULLSCREENGAMMA); } // input options - bool global_inputs() const { return bool_value(WINOPTION_GLOBAL_INPUTS); } bool dual_lightgun() const { return bool_value(WINOPTION_DUAL_LIGHTGUN); } static const options_entry s_option_entries[]; |