Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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;
49
const
int
MOUSE_JOYSTICK
=
MAX_JOYSTICKS
-1;
50
const
int
MAX_BUTTONS
= 48;
51
const
int
MAX_DIGITAL_HATSWITCHES
= 4;
52
const
int
MAX_DIGITAL_VALUES
= 9;
53
54
enum
55
{
56
VS_HAT_CENTERED
=0,
VS_HAT_LEFT
,
VS_HAT_RIGHT
,
VS_HAT_DOWN
,
VS_HAT_UP
,
VS_HAT_RIGHTUP
,
VS_HAT_RIGHTDOWN
,
VS_HAT_LEFTUP
,
57
VS_HAT_LEFTDOWN
58
};
59
60
extern
JoyStick
*
joystick
[
MAX_JOYSTICKS
];
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
81
int
nr_of_axes
,
nr_of_buttons
,
nr_of_hats
;
82
int
hat_margin
;
83
size_t
player
;
84
#define MAX_AXES 32
85
bool
axis_inverse
[
MAX_AXES
];
86
int
axis_axis
[
MAX_AXES
];
87
float
joy_axis
[
MAX_AXES
];
88
JoyStick
();
89
#if defined (IRIX) //could be POSIX type uchar_t?
90
uchar_t
digital_hat
[
MAX_DIGITAL_HATSWITCHES
];
91
#else
92
unsigned
char
digital_hat
[
MAX_DIGITAL_HATSWITCHES
];
93
#endif
94
95
bool
debug_digital_hatswitch
;
96
97
int
joy_buttons
;
98
bool
joy_available
;
99
float
joy_xmin
,
joy_xmax
,
joy_ymin
,
joy_ymax
,
joy_zmin
,
joy_zmax
;
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
src
in_joystick.h
Generated on Fri May 29 2015 23:07:33 for Vegastrike 0.5.1 rc1 by
1.8.4