mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
Cleanups to keyboard callback stuff.
This commit is contained in:
parent
a8573860fa
commit
d111a0c658
10
Makefile
10
Makefile
@ -116,10 +116,6 @@ endif
|
|||||||
|
|
||||||
ifeq ($(HAVE_NETPLAY), 1)
|
ifeq ($(HAVE_NETPLAY), 1)
|
||||||
OBJ += netplay.o
|
OBJ += netplay.o
|
||||||
#ifeq ($(HAVE_RSOUND), 1)
|
|
||||||
OBJ += audio/librsound.o audio/rsound.o
|
|
||||||
DEFINES += -DHAVE_RSOUND
|
|
||||||
#endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_COMMAND), 1)
|
ifeq ($(HAVE_COMMAND), 1)
|
||||||
@ -138,6 +134,12 @@ ifeq ($(HAVE_OSS_LIB), 1)
|
|||||||
LIBS += -lossaudio
|
LIBS += -lossaudio
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HAVE_RSOUND), 1)
|
||||||
|
OBJ += audio/rsound.o
|
||||||
|
DEFINES += $(RSOUND_CFLAGS)
|
||||||
|
LIBS += $(RSOUND_LIBS)
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_ALSA), 1)
|
ifeq ($(HAVE_ALSA), 1)
|
||||||
OBJ += audio/alsa.o audio/alsathread.o
|
OBJ += audio/alsa.o audio/alsathread.o
|
||||||
LIBS += $(ALSA_LIBS)
|
LIBS += $(ALSA_LIBS)
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "../../config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -21,6 +26,23 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "menu_common.h"
|
#include "menu_common.h"
|
||||||
#include "../../input/keyboard_line.h"
|
#include "../../input/keyboard_line.h"
|
||||||
|
#include "menu_input_line_cb.h"
|
||||||
|
|
||||||
|
void menu_key_start_line(rgui_handle_t *rgui, const char *label, input_keyboard_line_complete_t cb)
|
||||||
|
{
|
||||||
|
g_extern.system.key_event = NULL;
|
||||||
|
rgui->keyboard.display = true;
|
||||||
|
rgui->keyboard.label = label;
|
||||||
|
rgui->keyboard.buffer = input_keyboard_start_line(rgui, cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void menu_key_end_line(rgui_handle_t *rgui)
|
||||||
|
{
|
||||||
|
rgui->keyboard.display = false;
|
||||||
|
rgui->keyboard.label = NULL;
|
||||||
|
rgui->old_input_state = -1ULL; // Avoid triggering states on pressing return.
|
||||||
|
g_extern.system.key_event = menu_key_event;
|
||||||
|
}
|
||||||
|
|
||||||
static void menu_search_callback(void *userdata, const char *str)
|
static void menu_search_callback(void *userdata, const char *str)
|
||||||
{
|
{
|
||||||
@ -28,9 +50,68 @@ static void menu_search_callback(void *userdata, const char *str)
|
|||||||
|
|
||||||
if (str && *str)
|
if (str && *str)
|
||||||
file_list_search(rgui->selection_buf, str, &rgui->selection_ptr);
|
file_list_search(rgui->selection_buf, str, &rgui->selection_ptr);
|
||||||
rgui->keyboard.display = false;
|
menu_key_end_line(rgui);
|
||||||
rgui->keyboard.label = NULL;
|
}
|
||||||
rgui->old_input_state = -1ULL; // Avoid triggering states on pressing return.
|
|
||||||
|
#ifdef HAVE_NETPLAY
|
||||||
|
void netplay_port_callback(void *userdata, const char *str)
|
||||||
|
{
|
||||||
|
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
||||||
|
|
||||||
|
if (str && *str)
|
||||||
|
g_extern.netplay_port = strtoul(str, NULL, 0);
|
||||||
|
menu_key_end_line(rgui);
|
||||||
|
}
|
||||||
|
|
||||||
|
void netplay_ipaddress_callback(void *userdata, const char *str)
|
||||||
|
{
|
||||||
|
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
||||||
|
|
||||||
|
if (str && *str)
|
||||||
|
strlcpy(g_extern.netplay_server, str, sizeof(g_extern.netplay_server));
|
||||||
|
menu_key_end_line(rgui);
|
||||||
|
}
|
||||||
|
|
||||||
|
void netplay_nickname_callback(void *userdata, const char *str)
|
||||||
|
{
|
||||||
|
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
||||||
|
|
||||||
|
if (str && *str)
|
||||||
|
strlcpy(g_extern.netplay_nick, str, sizeof(g_extern.netplay_nick));
|
||||||
|
menu_key_end_line(rgui);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_RSOUND
|
||||||
|
void rsound_ipaddress_callback(void *userdata, const char *str)
|
||||||
|
{
|
||||||
|
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
||||||
|
|
||||||
|
if (str && *str)
|
||||||
|
strlcpy(g_settings.audio.device, str, sizeof(g_settings.audio.device));
|
||||||
|
menu_key_end_line(rgui);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void preset_filename_callback(void *userdata, const char *str)
|
||||||
|
{
|
||||||
|
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
||||||
|
|
||||||
|
if (str && *str)
|
||||||
|
{
|
||||||
|
char filepath[PATH_MAX];
|
||||||
|
|
||||||
|
fill_pathname_join(filepath, g_settings.video.shader_dir, str, sizeof(filepath));
|
||||||
|
strlcat(filepath, ".cgp", sizeof(filepath));
|
||||||
|
config_file_t *conf = config_file_new(NULL);
|
||||||
|
if (conf)
|
||||||
|
{
|
||||||
|
gfx_shader_write_conf_cgp(conf, &rgui->shader);
|
||||||
|
config_file_write(conf, filepath);
|
||||||
|
config_file_free(conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menu_key_end_line(rgui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mod)
|
void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mod)
|
||||||
@ -46,3 +127,4 @@ void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mo
|
|||||||
rgui->keyboard.buffer = input_keyboard_start_line(rgui, menu_search_callback);
|
rgui->keyboard.buffer = input_keyboard_start_line(rgui, menu_search_callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,17 @@
|
|||||||
#ifndef _MENU_INPUT_LINE_CB_H
|
#ifndef _MENU_INPUT_LINE_CB_H
|
||||||
#define _MENU_INPUT_LINE_CB_H
|
#define _MENU_INPUT_LINE_CB_H
|
||||||
|
|
||||||
|
#include "menu_common.h"
|
||||||
|
#include "../../input/keyboard_line.h"
|
||||||
|
|
||||||
void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers);
|
void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers);
|
||||||
|
|
||||||
|
void menu_key_start_line(rgui_handle_t *rgui, const char *label, input_keyboard_line_complete_t cb);
|
||||||
|
|
||||||
|
void netplay_port_callback(void *userdata, const char *str);
|
||||||
|
void netplay_ipaddress_callback(void *userdata, const char *str);
|
||||||
|
void netplay_nickname_callback(void *userdata, const char *str);
|
||||||
|
void rsound_ipaddress_callback(void *userdata, const char *str);
|
||||||
|
void preset_filename_callback(void *userdata, const char *str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -314,20 +314,6 @@ int menu_settings_toggle_setting(void *data, unsigned setting, unsigned action,
|
|||||||
return menu_set_settings(rgui, setting, action);
|
return menu_set_settings(rgui, setting, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rsound_ipaddress_callback(void *userdata, const char *str)
|
|
||||||
{
|
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
|
||||||
|
|
||||||
if (str && *str)
|
|
||||||
{
|
|
||||||
strlcpy(g_settings.audio.device, str, sizeof(g_settings.audio.device));
|
|
||||||
}
|
|
||||||
rgui->keyboard.display = false;
|
|
||||||
rgui->keyboard.label = NULL;
|
|
||||||
rgui->old_input_state = -1ULL; // Avoid triggering states on pressing return.
|
|
||||||
g_extern.system.key_event = menu_key_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_OSK
|
#ifdef HAVE_OSK
|
||||||
static bool osk_callback_enter_rsound(void *data)
|
static bool osk_callback_enter_rsound(void *data)
|
||||||
{
|
{
|
||||||
@ -419,68 +405,6 @@ static bool osk_callback_enter_filename_init(void *data)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void preset_filename_callback(void *userdata, const char *str)
|
|
||||||
{
|
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
|
||||||
|
|
||||||
if (str && *str)
|
|
||||||
{
|
|
||||||
char filepath[PATH_MAX];
|
|
||||||
|
|
||||||
fill_pathname_join(filepath, g_settings.video.shader_dir, str, sizeof(filepath));
|
|
||||||
strlcat(filepath, ".cgp", sizeof(filepath));
|
|
||||||
config_file_t *conf = config_file_new(NULL);
|
|
||||||
if (conf)
|
|
||||||
{
|
|
||||||
gfx_shader_write_conf_cgp(conf, &rgui->shader);
|
|
||||||
config_file_write(conf, filepath);
|
|
||||||
config_file_free(conf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rgui->keyboard.display = false;
|
|
||||||
rgui->keyboard.label = NULL;
|
|
||||||
rgui->old_input_state = -1ULL; // Avoid triggering states on pressing return.
|
|
||||||
g_extern.system.key_event = menu_key_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_NETPLAY
|
|
||||||
static void netplay_port_callback(void *userdata, const char *str)
|
|
||||||
{
|
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
|
||||||
|
|
||||||
if (str && *str)
|
|
||||||
g_extern.netplay_port = atoi(str);
|
|
||||||
rgui->keyboard.display = false;
|
|
||||||
rgui->keyboard.label = NULL;
|
|
||||||
rgui->old_input_state = -1ULL; // Avoid triggering states on pressing return.
|
|
||||||
g_extern.system.key_event = menu_key_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void netplay_ipaddress_callback(void *userdata, const char *str)
|
|
||||||
{
|
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
|
||||||
|
|
||||||
if (str && *str)
|
|
||||||
strlcpy(g_extern.netplay_server, str, sizeof(g_extern.netplay_server));
|
|
||||||
rgui->keyboard.display = false;
|
|
||||||
rgui->keyboard.label = NULL;
|
|
||||||
rgui->old_input_state = -1ULL; // Avoid triggering states on pressing return.
|
|
||||||
g_extern.system.key_event = menu_key_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void netplay_nickname_callback(void *userdata, const char *str)
|
|
||||||
{
|
|
||||||
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
|
|
||||||
|
|
||||||
if (str && *str)
|
|
||||||
strlcpy(g_extern.netplay_nick, str, sizeof(g_extern.netplay_nick));
|
|
||||||
rgui->keyboard.display = false;
|
|
||||||
rgui->keyboard.label = NULL;
|
|
||||||
rgui->old_input_state = -1ULL; // Avoid triggering states on pressing return.
|
|
||||||
g_extern.system.key_event = menu_key_event;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef RARCH_DEFAULT_PORT
|
#ifndef RARCH_DEFAULT_PORT
|
||||||
#define RARCH_DEFAULT_PORT 55435
|
#define RARCH_DEFAULT_PORT 55435
|
||||||
#endif
|
#endif
|
||||||
@ -1656,12 +1580,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
menu_key_start_line(rgui, "Server IP Address: ", rsound_ipaddress_callback);
|
||||||
g_extern.system.key_event = NULL;
|
|
||||||
rgui->keyboard.display = true;
|
|
||||||
rgui->keyboard.label = "Server IP Address: ";
|
|
||||||
rgui->keyboard.buffer = input_keyboard_start_line(rgui, rsound_ipaddress_callback);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -1780,12 +1699,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
menu_key_start_line(rgui, "Preset Filename: ", preset_filename_callback);
|
||||||
g_extern.system.key_event = NULL;
|
|
||||||
rgui->keyboard.display = true;
|
|
||||||
rgui->keyboard.label = "Preset Filename: ";
|
|
||||||
rgui->keyboard.buffer = input_keyboard_start_line(rgui, preset_filename_callback);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RGUI_SETTINGS_CUSTOM_BGM_CONTROL_ENABLE:
|
case RGUI_SETTINGS_CUSTOM_BGM_CONTROL_ENABLE:
|
||||||
@ -1844,20 +1758,14 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
|
|||||||
break;
|
break;
|
||||||
case RGUI_SETTINGS_NETPLAY_HOST_IP_ADDRESS:
|
case RGUI_SETTINGS_NETPLAY_HOST_IP_ADDRESS:
|
||||||
if (action == RGUI_ACTION_OK)
|
if (action == RGUI_ACTION_OK)
|
||||||
{
|
menu_key_start_line(rgui, "IP Address: ", netplay_ipaddress_callback);
|
||||||
g_extern.system.key_event = NULL;
|
|
||||||
rgui->keyboard.display = true;
|
|
||||||
rgui->keyboard.label = "IP Address: ";
|
|
||||||
rgui->keyboard.buffer = input_keyboard_start_line(rgui, netplay_ipaddress_callback);
|
|
||||||
}
|
|
||||||
else if (action == RGUI_ACTION_START)
|
else if (action == RGUI_ACTION_START)
|
||||||
{
|
*g_extern.netplay_server = '\0';
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RGUI_SETTINGS_NETPLAY_DELAY_FRAMES:
|
case RGUI_SETTINGS_NETPLAY_DELAY_FRAMES:
|
||||||
if (action == RGUI_ACTION_LEFT)
|
if (action == RGUI_ACTION_LEFT)
|
||||||
{
|
{
|
||||||
if (g_extern.state_slot >= 0)
|
if (g_extern.netplay_sync_frames >= 0)
|
||||||
g_extern.netplay_sync_frames--;
|
g_extern.netplay_sync_frames--;
|
||||||
}
|
}
|
||||||
else if (action == RGUI_ACTION_RIGHT)
|
else if (action == RGUI_ACTION_RIGHT)
|
||||||
@ -1867,28 +1775,15 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
|
|||||||
break;
|
break;
|
||||||
case RGUI_SETTINGS_NETPLAY_TCP_UDP_PORT:
|
case RGUI_SETTINGS_NETPLAY_TCP_UDP_PORT:
|
||||||
if (action == RGUI_ACTION_OK)
|
if (action == RGUI_ACTION_OK)
|
||||||
{
|
menu_key_start_line(rgui, "TCP/UDP Port: ", netplay_port_callback);
|
||||||
g_extern.system.key_event = NULL;
|
|
||||||
rgui->keyboard.display = true;
|
|
||||||
rgui->keyboard.label = "TCP/UDP Port: ";
|
|
||||||
rgui->keyboard.buffer = input_keyboard_start_line(rgui, netplay_port_callback);
|
|
||||||
}
|
|
||||||
else if (action == RGUI_ACTION_START)
|
else if (action == RGUI_ACTION_START)
|
||||||
{
|
|
||||||
g_extern.netplay_port = RARCH_DEFAULT_PORT;
|
g_extern.netplay_port = RARCH_DEFAULT_PORT;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RGUI_SETTINGS_NETPLAY_NICKNAME:
|
case RGUI_SETTINGS_NETPLAY_NICKNAME:
|
||||||
if (action == RGUI_ACTION_OK)
|
if (action == RGUI_ACTION_OK)
|
||||||
{
|
menu_key_start_line(rgui, "Nickname: ", netplay_nickname_callback);
|
||||||
g_extern.system.key_event = NULL;
|
|
||||||
rgui->keyboard.display = true;
|
|
||||||
rgui->keyboard.label = "Nickname: ";
|
|
||||||
rgui->keyboard.buffer = input_keyboard_start_line(rgui, netplay_nickname_callback);
|
|
||||||
}
|
|
||||||
else if (action == RGUI_ACTION_START)
|
else if (action == RGUI_ACTION_START)
|
||||||
{
|
*g_extern.netplay_nick = '\0';
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RGUI_SETTINGS_NETPLAY_MODE:
|
case RGUI_SETTINGS_NETPLAY_MODE:
|
||||||
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_LEFT || action == RGUI_ACTION_RIGHT)
|
if (action == RGUI_ACTION_OK || action == RGUI_ACTION_LEFT || action == RGUI_ACTION_RIGHT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user