Seems like a cool feature for car simulations. See for example: https://youtu.be/oquBKX-YIv8
There are several protocols for this used in various commercial games and also FOSS cross platform tools to use it.
You can use IR lights, face recognition, or even attach a (smartphone) gyroscope to your head

FOSS tools:
OpenTrack: https://github.com/opentrack/opentrack
or LinuxTrack: https://github.com/uglyDwarf/linuxtrack