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 #ifndef OSDL_JOYSTICK_H_
00028 #define OSDL_JOYSTICK_H_
00029
00030
00031 #include "OSDLJoystickCommon.h"
00032 #include "OSDLInputDevice.h"
00033
00034
00035 #include <string>
00036 #include <list>
00037
00038
00039
00040
00041
00042
00043
00044
00045 namespace OSDL
00046 {
00047
00048
00049
00050 namespace Events
00051 {
00052
00053
00054
00055 #if ! defined(OSDL_USES_SDL) || OSDL_USES_SDL
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 typedef ::SDL_Joystick LowLevelJoystick ;
00066
00067 #else // OSDL_USES_SDL
00068
00069 struct LowLevelJoystick {} ;
00070
00071 #endif // OSDL_USES_SDL
00072
00073
00074
00097 class OSDL_DLL Joystick: public OSDL::Events::InputDevice
00098 {
00099
00100
00101
00102
00103
00104
00105
00106
00107 friend class OSDL::Events::JoystickHandler ;
00108
00109
00110
00111 public:
00112
00113
00114
00124 explicit Joystick( JoystickNumber index ) ;
00125
00126
00127
00132 virtual ~Joystick() throw() ;
00133
00134
00135
00140 virtual const std::string & getName() const ;
00141
00142
00143
00150 virtual bool isOpen() const ;
00151
00152
00153
00160 virtual void open() ;
00161
00162
00163
00170 virtual void close() ;
00171
00172
00173
00180 virtual JoystickAxesCount getNumberOfAxes() const ;
00181
00182
00183
00190 virtual JoystickTrackballsCount getNumberOfTrackballs() const ;
00191
00192
00193
00200 virtual JoystickHatsCount getNumberOfHats() const ;
00201
00202
00203
00210 virtual JoystickButtonsCount getNumberOfButtons() const ;
00211
00212
00213
00223 virtual AxisPosition getAbscissaPosition() const ;
00224
00225
00226
00236 virtual AxisPosition getOrdinatePosition() const ;
00237
00238
00239
00251 virtual AxisPosition getPositionOfAxis(
00252 JoystickAxesCount index ) const ;
00253
00254
00255
00267 virtual HatPosition getPositionOfHat(
00268 JoystickHatsCount index ) const ;
00269
00270
00271
00284 virtual bool isButtonPressed(
00285 JoystickButtonsCount buttonNumber ) const ;
00286
00287
00288
00309 virtual bool getPositionOfTrackball(
00310 JoystickTrackballsCount ball,
00311 BallMotion & deltaX, BallMotion & deltaY ) const ;
00312
00313
00314
00322 virtual void update() ;
00323
00324
00325
00337 virtual const std::string toString(
00338 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00339
00340
00341
00342
00343
00344 protected:
00345
00346
00347
00354 virtual JoystickNumber getIndex() const ;
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00375 virtual void axisChanged(
00376 const JoystickAxisEvent & joystickEvent ) ;
00377
00378
00379
00389 virtual void trackballChanged(
00390 const JoystickTrackballEvent & joystickEvent ) ;
00391
00392
00393
00403 virtual void hatChanged(
00404 const JoystickHatEvent & joystickEvent ) ;
00405
00406
00407
00417 virtual void buttonPressed(
00418 const JoystickButtonEvent & joystickEvent ) ;
00419
00420
00421
00431 virtual void buttonReleased(
00432 const JoystickButtonEvent & joystickEvent ) ;
00433
00434
00435
00440 std::string _name ;
00441
00442
00443
00445 JoystickNumber _index ;
00446
00447
00448
00450 LowLevelJoystick * _internalJoystick ;
00451
00452
00453
00455 JoystickAxesCount _axisCount ;
00456
00457
00458
00460 JoystickTrackballsCount _trackballCount ;
00461
00462
00463
00465 JoystickHatsCount _hatCount ;
00466
00467
00468
00470 JoystickButtonsCount _buttonCount ;
00471
00472
00473
00474
00475 private:
00476
00477
00478
00487 explicit Joystick( const Joystick & source ) ;
00488
00489
00490
00499 Joystick & operator = ( const Joystick & source ) ;
00500
00501
00502 } ;
00503
00504
00505 }
00506
00507 }
00508
00509
00510
00511 #endif // OSDL_JOYSTICK_H_
00512