File tree Expand file tree Collapse file tree 3 files changed +43
-4
lines changed
Expand file tree Collapse file tree 3 files changed +43
-4
lines changed Original file line number Diff line number Diff line change @@ -1139,7 +1139,46 @@ namespace gamescope
11391139 {
11401140 if (m_pIME)
11411141 {
1142- type_text (m_pIME, vrEvent.data .keyboard .cNewInput );
1142+ const char *pchText = vrEvent.data .keyboard .cNewInput ;
1143+ size_t unStrLen = strlen ( pchText );
1144+ bool bEscaped = false ;
1145+ if ( unStrLen > 2 && pchText[0 ] == ' \x1b ' && pchText[1 ] == ' [' )
1146+ {
1147+ bEscaped = true ;
1148+ }
1149+
1150+ if ( bEscaped )
1151+ {
1152+ const char chControlChar = pchText[2 ];
1153+ gamescope_input_method_action eAction = GAMESCOPE_INPUT_METHOD_ACTION_NONE;
1154+ switch (chControlChar)
1155+ {
1156+ case ' D' : eAction = GAMESCOPE_INPUT_METHOD_ACTION_MOVE_LEFT; break ;
1157+ case ' C' : eAction = GAMESCOPE_INPUT_METHOD_ACTION_MOVE_RIGHT; break ;
1158+ case ' A' : eAction = GAMESCOPE_INPUT_METHOD_ACTION_MOVE_UP; break ;
1159+ case ' B' : eAction = GAMESCOPE_INPUT_METHOD_ACTION_MOVE_DOWN; break ;
1160+ }
1161+
1162+ if ( eAction != GAMESCOPE_INPUT_METHOD_ACTION_NONE )
1163+ {
1164+ perform_action ( m_pIME, eAction );
1165+ }
1166+ }
1167+ else
1168+ {
1169+ if ( unStrLen == 1 && pchText[0 ] == ' \n ' )
1170+ {
1171+ perform_action ( m_pIME, GAMESCOPE_INPUT_METHOD_ACTION_SUBMIT );
1172+ }
1173+ else if ( unStrLen == 1 && pchText[0 ] == ' \b ' )
1174+ {
1175+ perform_action ( m_pIME, GAMESCOPE_INPUT_METHOD_ACTION_DELETE_LEFT );
1176+ }
1177+ else
1178+ {
1179+ type_text ( m_pIME, pchText );
1180+ }
1181+ }
11431182 }
11441183 break ;
11451184 }
Original file line number Diff line number Diff line change 1818#include < wlr/types/wlr_seat.h>
1919#include " wlr_end.hpp"
2020
21- #include " gamescope-input-method-protocol.h"
22-
2321struct wlserver_input_method_manager *global_manager = nullptr ;
2422
2523/* The C/C++ standard library doesn't expose a reliable way to decode UTF-8,
@@ -407,7 +405,7 @@ void type_text(struct wlserver_input_method *ime, const char *text)
407405 wl_event_source_timer_update (ime->ime_reset_ime_keyboard_event_source , 100 /* ms */ );
408406}
409407
410- static void perform_action (struct wlserver_input_method *ime, enum gamescope_input_method_action action)
408+ void perform_action (struct wlserver_input_method *ime, enum gamescope_input_method_action action)
411409{
412410 if (actions.count (action) == 0 ) {
413411 ime_log.errorf (" unsupported action %d" , action);
Original file line number Diff line number Diff line change 33#pragma once
44
55#include " wlserver.hpp"
6+ #include " gamescope-input-method-protocol.h"
67
78void create_ime_manager (struct wlserver_t *wlserver);
89
910struct wlserver_input_method *create_local_ime ();
1011void destroy_ime (struct wlserver_input_method * ime);
1112void type_text (struct wlserver_input_method *ime, const char *text);
13+ void perform_action (struct wlserver_input_method *ime, enum gamescope_input_method_action action);
You can’t perform that action at this time.
0 commit comments