Make event handler wx safe

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1756 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-01-03 23:33:45 +00:00
parent 09b3d2d227
commit a72da4e76a
3 changed files with 22 additions and 1 deletions

View File

@ -23,6 +23,7 @@
#include "Thread.h" #include "Thread.h"
#include "Timer.h" #include "Timer.h"
#include "Common.h"
#include "Console.h" #include "Console.h"
#include "Core.h" #include "Core.h"
@ -55,6 +56,7 @@
#include "MemTools.h" #include "MemTools.h"
#include "Host.h" #include "Host.h"
#include "LogManager.h" #include "LogManager.h"
#include "EventHandler.h"
#include "State.h" #include "State.h"
@ -66,6 +68,8 @@
// glXMakeCurrent/ wglMakeCurrent takes a context and makes it current on the current thread. // glXMakeCurrent/ wglMakeCurrent takes a context and makes it current on the current thread.
// So it's fine to init ogl on one thread, and then make it current and start blasting on another. // So it's fine to init ogl on one thread, and then make it current and start blasting on another.
EventHandler *eventHandler = NULL;;
namespace Core namespace Core
{ {
// forwarding // forwarding
@ -100,6 +104,7 @@ SCoreStartupParameter g_CoreStartupParameter; //uck
Common::Event emuThreadGoing; Common::Event emuThreadGoing;
bool PanicAlertToVideo(const char* text, bool yes_no) bool PanicAlertToVideo(const char* text, bool yes_no)
{ {
DisplayMessage(text, 3000); DisplayMessage(text, 3000);
@ -119,6 +124,11 @@ bool Init(const SCoreStartupParameter _CoreParameter)
g_CoreStartupParameter = _CoreParameter; g_CoreStartupParameter = _CoreParameter;
#if defined GLTEST && GLTEST
// init the event handler
eventHandler = new EventHandler();
#endif
// start the thread again // start the thread again
_dbg_assert_(HLE, g_pThread == NULL); _dbg_assert_(HLE, g_pThread == NULL);
@ -391,6 +401,9 @@ THREAD_RETURN EmuThread(void *pArg)
PluginVideo::Video_Shutdown(); PluginVideo::Video_Shutdown();
PluginVideo::UnloadPlugin(); PluginVideo::UnloadPlugin();
if (eventHandler)
delete eventHandler;
HW::Shutdown(); HW::Shutdown();
LOG(MASTER_LOG, "EmuThread exited"); LOG(MASTER_LOG, "EmuThread exited");

View File

@ -1,5 +1,8 @@
#include "EventHandler.h" #include "EventHandler.h"
#if defined HAVE_WX && HAVE_WX
#include <wx/wx.h> #include <wx/wx.h>
#endif
bool EventHandler::RegisterEventListener(listenFuncPtr func, Keys key) { bool EventHandler::RegisterEventListener(listenFuncPtr func, Keys key) {
if (key.inputType == KeyboardInput) { if (key.inputType == KeyboardInput) {
@ -58,6 +61,7 @@ bool EventHandler::TestEvent (Keys k, sf::Event e)
return (false); return (false);
} }
#if defined HAVE_WX && HAVE_WX
// Taken from wxw source code // Taken from wxw source code
sf::Key::Code EventHandler::wxCharCodeToSF(int id) sf::Key::Code EventHandler::wxCharCodeToSF(int id)
{ {
@ -145,6 +149,7 @@ sf::Key::Code EventHandler::wxCharCodeToSF(int id)
return sfKey; return sfKey;
} }
#endif
void EventHandler::SFKeyToString(sf::Key::Code keycode, char *keyStr) { void EventHandler::SFKeyToString(sf::Key::Code keycode, char *keyStr) {
switch (keycode) { switch (keycode) {

View File

@ -1,5 +1,6 @@
#ifndef EVENTHANDER_H #ifndef EVENTHANDER_H
#define EVENTHANDER_H 1 #define EVENTHANDER_H 1
#include "Common.h"
#include <queue> #include <queue>
#include "Event.hpp" #include "Event.hpp"
@ -39,7 +40,9 @@ public:
void Update(); void Update();
bool addEvent(sf::Event *e); bool addEvent(sf::Event *e);
static bool TestEvent (Keys k, sf::Event e); static bool TestEvent (Keys k, sf::Event e);
#if defined HAVE_WX && HAVE_WX
static sf::Key::Code wxCharCodeToSF(int id); static sf::Key::Code wxCharCodeToSF(int id);
#endif
static void SFKeyToString(sf::Key::Code keycode, char *keyStr); static void SFKeyToString(sf::Key::Code keycode, char *keyStr);
}; };