• Main Page
  • Namespaces
  • Classes
  • Files
  • File List

event.h

Go to the documentation of this file.
00001 #ifndef WIT_EVENT_H
00002 #define WIT_EVENT_H
00003 
00004 #include "wit.h"
00005 
00006 namespace wit {
00007 
00008 class Hotspot;
00009 
00010 class Event {
00011 public:
00012     enum Type { 
00013         Joystick,       
00014         Analog,         
00015         Motion,         
00016         Pointer,        
00017         PointerLeave,   
00018         ButtonPress,    
00019         ButtonRelease,  
00020         User = 256      
00021     };
00022 
00023     int type() const;
00024 
00025 protected:
00026     Event(int type);
00027     
00028 private:
00029     int m_type;
00030 };
00031 
00032 class InputEvent : public Event {
00033 public:
00034     Controller controllerType;
00035     unsigned short controllerNumber;
00036 
00037 protected:
00038     InputEvent(int type, Controller ctype, unsigned short id);
00039 };
00040 
00041 class ButtonEvent : public InputEvent {
00042 public:
00043     ButtonEvent(Event::Type type, Controller ctype, unsigned short id, int button = Button_None);
00044 
00045     Button button;
00046 };
00047 
00048 class JoystickEvent : public InputEvent {
00049 public:
00050     JoystickEvent(Controller ctype, unsigned short id, bool isRightStick = false);
00051 
00052     void setByPosition(signed char px, signed char py);
00053     void setByPosition(float px, float py);
00054     void setByAngle(float pangle, float pmag);
00055 
00056     bool isRightStick;
00057     float x, y, angle, magnitude;
00058 };
00059 
00060 class AnalogEvent : public InputEvent {
00061 public:
00062     AnalogEvent(Controller ctype, unsigned short id, AnalogButton trigger, float pressure);
00063 
00064     AnalogButton trigger;
00065     float pressure;
00066 };
00067 
00068 class MotionEvent : public InputEvent {
00069 public:
00070     MotionEvent(Controller ctype, unsigned short id, float x, float y, float z, float pitch, float roll);
00071 
00072     float x, y, z, pitch, roll; // TODO: read yaw from MotionPlus when API becomes available
00073 };
00074 
00075 class PointerEvent : public InputEvent {
00076 public:
00077     PointerEvent(unsigned short id, float x, float y, float z);
00078 
00079     bool isValid() const;
00080     float x, y, z;
00081 };
00082 
00083 class PointerLeaveEvent : public InputEvent {
00084 public:
00085     PointerLeaveEvent(unsigned short id, Hotspot* hotspot);
00086 
00087     Hotspot* hotspot;
00088 };
00089 
00090 }
00091 
00092 #endif

Generated on Sat Sep 3 2011 10:25:00 for wit by  doxygen 1.7.2