summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornakeee <nakeee@gmail.com>2008-12-30 10:35:52 +0000
committernakeee <nakeee@gmail.com>2008-12-30 10:35:52 +0000
commit443e5051541b6e6fb495c5576c2c98dda915b7a7 (patch)
tree079abdb571b242da87766f4cf5c05bb8b83892ef
parente8949267f03e4ee9416e192ee83f9e6fb5b89712 (diff)
more event handler stuff
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1721 8ced0084-cf51-0410-be5f-012b33b47a6e
-rw-r--r--Source/Core/Core/Src/EventHandler.cpp28
-rw-r--r--Source/Core/Core/Src/EventHandler.h19
-rw-r--r--Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp7
-rw-r--r--Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.h3
4 files changed, 41 insertions, 16 deletions
diff --git a/Source/Core/Core/Src/EventHandler.cpp b/Source/Core/Core/Src/EventHandler.cpp
index bb296d8468..f252524343 100644
--- a/Source/Core/Core/Src/EventHandler.cpp
+++ b/Source/Core/Core/Src/EventHandler.cpp
@@ -1,6 +1,34 @@
#include "EventHandler.h"
#include <wx/wx.h>
+bool EventHandler::RegisterEventListener(listenFuncPtr func, Keys key) {
+ if (key.inputType == KeyboardInput) {
+ if (keys[key.keyCode][key.mods])
+ return false;
+ keys[key.keyCode][key.mods] = func;
+ } else if (key.inputType == MouseInput) {
+ if (mouse[key.mouseButton])
+ return false;
+ mouse[key.mouseButton] = func;
+ }
+
+ return true;
+}
+
+void EventHandler::Update() {
+ for (unsigned int i = 0; i < eventQueue.size();i++) {
+ sf::Event ev = eventQueue.front();
+ eventQueue.pop();
+ keys[ev.Key.Code][ev.Key.Alt+2*ev.Key.Shift+4*ev.Key.Control](ev);
+ }
+}
+
+bool EventHandler::addEvent(sf::Event *ev) {
+ eventQueue.push(*ev);
+ return true;
+}
+
+
bool EventHandler::TestEvent (Keys k, sf::Event e)
{
//Mouse event
diff --git a/Source/Core/Core/Src/EventHandler.h b/Source/Core/Core/Src/EventHandler.h
index 3ced661036..0141f46802 100644
--- a/Source/Core/Core/Src/EventHandler.h
+++ b/Source/Core/Core/Src/EventHandler.h
@@ -3,7 +3,7 @@
#include <queue>
#include "Event.hpp"
-typedef bool (*listenFuncPtr) (sf::Event *);
+typedef bool (*listenFuncPtr) (sf::Event);
enum InputType
{
KeyboardInput,
@@ -11,25 +11,32 @@ enum InputType
JoystickInput
};
+enum Modifiers {
+ UseAlt = 1,
+ UseShift = 2,
+ UseCtrl = 4
+};
+
struct Keys
{
InputType inputType;
- sf::Event::EventType eventType;
+ sf::Event::EventType eventType;
sf::Key::Code keyCode;
+ int mods;
sf::Mouse::Button mouseButton;
};
class EventHandler {
private:
- listenFuncPtr keys[sf::Key::Count][6];
+ listenFuncPtr keys[sf::Key::Count][8];
listenFuncPtr mouse[sf::Mouse::Count];
listenFuncPtr joys[sf::Joy::Count];
- std::queue<Keys> eventQueue;
+ std::queue<sf::Event> eventQueue;
public:
- bool RegisterEventListener(listenFuncPtr func, int event, int type);
+ bool RegisterEventListener(listenFuncPtr func, Keys key);
void Update();
- bool addEvent(sf::Event *);
+ bool addEvent(sf::Event *e);
static bool TestEvent (Keys k, sf::Event e);
static int wxCharCodeWXToSF(int id);
static void SFKeyToString(unsigned int keycode, char *keyStr);
diff --git a/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp b/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp
index 58317c537d..0748744441 100644
--- a/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp
+++ b/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.cpp
@@ -305,12 +305,8 @@ void LoadConfig()
char SectionName[32];
sprintf(SectionName, "PAD%i", i+1);
- file.Get(SectionName, "UseXPad", &pad[i].bEnableXPad, i==0);
file.Get(SectionName, "Attached", &pad[i].bAttached, i==0);
file.Get(SectionName, "DisableOnBackground", &pad[i].bDisable, false);
- file.Get(SectionName, "Rumble", &pad[i].bRumble, true);
- file.Get(SectionName, "XPad#", &pad[i].XPadPlayer);
-
for (int x = 0; x < NUMCONTROLS; x++) {
file.Get(SectionName, controlNames[x],
&pad[i].keyForControl[x],
@@ -330,11 +326,8 @@ void SaveConfig()
char SectionName[32];
sprintf(SectionName, "PAD%i", i+1);
- file.Set(SectionName, "UseXPad", pad[i].bEnableXPad);
file.Set(SectionName, "Attached", pad[i].bAttached);
file.Set(SectionName, "DisableOnBackground", pad[i].bDisable);
- file.Set(SectionName, "Rumble", pad[i].bRumble);
- file.Set(SectionName, "XPad#", pad[i].XPadPlayer);
for (int x = 0; x < NUMCONTROLS; x++)
{
diff --git a/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.h b/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.h
index f296d52fb7..785f34e351 100644
--- a/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.h
+++ b/Source/Plugins/Plugin_PadSimpleEvnt/Src/PadSimple.h
@@ -75,11 +75,8 @@ static const char* controlNames[] =
};
struct SPads {
- bool bEnableXPad; // Use an XPad in addition to the keyboard?
bool bAttached; // Pad is "attached" to the gamecube/wii
bool bDisable; // Disabled when dolphin isn't in focus
- bool bRumble; // Rumble for xpad
- int XPadPlayer; // Player# of the xpad
unsigned int keyForControl[NUMCONTROLS];// Keyboard mapping
};