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
31{
32public:
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. */
40
41 JoystickForceFeedback(const char *device_name);
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
55 {
56 return (rumble_.id != -1);
57 }
58 bool
60 {
61 return can_rumble_;
62 }
63 bool
65 {
66 return can_periodic_;
67 }
68 bool
70 {
71 return can_constant_;
72 }
73 bool
75 {
76 return can_spring_;
77 }
78 bool
80 {
81 return can_friction_;
82 }
83 bool
85 {
86 return can_damper_;
87 }
88 bool
90 {
91 return can_inertia_;
92 }
93 bool
95 {
96 return can_ramp_;
97 }
98 bool
100 {
101 return can_square_;
102 }
103 bool
105 {
106 return can_triangle_;
107 }
108 bool
110 {
111 return can_sine_;
112 }
113 bool
115 {
116 return can_saw_up_;
117 }
118 bool
120 {
121 return can_saw_down_;
122 }
123 bool
125 {
126 return can_custom_;
127 }
128
129private:
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
Cause force feedback on a joystick.
bool can_spring()
Check if spring effect is supported.
bool can_inertia()
Check if inertia effect is supported.
bool can_ramp()
Check if ramp effect is supported.
Direction
Direction of the effect.
@ DIRECTION_RIGHT
Right effect direction.
@ DIRECTION_DOWN
Downward effect direction.
@ DIRECTION_LEFT
Left effect direction.
@ DIRECTION_UP
Upward effect direction.
JoystickForceFeedback(const char *device_name)
Constructor.
bool can_friction()
Check if friction effect is supported.
bool can_square()
Check if square effect is supported.
bool is_rumbling()
Check if rumbling effect is active.
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.
bool can_saw_down()
Check if downward saw effect is supported.
bool can_triangle()
Check if triangle effect is supported.
bool can_rumble()
Check if rumbling effect is supported.
bool can_periodic()
Check if periodic effect is supported.
bool can_sine()
Check if sine effect is supported.
bool can_custom()
Check if custom effect is supported.
bool can_damper()
Check if damper effect is supported.
bool can_saw_up()
Check if upward saw effect is supported.
void stop_all()
Stop all current effects.
bool can_constant()
Check if constant effect is supported.
void stop_rumble()
Stop rumbling.
~JoystickForceFeedback()
Destructor.