vegastrike
0.5.1.r1
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
force_feedback.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
* Force Feedback support by Alexander Rawass <alexannika@users.sourceforge.net>
24
*/
25
26
//#define HAVE_FORCE_FEEDBACK 1
27
28
#ifndef _FORCE_FEEDBACK_H_
29
#define _FORCE_FEEDBACK_H_
30
#ifndef _WIN32
31
#include <sys/types.h>
32
#include <sys/stat.h>
33
#include <fcntl.h>
34
35
#include <unistd.h>
36
#include <string.h>
37
#include <sys/ioctl.h>
38
#endif
39
#include <stdio.h>
40
41
#if HAVE_FORCE_FEEDBACK
42
43
#include <linux/input.h>
44
45
#define BITS_PER_LONG (sizeof (long)*8)
46
#define OFF( x ) ( (x)%BITS_PER_LONG )
47
#define BIT( x ) ( 1UL<<OFF( x ) )
48
#define LONG( x ) ( (x)/BITS_PER_LONG )
49
#define test_bit( bit, array ) ( ( array[LONG( bit )]>>OFF( bit ) )&1 )
50
51
#define _is( x ) ( (int) ( 3.2768*( (float) x ) ) )
52
53
#endif //have_force_feedback
54
55
#define ALL_EFFECTS 1
56
57
enum
vseffects
58
{
59
eff_speed_damper
=0,
//the higher the speed, the more damped
60
eff_ab_wiggle_x
,
eff_ab_wiggle_y
,
eff_ab_jerk
,
//afterburner on
61
eff_ab_off_x
,
eff_ab_off_y
,
//afterburner off
62
eff_laser_jerk
,
eff_laser_vibrate
,
//laser fired
63
#if ALL_EFFECTS
64
eff_beam_on
,
eff_beam_off
,
//beam
65
eff_missile_jerk
,
eff_missile_vibrate
,
//missile
66
eff_hit_jerk
,
eff_hit_vibrate
,
//shield hits
67
#endif
68
eff_force
//additional force
69
};
70
71
#if ALL_EFFECTS
72
#define N_EFFECTS 15
73
#else
74
#define N_EFFECTS 9
75
#endif
76
77
class
ForceFeedback
78
{
79
public
:
ForceFeedback
();
80
~ForceFeedback
();
81
82
bool
haveFF
();
83
84
void
playDurationEffect
(
unsigned
int
eff_nr,
bool
activate );
85
void
playShortEffect
(
unsigned
int
eff_nr );
86
87
void
playHit
(
float
angle,
float
strength );
88
void
updateForce
(
float
angle,
float
strength );
89
void
updateSpeedEffect
(
float
strength );
90
void
playAfterburner
(
bool
activate );
91
void
playLaser
();
92
93
private
:
94
bool
have_ff;
95
96
#if HAVE_FORCE_FEEDBACK
97
private
:
98
void
init();
99
100
void
init_bogus(
int
i );
101
void
playEffect(
unsigned
int
eff_nr );
102
void
stopEffect(
unsigned
int
eff_nr );
103
104
int
device_nr;
105
106
struct
ff_effect effects[N_EFFECTS];
107
struct
input_event play, stop;
108
int
ff_fd;
109
unsigned
long
features[4];
110
int
n_effects;
/* Number of effects the device can play at the same time */
111
112
double
eff_last_time[
N_EFFECTS
];
113
114
double
min_effect_time;
115
116
bool
is_played[
N_EFFECTS
];
117
#endif //have_force_feedback
118
};
119
120
#endif //_FORCE_FEEDBACK_H_
121
src
force_feedback.h
Generated on Fri Feb 14 2014 09:03:09 for vegastrike by
1.8.4