* OpenXR: the controllers' slots are not read from the driver's view
A joypad driver that keeps its pads' state lends it to the snapshot
bridge through view(), and the bridge reads that in place of a copy
(48f9503c16). The headset's joypad wrapper is made from the driver it
wraps and kept that driver's view(), so under udev or winraw the
bridge read the controllers' slots from the driver's own pads there,
which are empty: the OpenXR controllers gave no input at all.
The wrapper of a driver that lends now has a view() of its own. It
lends none for the controllers' slots, which the bridge then copies
through the wrapper's button and axis calls, and the driver's for
every other slot.
openxr_input wraps a driver that lends all-zero views, and reads the
controllers' slot and one of the driver's the way the bridge does.
* Menu: bind capture goes to the bound user, not the controller slot
A bind capture knows the user whose binds it sets and the slot of the
controller it listens to, that user's Device Index. Three of its steps
used the user whose number is the slot instead: Bind All set every
bind after the first in that user's binds, each capture took the key
it replaced, whose mapping bit it clears, from that user's bind, and a
mouse bind listened to that user's mouse.
So with user 1's Device Index set by hand to the controller in slot 3,
Bind All for user 1 wrote all but its first bind over user 3's, which
were saved as such, and cleared the bit of a key user 3 still had
bound. A mouse bind for user 1 was never heard with one mouse, and
took user 3's click with a mouse for each user, though at run time
user 1's binds read user 1's mouse. All three now go to the bound
user.
frontend_overhead runs Bind All for user 1 on slot 3, and clicks each
user's mouse while binding user 1's B there.
* samples: hotkey_menu reads its sources as UTF-8
extract.py read input/input_driver.c in the locale's encoding, cp1252
for a native Windows Python, which fails on that file's UTF-8, so the
harness did not build there without PYTHONUTF8=1. It reads and writes
UTF-8 now; on Linux its output is unchanged.
* Input: a core port's rumble reaches every user mapped to it
A core port's rumble now goes to every user mapped to that port, the
users its input is read from, rather than to the user with the port's
number. Its motor answers true when any of theirs does; a port no user
is mapped to rumbles nothing and answers false. With every user on its
own port nothing changes.
* Input: Tap Delay holds Hotkey Enable back from its first frame
The hotkey pass reads the controllers as the last poll left them, and
the frame's own poll comes after it, under early, normal and late
polling alike. So with Hotkey Enable Tap Delay on, each press of the
Enable button reached the core for one frame before the tap saw it
and began holding it back.
While the tap is idle, a core read that finds the Enable's game button
down now asks whether the Enable is held in the frame's poll, and if
so holds the button back. The same button from another controller or
key, with the Enable up, is still the game's. Other reads cost one
test, and with Tap Delay at 0 nothing changes.
* Input: users sharing a core port drive the menu and fire profile hotkeys
With the menu up, user 1 and every user mapped to its core port drive
it. The other users on the hotkey user's core port fire hotkeys from
their own controllers in the one hotkey pass; with Hotkeys Follow
Player 1 those are core port 1's other users. With user 1 on None, the
users on core port 1 do both, and user 1 keeps them. With every user
on its own port nothing changes.
A sharing controller fires the hotkeys its profile binds, never the
hand-set ones, which stay the hotkey user's pad's: a hand-set button
names a button of one controller, and on a pad of another model it is
some other button. Its Hotkey Enable is its profile's too. While the
hotkey user has a Hotkey Enable, a sharer's hotkeys need the sharer's
own or the keyboard's, and a sharer holding its own opens only its own
hotkeys, not the hotkey user's; held on any of them, it holds game
input back. With none for the hotkey user, sharers fire freely. The
table of a sharer's profile hotkeys is made when a bind or its profile
changes, not each frame.
With Hotkey Enable Tap Delay each controller taps on its own: a tap
holds back and replays that controller's own Enable button. A hotkey
swallows the tap of the controller that fired it, and the keyboard's
tap when the keyboard's Enable opened it. Any controller's Enable held
short of the delay holds game input back, another controller's Enable
held past it included. Enable presses released while the delay is 0
are not played once it is turned on, user 1's included.
* Input: Plays As, a controller's own player, places it on connect
Sixteen entries, input_plays_as_device_N and input_plays_as_player_N,
name controllers as a reservation does, vid:pid then name, each with a
player (0 Auto). When they are read, each connected controller, lowest
slot first, takes the first entry naming it that no other has taken; a
0000:0000 vid:pid matches by the name after it, not every controller
without one. Giving a controller a player makes an entry for it,
refused when all sixteen are in use; set back to Auto, its entry is
freed.
The entries are read with the binds and written with the input
entries, a free entry's keys taken out. Two of a model are told apart
only by order, so a model's entries are written at their own places
in the order a start hands them out: lowest slot first, a gone one's
in its place, and one on Auto ahead of another of its model as an
Auto entry of its own. Once the main configuration is saved, the
entries in memory are laid out the same way, so reading it again in
the session gives each its own too. Saving an override puts them back
after its comparison load, as it does the binds. The reservations'
vid:pid parse is shared with them, unchanged.
On connect, a controller set to player N takes port N. Whoever else is
there moves to the first free port, unless it also plays as N, by its
own player or, on Auto, by N's reservation naming it: then the
newcomer shares, from the highest free port below Max Users. An Auto
controller that N's reservation names shares the same way when port N
holds a controller set to N. An explicit player beats a reservation
naming the controller. With any reservation set, Auto controllers are
otherwise left to the reservations; with none, and a player set by an
entry, they take the first free port. With no player set nothing
changes.
The moves are for this run only, through input_driver_exchange_ports(),
now in every build: the configuration keeps the ports the user set. A
reservation's own placement made while the ports are in a runtime
layout is runtime as well, so it is not saved either; reservations
place again at every connect.
A joypad driver restart lets go of every claim, since its pads can come
back in other slots with no disconnect: a pad reported again where it
is plugged in takes back its entry, the rest take theirs in slot order.
While a player is in effect, the registry's restore of the ports is
left to placement. A config reload keeps each controller's entry while
it still names it, so two of a model keep theirs. The entries count
among the settings whose change starts the joypad driver again at a
video restart, and so does a config reload that undid runtime moves.
* Input: a controller playing as another's player shares its core port
A user whose controller plays as another user's player feeds that
user's core port through the port map: that user's Mapped Port, from
remap files or identity. Its own Mapped Port is never changed or
saved. Everything that reads a user's core port reads this effective
port, and the Quick Menu's Mapped Port row reads "Shares Player 1 (core
port 1)" for a sharer.
An Auto controller placed to share with the player a reservation names
keeps sharing while it stays connected, also once that player's
controller leaves. The poll rebuilds the map when who shares changes,
and the core is told its controllers again between frames, not while
netplay or a replay owns the ports. Under First Press a press on any
of a player's controllers gives that player's user its port.
* Menu: a controller's player in Input > Controllers and Port N Controls
Settings > Input > Controllers, after RetroPad Binds, has a row per
connected controller in port order, then those past Max Users, then
the Plays As entries of controllers that are gone. A row's value is
the controller's player or, on Auto with a port, "Auto (1)", the player
Auto gives it. The sublabel names the player first and a controller
port only by its page name: "Player 1", "Player 1, shared · binds in
Port 3 Controls" for a controller sharing a player from another port,
"Not playing: more controllers than Max Users", or "Not connected".
On a Controllers row, Left and Right step through Auto, 1 to Max Users;
OK opens them as a list. RetroPad Binds > Port N Controls starts with a
row for each connected controller playing as the player port N feeds,
the same setting, then Add Controller: the other connected controllers
with a port, each with the player it plays as now, where a pick moves
that controller to this player. One controller on several players stays
Device Index's.
A change to a connected controller marks the configuration changed and
places it again as its connect did, with any controller it pushes off a
port, and no driver restarted. The entry point is in task_autodetect.c,
beside the reservation placement it reuses. A controller whose change
left no player in effect goes to the first free port. While Plays As is
in use, a change of Max Users places again the controllers left with no
port and those whose player comes within it. With every entry taken a
new one is refused with a notice.
A controller set to a player above Max Users reads "Above Max Users:
plays as Auto (Player 2)". On Port N Controls a row's sublabel reads
"This port" or "Shared · binds in Port 3 Controls". Device Index's note
for a controller another port reads becomes "used by Port 2".
After Add Controller, Port N Controls links to Port M Controls for each
controller playing as player N from port M, such as "OpenXR Controllers
(Port 4 Controls)": that controller's binds are port M's. Quick Menu >
Controls > Port N Controls starts with the same links to the pages that
hold its remaps. Both lists and the Quick Menu's Port N Controls are
made again on hotplug, and Port N Controls after a Device Index change,
with the cursor kept on its row.
The menu lanes are in stereo_headset_test, which already links the
shipping menu objects and runs in CI's OpenXR jobs; a build without
OpenXR skips it.
* Input: a controller's own hotkey buttons
A Plays As entry keeps a button and an axis of its own for any hotkey,
input_plays_as_<hotkey>_btn_N and _axis_N, written only where set; an
entry that has one is kept on Auto. It counts neither as a player nor
among the settings whose change starts the joypad driver again. A
sharer reads its own first, then its profile's, never the set's; the
hotkey port's own controller reads its own, then the set's, then its
profile's. Button and axis go each on their own.
The bind values, "8", "h0up", "+1", are read and written by helpers in
input_driver.c that the configuration's own binds now use too.
* Input: Hotkey Enable pairs with the controller it is on
A sharing controller's hotkeys go by its own Hotkey Enable, its bind or
its profile's, whatever the hotkey user has: one with an Enable fires
while it holds it or the keyboard's, one with none fires freely. With
Hotkey Device Type Merge on and a keyboard Hotkey Enable bound, a
sharer with none waits for the keyboard's, as master makes user 1's pad
wait. Holding a sharer's Enable holds game input back as any Hotkey
Enable does, and opens only that sharer's hotkeys.
Keyboard and mouse hotkeys keep master's Hotkey Enable rule whatever
sharers are connected: a sharer's Enable does not open them. Nor does
it open an input_combo_N entry with a key; an entry of RetroPad buttons
alone opens with it, as those buttons are every port's. A sharer with
an Enable of its own needs it for the menu toggle too, and whether a
pending menu tap is kept is read from the sharer's own binds, not the
set's.
The hotkey user's pad Enable plays no part in a sharer's hotkeys: each
controller's hotkeys are its own, and so is its Enable.
With Hotkey Enable Tap Delay, the hotkey of a sharer with no Enable of
its own leaves the keyboard's tap alone, as the keyboard's Enable did
not open it. Under Hotkey Device Type Merge, where such a sharer waits
for the keyboard's Enable, its hotkey swallows the keyboard's tap.
* Menu: hotkeys bound from a sharing controller are its own
Binding a hotkey also listens to the controllers that fire the hotkeys,
those on the hotkey user's core port, and its prompt gains "Listening
to Player 1's controllers", for the player the hotkey user plays as. A
press on the keyboard, the mouse, user 1's pad or the hotkey user's
goes to the set as before; a sharing controller's press is kept as that
controller's own, with an entry made for it at its player, refused with
the full notice when none is free. A press from a controller that has
its own bind for the hotkey replaces that bind, user 1's pad included.
Any bind, RetroPad binds too, also hears the port's own controller when
it is in a slot at or past Max Users, where Plays As placement can put
it, so that port's binds can be set from it.
A hotkey's row shows each connected controller's own after the set's,
"Select · OpenXR Controllers: L3", and clearing it clears theirs too.
* OpenXR: the headset shares player 1 on Auto and moves no one
For the headset's controllers, Combined or each hand in Separate, Auto
means sharing player 1, so a VR player's pad and headset both drive
player 1 with no setup. They take the highest free slot and the highest
free port below Max Users, so pads keep the low ones, and share their
player whether anyone is on its port or not, moving no one; a pad
turned on later lands on port 1 and shares with them. Set to a number,
they do the same with that player. Every other controller's Auto takes
the first free port.
A reservation naming the headset beats its Auto, as for pads, and a
number beats a reservation. A pad set to the player whose port a
headset on Auto holds takes that port, and the headset moves to the
highest free port, or gets none. Any change of Max Users places the
headset again at once, on the highest free port. Wherever Plays As asks
whether a player is in effect, a connected headset on Auto counts as
player 1, as one set to 1 does.
OpenXR looks up each controller's player only when the devices or the
entries change, and places a controller again when it starts or stops
playing as a player, or when a slot below Max Users frees up for one
placed past it. A player's controller that a pad pushed out of its slot
is placed by its player rather than taking the port with it. A headset
entry names the controller by the name OpenXR looks it up by.
The laser answers the core once, for the core port the headset's
controllers play on, so it no longer mixes with another user's mouse;
in Separate each hand's player gets it, the pointing hand aiming and
firing and the other reading offscreen. A headset controller with no
player drives no pointer, and the Monado e2e cases follow the new
placement.
mapped_port_test is built a second time with OpenXR, as
mapped_port_openxr_test, and CI runs both.
* Menu: OpenXR Controller Layout under Input > Controllers
Combined or Separate is how the headset's controllers appear, so it
moves from the headset's video rows to the bottom of
Settings > Input > Controllers, named for what it sets. The key and its
values are unchanged. Switching it reconnects the headset's
controllers, and the cursor stays on the row.
* Input: Plays As in core, content directory and game overrides
Save Override now saves the controllers' own players and hotkeys. Each
controller whose player or own hotkeys differ from the main
configuration's (with --appendconfig) has its whole entry written, all
of its entries for two of a model, in the order a start hands them
out, one on Auto ahead of another of its model as an Auto entry; one
the main configuration gives an entry and the session none is written
as Auto. An entry the same as the main configuration's is not written,
so a controller set back drops out of the override.
An override's entries are read on their own and go over the ones read
before by controller, as entries are matched to controllers (vid:pid,
else name), not by number: the last file naming a controller gives it
its whole entry, in the place of the one it had, two of a model taking
a file's entries in order, an Auto one included, the connected ones
lowest slot first; a controller no override names keeps the main
configuration's. Auto takes one back to Auto, and a controller new to
the entries takes a free one, if any of the sixteen is. Until now the
files' keys merged one by one, so an entry could pair one file's
controller with another's player, and no override could take an entry
back to Auto.
Loading or unloading an override from the menu, or loading the active
ones again, places the controllers again at once, as a Player change
does: those whose player changed, or all of them where the reload read
the configured ports back over the moves. Content load and close leave
it to the joypad driver's restart, as before.
mapped_port_test covers the merge, what is saved and the placing
again; video_screens_test saves, unloads and loads a game override
with a Plays As change.
* Input: a controller keeps its Plays As entry while its twin is unplugged
Two controllers of one model share the entries that name them, each
taking the first one no other connected controller holds. With one of
the two unplugged, anything that made the other take an entry again
could hand it the unplugged one's: a Player or Max Users change,
loading or unloading an override, any re-read of the main config, a
joypad driver restart, and Online Updater > Update Controller
Profiles, which reports every connected controller again. The
controller left then played the other one's player, and that one came
back to its twin's.
An unplugged controller's entry now stays its own for the rest of the
session, and only a connect takes it: that controller coming back, or
another of its model. A reload keeps it while the entry in its place
is still of its model, and an override's entries pair with it as if
the unplugged controller still held it from its slot. So an override
loaded with a twin unplugged gives the other twin the entry it adds
and leaves the unplugged one its own. Save Configuration and Save
Override count it as that controller's too, so what they write pairs
the same way when it is loaded again.
Placed again for a Player or Max Users change, or by Update Controller
Profiles, a controller keeps the entry it holds, or none. Reported
again by its driver while still connected, it keeps the one it holds.
A reload is judged as a whole once its last override is read: a
controller takes an entry it did not hold before only where the
reload added it for its model, so one an override newly names still
gets that entry.
A joypad driver restart still lets every claim go and hands the
entries out again in the order the controllers are reported, as a
start does, but its reports leave an unplugged controller's entry
alone. A driver's report queued behind a profile update's is not
dropped as a repeat of it, since the update takes no entry, and the
update it supersedes shows no toast, so one shows, as before.
* OpenXR e2e: FRAME_BINDS catches up with the grip poses already bound
Every profile binds pointer/grip to both hands' grip poses, and
input-frame-profile matches FRAME_BINDS exactly, so the table now lists
the poses as they are bound.
* Menu: OpenXR touch settings on Input > Controllers
Touch Hands, Touch Button and Touch Passthrough are added for the hands
that touch a screen they point at, the button that touches, and whether
that button's other binds fire too, with Touch Hands None to turn touch
off for the headset's controllers; a later commit puts them to use.
They follow OpenXR Controller Layout, Laser Pointer and Laser Beam,
which move here from Stereo 3D & Screens, at the end of Settings >
Input > Controllers, shown only for a video driver with a headset path.
A hotplug keeps the cursor on any of these rows, and overrides save
them per game.
* OpenXR: the headset's menu button is button 16, bound to Menu Toggle
The menu action of each profile presses button 16 of the pad, the left
hand's in Separate, instead of being a hotkey of its own, and the
built-in profiles bind Menu Toggle to it and label it "Menu", as pad
profiles name their Guide or Home button. It opens the menu from the
same button as before and can be bound elsewhere like a pad's Guide
button. Touch's one menu button presses button 16 once held a second.
In Edit Screens the menu button always opens the menu, whatever is
bound and whether or not Hotkey Enable is held.
Sharing player 1, the button goes by Hotkey Enable as a sharer's Guide
does where its profile has none: it opens the menu whether or not
player 1's Hotkey Enable is held, and the enabler alone opens nothing.
mapped_port_test covers both.
With the menu open, a press of the controllers' buttons hides the
laser's dots until a trigger is pulled, so hand drift cannot undo their
navigation. The menu button navigates nothing, and with no content Menu
Toggle leaves the menu open, so its press does not count.
* OpenXR: the Touch Button's buttons as pointer actions of each hand
Grip, stick click, bumper and A to Y each have an action per hand in the
laser's action set, bound from a table per profile in the same
suggestion as the pad's rows, so either controller layout can read them;
the trigger is the pad's own. The Frame's exact binding list in the e2e
gains them.
A runtime that refuses a suggestion loses its palm first, then these
rows, then edit mode's, a smaller loss tried before a larger, and keeps
the rest of the profile. INPUT_OPENXR_MAX_BINDS goes from 48 to 64 to
hold these rows with edit mode's (Index 52, Touch 51, the Frame 58); a
profile whose pad and Touch Button rows pass it is not suggested at
all, and the log names it.
* OpenXR: touch with the chosen button and hands
The Touch Button, read from its own action or, for the trigger, from the
pad's, touches a live screen the hand points at; the trigger still
clicks the menu, and is L2 or R2 on a screen once it is not the Touch
Button. A hand touches only if Touch Hands has it and its controller has
the button, as read from each hand's interaction profile; only such
hands aim at the screens, become the pointer or show a dot there, and
with none the screens stay the mouse's. The others aim at the menu
alone, which video_xr_pick() now takes as a flag. Touch Passthrough lets
the trigger's L2 or R2 through its touch.
A hand takes a changed setting at its next press. A button held through
a change of Touch Button, Touch Hands or the hand's controller profile
is no press: the trigger goes by its own last read, and any other button
counts as held until it is let go.
* OpenXR: a touch holds back its button's other binds
OpenXR gives an input to every action bound to it, so a Touch Button
other than the trigger also reaches the pad. While it touches, or a
press of it would, the pad's buttons bound to the same input of that
hand in the profile's rows are let go, in Combined and in Separate: the
Index grip's L or R, the Frame right stick's menu button. Touch
Passthrough leaves them pressed.
With the menu open, a press of the controllers takes the laser from the
dots until a trigger pull. Like the triggers' L2 and R2, what a Touch
Button's input feeds does not count as such a press, with Touch
Passthrough on or off, so the button can still touch a live screen
there. Another button on the same hand still counts.
* Menu: Touch Button offers the buttons the controllers have
The dropdown lists the buttons either hand's controller has, as its
interaction profile names them, and the one chosen; left and right step
through the same, skipping the rest. A choice the controllers lack, as
from an override made on another controller, reads "(not on this
controller)". With no controller known every button is offered. The poll
publishes those buttons through an atomic, since with threaded video XMB
draws the value on the video thread.
* docs: OpenXR controllers, touching and the menu button
Where the headset's input rows are now, what Touch Hands, Touch Button
and Touch Passthrough do, None included, and that the menu button is a
Menu Toggle bind that Hotkey Enable applies to as to a pad's Guide; on
Touch controllers in Combined it is Start, and button 16 once held a
second. Laser Pointer's description says the Touch Button touches a
screen and the trigger clicks the menu, true with Touch Passthrough on
too.
25 KiB
OpenXR headset output
RetroArch can show content in a virtual reality headset through OpenXR: each of a core's screens as a screen floating in the room, a stereoscopic core's left and right images one to each eye, and a head-tracked core's two eyes as the headset's own view. The menu shows as a screen of its own, and the headset's controllers work as a gamepad and as a laser pointer.
It runs on desktop Linux with the vulkan, glcore and gl video
drivers, and on the Meta Quest with vulkan and gl.
Building and enabling
- Linux:
./configure --enable-openxr. OpenXR is off by default. It needs Vulkan or OpenGL, and threads. The Khronos loader is built in-tree, so nothing has to be installed to build. - Quest: the
questgradle flavour.
At run time an OpenXR runtime has to be active (SteamVR or Monado on Linux). Then turn on Settings > Video > Stereo 3D & Screens > Headset Output (OpenXR). Under it come Edit Screens, Snap to Screens, Snap to Angles, Hinge Gap, Edit Smoothing and While Editing Screens, described below, then Headset Refresh Rate, Headset Performance Boost, Screen Placement (Fixed in Room, Follow Head, Lazy Follow), Screen Distance and Screen Width. The controllers' rows end Settings > Input > Controllers: OpenXR Controller Layout, Laser Pointer, Laser Beam, Touch Hands, Touch Button and Touch Passthrough (see below). The Recenter Headset Screens, Laser Pointer (Toggle) and Edit Headset Screens hotkeys are unbound by default.
Laser Beam draws a thin line from each controller to its laser's dot, turned to face you. It shows only where the dot can: outside edit mode, Laser Pointer Off, or its hotkey, hides both; while editing, both hands always have a laser, and the hotkey only switches Laser Pointer for afterwards. Edit Mode Only (the default) shows it while editing screens, Always also for the menu and light guns, Off never. Pointing at nothing, the line is 1.5 m long and fades out.
Without a runtime or a headset, RetroArch says so once and shows its window as usual.
The controllers
The headset's controllers are a gamepad: one for both hands (OpenXR Controller Layout Combined) or one per hand (Separate), with a profile of their own that can be changed like any controller's. The menu button is button 16 (on Touch controllers in Combined it is Start, and button 16 once held a second), with Menu Toggle on it by default, so Menu Toggle can be bound to another button and button 16 to something else. Hotkey Enable applies to it as to a pad's Guide button. In Edit Screens the menu button always opens the menu, whatever is bound and whether or not Hotkey Enable is held.
A controller also points. Laser Pointer says where: Auto, the menu while it is open and second screens such as a touch screen; Always, every screen, for light guns; Off, nowhere. The trigger clicks the menu, with either hand.
Pointed at a screen, the Touch Button touches it, or on Always fires the gun:
- Touch Hands: the hands that can touch (Both, Left, Right or None). Only those show a dot on the screens; the other hand still points at the menu. None turns touch off for the headset's controllers, and the screens stay the mouse's and the overlay's.
- Touch Button: Trigger, Grip, Stick Click, Bumper, A, B, X or Y. Only the buttons the controllers have are offered; a hand without the chosen one cannot touch. Where the hand points when the button goes down decides: anywhere else it is a plain button until let go. Every other button, the trigger too when it is not the Touch Button, is a plain button on the screens.
- Touch Passthrough: Off holds back what the Touch Button is bound to while it touches; On presses that too.
Overrides save all three per game, core or content directory.
Adjusting floating screens
In Settings > Video > Stereo 3D & Screens, use Screen to choose which floating screen to adjust. The number is the core's logical screen ID plus one, from 1 to 8. Only screens in the current frame's map are listed; a tracked projection's eyes are excluded. Without a map, including with no content loaded, Screen 1 is listed: a core without a view map shows its whole frame as Screen 1, which these rows then move like any other. Changing the order of views, or temporarily removing a screen, preserves that screen's saved adjustments.
- Horizontal Offset, Vertical Offset and Depth Offset move the selected screen relative to its normal placement, from -10 to +10 metres. Positive values move it right, up and towards you respectively, in the shared placement anchor's coordinates.
- Yaw, Pitch and Roll rotate it from -180 to +180 degrees. Scale changes its width and height together, from 0.1 to 10 times its normal size.
- Visible hides or shows it. The menu remains available even when every floating screen is hidden or moved out of sight.
- Reset Screen restores the selected screen's zero offsets, zero rotations, unit scale and visibility. Reset All Screens does this for all eight screen IDs, including those absent from the current map. Reset All Screens remains available when there is no floating screen to select.
These adjustments apply to floating screens, including the two eyes of a stereoscopic screen together. They do not change a tracked core's eye poses or fields of view. Changes also take effect while content is paused. The shared Screen Distance, Screen Width, Screen Placement and layout settings still determine the base placement. Recenter Headset Screens updates the shared anchor for all screens while preserving their relative offsets, rotations, scales and visibility; it does not reset them.
The menu opens at its own spot, straight ahead of the anchor. With Menu in Front of Screen 1 on, it floats 10 cm in front of Screen 1 and faces the way it does, so moving Screen 1 moves the menu with it. It looks as large as it does at its own spot, and comes no nearer to you than 40 cm. While Screen 1 is hidden, is a tracked core's projection or faces away from you, the menu stays at its own spot. A menu placed in edit mode (below) stays where it was put until it is reset there, or by Reset All Screens.
Screen adjustments are configuration settings. Save the configuration to
keep them as defaults, or use Quick Menu > Overrides to save core,
content-directory or game overrides. Loading an override applies its
screen values; unloading it restores the inherited values. The selector
itself is only a menu choice and is not saved. Configuration keys use
video_screenN_xr_x, _xr_y, _xr_z, _xr_yaw, _xr_pitch, _xr_roll,
_xr_scale and _xr_visible, with N from 1 to 8. Finite values outside
the supported ranges are clamped; non-finite values use the defaults.
With the legacy gl driver on desktop or Quest, opening the menu shows the whole window on an unadjusted floating screen. Per-screen adjustments resume when the menu closes. This keeps the menu and resets reachable without applying the primary content screen's hidden state or transform to the menu. The desktop glcore and vulkan paths use a separate menu screen.
Editing screens in the headset
Edit Screens moves the floating screens and the menu with the
controllers instead of the menu's rows. Start it from Settings > Video >
Stereo 3D & Screens > Edit Screens (shown with Headset Output on; the
menu closes into it), the Edit Headset Screens hotkey, the headset's
own Edit Screens action, or the HEADSET_EDIT_SCREENS network
command. It needs content running. The same hotkey, action or command
stops it, as do opening the menu, loading or closing content, and the
end of the headset session. The hotkey and the action are unbound by
default; bind the action in the runtime's controller settings, in both
RetroArch's game sets and its Edit Screens set. If the runtime refuses
the Edit Screens set's bindings for a hand's controller, Edit Screens
says it is unavailable. It also stops and says so when the runtime
binds neither that set's Grab nor its RetroArch Menu, as a controller
binding saved in the runtime before RetroArch had them can.
While editing, every item has a faint outline just outside it, a light line between two dark ones so it shows against any border. It is bright on what a hand holds, and on what a laser points at unless an item is chosen (below). Both hands have a laser whatever Laser Pointer is set to, with a beam unless Laser Beam is Off. The menu also shows a handle bar under it in the same light and dark, faint, and bright when the menu's outline is. While a held screen is hinged (see Snap to Screens), its edge and the edge it hinges on lose their outline, and a 6 mm green line runs along the hinge where the two overlap, midway between the edges and drawn a centimetre nearer the eye so it shows over both screens, while a let-go would settle the screen into the hinge and for 0.15 s after. Two screens no hand holds that rest exactly where a hinge holds one of them, so that taking it up would leave it there, show the same: any screen let go where a hinge holds it, or set out so. Screens only near a hinge show nothing until hinged once. A screen hinged at rest on two edges at a corner keeps one of those two rims. The headset's controllers only edit; keyboards and other gamepads still reach the content. The desktop window shows a notice when editing starts, with the controls, for about 8 seconds, and a short one when it stops. Select Next and Select Previous choose an item, below.
| Controller | Grab | Tilt | Distance and size | Turn and tilt (other hand) | Reset | Menu | Select Next / Previous |
|---|---|---|---|---|---|---|---|
| Steam Frame | grip | trigger | stick | stick | A; left hand: D-pad down | right stick click | left D-pad right / left |
| Valve Index | grip | trigger | stick | stick | A | left trackpad press | right B / left B |
| Oculus Touch | grip | trigger | stick | stick | X / A | menu button | B / Y |
| HTC Vive | grip | trigger | trackpad | trackpad | trackpad click | left menu button | right menu button / - |
| Simple controller | select | - | - | - | - | left menu button | - |
- A grip on an item grabs it: it keeps its place relative to the hand and follows it. Each hand holds one item; the other hand on the same item does nothing.
- Items keep the pitch and roll they had when grabbed, and their angle to the way the hand points across the floor: they move with the hand and turn left and right as it does, but raising, lowering or twisting the hand does not tip, roll or swivel them. Pointing nearly straight up or down, a twist of the hand turns them instead, and tipping it 5 degrees past straight up or down turns them round to face the other way. Hold the trigger while grabbing to let them ride the hand, pitch and roll too; let go of the trigger to keep them.
- The other hand's stick, while that hand holds nothing, turns and tilts the held item about its middle, whether or not the trigger is held, faster the further the stick is pushed, with no stop. Right turns it about the vertical, keeping its pitch and roll, anticlockwise as seen from above, so a screen facing you turns towards your right; left the other way. Up tips its top back about its own left-right line, as when pushing a monitor's top back; down the other way. Within about 25 degrees of left or right the stick only turns, and within about 25 degrees of up or down it only tilts; pushed clearly diagonally, it does both at once. As the stick turns and tilts it, the item clicks into steps of Snap to Angles, counted from facing you and from upright: it holds within about 2 degrees of each and the holding hand buzzes once; pushing on leaves the step. Carrying it or tilting it with the trigger never clicks. Snapping still catches it parallel or square, and wins over a step.
- On the holding hand's stick, up pushes the item away along the laser and down pulls it closer; right makes it larger and left smaller, faster the further the stick is pushed.
- Offsets stop at +-10 m and scale at 0.1 to 10, as in the menu: the item waits at the limit and moves on from there once the hand comes back.
- Reset on a screen does what Reset Screen does; on the menu it makes the menu follow Screen 1 again.
- The menu is grabbed by its handle bar, even where a screen is nearer, and within about 3 cm of the bar where the laser meets no other item; elsewhere on the menu the grip takes the screen behind. Once a laser is on the bar, the bar stays its target while the laser stays within those 3 cm, even over a screen; a laser that comes into the 3 cm from a screen keeps the screen. Grabbing the menu places it where it shows, even without moving it, so it no longer follows Screen 1. The legacy gl driver draws the menu in its window, so only screens can be grabbed there.
- Select Next and Select Previous choose an item: they step from Laser through each screen that can be moved, in number order (a 3D screen is one), then the menu while it is shown, and back to Laser. Laser is the usual way: grip and Reset act on what a laser points at. With an item chosen, its outline is bright and pointing lights nothing else; either hand's grip takes it from wherever the hand is, as if on a stick, and Reset resets it. While one hand holds it, the other points, grabs and resets as usual. The choice stays after letting go, until stepped back to Laser or edit mode ends; a chosen screen that is hidden or goes away goes back to Laser. This takes a screen hidden behind another.
- A faint tag just above the hand that last pressed Select Next or Select Previous (the left hand at first) names the chosen item: Laser, Screen 1, Screen 2 and so on, or Menu.
- Seen from behind, a screen or the menu shows a plain dark back. Edit mode grabs and outlines it from there as from the front.
- A head-tracked core's projection cannot be grabbed, nor can the whole frame a views core falls back to when its screens cannot be placed. In Follow Head a grabbed screen keeps its place in view; Lazy Follow does not glide while anything is held. Recenter lets go of what is held first. A hand that loses tracking leaves its item still.
While Editing Screens chooses whether the content keeps running (the default) or pauses; leaving edit mode resumes only content it paused.
Snap to Screens (on by default) lines a held screen up with the other screens within about 30 cm of it that no hand holds. Within 5 degrees of facing the same way as one, or of a quarter turn from it about its vertical, the held screen turns exactly so; of two, it turns to the one whose edge is nearer. Then, within 3 cm, it moves into the other's plane, and its left, right, top, bottom or centre lines up with the other's, level; edge to edge, or at a corner for a screen at a quarter turn, it keeps the gap described under Hinge Gap. Or, at any angle between them, an edge of the held screen hinges on an edge of the other where the two overlap along it, top, bottom or side, within 5 degrees of parallel and 3 cm of its plane, up to 10 cm out from the edge: it turns exactly parallel to that edge and moves into the other's plane, keeping its gap from that edge, centres or ends level along it, keeping its angle, like the two halves of a DS. The green line shows wherever a let-go would settle the screen into that hinge, and 0.15 s longer once it leaves, so a shaking hand never flickers it; it stays when the screen is let go there. A screen taken up where it rests hinged starts hinged, with no buzz, until it is carried out of the hinge it rests in, another hinge takes hold or the other hand takes the screen it hinges on. At a fold or a square corner with a gap only the screen carried in does: the other one's edge is off its plane, so it is taken up free. Screens that would overlap do not hinge. While a screen is hinged, the other hand's stick swings it about the shared edge, the tilt for a top or bottom edge and the turn for a side one, and it stays where the swing leaves it. The swing lets go just past square, but that axis keeps pivoting it on the same edge until the edge is carried out of the hinge's reach or the other hand takes the screen it hinges on; the stick's other axis turns or tilts it as before and can pull it off. Past each 3 cm range and the 1 cm click the pull fades out over as far again, a hinge fades out from 10 to 13 cm, and from 30 to 60 cm away every pull fades, so the screen catches up with the hand instead of jumping. A screen just taken does not move: snapping fades in as it is carried, whole once it is 5 cm or 10 degrees from where it was taken, but a hinge it rests in, where holding it moves nothing, holds at once. The holding hand gets a short buzz as a snap takes hold, and none again from that snap until the screen has left its pull. A hinge taking hold gets a longer, stronger buzz instead, and short buzzes due while it plays are skipped; it comes again only once the hinge has let go, 0.15 s after the screen leaves where it would settle, or for another edge, so a swing past square and back, or a wobble where the hinge takes hold, does not repeat it. The menu neither snaps nor is snapped to. Let go, it stays where, turned and as large as it was a moment (0.08 s) before the grip opened, so the hand's twitch as it opens does not move it. With Edit Smoothing on, which damps that twitch, it stays where, turned and as large as it shows, unless it settles into a hinge. That is where it is saved.
Snap to Angles (15 degrees by default) is the step the other hand's stick turns and tilts a held item in: 15, 30, 45 or 90 degrees. A hinged screen's steps count from flat with the other screen, both ways. Off turns and tilts it smoothly, with no steps and no buzz.
Hinge Gap (2 cm by default) is the gap Snap to Screens leaves between screens that meet edge to edge, side by side, at a corner or hinged at an angle: 0, 1, 2, 3, 5 or 10 cm. A screen within 1 cm of it clicks to it exactly, with a short buzz; let go within 3 cm of it, or within 6 cm of level along the edge, a hinged screen settles there exactly; anywhere else from touching to 10 cm the gap stays where the hand puts it, still hinged, and from 10 to 13 cm the hinge lets go. At 0 the edges touch. It does nothing while Snap to Screens is off; screens already placed do not move. Pushed past touching, a hinged screen stops there, so two screens can be pushed together with no gap and let go touching, with one short buzz per push (below a 3 cm gap, the click's). From 3 cm past (3.5 cm at a 1 cm gap) the hinge lets go and the screen slides on into the other, free from 5.5 cm (6 cm); pulled back, it hinges again 5 mm inside that 3 cm. With Snap to Screens off nothing stops them, and screens overlap freely.
Edit Smoothing (Medium by default) steadies the controllers' aim while editing, so a screen held far out on the laser does not shake with the hand: a slow or still hand is smoothed a lot and a fast one little, so quick moves keep up. Low, Medium and High smooth more in turn; Off uses the aim as tracked. Everything edit mode does with the lasers follows the smoothed aim: the dots and beams, what lights, what a grip takes, the stick and what is held; a screen is saved where it was shown. The lasers are never smoothed outside edit mode.
Edits change the same settings as the menu's rows and are saved the
same way: on quit while Save Configuration on Quit is on (the
default), or by saving the configuration or an override.
The menu's own place is saved as video_openxr_menu_xr_x, _xr_y,
_xr_z, _xr_yaw, _xr_pitch, _xr_roll, _xr_scale and
video_openxr_menu_placed; while that is false the menu follows Screen 1.
What a core sees
A core describes its frame with RETRO_ENVIRONMENT_SET_VIDEO_VIEWS: a
map of rectangles, each a screen or one eye's image of a screen. That
is all a core with two screens or a stereoscopic picture needs, with or
without a headset.
A core that draws from the head's position asks
RETRO_ENVIRONMENT_GET_VIDEO_VIEWS_STATUS whether a tracking headset
is there (RETRO_VIDEO_VIEWS_STATUS_HMD), takes each frame's eye poses
from RETRO_ENVIRONMENT_GET_VR_FRAME_STATE, and marks its map with
RETRO_VIDEO_VIEWS_FLAG_TRACKED. Its two eyes then fill the headset's
view. libretro.h documents the calls.
A core that follows the hands asks
RETRO_ENVIRONMENT_GET_VR_CONTROLLER_POSES for each controller's grip,
aim and palm poses as well as the hands joints.
How it is built
Everything that does not depend on a graphics API or a platform is shared. A headset path adds only what differs.
Shared, in gfx/common/ unless noted:
| Unit | What it does |
|---|---|
openxr_runtime |
The loader, instance, system and extensions. A platform whose loader has to be started first (Android) passes what it needs through openxr_runtime_platform_t. |
openxr_session |
The session's state machine and spaces, and what happens when the runtime ends or loses it. |
openxr_swapchain |
One set of swapchains for each screen (a slot), with acquire and release. |
openxr_frame |
The frame loop: waiting for the headset, pacing the core to it, the refresh rate, where the screens are, recentering, and the layers each frame ends with. It runs on a thread of its own, or inside the video frame for a context that shows only the headset. |
openxr_host, openxr_tracking |
What a core is told about the head and the eyes, in the space it asked for, and what is kept across a video driver restart. |
gfx/video_xr |
The geometry: where each screen goes and how a view maps onto it. |
input/common/input_openxr |
The controllers as joypads, their haptics, and the laser pointer. |
A host joins those units to one graphics API. There are three:
| Host | Used by | How images reach the headset |
|---|---|---|
gfx/common/vulkan_openxr.c |
vulkan on Linux, and the Quest's Vulkan context |
The video driver draws into the swapchain images. On Linux the frame loop has its own thread; on the Quest it runs inside the video frame. |
gfx/common/gl_openxr.c |
glcore and gl on Linux |
The frame loop's thread holds a GL context in the window's share group. The video thread draws into shared textures and the frame loop copies them in. |
gfx/drivers_context/gl_android_openxr_ctx.c |
gl on the Quest |
The context is the headset: gl draws its window, and the context shows it and a tracked map's eyes inside the video frame. |
Each host registers a video_xr_host_t (gfx/video_driver.h) with the
video driver layer. That is how the frontend asks for the headset's
state and answers a core's pose calls without knowing which host is
running.
Adding a headset
A headset on a platform that already has a host needs no video code, as long as its runtime offers Vulkan or OpenGL. This covers another PC headset through SteamVR or Monado, and another Android standalone headset. It may need:
- A controller profile: one entry in
input_openxr_profiles[](input/common/input_openxr.c) that maps its interaction profile's paths, with a table of its Touch Button rows. Without one the runtime remaps a profile that is already there (Index, Touch, Vive, Steam Frame, or the simple controller), which can lose buttons. - On Android, its loader and instance set-up through
openxr_runtime_platform_t, and a build flavour likequest.
Adding a graphics API or a platform
A new graphics API or platform, such as Direct3D on Windows, needs a host. Model it on the three above:
- A graphics binding: the structure the session is created with, and
a callback that lists a swapchain's images.
openxr_binding_gl.candopenxr_binding_gles.care the small examples. - The host. It owns the shared units' state, starts the frame loop on
a thread (
openxr_frame_start) or in-line (openxr_frame_start_inline), and registers avideo_xr_host_twhose calls forward toopenxr_host_*. - In the video driver: draw each screen, or each eye, into its slot's
image, then publish the quads (
openxr_frame_publish) or the projection (openxr_frame_publish_projection). Wait on the headset withopenxr_frame_pace_waitwhile it paces the core. - The driver's name in
video_driver_has_headset_path(), so the menu lists the headset's settings for it. - The build: the objects in
Makefile.commonandgriffin/griffin.c, and the platform inqb/config.libs.sh, which today allows OpenXR on Linux only.
Testing
samples/openxr/coreruns the shared units and the hosts against a stand-in runtime, with no headset and no GPU. A new host can be tested there against a fake graphics API, as the GL host is.samples/input/openxr_inputdoes the same for the controllers.samples/openxr/e2e/run.pyruns RetroArch against Monado's simulated headset in headless gamescope, through a test API layer (samples/openxr/test_layer) that records every frame's layers and images. It needs a GPU, so it is not run in CI.- The
edit-*cases drive edit mode through the test layer's scripted aims (aim ... [<roll>]) andedit/*actions on Vulkan, glcore and gl.