Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/util/joystick.cpp b/util/joystick.cpp
index 2ab6b8fc..9b602815 100644
--- a/util/joystick.cpp
+++ b/util/joystick.cpp
@@ -1,26 +1,40 @@
#include <stdlib.h>
#include "joystick.h"
/*
#ifdef LINUX
#include "linux_joystick.h"
#endif
*/
#include "allegro-joystick.h"
Joystick * Joystick::create(){
return new AllegroJoystick();
/*
#ifdef LINUX
return new LinuxJoystick();
#endif
return NULL;
*/
}
Joystick::Joystick(){
}
Joystick::~Joystick(){
}
+
+const char * Joystick::keyToName(Key key){
+ switch (key){
+ case Invalid : return "Invalid";
+ case Up : return "Up";
+ case Down : return "Down";
+ case Left : return "Left";
+ case Right : return "Right";
+ case Button1 : return "Button1";
+ case Button2 : return "Button2";
+ case Button3 : return "Button3";
+ case Button4 : return "Button4";
+ }
+}
diff --git a/util/joystick.h b/util/joystick.h
index c7fdb776..3c35200c 100644
--- a/util/joystick.h
+++ b/util/joystick.h
@@ -1,64 +1,67 @@
#ifndef _paintown_joystick_h
#define _paintown_joystick_h
#include <vector>
struct JoystickInput{
JoystickInput():
left(false),
right(false),
up(false),
down(false),
button1(false),
button2(false),
button3(false),
button4(false){
}
JoystickInput(const JoystickInput & copy):
left(copy.left),
right(copy.right),
up(copy.up),
down(copy.down),
button1(copy.button1),
button2(copy.button2),
button3(copy.button3),
button4(copy.button4){
}
bool left;
bool right;
bool up;
bool down;
bool button1;
bool button2;
bool button3;
bool button4;
};
class Joystick{
public:
virtual void poll() = 0;
virtual JoystickInput readAll() = 0;
virtual bool pressed() = 0;
virtual ~Joystick();
static Joystick * create();
enum Key{
+ Invalid = -1,
Up = 0,
Down,
Left,
Right,
Button1,
Button2,
Button3,
Button4,
};
+
+ static const char * keyToName(Key key);
protected:
Joystick();
};
#endif

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 1:36 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69277
Default Alt Text
(2 KB)

Event Timeline