[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Usata-commits] Changes to usata2/src/input-system.hpp
From: |
David Lau |
Subject: |
[Usata-commits] Changes to usata2/src/input-system.hpp |
Date: |
Tue, 25 Jan 2005 03:28:28 -0500 |
Index: usata2/src/input-system.hpp
diff -u usata2/src/input-system.hpp:1.1 usata2/src/input-system.hpp:1.2
--- usata2/src/input-system.hpp:1.1 Fri Jan 21 23:02:38 2005
+++ usata2/src/input-system.hpp Tue Jan 25 08:28:27 2005
@@ -10,25 +10,74 @@
// included in the software distribution, or visit
// http://www.fsf.org/licenses/gpl.html.
//
-// $Id: input-system.hpp,v 1.1 2005/01/21 23:02:38 skunix Exp $
+// $Id: input-system.hpp,v 1.2 2005/01/25 08:28:27 skunix Exp $
#ifndef USATA_INPUT_SYSTEM_HPP
#define USATA_INPUT_SYSTEM_HPP
#include <string>
-
+#include <memory>
+#include <boost/shared_ptr.hpp>
+#include <boost/signal.hpp>
+#include <vector>
namespace usata
{
namespace input
{
+
+ struct Key
+ {
+ enum
+ {
+ LEFT,
+ RIGHT,
+ UP,
+ DOWN,
+ ALT,
+ ENTER,
+ SPACE,
+ ESCAPE,
+ LAST
+ };
+ };
+
+
+ struct Type
+ {
+ enum {SYSTEM=0, KEY=1, JOY, MOUSE, NONE };
+ };
class Event
{
+ int mType;
+ public:
+ Event(int = Type::SYSTEM);
+ int type() const { return mType; }
+ virtual ~Event(){};
};
class KeyEvent : public Event
{
+ int mKey;
+ bool mState;
+ char mValue;
+ public:
+ KeyEvent(unsigned Key, bool state);
+ unsigned key(){ return mKey; }
+ bool state(){return mState;}
+ char as_char();
};
-
+
+ class SystemEvent : public Event
+ {
+ public:
+ typedef enum {QUIT} SEType;
+ private:
+ SEType mSEType;
+ public:
+ SystemEvent(SEType t):Event(Type::SYSTEM),
mSEType(t){}
+ int se_type()const{return mSEType;}
+ };
+
class GenericEvent : public Event
{
@@ -41,18 +90,46 @@
{
};
+
class Driver
{
- std::string m_name;
+ std::string mName;
public:
+
+ typedef enum { KEYBOARD, MOUSE, JOYSTICK }
DeviceType;
Driver(const std::string& name);
virtual ~Driver() throw();
- virtual void update();
- virtual Event* next();
+
+ virtual bool supports(DeviceType type)=0;
+ virtual bool enable(DeviceType type, bool)=0;
+ virtual void configure() = 0;
+
+ virtual void update() = 0;
+ virtual Event* next() = 0;
+
+ };
+ typedef boost::shared_ptr<Driver> Driver_sp;
+ class Translator
+ {
+ };
+
+ class Manager
+ {
+ typedef std::vector<Driver_sp> DriversV;
+ DriversV mDrivers;
+ public:
+ boost::signal<void ()> quit_signal;
+ Manager();
+ void trim(void);
+ void add_driver(Driver*);
+ void process();
+ ~Manager();
};
- }
+ Driver * default_driver();
+ }
+
}
#endif