We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4789 - Linux accelerometers no longer available as joysticks
Summary: Linux accelerometers no longer available as joysticks
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: HG 2.1
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-05 05:32 UTC by Daniel Drake
Modified: 2019-09-06 15:43 UTC (History)
0 users

See Also:


Attachments
Support SDL_HINT_ACCELEROMETER_AS_JOYSTICK on Linux (1.04 KB, patch)
2019-09-05 05:32 UTC, Daniel Drake
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Drake 2019-09-05 05:32:00 UTC
Created attachment 3952 [details]
Support SDL_HINT_ACCELEROMETER_AS_JOYSTICK on Linux

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.
Comment 1 Sam Lantinga 2019-09-06 15:43:15 UTC
Looks good to me, thanks!
https://hg.libsdl.org/SDL/rev/211e1b06ec47