mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
Fixed bug 4789 - Linux accelerometers no longer available as joysticks
Daniel Drake A long time ago, it was possible to play neverball on Linux using the accelerometer found in HP laptops. The kernel exposes the accelerometer as a joystick (/dev/input/jsX) as well as an evdev device (/dev/input/eventX). I guess it worked fine when SDL was using the js interface, but then stopped working here: http://hg.libsdl.org/SDL/rev/fdaeea9e7567 Looking at current code which uses udev to discover joysticks, it looks for the udev tag ID_INPUT_JOYSTICK. However udev's internal input_id logic specifically tags accelerometers as ID_INPUT_ACCELEROMETER and nothing else. This looks like a good fit for SDL_HINT_ACCELEROMETER_AS_JOYSTICK.
This commit is contained in:
parent
8a394209c4
commit
aaec90e5c5
@ -34,6 +34,7 @@
|
|||||||
#include "SDL_assert.h"
|
#include "SDL_assert.h"
|
||||||
#include "SDL_loadso.h"
|
#include "SDL_loadso.h"
|
||||||
#include "SDL_timer.h"
|
#include "SDL_timer.h"
|
||||||
|
#include "SDL_hints.h"
|
||||||
#include "../unix/SDL_poll.h"
|
#include "../unix/SDL_poll.h"
|
||||||
|
|
||||||
static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
|
static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
|
||||||
@ -421,6 +422,12 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
|||||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER");
|
||||||
|
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) &&
|
||||||
|
val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
||||||
|
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
||||||
|
}
|
||||||
|
|
||||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
|
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
|
||||||
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
||||||
devclass |= SDL_UDEV_DEVICE_MOUSE;
|
devclass |= SDL_UDEV_DEVICE_MOUSE;
|
||||||
|
Loading…
Reference in New Issue
Block a user