diff options
| author | 2023-01-29 03:02:02 +1100 | |
|---|---|---|
| committer | 2023-01-29 03:16:14 +1100 | |
| commit | 68472d3d72ea4bbc545c0669348172b4e96c7b41 (patch) | |
| tree | e34fca0f55c977624148d1c806ecc6c44a5edd11 /src/osd/modules/netdev | |
| parent | 01fcb2e0decf670a4cdee3d37b6f7ebde9b8f02b (diff) | |
Various input and OSD refactoring:
osd: Supply OSD object to modules on initialisation. Encapsulated some
event handling in the OSD objects rather than leaving it in free
functions. Put various stuff in namespaces.
osd/modules/input: Enabled dinput, xinput and winhybrid modules for
Windows SDL builds, and enabled background input for dinput and xinput
(and by extension winhybrid) modules. Also fixed some COM and X11
resource leaks.
osd/modules/input/input_sdl.cpp: Flipped SDL mouse button order to match
Windows, and exposed vertical and horizontal scroll as Z and rZ axes.
Moved SDL UI event handling out of input devices into OSD object.
osd/modules/input_rawinput.cpp: Changed lightgun Z axis token so it's
correctly identified as a relative axis (it maps to the scroll wheel
equivalent).
osd: Added an option to choose the network provider module. Mostly
useful if you build with both TUN/TAP and pcap support included, or if
you want to disable emulated networking completely.
emu/input.cpp: Use a better strategy for assembling input code names
that uses fewer temporary strings and doesn't require use of the
non-Unicode-aware space trimming function (fixes MT08552).
osd/modules/input_dinput.cpp: Improved polling logic.
osd: Made various parts of the input code less dependent on concrete emu
objects, and reduced inappropriately passing around the machine object.
Made input modules less dependent on OSD implementation. Encapsulated
some stuff and got rid of some vestigial newui and SDL1 support code.
Cleaned up some interfaces. Moved OSD options classes to their own
files.
Prepare to remove main.h from emu.h - it's mostly used to get the
application name, which the vast majority of emulated devices don't need
to do.
Diffstat (limited to 'src/osd/modules/netdev')
| -rw-r--r-- | src/osd/modules/netdev/netdev_module.h | 14 | ||||
| -rw-r--r-- | src/osd/modules/netdev/none.cpp | 18 | ||||
| -rw-r--r-- | src/osd/modules/netdev/pcap.cpp | 25 | ||||
| -rw-r--r-- | src/osd/modules/netdev/taptun.cpp | 25 |
4 files changed, 53 insertions, 29 deletions
diff --git a/src/osd/modules/netdev/netdev_module.h b/src/osd/modules/netdev/netdev_module.h index b1d537cacf5..b102e56fbb8 100644 --- a/src/osd/modules/netdev/netdev_module.h +++ b/src/osd/modules/netdev/netdev_module.h @@ -4,25 +4,23 @@ * netdev_module.h * */ +#ifndef MAME_OSD_NETDEV_NETDEV_MODULE_H +#define MAME_OSD_NETDEV_NETDEV_MODULE_H -#ifndef NETDEV_MODULE_H_ -#define NETDEV_MODULE_H_ +#pragma once -#include "osdepend.h" -#include "modules/osdmodule.h" //============================================================ // CONSTANTS //============================================================ -#define OSD_NETDEV_PROVIDER "netdevprovider" +#define OSD_NETDEV_PROVIDER "networkprovider" class netdev_module { public: - virtual ~netdev_module() { } + virtual ~netdev_module() = default; // no specific routines below ... may change }; - -#endif /* NETDEV_MODULE_H_ */ +#endif // MAME_OSD_NETDEV_NETDEV_MODULE_H diff --git a/src/osd/modules/netdev/none.cpp b/src/osd/modules/netdev/none.cpp index a5b520f26a5..8441c002802 100644 --- a/src/osd/modules/netdev/none.cpp +++ b/src/osd/modules/netdev/none.cpp @@ -4,20 +4,28 @@ * none.c * */ - #include "netdev_module.h" + #include "modules/osdmodule.h" + +namespace osd { + +namespace { + class netdev_none : public osd_module, public netdev_module { public: - netdev_none() - : osd_module(OSD_NETDEV_PROVIDER, "none"), netdev_module() + netdev_none() : osd_module(OSD_NETDEV_PROVIDER, "none"), netdev_module() { } virtual ~netdev_none() { } - virtual int init(const osd_options &options) override { return 0; } + virtual int init(osd_interface &osd, const osd_options &options) override { return 0; } }; -MODULE_DEFINITION(NETDEV_NONE, netdev_none) +} // anonymous namespace + +} // namespace osd + +MODULE_DEFINITION(NETDEV_NONE, osd::netdev_none) diff --git a/src/osd/modules/netdev/pcap.cpp b/src/osd/modules/netdev/pcap.cpp index 3ff82484b28..e8e0559e9bf 100644 --- a/src/osd/modules/netdev/pcap.cpp +++ b/src/osd/modules/netdev/pcap.cpp @@ -1,13 +1,15 @@ // license:BSD-3-Clause // copyright-holders:Carl +#include "netdev_module.h" + +#include "modules/osdmodule.h" + #if defined(OSD_NET_USE_PCAP) #include "emu.h" #include "dinetwork.h" #include "osdnet.h" -#include "netdev_module.h" -#include "modules/osdmodule.h" #include "modules/lib/osdlib.h" #if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS) @@ -26,6 +28,10 @@ #include <pcap.h> +namespace osd { + +namespace { + // Typedefs for dynamically loaded functions typedef int (*pcap_findalldevs_fn)(pcap_if_t **, char *); typedef pcap_t *(*pcap_open_live_fn)(const char *, int, int, int, char *); @@ -49,7 +55,7 @@ public: virtual ~pcap_module() { } - virtual int init(const osd_options &options) override; + virtual int init(osd_interface &osd, const osd_options &options) override; virtual void exit() override; virtual bool probe() override @@ -255,7 +261,7 @@ static CREATE_NETDEV(create_pcap) return dynamic_cast<osd_netdev *>(dev); } -int pcap_module::init(const osd_options &options) +int pcap_module::init(osd_interface &osd, const osd_options &options) { pcap_if_t *devs; char errbuf[PCAP_ERRBUF_SIZE]; @@ -286,12 +292,15 @@ void pcap_module::exit() clear_netdev(); } +} // anonymous namespace + +} // namespace osd + #else - #include "modules/osdmodule.h" - #include "netdev_module.h" - MODULE_NOT_SUPPORTED(pcap_module, OSD_NETDEV_PROVIDER, "pcap") +namespace osd { namespace { MODULE_NOT_SUPPORTED(pcap_module, OSD_NETDEV_PROVIDER, "pcap") } } + #endif -MODULE_DEFINITION(NETDEV_PCAP, pcap_module) +MODULE_DEFINITION(NETDEV_PCAP, osd::pcap_module) diff --git a/src/osd/modules/netdev/taptun.cpp b/src/osd/modules/netdev/taptun.cpp index 10ca76fb2d0..a1b8d4d84ce 100644 --- a/src/osd/modules/netdev/taptun.cpp +++ b/src/osd/modules/netdev/taptun.cpp @@ -1,5 +1,9 @@ // license:BSD-3-Clause // copyright-holders:Carl +#include "netdev_module.h" + +#include "modules/osdmodule.h" + #if defined(OSD_NET_USE_TAPTUN) #if defined(_WIN32) @@ -16,8 +20,6 @@ #include "emu.h" #include "dinetwork.h" #include "osdnet.h" -#include "modules/osdmodule.h" -#include "netdev_module.h" #include "unicode.h" #ifdef __linux__ @@ -32,6 +34,10 @@ #define PRODUCT_TAP_WIN_COMPONENT_ID "tap0901" #endif +namespace osd { + +namespace { + // Ethernet minimum frame length static constexpr int ETHERNET_MIN_FRAME = 64; @@ -44,7 +50,7 @@ public: } virtual ~taptun_module() { } - virtual int init(const osd_options &options); + virtual int init(osd_interface &osd, const osd_options &options); virtual void exit(); virtual bool probe() { return true; } @@ -343,7 +349,7 @@ static CREATE_NETDEV(create_tap) return dynamic_cast<osd_netdev *>(dev); } -int taptun_module::init(const osd_options &options) +int taptun_module::init(osd_interface &osd, const osd_options &options) { #if defined(_WIN32) for (std::wstring &id : get_tap_adapters()) @@ -359,13 +365,16 @@ void taptun_module::exit() clear_netdev(); } +} // anonymous namespace + +} // namespace osd + #else - #include "modules/osdmodule.h" - #include "netdev_module.h" - MODULE_NOT_SUPPORTED(taptun_module, OSD_NETDEV_PROVIDER, "taptun") +namespace osd { namespace { MODULE_NOT_SUPPORTED(taptun_module, OSD_NETDEV_PROVIDER, "taptun") } } + #endif -MODULE_DEFINITION(NETDEV_TAPTUN, taptun_module) +MODULE_DEFINITION(NETDEV_TAPTUN, osd::taptun_module) |
