OpenVR-Advanced-Settings / OpenVR-AdvancedSettings

OpenVR Advanced Settings Dashboard Overlay
GNU General Public License v3.0
1.23k stars 124 forks source link

Hotkeys to switch between 'Space Offset' profiles #365

Open CylonSurfer opened 4 years ago

CylonSurfer commented 4 years ago

The ability to switch between 'Space Offset' profiles via the use of keyboard hotkeys while in game.

For example, I have a default profile with no height offset and I want to switch to a profile I have created with a height offset of -0.20 so I would press 'ctrl + i' or some other key combination (or even run a commandline) . This would really help with mods for games such as Fallout 4 VR, which instead of moving the camera height when the player enters a Power Armor in order to make the player taller it changes world scale. Via the use of hotkeyed profiles I could script the pressing of the keys when a player enters the Power Armor in order to actually change the players height rather than the game changing scale.

username223 commented 4 years ago

It's a relatively complex problem that has a few different possible solutions, all with relatively high up front cost.

Catch hotkeys in window

This is the simplest solution, but it would still require some changes. Qt only catches key events when the window is in focus. Currently we don't show a window unless the app is run with --desktop-mode, which makes the VR view disappear. Showing both at the same time is possible, but not an ideal solution for this problem since the OVRAS window needs to be in focus for the feature to work.

Globally catch hotkeys

Globally catching hotkeys is OS specific. There are some third party libraries for this. This solution is relatively simple, but it does not directly solve the issue since every single function would require a hotkey.

Add some form of Inter Process Communication (IPC)

This is the hardest to implement but would also be the most powerful. The implementations are also OS specific. Most likely DBUS would be used for Linux and COM for Windows. The OS differences means that we would likely have to create an external C bindings library for OVRAS to abstract away the DBUS/COM stuff.

This solution is probably way overkill considering how OVRAS is basically just a GUI for openvr and how much of a nightmare DBUS/COM is to work with, in addition to having to create and maintain a bindings library.

VR bindings for switching profiles

A completely different approach would be to make a VR controller binding for changing profiles. This solution is relatively easy to implement, but would probably be very limited in usability.

@Kung-vr @ykeara What do you think?

CylonSurfer commented 4 years ago

Thanks for the reply. In my use case the only solution I wouldn't see working would be VR controller bindings for changing the profiles as I have no way to emulate controller input via scripting. Wouldn't a key combination do the same thing though? Instead of your app listening for a controller button press it would be listening for a standard Windows / Linux keyboard press or combination of keys being pressed?

username223 commented 4 years ago

We already have the VR inputs implemented through the OpenVR API, so it's trivial to add another.

Global hotkeys (window not in focus) are more difficult and platform specific, so we would need to use a third party library. This is not that big of an issue, but it does lead to some issues in choosing which functionality should be exposed through the keyboard shortcuts.