mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Move scancode to key to openrct2ui
This commit is contained in:
@@ -99,6 +99,19 @@ static void game_handle_key_scroll()
|
||||
}
|
||||
}
|
||||
|
||||
static sint32 input_scancode_to_rct_keycode(sint32 sdl_key)
|
||||
{
|
||||
char keycode = (char)SDL_GetKeyFromScancode((SDL_Scancode)sdl_key);
|
||||
|
||||
// Until we reshuffle the text files to use the new positions
|
||||
// this will suffice to move the majority to the correct positions.
|
||||
// Note any special buttons PgUp PgDwn are mapped wrong.
|
||||
if (keycode >= 'a' && keycode <= 'z')
|
||||
keycode = toupper(keycode);
|
||||
|
||||
return keycode;
|
||||
}
|
||||
|
||||
void input_handle_keyboard(bool isTitle)
|
||||
{
|
||||
if (gOpenRCT2Headless) {
|
||||
@@ -162,7 +175,8 @@ void input_handle_keyboard(bool isTitle)
|
||||
|
||||
rct_window * w = window_find_by_class(WC_TEXTINPUT);
|
||||
if (w != NULL) {
|
||||
window_text_input_key(w, key);
|
||||
char keychar = input_scancode_to_rct_keycode(key & 0xFF);
|
||||
window_text_input_key(w, keychar);
|
||||
} else if (!gUsingWidgetTextBox) {
|
||||
w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
|
||||
if (w != NULL) {
|
||||
|
||||
@@ -656,7 +656,7 @@ void window_zoom_out(rct_window *w, bool atCursor);
|
||||
void main_window_zoom(bool zoomIn, bool atCursor);
|
||||
|
||||
void window_show_textinput(rct_window *w, rct_widgetindex widgetIndex, uint16 title, uint16 text, sint32 value);
|
||||
void window_text_input_key(rct_window* w, sint32 key);
|
||||
void window_text_input_key(rct_window* w, char keychar);
|
||||
|
||||
void window_draw_all(rct_drawpixelinfo *dpi, sint16 left, sint16 top, sint16 right, sint16 bottom);
|
||||
void window_draw(rct_drawpixelinfo *dpi, rct_window *w, sint32 left, sint32 top, sint32 right, sint32 bottom);
|
||||
|
||||
@@ -107,7 +107,6 @@ void platform_free();
|
||||
void platform_update_palette(const uint8 *colours, sint32 start_index, sint32 num_colours);
|
||||
void platform_toggle_windowed_mode();
|
||||
void platform_refresh_video();
|
||||
sint32 platform_scancode_to_rct_keycode(sint32 sdl_key);
|
||||
void platform_get_date_utc(rct2_date *out_date);
|
||||
void platform_get_time_utc(rct2_time *out_time);
|
||||
void platform_get_date_local(rct2_date *out_date);
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <sys/time.h>
|
||||
#include <pwd.h>
|
||||
#include <time.h>
|
||||
#include <SDL_syswm.h>
|
||||
#include "../config/Config.h"
|
||||
#include "../localisation/date.h"
|
||||
#include "../localisation/language.h"
|
||||
|
||||
@@ -135,19 +135,6 @@ void platform_init()
|
||||
gPalette[255].blue = 255;
|
||||
}
|
||||
|
||||
sint32 platform_scancode_to_rct_keycode(sint32 sdl_key)
|
||||
{
|
||||
char keycode = (char)SDL_GetKeyFromScancode((SDL_Scancode)sdl_key);
|
||||
|
||||
// Until we reshuffle the text files to use the new positions
|
||||
// this will suffice to move the majority to the correct positions.
|
||||
// Note any special buttons PgUp PgDwn are mapped wrong.
|
||||
if (keycode >= 'a' && keycode <= 'z')
|
||||
keycode = toupper(keycode);
|
||||
|
||||
return keycode;
|
||||
}
|
||||
|
||||
void platform_free()
|
||||
{
|
||||
// free(gKeysPressed);
|
||||
|
||||
@@ -331,12 +331,10 @@ static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
}
|
||||
}
|
||||
|
||||
void window_text_input_key(rct_window* w, sint32 key)
|
||||
void window_text_input_key(rct_window* w, char keychar)
|
||||
{
|
||||
char new_char = platform_scancode_to_rct_keycode(0xFF&key);
|
||||
|
||||
// If the return button is pressed stop text input
|
||||
if (new_char == '\r'){
|
||||
if (keychar == '\r'){
|
||||
context_stop_text_input();
|
||||
window_close(w);
|
||||
rct_window* calling_w = window_find_by_number(calling_class, calling_number);
|
||||
|
||||
Reference in New Issue
Block a user