summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/input
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2022-06-18 10:08:43 -0400
committer AJR <ajrhacker@users.noreply.github.com>2022-06-18 10:08:43 -0400
commit848b631613d5842d258c885722564e3a050d1047 (patch)
tree3b27aa2cc92908bbc11e61526a315dacc7eb71cf /src/osd/modules/input
parentce439f443497bbd312c6b727ebfaee7f57fb2480 (diff)
input_sdlcommon.cpp: Move devmap_init down into class
Diffstat (limited to 'src/osd/modules/input')
-rw-r--r--src/osd/modules/input/input_sdl.cpp2
-rw-r--r--src/osd/modules/input/input_sdlcommon.cpp50
-rw-r--r--src/osd/modules/input/input_sdlcommon.h52
-rw-r--r--src/osd/modules/input/input_x11.cpp2
4 files changed, 56 insertions, 50 deletions
diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp
index 76f8c494f70..731c3683ee6 100644
--- a/src/osd/modules/input/input_sdl.cpp
+++ b/src/osd/modules/input/input_sdl.cpp
@@ -1058,7 +1058,7 @@ public:
m_sixaxis_mode = downcast<const sdl_options *>(options())->sixaxis();
- devmap_init(machine, &m_joy_map, SDLOPTION_JOYINDEX, 8, "Joystick mapping");
+ m_joy_map.init(machine, SDLOPTION_JOYINDEX, 8, "Joystick mapping");
osd_printf_verbose("Joystick: Start initialization\n");
for (int physical_stick = 0; physical_stick < SDL_NumJoysticks(); physical_stick++)
diff --git a/src/osd/modules/input/input_sdlcommon.cpp b/src/osd/modules/input/input_sdlcommon.cpp
index 1f84e28f2f6..659add8dc79 100644
--- a/src/osd/modules/input/input_sdlcommon.cpp
+++ b/src/osd/modules/input/input_sdlcommon.cpp
@@ -13,11 +13,10 @@
#if defined(OSD_SDL)
-// standard sdl header
-#include <SDL2/SDL.h>
+#include "input_sdlcommon.h"
+
#include <cctype>
#include <cstddef>
-#include <mutex>
#include <memory>
#include <algorithm>
@@ -36,7 +35,6 @@
#include "../../sdl/osdsdl.h"
#include "input_common.h"
-#include "input_sdlcommon.h"
#define GET_WINDOW(ev) window_from_id((ev)->windowID)
@@ -292,4 +290,48 @@ void sdl_osd_interface::process_events_buf()
SDL_PumpEvents();
}
+//============================================================
+// devmap_init - initializes a device_map based on
+// an input option prefix and max number of devices
+//============================================================
+
+void device_map_t::init(running_machine &machine, const char *opt, int max_devices, const char *label)
+{
+ int dev;
+ char defname[20];
+
+ // The max devices the user specified, better not be bigger than the max the arrays can old
+ assert(max_devices <= MAX_DEVMAP_ENTRIES);
+
+ // Initialize the map to default uninitialized values
+ for (dev = 0; dev < MAX_DEVMAP_ENTRIES; dev++)
+ {
+ map[dev].name.clear();
+ map[dev].physical = -1;
+ logical[dev] = -1;
+ }
+ initialized = 0;
+
+ // populate the device map up to the max number of devices
+ for (dev = 0; dev < max_devices; dev++)
+ {
+ const char *dev_name;
+
+ // derive the parameter name from the option name and index. For instance: lightgun_index1 to lightgun_index8
+ sprintf(defname, "%s%d", opt, dev + 1);
+
+ // Get the user-specified name that matches the parameter
+ dev_name = machine.options().value(defname);
+
+ // If they've specified a name and it's not "auto", treat it as a custom mapping
+ if (dev_name && *dev_name && strcmp(dev_name, OSDOPTVAL_AUTO))
+ {
+ // remove the spaces from the name store it in the index
+ map[dev].name = remove_spaces(dev_name);
+ osd_printf_verbose("%s: Logical id %d: %s\n", label, dev + 1, map[dev].name);
+ initialized = 1;
+ }
+ }
+}
+
#endif
diff --git a/src/osd/modules/input/input_sdlcommon.h b/src/osd/modules/input/input_sdlcommon.h
index 74b12a875ba..ca71b508f24 100644
--- a/src/osd/modules/input/input_sdlcommon.h
+++ b/src/osd/modules/input/input_sdlcommon.h
@@ -13,7 +13,13 @@
#pragma once
+// standard sdl header
+#include <SDL2/SDL.h>
+
#include <algorithm>
+#include <memory>
+#include <mutex>
+#include <string>
#include <unordered_map>
#define MAX_DEVMAP_ENTRIES 16
@@ -28,6 +34,8 @@ struct device_map_t
} map[MAX_DEVMAP_ENTRIES];
int logical[MAX_DEVMAP_ENTRIES];
int initialized;
+
+ void init(running_machine &machine, const char *opt, int max_devices, const char *label);
};
//============================================================
@@ -131,48 +139,4 @@ static inline std::string remove_spaces(const char *s)
return output;
}
-//============================================================
-// devmap_init - initializes a device_map based on
-// an input option prefix and max number of devices
-//============================================================
-
-static inline void devmap_init(running_machine &machine, device_map_t *devmap, const char *opt, int max_devices, const char *label)
-{
- int dev;
- char defname[20];
-
- // The max devices the user specified, better not be bigger than the max the arrays can old
- assert(max_devices <= MAX_DEVMAP_ENTRIES);
-
- // Initialize the map to default uninitialized values
- for (dev = 0; dev < MAX_DEVMAP_ENTRIES; dev++)
- {
- devmap->map[dev].name.clear();
- devmap->map[dev].physical = -1;
- devmap->logical[dev] = -1;
- }
- devmap->initialized = 0;
-
- // populate the device map up to the max number of devices
- for (dev = 0; dev < max_devices; dev++)
- {
- const char *dev_name;
-
- // derive the parameter name from the option name and index. For instance: lightgun_index1 to lightgun_index8
- sprintf(defname, "%s%d", opt, dev + 1);
-
- // Get the user-specified name that matches the parameter
- dev_name = machine.options().value(defname);
-
- // If they've specified a name and it's not "auto", treat it as a custom mapping
- if (dev_name && *dev_name && strcmp(dev_name, OSDOPTVAL_AUTO))
- {
- // remove the spaces from the name store it in the index
- devmap->map[dev].name = remove_spaces(dev_name);
- osd_printf_verbose("%s: Logical id %d: %s\n", label, dev + 1, devmap->map[dev].name);
- devmap->initialized = 1;
- }
- }
-}
-
#endif // MAME_OSD_INPUT_INPUT_SDLCOMMON_H
diff --git a/src/osd/modules/input/input_x11.cpp b/src/osd/modules/input/input_x11.cpp
index 0657e99fd2d..0cd0caa64df 100644
--- a/src/osd/modules/input/input_x11.cpp
+++ b/src/osd/modules/input/input_x11.cpp
@@ -479,7 +479,7 @@ public:
{
osd_printf_verbose("Lightgun: Begin initialization\n");
- devmap_init(machine, &m_lightgun_map, SDLOPTION_LIGHTGUNINDEX, 8, "Lightgun mapping");
+ m_lightgun_map.init(machine, SDLOPTION_LIGHTGUNINDEX, 8, "Lightgun mapping");
x11_event_manager::instance().initialize();
m_display = x11_event_manager::instance().display();