joystick_plugin:: -> joystick_driver_

This commit is contained in:
Ilari Liusvaara 2013-01-21 12:48:07 +02:00
parent 13f69fac09
commit ad997c36bd
10 changed files with 76 additions and 74 deletions

View file

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

View file

@ -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.
*/

View file

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

View file

@ -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<const std::string&> 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();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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