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

Summary: Linux accelerometers no longer available as joysticks
Product: SDL Reporter: Daniel Drake <dan>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: Support SDL_HINT_ACCELEROMETER_AS_JOYSTICK on Linux

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