Fawkes API
Fawkes Development Version
force_feedback.h
1
2
/***************************************************************************
3
* force_feedback.h - Force feedback for joysticks using Linux input API
4
*
5
* Created: Sun Feb 06 23:50:57 2011 (Super Bowl XLV)
6
* Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#ifndef _PLUGINS_JOYSTICK_FORCE_FEEDBACK_H_
24
#define _PLUGINS_JOYSTICK_FORCE_FEEDBACK_H_
25
26
#include <linux/input.h>
27
28
#include <stdint.h>
29
30
class
JoystickForceFeedback
31
{
32
public
:
33
/** Direction of the effect. */
34
typedef
enum
{
35
DIRECTION_DOWN
= 0x0000,
/**< Downward effect direction. */
36
DIRECTION_LEFT
= 0x4000,
/**< Left effect direction. */
37
DIRECTION_UP
= 0x8000,
/**< Upward effect direction. */
38
DIRECTION_RIGHT
= 0xC000
/**< Right effect direction. */
39
}
Direction
;
40
41
JoystickForceFeedback
(
const
char
*device_name);
42
~JoystickForceFeedback
();
43
44
void
rumble
(uint16_t strong_magnitude,
45
uint16_t weak_magnitude,
46
Direction
direction =
DIRECTION_DOWN
,
47
uint16_t length = 0,
48
uint16_t delay = 0);
49
50
void
stop_all
();
51
void
stop_rumble
();
52
53
bool
54
is_rumbling
()
55
{
56
return
(rumble_.id != -1);
57
}
58
bool
59
can_rumble
()
60
{
61
return
can_rumble_;
62
}
63
bool
64
can_periodic
()
65
{
66
return
can_periodic_;
67
}
68
bool
69
can_constant
()
70
{
71
return
can_constant_;
72
}
73
bool
74
can_spring
()
75
{
76
return
can_spring_;
77
}
78
bool
79
can_friction
()
80
{
81
return
can_friction_;
82
}
83
bool
84
can_damper
()
85
{
86
return
can_damper_;
87
}
88
bool
89
can_inertia
()
90
{
91
return
can_inertia_;
92
}
93
bool
94
can_ramp
()
95
{
96
return
can_ramp_;
97
}
98
bool
99
can_square
()
100
{
101
return
can_square_;
102
}
103
bool
104
can_triangle
()
105
{
106
return
can_triangle_;
107
}
108
bool
109
can_sine
()
110
{
111
return
can_sine_;
112
}
113
bool
114
can_saw_up
()
115
{
116
return
can_saw_up_;
117
}
118
bool
119
can_saw_down
()
120
{
121
return
can_saw_down_;
122
}
123
bool
124
can_custom
()
125
{
126
return
can_custom_;
127
}
128
129
private
:
130
int
fd_;
131
struct
ff_effect rumble_;
132
133
int
num_effects_;
134
135
bool
can_rumble_;
136
bool
can_periodic_;
137
bool
can_constant_;
138
bool
can_spring_;
139
bool
can_friction_;
140
bool
can_damper_;
141
bool
can_inertia_;
142
bool
can_ramp_;
143
bool
can_square_;
144
bool
can_triangle_;
145
bool
can_sine_;
146
bool
can_saw_up_;
147
bool
can_saw_down_;
148
bool
can_custom_;
149
};
150
151
#endif
JoystickForceFeedback::can_spring
bool can_spring()
Definition:
force_feedback.h:78
JoystickForceFeedback::stop_all
void stop_all()
Stop all current effects.
Definition:
force_feedback.cpp:290
JoystickForceFeedback::can_ramp
bool can_ramp()
Definition:
force_feedback.h:98
JoystickForceFeedback::can_damper
bool can_damper()
Definition:
force_feedback.h:88
JoystickForceFeedback::can_saw_down
bool can_saw_down()
Definition:
force_feedback.h:123
JoystickForceFeedback::can_triangle
bool can_triangle()
Definition:
force_feedback.h:108
JoystickForceFeedback::can_rumble
bool can_rumble()
Definition:
force_feedback.h:63
JoystickForceFeedback::~JoystickForceFeedback
~JoystickForceFeedback()
Destructor.
Definition:
force_feedback.cpp:226
JoystickForceFeedback::DIRECTION_DOWN
Downward effect direction.
Definition:
force_feedback.h:44
JoystickForceFeedback
Definition:
force_feedback.h:29
JoystickForceFeedback::can_periodic
bool can_periodic()
Definition:
force_feedback.h:68
JoystickForceFeedback::DIRECTION_LEFT
Left effect direction.
Definition:
force_feedback.h:45
JoystickForceFeedback::can_friction
bool can_friction()
Definition:
force_feedback.h:83
JoystickForceFeedback::DIRECTION_UP
Upward effect direction.
Definition:
force_feedback.h:46
JoystickForceFeedback::can_saw_up
bool can_saw_up()
Definition:
force_feedback.h:118
JoystickForceFeedback::can_sine
bool can_sine()
Definition:
force_feedback.h:113
JoystickForceFeedback::rumble
void rumble(uint16_t strong_magnitude, uint16_t weak_magnitude, Direction direction=DIRECTION_DOWN, uint16_t length=0, uint16_t delay=0)
Rumble the joystick.
Definition:
force_feedback.cpp:245
JoystickForceFeedback::stop_rumble
void stop_rumble()
Stop rumbling.
Definition:
force_feedback.cpp:278
JoystickForceFeedback::Direction
Direction
Direction of the effect.
Definition:
force_feedback.h:38
JoystickForceFeedback::can_square
bool can_square()
Definition:
force_feedback.h:103
JoystickForceFeedback::JoystickForceFeedback
JoystickForceFeedback(const char *device_name)
Constructor.
Definition:
force_feedback.cpp:122
JoystickForceFeedback::can_constant
bool can_constant()
Definition:
force_feedback.h:73
JoystickForceFeedback::can_custom
bool can_custom()
Definition:
force_feedback.h:128
JoystickForceFeedback::can_inertia
bool can_inertia()
Definition:
force_feedback.h:93
JoystickForceFeedback::is_rumbling
bool is_rumbling()
Definition:
force_feedback.h:58
JoystickForceFeedback::DIRECTION_RIGHT
Right effect direction.
Definition:
force_feedback.h:47
src
plugins
joystick
force_feedback.h
Generated by
1.8.16