Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * force_feedback.h - Force feedback for joysticks using Linux input API 00004 * 00005 * Created: Sun Feb 06 23:50:57 2011 (Super Bowl XLV) 00006 * Copyright 2006-2011 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __PLUGINS_JOYSTICK_FORCE_FEEDBACK_H_ 00024 #define __PLUGINS_JOYSTICK_FORCE_FEEDBACK_H_ 00025 00026 #include <stdint.h> 00027 #include <linux/input.h> 00028 00029 class JoystickForceFeedback 00030 { 00031 public: 00032 /** Direction of the effect. */ 00033 typedef enum { 00034 DIRECTION_DOWN = 0x0000, /**< Downward effect direction. */ 00035 DIRECTION_LEFT = 0x4000, /**< Left effect direction. */ 00036 DIRECTION_UP = 0x8000, /**< Upward effect direction. */ 00037 DIRECTION_RIGHT = 0xC000 /**< Right effect direction. */ 00038 } Direction; 00039 00040 JoystickForceFeedback(const char *device_name); 00041 ~JoystickForceFeedback(); 00042 00043 void rumble(uint16_t strong_magnitude, uint16_t weak_magnitude, 00044 Direction direction = DIRECTION_DOWN, 00045 uint16_t length = 0, uint16_t delay = 0); 00046 00047 void stop_all(); 00048 void stop_rumble(); 00049 00050 bool is_rumbling() { return (__rumble.id != -1); } 00051 bool can_rumble() { return __can_rumble; } 00052 bool can_periodic() { return __can_periodic; } 00053 bool can_constant() { return __can_constant; } 00054 bool can_spring() { return __can_spring; } 00055 bool can_friction() { return __can_friction; } 00056 bool can_damper() { return __can_damper; } 00057 bool can_inertia() { return __can_inertia; } 00058 bool can_ramp() { return __can_ramp; } 00059 bool can_square() { return __can_square; } 00060 bool can_triangle() { return __can_triangle; } 00061 bool can_sine() { return __can_sine; } 00062 bool can_saw_up() { return __can_saw_up; } 00063 bool can_saw_down() { return __can_saw_down; } 00064 bool can_custom() { return __can_custom; } 00065 00066 private: 00067 int __fd; 00068 struct ff_effect __rumble; 00069 00070 int __num_effects; 00071 00072 bool __can_rumble; 00073 bool __can_periodic; 00074 bool __can_constant; 00075 bool __can_spring; 00076 bool __can_friction; 00077 bool __can_damper; 00078 bool __can_inertia; 00079 bool __can_ramp; 00080 bool __can_square; 00081 bool __can_triangle; 00082 bool __can_sine; 00083 bool __can_saw_up; 00084 bool __can_saw_down; 00085 bool __can_custom; 00086 00087 }; 00088 00089 00090 #endif