osd: Added option to accept SDL game controller/joystick input when losing UI focus.

This commit is contained in:
Vas Crabb 2023-01-14 15:57:22 +11:00
parent 33c6487b88
commit 2592ac32c1
11 changed files with 126 additions and 53 deletions

View File

@ -4,7 +4,7 @@ Universal Command-line Options
==============================
This section contains configuration options that are applicable to *all* MAME
configurations (both including both SDL and Windows native).
configurations (including both SDL and Windows native).
.. contents:: :local:
@ -698,9 +698,10 @@ OSD-related Options
**-controller_map** / **-ctrlmap** *<filename>*
Path to a text file containing game controller button and axis mappings in
the format used by SDL2 and Steam. Must use an ASCII-compatible text
encoding with native line endings (e.g. CRLF on Windows). Currently only
supported when using the ``sdlgame`` joystick provider.
the format used by SDL2 and Steam, or ``none`` to use only built-in
mappings. Must use an ASCII-compatible text encoding with native line
endings (e.g. CRLF on Windows). Currently only supported when using the
``sdlgame`` joystick provider. The default setting is ``none``.
A `community-sourced list of game controller mappings
<https://github.com/gabomdq/SDL_GameControllerDB>`_ can be found on GitHub.
@ -714,10 +715,24 @@ OSD-related Options
in the **config** folder inside your Steam installation folder.
Example:
.. code-bock:: bash
.. code-block:: bash
mame -controller_map gamecontrollerdb.txt sf2ce
.. _mame-commandline-backgroundinput:
**-[no]background_input**
Sets whether input is accepted or ignored when MAME does not have UI focus.
Currently supported for RawInput mouse/keyboard input on Windows, and SDL
game controller/joystick input. This setting is ignored when the debugger
is enabled. The default is OFF (**-nobackground_input**).
Example:
.. code-block:: bash
mame -background_input ssf2tb
.. _mame-commandline-uifontprovider:
**-uifontprovider** *<module>*
@ -912,7 +927,8 @@ Example:
**-joystickprovider** *<module>*
Chooses how MAME will get joystick input. The default is ``auto``.
Chooses how MAME will get joystick and other game controller input. The
default is ``auto``.
.. list-table:: Supported joystick input providers per-platform
:header-rows: 0
@ -941,19 +957,32 @@ Example:
.. [#JIPAutoSDL] On SDL, auto will default to ``sdlgame``.
.. Tip:: Note that Microsoft Xbox 360 and Xbox One controllers connected to
Windows will work best with ``winhybrid`` or ``xinput``. The
``winhybrid`` option supports a mix of DirectInput and XInput
controllers at the same time.
winhybrid
Uses XInput for compatible game controllers, falling back to DirectInput for
other game controllers. Typically provides the best experience on Windows.
dinput
Uses DirectInput for all game controllers. May be useful if you want to use
more than four XInput game controllers simultaneously. Note that LT and RT
controls are combined with using XInput game controllers via DirectInput.
xinput
Supports up to four XInput game controllers.
sdlgame
Uses the SDL game controller API for game controllers with button/axis
mappings available, falling back to the SDL joystick API for other game
controllers. Provides consistent button and axis assignment and meaningful
control names for popular game controllers. Use the :ref:`controller_map
option <mame-commandline-controllermap>` to supply mappings for additional
game controllers or override built-in mappings.
sdljoy
Uses the SDL joystick API for all game controllers.
none
Ignores all game controllers.
Example:
.. code-block:: bash
mame mk2 -joystickprovider winhybrid
.. Tip:: On Windows, winhybrid is likely to give the best experience by
supporting both XInput and DirectInput controllers.
.. _mame-commandline-cliverbs:

View File

@ -1,14 +1,17 @@
.. _index-commandline:
Commandline Index
=================
Command-line Index
==================
This is a complete index of all commandline options and commands for MAME, suitable for quickly finding a given command.
This is a complete index of all command-line options and verbs for MAME,
suitable for quickly finding a given option.
Universal Commandline Options
-----------------------------
This section contains configuration options that are applicable to *all* MAME sub-builds (both SDL and Windows native).
Universal Command-line Options
------------------------------
This section contains configuration options that are applicable to *all* MAME
configurations (including both SDL and Windows native).
Core Verbs
@ -53,6 +56,8 @@ OSD-related Options
~~~~~~~~~~~~~~~~~~~
| :ref:`uimodekey <mame-commandline-uimodekey>`
| :ref:`controller_map <mame-commandline-controllermap>`
| :ref:`background_input <mame-commandline-backgroundinput>`
| :ref:`uifontprovider <mame-commandline-uifontprovider>`
| :ref:`keyboardprovider <mame-commandline-keyboardprovider>`
| :ref:`mouseprovider <mame-commandline-mouseprovider>`
@ -351,8 +356,11 @@ PortAudio Options
| :ref:`pa_latency <mame-commandline-palatency>`
Windows-Specific Commandline Options
------------------------------------
Windows-Specific Command-line Options
-------------------------------------
This section contains configuration options that are specific to the native
(non-SDL) Windows version of MAME.
Windows Performance Options
@ -377,10 +385,12 @@ Windows Input Device Options
| :ref:`[no]dual_lightgun <mame-wcommandline-duallightgun>`
SDL-Specific Commandline Options
--------------------------------
This section contains configuration options that are specific to any build supported by SDL (including Windows where compiled as SDL instead of native).
SDL-Specific Command-line Options
---------------------------------
This section contains configuration options that are specific to any build
supported by SDL (including Windows when built with SDL instead of native).
SDL Performance Options

View File

@ -1,11 +1,11 @@
MAME Commandline Usage and OS-Specific Configuration
----------------------------------------------------
MAME Command-line Usage and OS-Specific Configuration
-----------------------------------------------------
.. toctree::
:titlesonly:
:titlesonly:
commandline-all
windowsconfig
sdlconfig
commandline-all
windowsconfig
sdlconfig
commandline-index
commandline-index

View File

@ -1,10 +1,8 @@
SDL-Specific Commandline Options
================================
This section contains configuration options that are specific to any build
supported by SDL (including Windows where compiled as SDL instead of
native).
supported by SDL (including Windows when built with SDL instead of native).

View File

@ -1,7 +1,8 @@
Windows-Specific Commandline Options
====================================
Windows-Specific Command-line Options
=====================================
This section contains configuration options that are specific to the native (non-SDL) Windows version of MAME.
This section contains configuration options that are specific to the native
(non-SDL) Windows version of MAME.
@ -12,7 +13,10 @@ Performance options
**-priority** *<priority>*
Sets the thread priority for the MAME threads. By default the priority is left alone to guarantee proper cooperation with other applications. The valid range is -15 to 1, with 1 being the highest priority. The default is *0* (*NORMAL priority*).
Sets the thread priority for the MAME threads. By default the priority is
left alone to guarantee proper cooperation with other applications. The
valid range is -15 to 1, with 1 being the highest priority. The default is
*0* (*NORMAL priority*).
.. _mame-wcommandline-profile:
@ -28,25 +32,46 @@ Full screen options
**-[no]triplebuffer** / **-[no]tb**
Enables or disables "triple buffering". Normally, MAME just draws directly to the screen, without any fancy buffering. But with this option enabled, MAME creates three buffers to draw to, and cycles between them in order. It attempts to keep things flowing such that one buffer is currently displayed, the second buffer is waiting to be displayed, and the third buffer is being drawn to. **-triplebuffer** will override **-waitvsync**, if the buffer is successfully created. This option does not work with **-video gdi**. The default is OFF (**-notriplebuffer**).
Enables or disables “triple buffering”. Normally, MAME just draws directly
to the screen, without any fancy buffering. But with this option enabled,
MAME creates three buffers to draw to, and cycles between them in order. It
attempts to keep things flowing such that one buffer is currently displayed,
the second buffer is waiting to be displayed, and the third buffer is being
drawn to. **-triplebuffer** will override **-waitvsync**, if the buffer is
successfully created. This option does not work with **-video gdi**. The
default is OFF (**-notriplebuffer**).
.. _mame-wcommandline-fullscreenbrightness:
**-full_screen_brightness** *<value>* / **-fsb** *<value>*
Controls the brightness, or black level, of the entire display. The standard value is 1.0. Selecting lower values (down to 0.1) will produce a darkened display, while selecting higher values (up to 2.0) will give a brighter display. Note that not all video cards have hardware to support this option. This option does not work with **-video gdi**. The default is ``1.0``.
Controls the brightness, or black level, of the entire display. The
standard value is 1.0. Lower values (down to 0.1) will produce a darkened
display, while higher values (up to 2.0) will give a brighter display. Note
that not all video cards have hardware to support this option. This option
does not work with **-video gdi**. The default is *1.0*.
.. _mame-wcommandline-fullscreencontrast:
**-full_screen_contrast** *<value>* / **-fsc** *<value>*
Controls the contrast, or white level, of the entire display. The standard value is 1.0. Selecting lower values (down to 0.1) will produce a dimmer display, while selecting higher values (up to 2.0) will give a more saturated display. Note that not all video cards have hardware to support this option. This option does not work with **-video gdi**. The default is ``1.0``.
Controls the contrast, or white level, of the entire display. The standard
value is 1.0. Lower values (down to 0.1) will produce a dimmer display,
while higher values (up to 2.0) will give a more saturated display. Note
that not all video cards have hardware to support this option. This option
does not work with **-video gdi**. The default is *1.0*.
.. _mame-wcommandline-fullscreengamma:
**-full_screen_gamma** *<value>* / **-fsg** *<value>*
Controls the gamma, which produces a potentially nonlinear black to white ramp, for the entire display. The standard value is 1.0, which gives a linear ramp from black to white. Selecting lower values (down to 0.1) will increase the nonlinearity toward black, while selecting higher values (up to 3.0) will push the nonlinearity toward white. Note that not all video cards have hardware to support this option. This option does not work with **-video gdi**. The default is ``1.0``.
Controls the gamma, which produces a potentially nonlinear black to white
ramp, for the entire display. The standard value is 1.0, which gives a
linear ramp from black to white. Lower values (down to 0.1) will increase
the nonlinearity toward black, while higher values (up to 3.0) will push the
nonlinearity toward white. Note that not all video cards have hardware to
support this option. This option does not work with **-video gdi**. The
default is *1.0*.
@ -57,4 +82,10 @@ Input device options
**-[no]dual_lightgun** / **-[no]dual**
Controls whether or not MAME attempts to track two lightguns connected at the same time. This option requires -lightgun. This option is a hack for supporting certain older dual lightgun setups. If you have multiple lightguns connected, you will probably just need to enable -mouse and configure each lightgun independently. The default is *OFF* (**-nodual_lightgun**).
Controls whether or not MAME attempts to track two lightguns connected
simultaneously. This option requires the :ref:`lightgun option
<mame-commandline-lightgun>` to be on. This option is a hack for supporting
certain older dual lightgun setups. If you have multiple lightguns
connected, you will probably just need to enable the :ref:`mouse option
<mame-commandline-mouse>` and configure each lightgun independently. The
default is OFF (**-nodual_lightgun**).

View File

@ -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())

View File

@ -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;

View File

@ -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: " },

View File

@ -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); }

View File

@ -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 }

View File

@ -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[];