Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
in_joystick.h
Go to the documentation of this file.
1 /*
2  * Vega Strike
3  * Copyright (C) 2001-2002 Daniel Horn
4  *
5  * http://vegastrike.sourceforge.net/
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 /*
23  * Joystick support written by Alexander Rawass <alexannika@users.sourceforge.net>
24  */
25 #include "config.h"
26 #include "in_kb_data.h"
27 #ifndef _JOYSTICK_H_
28 #define _JOYSTICK_H_
29 
30 #if defined (HAVE_SDL)
31 #include <SDL/SDL.h>
32 #endif
33 
34 #include "vegastrike.h"
35 //#include "glob.h"
36 //#include "dbg.h"
37 #include "in_kb.h"
38 #define NUMJBUTTONS 32
39 
40 class JoyStick;
41 
42 //typedef void (*JoyHandler) (int);
43 
44 extern void ProcessJoystick( int whichjoystick );
45 extern void InitJoystick();
46 extern void DeInitJoystick();
47 
48 const int MAX_JOYSTICKS = 16;
50 const int MAX_BUTTONS = 48;
52 const int MAX_DIGITAL_VALUES = 9;
53 
54 enum
55 {
58 };
59 
61 
62 class JoyStick
63 {
64  bool mouse;
65  void InitMouse( int i );
66  void GetMouse( float &x, float &y, float &z, int &buttons );
67 public:
68 //initializes the joystick
69  JoyStick( int );
70 //engine calls GetJoyStick to get coordinates and buttons
71  void GetJoyStick( float &x, float &y, float &z, int &buttons );
72  bool isAvailable( void );
73  bool is_around( float axe, float hswitch );
74  int NumButtons();
75 
76 #if defined (HAVE_SDL)
77  SDL_Joystick *joy;
78 #else
79  void *otherdata; //bad form to have an ifdef in a struct
80 #endif
83  size_t player;
84 #define MAX_AXES 32
88  JoyStick();
89 #if defined (IRIX) //could be POSIX type uchar_t?
91 #else
93 #endif
94 
96 
100  float joy_x, joy_y, joy_z;
101  float deadzone;
102 }
103 ;
104 
105 extern JoyStick *joystick[MAX_JOYSTICKS];
106 typedef void (*JoyHandler)( KBSTATE, float x, float y, int mod );
107 void BindJoyKey( int key, int joystick, KBHandler handler, const KBData &data );
108 void UnbindJoyKey( int joystick, int key );
109 
110 void UnbindHatswitchKey( int hatswitch, int val_index );
111 void BindHatswitchKey( int hatswitch, int val_index, KBHandler handler, const KBData &data );
112 
113 void BindDigitalHatswitchKey( int joystick, int hatswitch, int dir_index, KBHandler handler, const KBData &data );
114 void UnbindDigitalHatswitchKey( int joystick, int hatswitch, int dir_index );
115 
116 #endif //_JOYSTICK_H_
117