-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
First attempt GLFW gamepad driver (don't merge yet?) #222
Conversation
src/core/os_glfw.h
Outdated
@@ -10,6 +10,9 @@ | |||
#include <GLFW/glfw3native.h> | |||
#endif | |||
|
|||
#ifdef OS_GLFW_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did something dubious here. Right now os_glfw.h can only be included in one file because it defines non-static symbols. But os_glfw seems(?) to be the only way we have of getting glfw.h. For this reason gamepad.c #defines OS_GLFW_H and then includes os_glfw.h. Maybe this could be done a cleaner way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os_glfw
is designed to only be included in one translation unit right now, the os_*.c
translation units (since it provides most of the symbols in os.h).
Joystick input could go through the existing "os" layer or GLFW could be included directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's OK with you I think I'll switch to including GLFW directly.
I wonder if the driver should be named "GLFWGamepad" instead of "Gamepad", or something.
src/modules/headset/headset.h
Outdated
MAX_DEVICES, | ||
|
||
DEVICE_GAMEPAD_FIRST = DEVICE_GAMEPAD_1, | ||
DEVICE_GAMEPAD_LAST = DEVICE_GAMEPAD_1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current gamepad driver accepts 1 gamepad at a time. If you have 2 plugged in and unplug 1, it promotes the other plugged-in one.
But notice, the way gamepad.c is written it can handle an arbitrary number of gamepad devices. The GLFW maximum number of gamepads is, I think, 14. I think having 4 gamepad devices would make a lot of sense. In my testing I had a problem because "spacemouse emulator" was showing up as a joystick device on Windows according to GLFW, so a real gamepad never got a chance to grab the GAMEPAD_1 slot (I uninstalled spacemouse for testing to work around this). If we supported 4 gamepads this would not have been a problem.
|
||
void discoverGamepads() { | ||
for(int jid = 0; jid < GLFW_JOYSTICK_LAST; jid++) { | ||
if (glfwJoystickPresent(jid)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use glfwJoystickPresent()
, but maybe we should use glfwJoystickIsGamepad()
. It is not clear to me exactly which devices say yes to "present" but not to "isGamepad".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GLFW docs say if you're only interested in gamepads, you can use isGamepad as a replacement for isPresent
Currently it isn't possible to access the separate left/right triggers, left/right joysticks, or access the dpad. These features seem important for gamepad input. Also I think mapping both shoulder buttons to the grip button/axis is confusing, if I saw a grip input on a gamepad I would think it was force-sensitive. Maybe there could be buttons for |
Agreed, those were stopgap behaviors.
What do you think of possibility 2? I have no idea what to do with the D-pad. |
Option 2 sounds like "arrayed buttons and axes" are being proposed. So anywhere a |
I think the dpad could be 4 new buttons. |
@bjornbytes What you say in both of your new comments sounds good to me. |
Ok. I can think of some downsides to adopting the system of arrayed buttons and axes.
There are some benefits though like being able to use numbers instead of format strings if you wanted to programmatically generate buttons or something. So the benefits would need to be weighed against the drawbacks. |
Some zip writers do not write the compressed size to the local file headers.
Lua was happily compiling nil chunks and making them return empty strings, which was not a good error experience in situations where your file couldn't be loaded properly. Now we return nil plus an error message, which matches LOVE and other Lua conventions.
Instead it returns a boolean indicating if the send worked.
Instead of anisotropic being its own filter, it is now removed and anisotropy settings can be used with any of the other filter modes.
Surprisingly, this appears to be the only place reading out of enum arrays like this, so there shouldn't be any other places to fix.
as mentioned on slack. there are some situations you can get into (high load in some place or other) where the newer frame submission api will behave much more consistently, and I've noticed no negative effects. besides, the other one is deprecated as best i can tell.
update ovr driver to newer frame submission api
Kill mat4_transform_project
seems a little strange that vibrating head or something would affect the right controller.
implement haptics on oculus desktop
Merged with master and fixed some bugs. Outstanding questions before this can be merged:
|
|
"it would be okay to delegate this to Lua" if we include the isPresent. "I'd prefer separate enumerants like thumbstick/left and thumbstick/right for the multiple buttons/axes" Alright, but long term I'd still like some sort of method (or easy means to build a method) for merging "thumbstick", "thumbstick/left" and "touchpad" into one input in apps that need that. Sorry I haven't worked on this in a while… |
I wonder if getPose could return true and all zeroes if the gamepad is connected. This causes an issue with PS move controllers because with those you would no longer be able to tell if tracking is lost for those. But you would at least be able to do |
I'm...not sure what to do about this, but I think about it often. There should definitely be joystick input, eventually. But the current structure of the headset module, and how it handles input, makes integrating joysticks challenging. The design of OpenXR's action system, which lovr.headset sort of followed, is not really conducive to joysticks (can't have 'numbered' devices, can't detect whether a device is present/connected). Thinking super highlevel/longterm I think aligning with OpenXR actions was a mistake, and an engine needs to have its own input abstraction, so that it can integrate with keyboard/mice/joysticks/spacethings. Maybe that input abstraction is still action-based, but it has to be on top of OpenXR, treating it like a lower-level driver. Otherwise it simply can't integrate with the other stuff cleanly. So, maybe someday it will look like Plugins are a thing now. Maybe starting there would be more successful, free from the confines of lovr.headset? There's even https://github.com/Rabios/lovr-joystick which is an ffi-based solution. It also seems like this PR has fallen victim to gitrot. I think it's best to close backs away slowly |
This is a standalone driver that provides gamepad support on desktop. Gamepad support on oculus mobile would have to be done separately. In my testing this works on Mac and Windows.
This should probably wait until the isTracked changes to go in. Right now isTracked() returns false for all gamepads because they don't have a pose.