-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Linux support for illuminance sensors #17208
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # input/drivers/x11_input.c
- Whoops, forgot to declare `sdl`
- Allow the poll rate to be specified - Poll the sensor on a separate thread - Open a file handle each time we poll the sensor, since sysfs doesn't update the contents of an existing handle
Oh, one more thing; if the sensor is closed while the poll thread is in |
I think I'll use |
If you want to do any threading at all I'd have to suggest using rthreads instead, at least that way we are not tied/dependent on pthread. Anyway is this PR good to merge? |
Do we support any Linux environments that don't provide pthread? The functionality in this PR is fundamentally Linux-specific. Linux follows POSIX semantics about which of its library functions can be cancelled, and that includes the I also use The Windows implementation of rthreads is irrelevant here because this PR will never run on Windows. Same goes for the Having said that, I'm still evaluating whether this actually solves the problem; it's possible that I'll need to try something else.
Almost. First I want to solve the problem of blocking the thread when closing the sensor. |
@LibretroAdmin All right, I'm good to go. Thanks for checking this out. |
Alright I'll give it a look over the next day or so. |
Description
This pull requests implements support for illuminance sensors on Linux; the reading is exposed through
retro_sensor_interface
andRETRO_SENSOR_ILLUMINANCE
. I used my Steam Deck to develop and test it, but this should work on any Linux device that has a light sensor.Here's a video of it in action:
https://www.youtube.com/watch?v=0cCWS5X3Jcg
Some details about the implementation:
sdl2
) exceptwayland
. The implementation is orthogonal to the other controller drivers, as illuminance sensors use a different interface than gamepads.rate
parameter ofretro_set_sensor_state_t
. If the rate is zero, it defaults to 5 times a second. I don't use locks, as I'm assuming that aligned 4-byte reads and writes are atomic on the CPUs that would run this patch. If this assumption is incorrect, please let me know.retro_set_sensor_state_t
, and I'm working on it for melonDS DS.Related Pull Requests
#16188 touches the same interface (though not for illuminance), and will likely have to be updated to address merge conflicts.