(steam) Replace OSK with the Steam one on the deck

This commit is contained in:
Mats 2022-03-15 20:18:24 +01:00 committed by Autechre
parent ea77410037
commit 910a652b3c
4 changed files with 81 additions and 0 deletions

View File

@ -20,6 +20,10 @@
#include "../configuration.h"
#include "../verbosity.h"
#ifdef HAVE_MIST
#include "../steam/steam.h"
#endif
/* Standard reference DPI value, used when determining
* DPI-aware scaling factors */
#define REFERENCE_DPI 96.0f
@ -1175,6 +1179,10 @@ void gfx_display_draw_keyboard(
rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true;
#ifdef HAVE_MIST
if(steam_has_osk_open()) return;
#endif
gfx_display_draw_quad(
p_disp,
userdata,

View File

@ -80,6 +80,10 @@
#include "../switch_performance_profiles.h"
#endif
#ifdef HAVE_MIST
#include "../steam/steam.h"
#endif
#ifdef HAVE_LIBNX
#define LIBNX_SWKBD_LIMIT 500 /* enforced by HOS */
@ -5934,6 +5938,11 @@ unsigned menu_event(
if (display_kb)
{
#ifdef HAVE_MIST
/* Do not process input events if the Steam OSK is open */
if (!steam_has_osk_open())
{
#endif
bool show_osk_symbols = input_event_osk_show_symbol_pages(menu_st->driver_data);
input_event_osk_iterate(input_st->osk_grid, input_st->osk_idx);
@ -6011,6 +6020,10 @@ unsigned menu_event(
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START))
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
#ifdef HAVE_MIST
}
#endif
BIT256_CLEAR_ALL_PTR(p_trigger_input);
}
else
@ -6404,6 +6417,11 @@ static int menu_input_pointer_post_iterate(
/* On screen keyboard overrides normal menu input... */
if (osk_active)
{
#ifdef HAVE_MIST
/* Disable OSK pointer input if the Steam OSK is used */
if (!steam_has_osk_open())
{
#endif
/* If pointer has been 'dragged', then it counts as
* a miss. Only register 'release' event if pointer
* has remained stationary */
@ -6425,6 +6443,9 @@ static int menu_input_pointer_post_iterate(
input_st->osk_grid[input_st->osk_ptr]);
}
}
#ifdef HAVE_MIST
}
#endif
}
/* Message boxes override normal menu input...
* > If a message box is shown, any kind of pointer
@ -8098,6 +8119,9 @@ bool menu_input_dialog_start_search(void)
if (!menu)
return false;
#ifdef HAVE_MIST
steam_open_osk();
#endif
menu_st->input_dialog_kb_display = true;
strlcpy(menu_st->input_dialog_kb_label,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH),
@ -8146,6 +8170,9 @@ bool menu_input_dialog_start(menu_input_ctx_line_t *line)
if (!line || !menu)
return false;
#ifdef HAVE_MIST
steam_open_osk();
#endif
menu_st->input_dialog_kb_display = true;
/* Only copy over the menu label and setting if they exist. */

View File

@ -1,8 +1,11 @@
#include <ctype.h>
#include <mist.h>
#include <retro_timers.h>
#include <stdio.h>
#include <string.h>
#include "../input/input_driver.h"
#include "../menu/menu_driver.h"
#include "../menu/menu_entries.h"
#include "../retroarch.h"
#include "../runloop.h"
@ -11,6 +14,7 @@
#include "steam.h"
static bool mist_initialized = false;
static bool mist_showing_osk = false;
static steam_core_dlc_list_t *mist_dlc_list = NULL;
void str_to_lower(char *str)
@ -63,6 +67,14 @@ void steam_poll(void)
command_event(CMD_EVENT_CORE_INFO_INIT, NULL);
steam_get_core_dlcs(&core_dlc_list, false);
break;
/* The Steam OSK is dismissed */
case MistCallback_FloatingGamepadTextInputDismissed:
/* If we do not poll for input the callback might race condition and
will dismiss the input even when enter is pressed */
retro_sleep(50);
runloop_iterate();
menu_input_dialog_end();
break;
}
result = mist_next_callback(&has_callback, &callback);
@ -308,6 +320,36 @@ error:
return;
}
bool steam_open_osk(void)
{
bool shown = false;
bool on_deck = false;
video_driver_state_t *video_st = video_state_get_ptr();
/* Only open the Steam OSK if running on a Steam Deck,
as currently the Big Picture OSK seems to be semi-broken */
mist_steam_utils_is_steam_running_on_steam_deck(&on_deck);
if(!on_deck) return false;
mist_steam_utils_show_floating_gamepad_text_input(
MistFloatingGamepadTextInputMode_SingleLine,
0,
0,
video_st->width,
video_st->height / 2,
&shown
);
mist_showing_osk = shown;
return shown;
}
bool steam_has_osk_open(void)
{
return mist_showing_osk;
}
void steam_deinit(void)
{
MistResult result;

View File

@ -1,6 +1,7 @@
#ifndef __RARCH_STEAM_H
#define __RARCH_STEAM_H
#include <boolean.h>
#include <mist.h>
#include "core_info.h"
@ -37,6 +38,9 @@ void steam_core_dlc_list_free(steam_core_dlc_list_t *list); /* NOTE: This should
void steam_install_core_dlc(steam_core_dlc_t *core_dlc);
void steam_uninstall_core_dlc(steam_core_dlc_t *core_dlc);
bool steam_open_osk(void);
bool steam_has_osk_open(void);
/* Located in tasks/task_steam.c */
void task_push_steam_core_dlc_install(AppId app_id, const char *name);