Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00038 #ifndef _CE_JOYSTICK_H_
00039 #define _CE_JOYSTICK_H_ 0x1
00041 #ifndef CE_WITHOUT_JOYSTICK
00042
00043 #ifndef __cplusplus
00044 #error ceJoystick.h requires C++ compilation (use a .cpp suffix)
00045 #endif
00046
00047 #if __GNUC__ >= 0x3
00048 #pragma GCC system_header
00049 #endif
00050
00051 #if _MSC_VER > 1000
00052 #pragma once
00053 #pragma warning(disable: 4100)
00054 #endif
00055
00056 #include "ceInputDevice.h"
00057 #include "begin_code.h"
00058
00059 #ifndef _MMSYSTEM_H
00060 #define JOYSTICKID1 0x0
00061 #define JOYSTICKID2 0x1
00062
00063 #define JOY_BUTTON1 0x1
00064 #define JOY_BUTTON2 0x2
00065 #define JOY_BUTTON3 0x4
00066 #define JOY_BUTTON4 0x8
00067 #endif
00068
00069 namespace ce {
00070
00071
00072
00074 struct DECLSPEC SJoystickState
00075 {
00076 unsigned int x;
00077 unsigned int y;
00078 unsigned int z;
00079 unsigned int buttons;
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00097 inline SJoystickState(void) : x(0x0), y(0x0), z(0x0), buttons(0x0) { };
00098
00102 inline SJoystickState(const SJoystickState &State) :
00103 x(State.x), y(State.y), z(State.z), buttons(State.buttons) { };
00104
00105 const SJoystickState& APICALL
00106 operator = (const SJoystickState &State)
00107 {
00108 if (this == &State) return *(this);
00109
00110 this -> x = State.x;
00111 this -> y = State.y;
00112 this -> z = State.z;
00113 this -> buttons = State.buttons;
00114
00115 return *(this);
00116 };
00117
00118 const SJoystickState* APICALL
00119 operator -> (void) const
00120 { return this; };
00121
00122 };
00123
00124 inline const int APICALL
00125 operator == (const SJoystickState &StateA, const SJoystickState &StateB)
00126 {
00127 if ((StateA.x != StateB.x) || (StateA.y != StateB.y) ||
00128 (StateA.z != StateB.z) || (StateA.buttons != StateB.buttons))
00129 return FALSE;
00130 }
00131
00132 inline const int APICALL
00133 operator != (const SJoystickState &StateA, const SJoystickState &StateB)
00134 {
00135 if ((StateA.x != StateB.x) || (StateA.y != StateB.y) ||
00136 (StateA.z != StateB.z) || (StateA.buttons != StateB.buttons))
00137 return TRUE;
00138 }
00139
00140
00141
00142
00143
00144 class IJoystickDevice;
00145
00152 class DECLSPEC IJoystickEvent
00153 {
00154 public:
00155
00156 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00157 virtual ~IJoystickEvent(void) { };
00158 #endif
00159
00167 virtual void APICALL
00168 OnJoyButtonPressed(const IJoystickDevice *Owner, const int joyid,
00169 const unsigned int button, const SJoystickState &State) = 0;
00170
00178 virtual void APICALL
00179 OnJoyButtonReleased(const IJoystickDevice *Owner, const int joyid,
00180 const unsigned int button, const SJoystickState &State) = 0;
00181
00189 virtual void APICALL
00190 OnJoystickEvent(const IJoystickDevice *Owner,
00191 const int joyid, const SJoystickState &State) = 0;
00192
00193 };
00194
00195
00196
00197
00198
00206 class IJoystickDevice : public IInputDevice
00207 {
00208 public:
00209
00210 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00211 virtual ~IJoystickDevice(void) { };
00212 #endif
00213
00219 virtual int APICALL
00220 GetNumSupported(void) const = 0;
00221
00229 virtual int APICALL
00230 IsJoyButtonPressed(
00231 const int joyid = 0x0, const int button = 0x0) const = 0;
00232
00240 virtual int APICALL
00241 IsJoyButtonReleased(
00242 const int joyid = 0x0, const int button = 0x0) const = 0;
00243
00251 virtual int APICALL
00252 GetJoyPosition(const int joyid, unsigned int *get_x, unsigned int *get_y,
00253 unsigned int *get_z = NULL) const = 0;
00254
00259 virtual unsigned int APICALL
00260 GetJoyXPosition(const int joyid = 0x0) const = 0;
00261
00266 virtual unsigned int APICALL
00267 GetJoyYPosition(const int joyid = 0x0) const = 0;
00268
00273 virtual unsigned int APICALL
00274 GetJoyZPosition(const int joyid = 0x0) const = 0;
00275
00276
00277
00278
00282 virtual void APICALL
00283 SetJoystickEvent(IJoystickEvent *Event) const = 0;
00284
00288 virtual IJoystickEvent* APICALL
00289 GetJoystickEvent(void) const = 0;
00290
00291 };
00292
00293
00294
00295 }
00296
00297 #include "close_code.h"
00298
00299 #if _MSC_VER > 1000
00300 #pragma warning(default:4100)
00301 #endif
00302
00303 #endif // CE_WITHOUT_JOYSTICK
00304 #endif // _CE_JOYSTICK_H_