Skip to content

libretro.h: add a sensor sub-device index for composite controllers - #19453

Open
XenuIsWatching wants to merge 1 commit into
libretro:masterfrom
XenuIsWatching:sensor-subdevice-index
Open

libretro.h: add a sensor sub-device index for composite controllers#19453
XenuIsWatching wants to merge 1 commit into
libretro:masterfrom
XenuIsWatching:sensor-subdevice-index

Conversation

@XenuIsWatching

Copy link
Copy Markdown

Some controllers carry more than one sensor of the same kind on a single port. A Wii Remote with a Nunchuk attached is one player with two accelerometers, and adding MotionPlus makes it two accelerometers and a gyroscope, but retro_sensor_interface addresses exactly one sensor of each kind per port. A second port is not an alternative, because ports denote players.

Carry a sub-device index in the upper bits of the existing ID, the same way RETRO_DEVICE_SUBCLASS encodes a subclass into a device ID. Index 0 denotes the controller itself and encodes to exactly the values already in use, so every existing core and frontend is unaffected.

No new environment call or capability flag is needed, because the existing contract already describes the fallback: a frontend that does not implement this returns false from retro_set_sensor_state_t and 0 from retro_sensor_get_input_t, both of which are already documented, and a core that receives either answer behaves as it does today. Cores and frontends can therefore adopt this independently of one another.

Some controllers carry more than one sensor of the same kind on a single
port. A Wii Remote with a Nunchuk attached is one player with two
accelerometers, and adding MotionPlus makes it two accelerometers and a
gyroscope, but retro_sensor_interface addresses exactly one sensor of
each kind per port. A second port is not an alternative, because ports
denote players.

Carry a sub-device index in the upper bits of the existing ID, the same
way RETRO_DEVICE_SUBCLASS encodes a subclass into a device ID. Index 0
denotes the controller itself and encodes to exactly the values already
in use, so every existing core and frontend is unaffected.

No new environment call or capability flag is needed, because the
existing contract already describes the fallback: a frontend that does
not implement this returns false from retro_set_sensor_state_t and 0
from retro_sensor_get_input_t, both of which are already documented, and
a core that receives either answer behaves as it does today. Cores and
frontends can therefore adopt this independently of one another.

Definitions only; no behaviour changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant