mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Windows: Add WM_CHAR input support (not used for anything yet).
Some unicode cleanup.
This commit is contained in:
parent
9919126e0a
commit
01cb22f16a
5 changed files with 44 additions and 12 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "base/timeutil.h"
|
||||
#include "base/NativeApp.h"
|
||||
#include "base/mutex.h"
|
||||
#include "util/text/utf8.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "../Globals.h"
|
||||
|
@ -99,7 +100,7 @@ unsigned int WINAPI TheThread(void *)
|
|||
u32 colour_depth = GetDeviceCaps(dc, BITSPIXEL);
|
||||
ReleaseDC(NULL, dc);
|
||||
if (colour_depth != 32){
|
||||
MessageBoxA(0, "Please switch your display to 32-bit colour mode", "OpenGL Error", MB_OK);
|
||||
MessageBox(0, L"Please switch your display to 32-bit colour mode", L"OpenGL Error", MB_OK);
|
||||
ExitProcess(1);
|
||||
}
|
||||
|
||||
|
@ -107,7 +108,7 @@ unsigned int WINAPI TheThread(void *)
|
|||
if (!host->InitGL(&error_string)) {
|
||||
Reporting::ReportMessage("OpenGL init error: %s", error_string.c_str());
|
||||
std::string full_error = StringFromFormat( "Failed initializing OpenGL. Try upgrading your graphics drivers.\n\nError message:\n\n%s", error_string.c_str());
|
||||
MessageBoxA(0, full_error.c_str(), "OpenGL Error", MB_OK | MB_ICONERROR);
|
||||
MessageBox(0, ConvertUTF8ToWString(full_error).c_str(), L"OpenGL Error", MB_OK | MB_ICONERROR);
|
||||
ERROR_LOG(BOOT, full_error.c_str());
|
||||
|
||||
// No safe way out without OpenGL.
|
||||
|
|
|
@ -91,25 +91,41 @@ namespace WindowsRawInput {
|
|||
}
|
||||
|
||||
static int GetTrueVKey(const RAWKEYBOARD &kb) {
|
||||
int vKey = kb.VKey;
|
||||
switch (kb.VKey) {
|
||||
case VK_SHIFT:
|
||||
return MapVirtualKey(kb.MakeCode, MAPVK_VSC_TO_VK_EX);
|
||||
vKey = MapVirtualKey(kb.MakeCode, MAPVK_VSC_TO_VK_EX);
|
||||
break;
|
||||
|
||||
case VK_CONTROL:
|
||||
if (kb.Flags & RI_KEY_E0)
|
||||
return VK_RCONTROL;
|
||||
vKey = VK_RCONTROL;
|
||||
else
|
||||
return VK_LCONTROL;
|
||||
vKey = VK_LCONTROL;
|
||||
break;
|
||||
|
||||
case VK_MENU:
|
||||
if (kb.Flags & RI_KEY_E0)
|
||||
return VK_RMENU; // Right Alt / AltGr
|
||||
vKey = VK_RMENU; // Right Alt / AltGr
|
||||
else
|
||||
return VK_LMENU; // Left Alt
|
||||
vKey = VK_LMENU; // Left Alt
|
||||
|
||||
//case VK_RETURN:
|
||||
// if (kb.Flags & RI_KEY_E0)
|
||||
// vKey = VK_RETURN; // Numeric return - no code for this. Can special case.
|
||||
// break;
|
||||
|
||||
// Source: http://molecularmusings.wordpress.com/2011/09/05/properly-handling-keyboard-input/
|
||||
case VK_NUMLOCK:
|
||||
// correct PAUSE/BREAK and NUM LOCK silliness, and set the extended bit
|
||||
vKey = MapVirtualKey(kb.VKey, MAPVK_VK_TO_VSC) | 0x100;
|
||||
break;
|
||||
|
||||
default:
|
||||
return kb.VKey;
|
||||
break;
|
||||
}
|
||||
|
||||
return windowsTransTable[vKey];
|
||||
}
|
||||
|
||||
void ProcessKeyboard(RAWINPUT *raw, bool foreground) {
|
||||
|
@ -123,7 +139,7 @@ namespace WindowsRawInput {
|
|||
|
||||
if (raw->data.keyboard.Message == WM_KEYDOWN || raw->data.keyboard.Message == WM_SYSKEYDOWN) {
|
||||
key.flags = KEY_DOWN;
|
||||
key.keyCode = windowsTransTable[GetTrueVKey(raw->data.keyboard)];
|
||||
key.keyCode = GetTrueVKey(raw->data.keyboard);
|
||||
|
||||
if (key.keyCode) {
|
||||
NativeKey(key);
|
||||
|
@ -131,7 +147,7 @@ namespace WindowsRawInput {
|
|||
}
|
||||
} else if (raw->data.keyboard.Message == WM_KEYUP) {
|
||||
key.flags = KEY_UP;
|
||||
key.keyCode = windowsTransTable[GetTrueVKey(raw->data.keyboard)];
|
||||
key.keyCode = GetTrueVKey(raw->data.keyboard);
|
||||
|
||||
if (key.keyCode) {
|
||||
NativeKey(key);
|
||||
|
@ -143,6 +159,15 @@ namespace WindowsRawInput {
|
|||
}
|
||||
}
|
||||
|
||||
LRESULT ProcessChar(HWND hWnd, WPARAM wParam, LPARAM lParam) {
|
||||
KeyInput key;
|
||||
key.keyCode = wParam; // Note that this is NOT a NKCODE but a Unicode character!
|
||||
key.flags = KEY_CHAR;
|
||||
key.deviceId = DEVICE_ID_KEYBOARD;
|
||||
NativeKey(key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ProcessMouse(RAWINPUT *raw, bool foreground) {
|
||||
if (menuActive && UpdateMenuActive()) {
|
||||
// Ignore mouse input while a menu is active, it's probably interacting with the menu.
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
namespace WindowsRawInput {
|
||||
void Init();
|
||||
LRESULT Process(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
// Not actually RawInput but it kinda belongs here anyway.
|
||||
LRESULT ProcessChar(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
void LoseFocus();
|
||||
void NotifyMenu();
|
||||
void Shutdown();
|
||||
|
|
|
@ -1595,6 +1595,10 @@ namespace MainWindow
|
|||
|
||||
// TODO: Could do something useful with WM_INPUT_DEVICE_CHANGE?
|
||||
|
||||
// Not sure why we are actually getting WM_CHAR even though we use RawInput, but alright..
|
||||
case WM_CHAR:
|
||||
return WindowsRawInput::ProcessChar(hWnd, wParam, lParam);
|
||||
|
||||
case WM_VERYSLEEPY_MSG:
|
||||
switch (wParam) {
|
||||
case VERYSLEEPY_WPARAM_SUPPORTED:
|
||||
|
@ -1930,7 +1934,7 @@ namespace MainWindow
|
|||
HWND versionBox = GetDlgItem(hDlg, IDC_VERSION);
|
||||
char temp[256];
|
||||
sprintf(temp, "PPSSPP %s", PPSSPP_GIT_VERSION);
|
||||
SetWindowTextA(versionBox, temp);
|
||||
SetWindowText(versionBox, ConvertUTF8ToWString(temp).c_str());
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ void EnableCrashingOnCrashes()
|
|||
typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags);
|
||||
const DWORD EXCEPTION_SWALLOWING = 0x1;
|
||||
|
||||
HMODULE kernel32 = LoadLibraryA("kernel32.dll");
|
||||
HMODULE kernel32 = LoadLibrary(L"kernel32.dll");
|
||||
tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32,
|
||||
"GetProcessUserModeExceptionPolicy");
|
||||
tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32,
|
||||
|
|
Loading…
Add table
Reference in a new issue