mirror of https://github.com/encounter/SDL.git
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_loadso.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "../unix/SDL_poll.h"
|
||||
|
||||
static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };
|
||||
|
@ -420,6 +421,12 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
|
|||
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
||||
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");
|
||||
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
|
||||
|
|
Loading…
Reference in New Issue