From 64672b4b63e57ffde00deb09f527a5bbd822a734 Mon Sep 17 00:00:00 2001 From: "Mark W. Kidd" Date: Tue, 13 Jul 2021 14:51:59 -0500 Subject: [PATCH] consolidate menu_input.h declarations --- input/input_driver.h | 74 ++++++++--------------------- menu/menu_input.h | 70 +++++++++++++++++++++++---- network/netplay/netplay_handshake.c | 1 + retroarch.c | 6 +-- 4 files changed, 85 insertions(+), 66 deletions(-) diff --git a/input/input_driver.h b/input/input_driver.h index bf14c4629e..df034d747c 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -450,35 +450,6 @@ const void *hid_driver_get_data(void); void hid_driver_reset_data(void); #endif -/** Line complete callback. - * Calls back after return is pressed with the completed line. - * Line can be NULL. - **/ -typedef void (*input_keyboard_line_complete_t)(void *userdata, - const char *line); - -typedef bool (*input_keyboard_press_t)(void *userdata, unsigned code); - -struct input_keyboard_ctx_wait -{ - void *userdata; - input_keyboard_press_t cb; -}; - -/** - * input_keyboard_event: - * @down : Keycode was pressed down? - * @code : Keycode. - * @character : Character inputted. - * @mod : TODO/FIXME: ??? - * - * Keyboard event utils. Called by drivers when keyboard events are fired. - * This interfaces with the global driver struct and libretro callbacks. - **/ -void input_keyboard_event(bool down, unsigned code, uint32_t character, - uint16_t mod, unsigned device); - - /* Set input_device_info */ void input_config_set_device_name(unsigned port, const char *name); void input_config_set_device_display_name(unsigned port, const char *name); @@ -536,6 +507,26 @@ void input_config_reset(void); void set_connection_listener(pad_connection_listener_t *listener); +typedef bool (*input_keyboard_press_t)(void *userdata, unsigned code); + +struct input_keyboard_ctx_wait +{ + void *userdata; + input_keyboard_press_t cb; +}; + +/** + * Called by drivers when keyboard events are fired. Interfaces with the global + * driver struct and libretro callbacks. + * + * @param down Was Keycode pressed down? + * @param code Keycode. + * @param character Character inputted. + * @param mod TODO/FIXME/??? + **/ +void input_keyboard_event(bool down, unsigned code, uint32_t character, + uint16_t mod, unsigned device); + extern input_device_driver_t dinput_joypad; extern input_device_driver_t linuxraw_joypad; extern input_device_driver_t parport_joypad; @@ -591,31 +582,6 @@ extern hid_driver_t libusb_hid; extern hid_driver_t wiiusb_hid; #endif -typedef struct menu_input_ctx_line -{ - const char *label; - const char *label_setting; - unsigned type; - unsigned idx; - input_keyboard_line_complete_t cb; -} menu_input_ctx_line_t; - -const char *menu_input_dialog_get_label_setting_buffer(void); - -const char *menu_input_dialog_get_label_buffer(void); - -const char *menu_input_dialog_get_buffer(void); - -unsigned menu_input_dialog_get_kb_idx(void); - -bool menu_input_dialog_start_search(void); - -bool menu_input_dialog_get_display_kb(void); - -bool menu_input_dialog_start(menu_input_ctx_line_t *line); - -void menu_input_dialog_end(void); - RETRO_END_DECLS #endif diff --git a/menu/menu_input.h b/menu/menu_input.h index 6c36189595..37eccaaaa7 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -182,22 +182,74 @@ typedef struct menu_input_ctx_hitbox int32_t y2; } menu_input_ctx_hitbox_t; -/* Provides access to all pointer device parameters */ -void menu_input_get_pointer_state(menu_input_pointer_t *pointer); +/** + * Copy parameters from the global menu_input_state to a menu_input_pointer_t + * in order to provide access to all pointer device parameters. + * + * @param copy_target menu_input_pointer_t struct where values will be copied + **/ +void menu_input_get_pointer_state(menu_input_pointer_t *copy_target); -/* Getters/setters for menu item (index) currently - * selected/highlighted (hovered over) by the pointer - * device - * Note: Each menu driver is responsible for setting this */ +/** + * Get the menu item index currently selected or hovered over by the pointer. + * + * @return the selected menu index + **/ unsigned menu_input_get_pointer_selection(void); +/** + * Set the menu item index that is currently selected or hovered over by the + * pointer. Note: Each menu driver is responsible for setting this. + * + * @param selection the selected menu index + **/ void menu_input_set_pointer_selection(unsigned selection); -/* Allows pointer y acceleration to be overridden - * (typically want to set acceleration to zero when - * calling populate entries) */ +/** + * Allows the pointer's y acceleration to be overridden. For example, menu + * drivers typically set acceleration to zero when populating entries. + * + * @param y_accel + **/ void menu_input_set_pointer_y_accel(float y_accel); +/** + * Line complete callback. Calls back after return is pressed with the + * completed line. Line can be NULL. (Meaning that it might return a NULL + * pointer instead of an empty string?) + * + * @param userdata + * @param line a string representation of the completed line + * (FIXME it might return a NULL pointer instead of an empty + * string?) + **/ +typedef void (*input_keyboard_line_complete_t)(void *userdata, const char *line); + +typedef struct menu_input_ctx_line +{ + const char *label; + const char *label_setting; + unsigned type; + unsigned idx; + input_keyboard_line_complete_t cb; +} menu_input_ctx_line_t; + +bool menu_input_dialog_start(menu_input_ctx_line_t *line); + +const char *menu_input_dialog_get_label_setting_buffer(void); + +const char *menu_input_dialog_get_label_buffer(void); + +const char *menu_input_dialog_get_buffer(void); + +unsigned menu_input_dialog_get_kb_idx(void); + +bool menu_input_dialog_start_search(void); + +bool menu_input_dialog_get_display_kb(void); + +void menu_input_dialog_end(void); + RETRO_END_DECLS #endif diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index 08bb128e98..312040c648 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -36,6 +36,7 @@ #include "../../content.h" #include "../../retroarch.h" #include "../../version.h" +#include "../../menu/menu_input.h" struct nick_buf_s { diff --git a/retroarch.c b/retroarch.c index 1d22d09157..787044938f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -24507,18 +24507,18 @@ static unsigned menu_event( return ret; } -void menu_input_get_pointer_state(menu_input_pointer_t *pointer) +void menu_input_get_pointer_state(menu_input_pointer_t *copy_target) { struct rarch_state *p_rarch = &rarch_st; menu_input_t *menu_input = &p_rarch->menu_input_state; - if (!pointer) + if (!copy_target) return; /* Copy parameters from global menu_input_state * (i.e. don't pass by reference) * This is a fast operation */ - memcpy(pointer, &menu_input->pointer, sizeof(menu_input_pointer_t)); + memcpy(copy_target, &menu_input->pointer, sizeof(menu_input_pointer_t)); } unsigned menu_input_get_pointer_selection(void)