Debian Codegraph @

3rdparty/joystick/FlightGear_js.h

raw symbols SCIP
1 /*
2 PLIB - A Suite of Portable Game Libraries
3 Copyright (C) 1998,2002 Steve Baker
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 For further information visit http://plib.sourceforge.net
20
21 $Id: js.h 2067 2006-01-30 07:36:01Z bram $
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 // bool SetForceFeedBack ( int axe, float force );
90 } ;
91
92 extern void jsInit () ;
93 void jsShutdown();
94
95 void jsSetError(int, const std::string& msg);
96
97 #endif