diff --git a/include/core/joystickapi.hpp b/include/core/joystickapi.hpp new file mode 100644 index 00000000..13adb445 --- /dev/null +++ b/include/core/joystickapi.hpp @@ -0,0 +1,37 @@ +#ifndef _joystickapi__hpp__included__ +#define _joystickapi__hpp__included__ + +/** + * Joystick initialization function. + * + * - The third initialization function to be called by window_init(). + * - The call occurs in the main thread. + * - Implemented by the joystick plugin. + */ +void joystick_driver_init() throw(); +/** + * Joystick quit function. + * + * - The third last quit function to be called by window_quit(). + * - The call occurs in the main thread. + * - Implemented by the joystick plugin. + */ +void joystick_driver_quit() throw(); +/** + * This thread becomes the joystick polling thread. + * + * - Called in joystick polling thread. + */ +void joystick_driver_thread_fn() throw(); +/** + * Signal the joystick thread to quit. + */ +void joystick_driver_signal() throw(); +/** + * Identification for joystick plugin. + */ +const char* joystick_driver_name; + +#endif + + diff --git a/include/core/window.hpp b/include/core/window.hpp index c80d7db4..ce15e673 100644 --- a/include/core/window.hpp +++ b/include/core/window.hpp @@ -100,46 +100,6 @@ struct graphics_plugin static const char* name; }; -/** - * Functions implemented by the joystick plugin. - * - * Unless explicitly noted otherwise, all the methods are to be called from emulation thread if that exists, otherwise - * from the main thread. - */ -struct joystick_plugin -{ -/** - * Joystick initialization function. - * - * - The third initialization function to be called by window_init(). - * - The call occurs in the main thread. - * - Implemented by the joystick plugin. - */ - static void init() throw(); -/** - * Joystick quit function. - * - * - The third last quit function to be called by window_quit(). - * - The call occurs in the main thread. - * - Implemented by the joystick plugin. - */ - static void quit() throw(); -/** - * This thread becomes the joystick polling thread. - * - * - Called in joystick polling thread. - */ - static void thread_fn() throw(); -/** - * Signal the joystick thread to quit. - */ - static void signal() throw(); -/** - * Identification for joystick plugin. - */ - static const char* name; -}; - /** * Platform-specific-related functions. */ diff --git a/src/core/joystick.cpp b/src/core/joystick.cpp index 2cbb4771..a53f7cd5 100644 --- a/src/core/joystick.cpp +++ b/src/core/joystick.cpp @@ -1,5 +1,6 @@ #include "core/command.hpp" #include "core/joystick.hpp" +#include "core/joystickapi.hpp" #include "core/window.hpp" #include "core/keymapper.hpp" #include "library/keyboard.hpp" @@ -20,7 +21,7 @@ namespace function_ptr_command<> show_joysticks(lsnes_cmd, "show-joysticks", "Show joysticks", "Syntax: show-joysticks\nShow joystick data.\n", []() throw(std::bad_alloc, std::runtime_error) { - messages << "Driver: " << joystick_plugin::name << std::endl; + messages << "Driver: " << joystick_driver_name << std::endl; messages << "--------------------------------------" << std::endl; for(auto i : joynumbers) messages << joysticks[i.first].compose_report(i.second) << std::endl; diff --git a/src/core/window.cpp b/src/core/window.cpp index 00eca75d..cb8f6c56 100644 --- a/src/core/window.cpp +++ b/src/core/window.cpp @@ -2,6 +2,7 @@ #include "core/command.hpp" #include "core/dispatch.hpp" #include "core/framerate.hpp" +#include "core/joystickapi.hpp" #include "lua/lua.hpp" #include "core/misc.hpp" #include "core/window.hpp" @@ -63,7 +64,7 @@ namespace []() throw(std::bad_alloc, std::runtime_error) { messages << "Graphics:\t" << graphics_plugin::name << std::endl; messages << "Sound:\t" << audioapi_driver_name << std::endl; - messages << "Joystick:\t" << joystick_plugin::name << std::endl; + messages << "Joystick:\t" << joystick_driver_name << std::endl; }); function_ptr_command enable_sound(lsnes_cmd, "enable-sound", "Enable/Disable sound", @@ -244,12 +245,12 @@ void platform::init() graphics_plugin::init(); audioapi_init(); audioapi_driver_init(); - joystick_plugin::init(); + joystick_driver_init(); } void platform::quit() { - joystick_plugin::quit(); + joystick_driver_quit(); audioapi_driver_quit(); audioapi_quit(); graphics_plugin::quit(); diff --git a/src/dummy/joystick.cpp b/src/dummy/joystick.cpp index 83c2c611..1abda40e 100644 --- a/src/dummy/joystick.cpp +++ b/src/dummy/joystick.cpp @@ -1,19 +1,19 @@ -#include "core/window.hpp" +#include "core/joystickapi.hpp" -void joystick_plugin::init() throw() +void joystick_driver_init() throw() { } -void joystick_plugin::quit() throw() +void joystick_driver_quit() throw() { } -void joystick_plugin::thread_fn() throw() +void joystick_driver_thread_fn() throw() { } -void joystick_plugin::signal() throw() +void joystick_driver_signal() throw() { } -const char* joystick_plugin::name = "Dummy joystick plugin"; +const char* joystick_driver_name = "Dummy joystick plugin"; diff --git a/src/platform/dummy/joystick.cpp b/src/platform/dummy/joystick.cpp index 83c2c611..1abda40e 100644 --- a/src/platform/dummy/joystick.cpp +++ b/src/platform/dummy/joystick.cpp @@ -1,19 +1,19 @@ -#include "core/window.hpp" +#include "core/joystickapi.hpp" -void joystick_plugin::init() throw() +void joystick_driver_init() throw() { } -void joystick_plugin::quit() throw() +void joystick_driver_quit() throw() { } -void joystick_plugin::thread_fn() throw() +void joystick_driver_thread_fn() throw() { } -void joystick_plugin::signal() throw() +void joystick_driver_signal() throw() { } -const char* joystick_plugin::name = "Dummy joystick plugin"; +const char* joystick_driver_name = "Dummy joystick plugin"; diff --git a/src/platform/evdev/joystick.cpp b/src/platform/evdev/joystick.cpp index 8a863115..502b0104 100644 --- a/src/platform/evdev/joystick.cpp +++ b/src/platform/evdev/joystick.cpp @@ -1,6 +1,7 @@ #include "core/command.hpp" #include "core/keymapper.hpp" #include "core/joystick.hpp" +#include "core/joystickapi.hpp" #include "core/window.hpp" #include "library/string.hpp" @@ -288,13 +289,13 @@ namespace volatile bool quit_ack = false; } -void joystick_plugin::init() throw() +void joystick_driver_init() throw() { probe_all_joysticks(); quit_ack = quit_signaled = false; } -void joystick_plugin::quit() throw() +void joystick_driver_quit() throw() { quit_signaled = true; while(!quit_ack); @@ -303,7 +304,7 @@ void joystick_plugin::quit() throw() #define POLL_WAIT 20000 -void joystick_plugin::thread_fn() throw() +void joystick_driver_thread_fn() throw() { while(!quit_signaled) { for(auto fd : joystick_set()) @@ -314,10 +315,10 @@ void joystick_plugin::thread_fn() throw() quit_ack = true; } -void joystick_plugin::signal() throw() +void joystick_driver_signal() throw() { quit_signaled = true; while(!quit_ack); } -const char* joystick_plugin::name = "Evdev joystick plugin"; +const char* joystick_driver_name = "Evdev joystick plugin"; diff --git a/src/platform/win32mm/joystick.cpp b/src/platform/win32mm/joystick.cpp index fb00b49b..80ca2f28 100644 --- a/src/platform/win32mm/joystick.cpp +++ b/src/platform/win32mm/joystick.cpp @@ -2,6 +2,7 @@ #include "core/framerate.hpp" #include "core/joystick.hpp" #include "core/keymapper.hpp" +#include "core/joystickapi.hpp" #include "core/window.hpp" #include "library/minmax.hpp" #include "library/string.hpp" @@ -29,7 +30,7 @@ namespace "Button32"}; } -void joystick_plugin::init() throw() +void joystick_driver_init() throw() { unsigned max_joysticks = joyGetNumDevs(); if(!max_joysticks) @@ -59,7 +60,7 @@ void joystick_plugin::init() throw() quit_ack = quit_signaled = false; } -void joystick_plugin::quit() throw() +void joystick_driver_quit() throw() { quit_signaled = true; while(!quit_ack); @@ -68,7 +69,7 @@ void joystick_plugin::quit() throw() #define POLL_WAIT 20000 -void joystick_plugin::thread_fn() throw() +void joystick_driver_thread_fn() throw() { while(!quit_signaled) { for(auto i : joystick_set()) { @@ -93,10 +94,10 @@ void joystick_plugin::thread_fn() throw() quit_ack = true; } -void joystick_plugin::signal() throw() +void joystick_driver_signal() throw() { quit_signaled = true; while(!quit_ack); } -const char* joystick_plugin::name = "Win32mm joystick plugin"; +const char* joystick_driver_name = "Win32mm joystick plugin"; diff --git a/src/platform/wxwidgets/joystick.cpp b/src/platform/wxwidgets/joystick.cpp index 00e8963f..7c32d236 100644 --- a/src/platform/wxwidgets/joystick.cpp +++ b/src/platform/wxwidgets/joystick.cpp @@ -57,7 +57,7 @@ namespace }* jtimer; } -void joystick_plugin::init() throw() +void joystick_driver_init() throw() { unsigned max_joysticks = wxJoystick::GetNumberJoysticks(); if(!max_joysticks) @@ -88,7 +88,7 @@ void joystick_plugin::init() throw() jtimer = new joystick_timer(); } -void joystick_plugin::quit() throw() +void joystick_driver_quit() throw() { if(jtimer) jtimer->stop(); @@ -101,15 +101,15 @@ void joystick_plugin::quit() throw() joystick_quit(); } -void joystick_plugin::thread_fn() throw() +void joystick_driver_thread_fn() throw() { //We don't poll in this thread, so just quit instantly. } -void joystick_plugin::signal() throw() +void joystick_driver_signal() throw() { //We don't poll in dedicated thread, so nothing to do. } -const char* joystick_plugin::name = "Wxwidgets joystick plugin"; +const char* joystick_driver_name = "Wxwidgets joystick plugin"; #endif diff --git a/src/platform/wxwidgets/main.cpp b/src/platform/wxwidgets/main.cpp index 542dcac6..72b1f929 100644 --- a/src/platform/wxwidgets/main.cpp +++ b/src/platform/wxwidgets/main.cpp @@ -7,6 +7,7 @@ #include "core/controller.hpp" #include "core/dispatch.hpp" #include "core/framerate.hpp" +#include "core/joystickapi.hpp" #include "core/loadlib.hpp" #include "lua/lua.hpp" #include "core/mainloop.hpp" @@ -67,7 +68,7 @@ namespace void* joystick_thread(int _args) { - joystick_plugin::thread_fn(); + joystick_driver_thread_fn(); } struct uiserv_event : public wxEvent @@ -471,7 +472,7 @@ bool lsnes_app::OnInit() thread_class* dummy_loop = new thread_class(eloop_helper, 8); wxsetingsdialog_display(NULL, false); platform::exit_dummy_event_loop(); - joystick_plugin::signal(); + joystick_driver_signal(); joystick_thread_handle->join(); dummy_loop->join(); save_configuration(); @@ -548,7 +549,7 @@ int lsnes_app::OnExit() information_dispatch::do_dump_end(); rrdata::close(); quit_lua(); - joystick_plugin::signal(); + joystick_driver_signal(); joystick_thread_handle->join(); platform::quit(); return 0;