mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 21:35:28 +00:00
is properties the right way?
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1808 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
ce2b4bead9
commit
f95937bc2e
@ -29,14 +29,14 @@ EventHandler *EventHandler::GetInstance() {
|
|||||||
|
|
||||||
void EventHandler::Destroy() {
|
void EventHandler::Destroy() {
|
||||||
if (m_Instance)
|
if (m_Instance)
|
||||||
delete m_Instance;
|
delete m_Instance;
|
||||||
fprintf(stderr, "deleting instance %p\n", m_Instance);
|
fprintf(stderr, "deleting instance %p\n", m_Instance);
|
||||||
m_Instance = 0;
|
m_Instance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventHandler::RegisterEventListener(listenFuncPtr func, Keys key) {
|
bool EventHandler::RegisterEventListener(listenFuncPtr func, Keys key) {
|
||||||
if (key.inputType == KeyboardInput) {
|
if (key.inputType == KeyboardInput) {
|
||||||
fprintf(stderr, "Registering %d:%d %p\n", key.keyCode, key.mods, func);
|
fprintf(stderr, "Registering %d:%d %p %p \n", key.keyCode, key.mods, func, this);
|
||||||
if (key.keyCode == sf::Key::Count || key.mods >= NUMMODS ||
|
if (key.keyCode == sf::Key::Count || key.mods >= NUMMODS ||
|
||||||
key.keyCode >= NUMKEYS)
|
key.keyCode >= NUMKEYS)
|
||||||
return false;
|
return false;
|
||||||
@ -72,7 +72,7 @@ void EventHandler::Update() {
|
|||||||
for (unsigned int i = 0; i < eventQueue.size();i++) {
|
for (unsigned int i = 0; i < eventQueue.size();i++) {
|
||||||
sf::Event ev = eventQueue.front();
|
sf::Event ev = eventQueue.front();
|
||||||
eventQueue.pop();
|
eventQueue.pop();
|
||||||
fprintf(stderr, "Updating event type %d code %d mod %d func %p\n", ev.Type, ev.Key.Code, ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control, keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control]);
|
fprintf(stderr, "Updating event type %d code %d mod %d func %p %p\n", ev.Type, ev.Key.Code, ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control, keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control], this);
|
||||||
if(keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control])
|
if(keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control])
|
||||||
keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control](ev);
|
keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control](ev);
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ void EventHandler::Update() {
|
|||||||
|
|
||||||
bool EventHandler::addEvent(sf::Event *ev) {
|
bool EventHandler::addEvent(sf::Event *ev) {
|
||||||
eventQueue.push(*ev);
|
eventQueue.push(*ev);
|
||||||
fprintf(stderr, "Got event type %d code %d\n", ev->Type, ev->Key.Code);
|
fprintf(stderr, "Got event type %d code %d %p\n", ev->Type, ev->Key.Code, this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,6 +313,6 @@ class EventHandlerCleaner
|
|||||||
public:
|
public:
|
||||||
~EventHandlerCleaner()
|
~EventHandlerCleaner()
|
||||||
{
|
{
|
||||||
EventHandler::Destroy();
|
//EventHandler::Destroy();
|
||||||
}
|
}
|
||||||
} EventHandlerCleanerInst;
|
} EventHandlerCleanerInst;
|
||||||
|
@ -6,7 +6,7 @@ namespace InputCommon
|
|||||||
{
|
{
|
||||||
void Init() {
|
void Init() {
|
||||||
// init the event handler
|
// init the event handler
|
||||||
EventHandler::GetInstance();
|
//EventHandler::GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown() {
|
void Shutdown() {
|
||||||
|
@ -89,7 +89,7 @@ void __Logv(int log, int v, const char *format, ...) {}
|
|||||||
bool registerKey(int nPad, int id, sf::Key::Code code, int mods) {
|
bool registerKey(int nPad, int id, sf::Key::Code code, int mods) {
|
||||||
|
|
||||||
Keys key, oldKey;
|
Keys key, oldKey;
|
||||||
EventHandler *eventHandler = EventHandler::GetInstance();
|
static EventHandler *eventHandler = EventHandler::GetInstance();
|
||||||
|
|
||||||
key.inputType = KeyboardInput;
|
key.inputType = KeyboardInput;
|
||||||
key.keyCode = code;
|
key.keyCode = code;
|
||||||
|
@ -14,13 +14,20 @@
|
|||||||
#else
|
#else
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
enum OGL_Props {
|
||||||
|
OGL_FULLSCREEN,
|
||||||
|
OGL_STRETCHTOFIT,
|
||||||
|
OGL_KEEPRATIO,
|
||||||
|
OGL_PROP_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
class GLWindow {
|
class GLWindow {
|
||||||
private:
|
private:
|
||||||
u32 width, height;
|
u32 width, height;
|
||||||
int yOffset, xOffset;
|
int yOffset, xOffset;
|
||||||
float xMax, yMax;
|
float xMax, yMax;
|
||||||
public:
|
bool properties[OGL_PROP_COUNT];
|
||||||
|
public:
|
||||||
|
|
||||||
virtual void SwapBuffers() {};
|
virtual void SwapBuffers() {};
|
||||||
virtual void SetWindowText(const char *text) {};
|
virtual void SetWindowText(const char *text) {};
|
||||||
@ -28,7 +35,9 @@ class GLWindow {
|
|||||||
virtual void Update() {};;
|
virtual void Update() {};;
|
||||||
virtual bool MakeCurrent() {return false;};
|
virtual bool MakeCurrent() {return false;};
|
||||||
|
|
||||||
|
bool getProperty(OGL_Props prop) {return properties[prop];}
|
||||||
|
virtual bool setProperty(OGL_Props prop, bool value)
|
||||||
|
{return properties[prop] = value;}
|
||||||
u32 GetWidth() {return width;}
|
u32 GetWidth() {return width;}
|
||||||
u32 GetHeight() {return height;}
|
u32 GetHeight() {return height;}
|
||||||
void SetSize(u32 newWidth, u32 newHeight) {
|
void SetSize(u32 newWidth, u32 newHeight) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "X11Window.h"
|
#include "X11Window.h"
|
||||||
|
|
||||||
|
static EventHandler *eventHandler = EventHandler::GetInstance();
|
||||||
|
|
||||||
X11Window::X11Window(int _iwidth, int _iheight) {
|
X11Window::X11Window(int _iwidth, int _iheight) {
|
||||||
int _twidth, _theight;
|
int _twidth, _theight;
|
||||||
if(g_Config.bFullscreen) {
|
if(g_Config.bFullscreen) {
|
||||||
@ -206,6 +208,7 @@ bool X11Window::PeekMessages() {
|
|||||||
|
|
||||||
// Taken from sfml code
|
// Taken from sfml code
|
||||||
void X11Window::ProcessEvent(XEvent WinEvent) {
|
void X11Window::ProcessEvent(XEvent WinEvent) {
|
||||||
|
// static EventHandler *eventHandler = EventHandler::GetInstance();
|
||||||
switch (WinEvent.type) {
|
switch (WinEvent.type) {
|
||||||
|
|
||||||
case KeyPress :
|
case KeyPress :
|
||||||
@ -223,7 +226,7 @@ void X11Window::ProcessEvent(XEvent WinEvent) {
|
|||||||
Evt.Key.Alt = WinEvent.xkey.state & Mod1Mask;
|
Evt.Key.Alt = WinEvent.xkey.state & Mod1Mask;
|
||||||
Evt.Key.Control = WinEvent.xkey.state & ControlMask;
|
Evt.Key.Control = WinEvent.xkey.state & ControlMask;
|
||||||
Evt.Key.Shift = WinEvent.xkey.state & ShiftMask;
|
Evt.Key.Shift = WinEvent.xkey.state & ShiftMask;
|
||||||
EventHandler::GetInstance()->addEvent(&Evt);
|
eventHandler->addEvent(&Evt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Key up event
|
// Key up event
|
||||||
@ -241,7 +244,7 @@ void X11Window::ProcessEvent(XEvent WinEvent) {
|
|||||||
Evt.Key.Alt = WinEvent.xkey.state & Mod1Mask;
|
Evt.Key.Alt = WinEvent.xkey.state & Mod1Mask;
|
||||||
Evt.Key.Control = WinEvent.xkey.state & ControlMask;
|
Evt.Key.Control = WinEvent.xkey.state & ControlMask;
|
||||||
Evt.Key.Shift = WinEvent.xkey.state & ShiftMask;
|
Evt.Key.Shift = WinEvent.xkey.state & ShiftMask;
|
||||||
EventHandler::GetInstance()->addEvent(&Evt);
|
eventHandler->addEvent(&Evt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,7 +285,7 @@ void X11Window::Update() {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler::GetInstance()->Update();
|
eventHandler->Update();
|
||||||
|
|
||||||
float FactorW = 640.0f / (float)GetWidth();
|
float FactorW = 640.0f / (float)GetWidth();
|
||||||
float FactorH = 480.0f / (float)GetHeight();
|
float FactorH = 480.0f / (float)GetHeight();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user