mirror of https://github.com/OpenRCT2/OpenRCT2.git
Added the ability to read the current keyboard assignment
This commit is contained in:
parent
f2ec0a4bb7
commit
880ae7cb94
|
@ -2526,6 +2526,7 @@ STR_2521 :Show staff list
|
|||
STR_2522 :Show recent messages
|
||||
STR_2523 :Show map
|
||||
STR_2524 :Screenshot
|
||||
### The following need to be reordered to match SDL_keycode layout.
|
||||
STR_2525 :???
|
||||
STR_2526 :???
|
||||
STR_2527 :???
|
||||
|
|
|
@ -154,8 +154,8 @@ static const struct { const char *key; int value; } _currencyLookupTable[] = {
|
|||
};
|
||||
|
||||
typedef struct shortcut_entry{
|
||||
uint8 shortcut;
|
||||
uint8 key;
|
||||
uint8 modifier;
|
||||
}shortcut_entry;
|
||||
|
||||
//typedef struct hotkey_configuration{
|
||||
|
|
|
@ -70,6 +70,17 @@ void osinterface_init()
|
|||
// RCT2_CALLPROC(0x00404584); // dinput_init()
|
||||
}
|
||||
|
||||
int osinterface_scancode_to_rct_keycode(int sdl_key){
|
||||
char keycode = (char)SDL_GetKeyFromScancode((SDL_Scancode)sdl_key);
|
||||
|
||||
// Until we reshufle 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not quite the same as the below function as we don't want to
|
||||
* derfererence the cursor before the function.
|
||||
|
|
|
@ -112,5 +112,6 @@ int osinterface_directory_exists(const char *path);
|
|||
int osinterface_ensure_directory_exists(const char *path);
|
||||
|
||||
char osinterface_get_path_separator();
|
||||
int osinterface_scancode_to_rct_keycode(int sdl_key);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -997,6 +997,15 @@ enum {
|
|||
STR_REAL_NAME_TIP = 2488,
|
||||
STR_HOTKEY = 2489,
|
||||
|
||||
STR_SHORTCUT_DESCRIPTION_0 = 2493,
|
||||
|
||||
STR_SHORTCUT_DESCRIPTION_31 = 2524,
|
||||
STR_INDIVIDUAL_KEYS_BASE = 2525,
|
||||
|
||||
STR_SHORTCUT_ENTRY_FORMAT = 2781,
|
||||
STR_SHIFT_PLUS = 2782,
|
||||
STR_CTRL_PLUS = 2783,
|
||||
|
||||
STR_FINACNES_PARK_VALUE = 2787,
|
||||
|
||||
STR_ENTER_NAME_INTO_SCENARIO_CHART = 2790,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "config.h"
|
||||
#include "window.h"
|
||||
#include "widget.h"
|
||||
#include "osinterface.h"
|
||||
|
||||
#define WW 340
|
||||
#define WH 240
|
||||
|
@ -237,23 +238,36 @@ static void window_shortcut_scrollpaint()
|
|||
gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x2000031);
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(0x13CE954, uint16) = i + 2493;
|
||||
RCT2_GLOBAL(0x13CE954, uint16) = i + STR_SHORTCUT_DESCRIPTION_0;
|
||||
RCT2_GLOBAL(0x13CE956, uint16) = 0;
|
||||
RCT2_GLOBAL(0x13CE958, uint16) = 0;
|
||||
|
||||
|
||||
shortcut_entry sc_entry = RCT2_ADDRESS(RCT2_ADDRESS_CONFIG_KEYBOARD_SHORTCUTS, shortcut_entry)[i];
|
||||
// This is the original version that will not take into account remapped keys.
|
||||
//shortcut_entry sc_entry = RCT2_ADDRESS(RCT2_ADDRESS_CONFIG_KEYBOARD_SHORTCUTS, shortcut_entry)[i];
|
||||
//if (sc_entry.key != 255){
|
||||
// RCT2_GLOBAL(0x13CE958, uint16) = sc_entry.key + 2525;
|
||||
// if (sc_entry.modifier){
|
||||
// RCT2_GLOBAL(0x13CE956, uint16) = 2782;
|
||||
// if (sc_entry.key != 1){
|
||||
// RCT2_GLOBAL(0x13CE956, uint16) = 2783;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
if (sc_entry.shortcut != 255){
|
||||
RCT2_GLOBAL(0x13CE958, uint16) = sc_entry.shortcut + 2525;
|
||||
if (sc_entry.key){
|
||||
RCT2_GLOBAL(0x13CE956, uint16) = 2782;
|
||||
if (sc_entry.key != 1){
|
||||
RCT2_GLOBAL(0x13CE956, uint16) = 2783;
|
||||
}
|
||||
uint16 shortcut_entry = gShortcutKeys[i];
|
||||
if (shortcut_entry != 0xFFFF){
|
||||
RCT2_GLOBAL(0x13CE958, uint16) = STR_INDIVIDUAL_KEYS_BASE + osinterface_scancode_to_rct_keycode(shortcut_entry & 0xFF);
|
||||
//Display the modifer
|
||||
if (shortcut_entry & 0x100){
|
||||
RCT2_GLOBAL(0x13CE956, uint16) = STR_SHIFT_PLUS;
|
||||
}
|
||||
else if (shortcut_entry & 0x200){
|
||||
RCT2_GLOBAL(0x13CE956, uint16) = STR_CTRL_PLUS;
|
||||
}
|
||||
}
|
||||
RCT2_GLOBAL(0x13CE952, uint16) = 2781;
|
||||
|
||||
|
||||
RCT2_GLOBAL(0x13CE952, uint16) = STR_SHORTCUT_ENTRY_FORMAT;
|
||||
|
||||
gfx_draw_string_left(dpi, format, (void*)0x13CE952, 0, 0, y - 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue