From b35169a979fc98184bc02c9c4493d8b7255204b7 Mon Sep 17 00:00:00 2001 From: Stephanie Gawroriski Date: Sat, 23 Dec 2023 14:52:14 -0500 Subject: [PATCH] Simplify greatly. --- libretro-common/include/libretro.h | 143 +++-------------------------- runloop.c | 12 ++- 2 files changed, 22 insertions(+), 133 deletions(-) diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index 346eeb13a141..9ca0272afc75 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -1864,11 +1864,11 @@ enum retro_mod * multiplayer, where a deterministic core supporting multiple * input devices does not need to take any action on its own. */ -#define RETRO_ENVIRONMENT_QUERY_INPUT_DEVICE_ID 79 - /* const struct retro_query_input_device_id * -- - * Allows a core to query information about what an id of - * a given device represents along with generic input information. - * The structure used is freeform. +#define RETRO_ENVIRONMENT_GET_EXTRA_INPUT_ACTIONS 79 + /* const struct retro_get_extra_input_actions * -- + * Allows the core to query information on input actions + * that are additionally available but not bound to any + * physical button or key. * If this returns zero then the core must assume that the * frontend does not provide such functionality. * This realistically should be called before @@ -3382,142 +3382,25 @@ struct retro_input_descriptor const char *description; }; -/** Used with @c retro_query_input_device_id to classify a specific input. */ -enum retro_query_input_device_id_class -{ - /** Unbound action, not bound to any key. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_UNBOUND, - - /** Standard digital button. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_DIGITAL_BUTTON, - - /** Analog button. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_ANALOG_BUTTON, - - /** Analog trigger. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_ANALOG_TRIGGER, - - /** Analog Joystick. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_JOYSTICK, - - /** Digital hat (d-pad). */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_HAT, - - /** Throttle. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_THROTTLE, - - /** Touch pad. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_TOUCH_PAD, - - /** Mouse. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_MOUSE, - - /** Light Gun. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_LIGHT_GUN, - - /** Number Pad, 1 on bottom. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_NUMBER_PAD, - - /** Dial Pad, 1 on top. */ - RETRO_QUERY_INPUT_DEVICE_ID_CLASS_DIAL_PAD, - - /** The number of input classes. */ - RETRO_NUM_QUERY_INPUT_DEVICE_ID_CLASS -}; - -/** Used with @c retro_query_input_device_id to specify where on the controller an input is. */ -enum retro_query_input_device_id_location -{ - /** Undefined. */ - RETRO_QUERY_INPUT_DEVICE_ID_LOCATION_UNDEFINED, - - /** Left. */ - RETRO_QUERY_INPUT_DEVICE_ID_LOCATION_LEFT, - - /** Middle. */ - RETRO_QUERY_INPUT_DEVICE_ID_LOCATION_MIDDLE, - - /** Right. */ - RETRO_QUERY_INPUT_DEVICE_ID_LOCATION_RIGHT, - - /** Top. */ - RETRO_QUERY_INPUT_DEVICE_ID_LOCATION_TOP, - - /** Bottom. */ - RETRO_QUERY_INPUT_DEVICE_ID_LOCATION_BOTTOM, - - /** Back. */ - RETRO_QUERY_INPUT_DEVICE_ID_LOCATION_BACK, - - /** The number of locations. */ - RETRO_NUM_QUERY_INPUT_DEVICE_ID_LOCATION -}; - -/** Used with @c retro_query_input_device_id to specify the direction of the input relative to the location. */ -enum retro_query_input_device_id_direction -{ - /** Undefined. */ - RETRO_QUERY_INPUT_DEVICE_ID_DIRECTION_UNDEFINED, - - /** Left. */ - RETRO_QUERY_INPUT_DEVICE_ID_DIRECTION_LEFT, - - /** Right. */ - RETRO_QUERY_INPUT_DEVICE_ID_DIRECTION_RIGHT, - - /** Up. */ - RETRO_QUERY_INPUT_DEVICE_ID_DIRECTION_UP, - - /** Down. */ - RETRO_QUERY_INPUT_DEVICE_ID_DIRECTION_DOWN, - - /** The number of directions. */ - RETRO_NUM_QUERY_INPUT_DEVICE_ID_DIRECTION -}; - -/** Used with @c RETRO_ENVIRONMENT_QUERY_INPUT_DEVICE_ID to query device info. */ -struct retro_query_input_device_id +/** Used with @c RETRO_ENVIRONMENT_GET_EXTRA_INPUT_ACTIONS to query device info. */ +struct retro_get_extra_input_actions { /** Query for device information. */ struct { /** The device type to query such as @c RETRO_DEVICE_JOYPAD . */ unsigned device; - - /** The ID of the specific input such as @c RETRO_DEVICE_ID_JOYPAD_Y. */ - unsigned id; } query; /** Response given from the give query. */ struct { - /** General response given for all commands. */ - struct { - /** The number of unbound actions. */ - unsigned numUnbound; - - /** The start id of unbound actions. */ - unsigned unboundStartId; - } general; - - /** Response for the specific device and ID. */ - struct { - /** Whether or not this input is known, if it is then other fields are valid. */ - bool known_id; - - /** The class of input this is, one of @c retro_query_input_device_id_class .*/ - enum retro_query_input_device_id_class input_class; - - /** The location where this button is on a controller, one of @c retro_query_input_device_id_location . */ - enum retro_query_input_device_id_location location; - - /** The direction the button is on relative to its location on the controller, one of @c retro_query_input_device_id_direction .*/ - enum retro_query_input_device_id_direction direction; + /** Is this device type known? */ + bool known; - /** The description of this specific id, such as @c "Right Trigger". */ - const char* description; + /** The number of extra IDs. */ + unsigned numExtra; - /** The glyph that is shown for this input, may be @c NULL . */ - const char* glyph; - } specific; + /** The start ID of the extra IDs. */ + unsigned numExtraStartId; } response; }; diff --git a/runloop.c b/runloop.c index f51b3b230234..3faaee93f0ea 100644 --- a/runloop.c +++ b/runloop.c @@ -1401,8 +1401,14 @@ static void core_performance_counter_stop(struct retro_perf_counter *perf) perf->total += cpu_features_get_perf_counter() - perf->start; } +void rarch_query_input_device_id(rarch_system_info_t *system_info, + struct retro_get_extra_input_actions *idQuery) { + + /* We only know about the joypad. */ + if (idQuery->query.device != RETRO_DEVICE_JOYPAD) { + idQuery->response.known = false; + } -void rarch_query_input_device_id(rarch_system_info_t *system_info, struct retro_query_input_device_id *idQuery) { /* TODO: Implement this. */ } @@ -3555,8 +3561,8 @@ bool runloop_environment_cb(unsigned cmd, void *data) } } break; - case RETRO_ENVIRONMENT_QUERY_INPUT_DEVICE_ID: - rarch_query_input_device_id(sys_info, (struct retro_query_input_device_id*)data); + case RETRO_ENVIRONMENT_GET_EXTRA_INPUT_ACTIONS: + rarch_query_input_device_id(sys_info, (struct retro_get_extra_input_actions*)data); break; default: