diff --git a/BBGE/Joystick.cpp b/BBGE/Joystick.cpp index 8fb780f..876e943 100644 --- a/BBGE/Joystick.cpp +++ b/BBGE/Joystick.cpp @@ -22,24 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Core.h" -#ifdef __LINUX__ -#include -#include -#include -#include -#include -#include -#include - -#define BITS_TO_LONGS(x) \ - (((x) + 8 * sizeof (unsigned long) - 1) / (8 * sizeof (unsigned long))) -#define AQUARIA_BITS_PER_LONG (sizeof(long) * 8) -#define AQUARIA_OFF(x) ((x)%AQUARIA_BITS_PER_LONG) -#define AQUARIA_BIT(x) (1UL<> AQUARIA_OFF(bit)) & 1) -#endif - Joystick::Joystick() { stickIndex = -1; @@ -48,10 +30,6 @@ Joystick::Joystick() sdl_haptic = NULL; # endif sdl_joy = NULL; -#if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2) - eventfd = -1; - effectid = -1; -#endif inited = false; buttonBitmask = 0; deadZone1 = 0.3; @@ -124,57 +102,10 @@ void Joystick::init(int stick) { debugLog("Not enough Joystick(s) found"); } - -#if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2) - os.seekp(0); - os << "AQUARIA_EVENT_JOYSTICK" << stick; - - std::string envkey = os.str(); - const char* evdevice = getenv(envkey.c_str()); - - if (evdevice != NULL) { - eventfd = open(evdevice, O_RDWR, 0); - if (eventfd < 0) { - debugLog(std::string("Could not open rumble device [") + evdevice + "]: " + strerror(errno)); - } - else { - debugLog(std::string("Successfully opened rumble device [") + evdevice + "]"); - unsigned long features[BITS_TO_LONGS(FF_CNT)]; - - if (ioctl(eventfd, EVIOCGBIT(EV_FF, sizeof(features)), features) == -1) { - debugLog(std::string("Cannot query joystick/gamepad features: ") + strerror(errno)); - close(eventfd); - eventfd = -1; - } - else if (!test_bit(FF_RUMBLE, features)) { - debugLog("Rumble is not supported by your gamepad/joystick."); - close(eventfd); - eventfd = -1; - } - } - } - else { - std::cout << - "Environment varialbe " << envkey << " is not set.\n" - "Set this environment variable to the device file that shall be used for joystick number " << stick << " in order to enable rumble support.\n" - "Example:\n" - "\texport " << envkey << "=/dev/input/event6\n\n"; - } -#endif - } void Joystick::shutdown() { -#if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2) - if (eventfd >= 0) { - if (effectid != -1 && ioctl(eventfd, EVIOCRMFF, effectid) == -1) { - debugLog(std::string("Remove rumble effect: ") + strerror(errno)); - } - close(eventfd); - eventfd = -1; - } -#endif #ifdef BBGE_BUILD_SDL2 if (sdl_haptic) { @@ -214,49 +145,6 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time) SDL_HapticRumbleStop(sdl_haptic); } } - -#elif defined(__LINUX__) - if (eventfd >= 0) { - struct ff_effect effect; - struct input_event event; - - effect.type = FF_RUMBLE; - effect.id = effectid; - effect.direction = 0; - effect.trigger.button = 0; - effect.trigger.interval = 0; - effect.replay.length = (uint16_t) (time * 1000); - effect.replay.delay = 0; - if (leftMotor > rightMotor) { - effect.u.rumble.strong_magnitude = (uint16_t) (leftMotor * 0xffff); - effect.u.rumble.weak_magnitude = (uint16_t) (rightMotor * 0xffff); - } - else { - effect.u.rumble.strong_magnitude = (uint16_t) (rightMotor * 0xffff); - effect.u.rumble.weak_magnitude = (uint16_t) (leftMotor * 0xffff); - } - - if (ioctl(eventfd, EVIOCSFF, &effect) == -1) { - debugLog(std::string("Upload rumble effect: ") + strerror(errno)); - return; - } - - event.time.tv_sec = 0; - event.time.tv_usec = 0; - event.type = EV_FF; - event.code = effectid = effect.id; - - if (leftMotor == 0 && rightMotor == 0) { - event.value = 0; - } - else { - event.value = 1; - } - - if (write(eventfd, (const void*) &event, sizeof(event)) == -1) { - debugLog(std::string("Play rumble effect: ") + strerror(errno)); - } - } #endif } } diff --git a/BBGE/Joystick.h b/BBGE/Joystick.h index 1b4692f..c9ed867 100644 --- a/BBGE/Joystick.h +++ b/BBGE/Joystick.h @@ -33,17 +33,12 @@ public: private: bool inited; unsigned buttonBitmask; // FIXME: this should go + SDL_Joystick *sdl_joy; # ifdef BBGE_BUILD_SDL2 SDL_GameController *sdl_controller; SDL_Haptic *sdl_haptic; # endif - SDL_Joystick *sdl_joy; - -#if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2) - int eventfd; - short effectid; -#endif }; diff --git a/README.txt b/README.txt index b7d217d..b4ae7c8 100644 --- a/README.txt +++ b/README.txt @@ -175,27 +175,3 @@ are updated with those from the repo's game_scripts/_mods directory. If this doesn't apply to your setup, ask. [email, github, IRC, ...] - - - - -[SDL 1.2 ONLY -- LINUX RUMBLE SUPPORT] ---------------------------------------- - -SDL 1.2 does not support rumble features, even though Linux does. This -feature will be added in SDL 1.3, which is still a long time coming. - -In the meantime there is a hackish rumble implementation for Linux that -needs environment variables to be set that map joysticks via their indices -to event devices. E.g. to map the first joystick to the event device -"/dev/input/event6" you need to run aquaria like this: - -$ export AQUARIA_EVENT_JOYSTICK0=/dev/input/event6 -$ aquaria - -Because aquaria is a single player game you never need to map another joystick -than the first one. Also keep in mind that your joystick event device has -another path. E.g. I use this command to run aquaria: - -$ export AQUARIA_EVENT_JOYSTICK0=/dev/input/by-id/usb-©Microsoft_Corporation_Controller_0709960-event-joystick -$ aquaria