| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef __INCLUDED_JS_H__ |
| 25 |
#define __INCLUDED_JS_H__ 1 |
| 26 |
#define JS_NEW |
| 27 |
|
| 28 |
#include <string> |
| 29 |
#include <cstring> |
| 30 |
#include <cstdlib> |
| 31 |
|
| 32 |
#define _JS_MAX_AXES 32 |
| 33 |
#define _JS_MAX_BUTTONS 32 |
| 34 |
#define _JS_MAX_HATS 4 |
| 35 |
|
| 36 |
#define JS_TRUE 1 |
| 37 |
#define JS_FALSE 0 |
| 38 |
|
| 39 |
|
| 40 |
class jsJoystick |
| 41 |
{ |
| 42 |
int id ; |
| 43 |
protected: |
| 44 |
struct os_specific_s *os ; |
| 45 |
friend struct os_specific_s ; |
| 46 |
int error ; |
| 47 |
char name [ 128 ] ; |
| 48 |
int num_axes ; |
| 49 |
int num_buttons ; |
| 50 |
|
| 51 |
float dead_band [ _JS_MAX_AXES ] ; |
| 52 |
float saturate [ _JS_MAX_AXES ] ; |
| 53 |
float center [ _JS_MAX_AXES ] ; |
| 54 |
float max [ _JS_MAX_AXES ] ; |
| 55 |
float min [ _JS_MAX_AXES ] ; |
| 56 |
|
| 57 |
void open () ; |
| 58 |
void close () ; |
| 59 |
|
| 60 |
float fudge_axis ( float value, int axis ) const ; |
| 61 |
|
| 62 |
public: |
| 63 |
|
| 64 |
jsJoystick ( int ident = 0 ) ; |
| 65 |
~jsJoystick () { close () ; } |
| 66 |
|
| 67 |
const char* getName () const { return name ; } |
| 68 |
int getNumAxes () const { return num_axes ; } |
| 69 |
int getNumButtons () const { return num_buttons; } |
| 70 |
int notWorking () const { return error ; } |
| 71 |
void setError () { error = JS_TRUE ; } |
| 72 |
|
| 73 |
float getDeadBand ( int axis ) const { return dead_band [ axis ] ; } |
| 74 |
void setDeadBand ( int axis, float db ) { dead_band [ axis ] = db ; } |
| 75 |
|
| 76 |
float getSaturation ( int axis ) const { return saturate [ axis ] ; } |
| 77 |
void setSaturation ( int axis, float st ) { saturate [ axis ] = st ; } |
| 78 |
|
| 79 |
void setMinRange ( float *axes ) { memcpy ( min , axes, num_axes * sizeof(float) ) ; } |
| 80 |
void setMaxRange ( float *axes ) { memcpy ( max , axes, num_axes * sizeof(float) ) ; } |
| 81 |
void setCenter ( float *axes ) { memcpy ( center, axes, num_axes * sizeof(float) ) ; } |
| 82 |
|
| 83 |
void getMinRange ( float *axes ) const { memcpy ( axes, min , num_axes * sizeof(float) ) ; } |
| 84 |
void getMaxRange ( float *axes ) const { memcpy ( axes, max , num_axes * sizeof(float) ) ; } |
| 85 |
void getCenter ( float *axes ) const { memcpy ( axes, center, num_axes * sizeof(float) ) ; } |
| 86 |
|
| 87 |
void read ( int *buttons, float *axes ) ; |
| 88 |
void rawRead ( int *buttons, float *axes ) ; |
| 89 |
|
| 90 |
} ; |
| 91 |
|
| 92 |
extern void jsInit () ; |
| 93 |
void jsShutdown(); |
| 94 |
|
| 95 |
void jsSetError(int, const std::string& msg); |
| 96 |
|
| 97 |
#endif |