Use System_GetPropertyInt to report the keyboard layout
This commit is contained in:
parent
37c2dd8dd4
commit
26203552b4
7 changed files with 60 additions and 47 deletions
|
@ -1171,10 +1171,6 @@ if(WIN32)
|
||||||
target_link_libraries(Common winmm d3d9 dsound)
|
target_link_libraries(Common winmm d3d9 dsound)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TARGET SDL2::SDL2 AND NOT IOS)
|
|
||||||
target_link_libraries(Common SDL2::SDL2)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
list(APPEND NativeAppSource
|
list(APPEND NativeAppSource
|
||||||
android/jni/TestRunner.cpp
|
android/jni/TestRunner.cpp
|
||||||
UI/DiscordIntegration.cpp
|
UI/DiscordIntegration.cpp
|
||||||
|
|
|
@ -47,6 +47,12 @@ enum SystemDeviceType {
|
||||||
DEVICE_TYPE_DESKTOP = 2, // Desktop computer
|
DEVICE_TYPE_DESKTOP = 2, // Desktop computer
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum SystemKeyboardLayout {
|
||||||
|
KEYBOARD_LAYOUT_QWERTY = 0,
|
||||||
|
KEYBOARD_LAYOUT_QWERTZ = 1,
|
||||||
|
KEYBOARD_LAYOUT_AZERTY = 2,
|
||||||
|
};
|
||||||
|
|
||||||
enum SystemProperty {
|
enum SystemProperty {
|
||||||
SYSPROP_NAME,
|
SYSPROP_NAME,
|
||||||
SYSPROP_LANGREGION,
|
SYSPROP_LANGREGION,
|
||||||
|
@ -104,6 +110,8 @@ enum SystemProperty {
|
||||||
SYSPROP_ANDROID_SCOPED_STORAGE,
|
SYSPROP_ANDROID_SCOPED_STORAGE,
|
||||||
|
|
||||||
SYSPROP_CAN_JIT,
|
SYSPROP_CAN_JIT,
|
||||||
|
|
||||||
|
SYSPROP_KEYBOARD_LAYOUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string System_GetProperty(SystemProperty prop);
|
std::string System_GetProperty(SystemProperty prop);
|
||||||
|
|
|
@ -19,12 +19,6 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#if defined(SDL)
|
|
||||||
#include <SDL_keyboard.h>
|
|
||||||
#elif defined(USING_WIN_UI)
|
|
||||||
#include "CommonWindows.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ppsspp_config.h"
|
#include "ppsspp_config.h"
|
||||||
|
|
||||||
#include "Common/System/NativeApp.h"
|
#include "Common/System/NativeApp.h"
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
#if defined(SDL)
|
|
||||||
#include <SDL_keyboard.h>
|
|
||||||
#elif defined(USING_WIN_UI)
|
|
||||||
#include "CommonWindows.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ppsspp_config.h"
|
#include "ppsspp_config.h"
|
||||||
|
|
||||||
#include "Common/CommonFuncs.h"
|
#include "Common/CommonFuncs.h"
|
||||||
#include "Common/Input/KeyCodes.h"
|
#include "Common/Input/KeyCodes.h"
|
||||||
#include "Common/Input/InputState.h"
|
#include "Common/Input/InputState.h"
|
||||||
|
#include "Common/System/System.h"
|
||||||
#include "Core/KeyMapDefaults.h"
|
#include "Core/KeyMapDefaults.h"
|
||||||
#include "Core/KeyMap.h"
|
#include "Core/KeyMap.h"
|
||||||
|
|
||||||
|
@ -303,39 +298,18 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
|
||||||
switch (dmap) {
|
switch (dmap) {
|
||||||
case DEFAULT_MAPPING_KEYBOARD:
|
case DEFAULT_MAPPING_KEYBOARD:
|
||||||
{
|
{
|
||||||
bool azerty = false;
|
int keyboardLayout = System_GetPropertyInt(SYSPROP_KEYBOARD_LAYOUT);
|
||||||
bool qwertz = false;
|
switch (keyboardLayout) {
|
||||||
#if defined(SDL)
|
case KEYBOARD_LAYOUT_QWERTZ:
|
||||||
char q, w, y;
|
|
||||||
q = SDL_GetKeyFromScancode(SDL_SCANCODE_Q);
|
|
||||||
w = SDL_GetKeyFromScancode(SDL_SCANCODE_W);
|
|
||||||
y = SDL_GetKeyFromScancode(SDL_SCANCODE_Y);
|
|
||||||
if (q == 'a' && w == 'z' && y == 'y')
|
|
||||||
azerty = true;
|
|
||||||
else if (q == 'q' && w == 'w' && y == 'z')
|
|
||||||
qwertz = true;
|
|
||||||
#elif defined(USING_WIN_UI)
|
|
||||||
HKL localeId = GetKeyboardLayout(0);
|
|
||||||
// TODO: Is this list complete enough?
|
|
||||||
switch ((int)(intptr_t)localeId & 0xFFFF) {
|
|
||||||
case 0x407:
|
|
||||||
qwertz = true;
|
|
||||||
break;
|
|
||||||
case 0x040c:
|
|
||||||
case 0x080c:
|
|
||||||
case 0x1009:
|
|
||||||
azerty = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (azerty) {
|
|
||||||
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultAzertyKeyboardKeyMap, ARRAY_SIZE(defaultAzertyKeyboardKeyMap), replace);
|
|
||||||
} else if (qwertz) {
|
|
||||||
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertzKeyboardKeyMap, ARRAY_SIZE(defaultQwertzKeyboardKeyMap), replace);
|
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertzKeyboardKeyMap, ARRAY_SIZE(defaultQwertzKeyboardKeyMap), replace);
|
||||||
} else {
|
break;
|
||||||
|
case KEYBOARD_LAYOUT_AZERTY:
|
||||||
|
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultAzertyKeyboardKeyMap, ARRAY_SIZE(defaultAzertyKeyboardKeyMap), replace);
|
||||||
|
break;
|
||||||
|
case KEYBOARD_LAYOUT_QWERTY:
|
||||||
|
default:
|
||||||
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertyKeyboardKeyMap, ARRAY_SIZE(defaultQwertyKeyboardKeyMap), replace);
|
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertyKeyboardKeyMap, ARRAY_SIZE(defaultQwertyKeyboardKeyMap), replace);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#ifdef SDL
|
#ifdef SDL
|
||||||
#include "SDL/SDLJoystick.h"
|
#include "SDL/SDLJoystick.h"
|
||||||
#include "SDL_audio.h"
|
#include "SDL_audio.h"
|
||||||
|
#include "SDL_keyboard.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Common/System/NativeApp.h"
|
#include "Common/System/NativeApp.h"
|
||||||
|
@ -176,6 +177,19 @@ int System_GetPropertyInt(SystemProperty prop) {
|
||||||
return g_retFmt.freq;
|
return g_retFmt.freq;
|
||||||
case SYSPROP_AUDIO_FRAMES_PER_BUFFER:
|
case SYSPROP_AUDIO_FRAMES_PER_BUFFER:
|
||||||
return g_retFmt.samples;
|
return g_retFmt.samples;
|
||||||
|
case SYSPROP_KEYBOARD_LAYOUT:
|
||||||
|
{
|
||||||
|
// TODO: Use Qt APIs for detecting this
|
||||||
|
char q, w, y;
|
||||||
|
q = SDL_GetKeyFromScancode(SDL_SCANCODE_Q);
|
||||||
|
w = SDL_GetKeyFromScancode(SDL_SCANCODE_W);
|
||||||
|
y = SDL_GetKeyFromScancode(SDL_SCANCODE_Y);
|
||||||
|
if (q == 'a' && w == 'z' && y == 'y')
|
||||||
|
return KEYBOARD_LAYOUT_AZERTY;
|
||||||
|
else if (q == 'q' && w == 'w' && y == 'z')
|
||||||
|
return KEYBOARD_LAYOUT_QWERTZ;
|
||||||
|
return KEYBOARD_LAYOUT_QWERTY;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
case SYSPROP_DEVICE_TYPE:
|
case SYSPROP_DEVICE_TYPE:
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
|
|
|
@ -375,6 +375,18 @@ int System_GetPropertyInt(SystemProperty prop) {
|
||||||
#endif
|
#endif
|
||||||
case SYSPROP_DISPLAY_COUNT:
|
case SYSPROP_DISPLAY_COUNT:
|
||||||
return SDL_GetNumVideoDisplays();
|
return SDL_GetNumVideoDisplays();
|
||||||
|
case SYSPROP_KEYBOARD_LAYOUT:
|
||||||
|
{
|
||||||
|
char q, w, y;
|
||||||
|
q = SDL_GetKeyFromScancode(SDL_SCANCODE_Q);
|
||||||
|
w = SDL_GetKeyFromScancode(SDL_SCANCODE_W);
|
||||||
|
y = SDL_GetKeyFromScancode(SDL_SCANCODE_Y);
|
||||||
|
if (q == 'a' && w == 'z' && y == 'y')
|
||||||
|
return KEYBOARD_LAYOUT_AZERTY;
|
||||||
|
else if (q == 'q' && w == 'w' && y == 'z')
|
||||||
|
return KEYBOARD_LAYOUT_QWERTZ;
|
||||||
|
return KEYBOARD_LAYOUT_QWERTY;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,6 +279,21 @@ int System_GetPropertyInt(SystemProperty prop) {
|
||||||
return DEVICE_TYPE_DESKTOP;
|
return DEVICE_TYPE_DESKTOP;
|
||||||
case SYSPROP_DISPLAY_COUNT:
|
case SYSPROP_DISPLAY_COUNT:
|
||||||
return GetSystemMetrics(SM_CMONITORS);
|
return GetSystemMetrics(SM_CMONITORS);
|
||||||
|
case SYSPROP_KEYBOARD_LAYOUT:
|
||||||
|
{
|
||||||
|
HKL localeId = GetKeyboardLayout(0);
|
||||||
|
// TODO: Is this list complete enough?
|
||||||
|
switch ((int)(intptr_t)localeId & 0xFFFF) {
|
||||||
|
case 0x407:
|
||||||
|
return KEYBOARD_LAYOUT_QWERTZ;
|
||||||
|
case 0x040c:
|
||||||
|
case 0x080c:
|
||||||
|
case 0x1009:
|
||||||
|
return KEYBOARD_LAYOUT_AZERTY;
|
||||||
|
default:
|
||||||
|
return KEYBOARD_LAYOUT_QWERTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue