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,v 1.1.2.1 2012/01/02 16:27:11 berniw Exp $ 22 */ 23 24 #ifndef __INCLUDED_JS_H__ 25 #define __INCLUDED_JS_H__ 1 26 #define JS_NEW 27 28 #include "ul.h" 29 30 #include <stdio.h> 31 #include <stdlib.h> 32 #include <string.h> // -dw- for memcpy 33 34 #define _JS_MAX_AXES 16 35 #define _JS_MAX_BUTTONS 32 36 #define _JS_MAX_HATS 4 37 38 #define JS_TRUE 1 39 #define JS_FALSE 0 40 41 42 class jsJoystick 43 { 44 int id ; 45 protected: 46 struct os_specific_s *os ; 47 friend struct os_specific_s ; 48 int error ; 49 char name [ 128 ] ; 50 int num_axes ; 51 int num_buttons ; 52 53 float dead_band [ _JS_MAX_AXES ] ; 54 float saturate [ _JS_MAX_AXES ] ; 55 float center [ _JS_MAX_AXES ] ; 56 float max [ _JS_MAX_AXES ] ; 57 float min [ _JS_MAX_AXES ] ; 58 59 void open () ; 60 void close () ; 61 62 float fudge_axis ( float value, int axis ) const ; 63 64 public: 65 66 jsJoystick ( int ident = 0 ) ; ~jsJoystick()67 ~jsJoystick () { close () ; } 68 getName()69 const char* getName () const { return name ; } getNumAxes()70 int getNumAxes () const { return num_axes ; } getNumButtons()71 int getNumButtons () const { return num_buttons; } notWorking()72 int notWorking () const { return error ; } setError()73 void setError () { error = JS_TRUE ; } 74 getDeadBand(int axis)75 float getDeadBand ( int axis ) const { return dead_band [ axis ] ; } setDeadBand(int axis,float db)76 void setDeadBand ( int axis, float db ) { dead_band [ axis ] = db ; } 77 getSaturation(int axis)78 float getSaturation ( int axis ) const { return saturate [ axis ] ; } setSaturation(int axis,float st)79 void setSaturation ( int axis, float st ) { saturate [ axis ] = st ; } 80 setMinRange(float * axes)81 void setMinRange ( float *axes ) { memcpy ( min , axes, num_axes * sizeof(float) ) ; } setMaxRange(float * axes)82 void setMaxRange ( float *axes ) { memcpy ( max , axes, num_axes * sizeof(float) ) ; } setCenter(float * axes)83 void setCenter ( float *axes ) { memcpy ( center, axes, num_axes * sizeof(float) ) ; } 84 getMinRange(float * axes)85 void getMinRange ( float *axes ) const { memcpy ( axes, min , num_axes * sizeof(float) ) ; } getMaxRange(float * axes)86 void getMaxRange ( float *axes ) const { memcpy ( axes, max , num_axes * sizeof(float) ) ; } getCenter(float * axes)87 void getCenter ( float *axes ) const { memcpy ( axes, center, num_axes * sizeof(float) ) ; } 88 89 void read ( int *buttons, float *axes ) ; 90 void rawRead ( int *buttons, float *axes ) ; 91 // bool SetForceFeedBack ( int axe, float force ); 92 } ; 93 94 extern void jsInit () ; 95 96 #endif 97 98 99