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 "Timer.h"
#include "Common.h"
#include "Console.h"
#include "Core.h"
@ -55,6 +56,7 @@
#include "MemTools.h"
#include "Host.h"
#include "LogManager.h"
#include "EventHandler.h"
#include "State.h"
@ -66,6 +68,8 @@
// 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.
EventHandler *eventHandler = NULL;;
namespace Core
{
// forwarding
@ -100,6 +104,7 @@ SCoreStartupParameter g_CoreStartupParameter; //uck
Common::Event emuThreadGoing;
bool PanicAlertToVideo(const char* text, bool yes_no)
{
DisplayMessage(text, 3000);
@ -119,6 +124,11 @@ bool Init(const SCoreStartupParameter _CoreParameter)
g_CoreStartupParameter = _CoreParameter;
#if defined GLTEST && GLTEST
// init the event handler
eventHandler = new EventHandler();
#endif
// start the thread again
_dbg_assert_(HLE, g_pThread == NULL);
@ -391,6 +401,9 @@ THREAD_RETURN EmuThread(void *pArg)
PluginVideo::Video_Shutdown();
PluginVideo::UnloadPlugin();
if (eventHandler)
delete eventHandler;
HW::Shutdown();
LOG(MASTER_LOG, "EmuThread exited");

View File

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

View File

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