mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 23:11:25 +12:00
Qt: fix diacritics in keyboard handler
This commit is contained in:
parent
7408f50d71
commit
eedf96e1f4
3 changed files with 21 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
#include "Emu/IdManager.h"
|
#include "Emu/IdManager.h"
|
||||||
#include "Emu/Cell/PPUModule.h"
|
#include "Emu/Cell/PPUModule.h"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "basic_keyboard_handler.h"
|
#include "basic_keyboard_handler.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
@ -116,29 +116,39 @@ void basic_keyboard_handler::keyReleaseEvent(QKeyEvent* keyEvent)
|
||||||
|
|
||||||
// This should get the actual unmodified key without getting too crazy.
|
// This should get the actual unmodified key without getting too crazy.
|
||||||
// key() only shows the modifiers and the modified key (e.g. no easy way of knowing that - was pressed in 'SHIFT+-' in order to get _)
|
// key() only shows the modifiers and the modified key (e.g. no easy way of knowing that - was pressed in 'SHIFT+-' in order to get _)
|
||||||
int basic_keyboard_handler::getUnmodifiedKey(QKeyEvent* keyEvent)
|
s32 basic_keyboard_handler::getUnmodifiedKey(QKeyEvent* keyEvent)
|
||||||
{
|
{
|
||||||
if (!keyEvent)
|
if (!keyEvent)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int key = keyEvent->key();
|
const int key = keyEvent->key();
|
||||||
|
|
||||||
|
if (key < 0)
|
||||||
|
{
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT raw_key = static_cast<UINT>(key);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (keyEvent->modifiers() != Qt::NoModifier && !keyEvent->text().isEmpty())
|
if (keyEvent->modifiers() != Qt::NoModifier && !keyEvent->text().isEmpty())
|
||||||
{
|
{
|
||||||
const auto virtual_key = keyEvent->nativeVirtualKey();
|
UINT mapped_key = MapVirtualKeyA((UINT)keyEvent->nativeVirtualKey(), MAPVK_VK_TO_CHAR);
|
||||||
const auto mapped_key = (int)MapVirtualKeyA((UINT)virtual_key, MAPVK_VK_TO_CHAR);
|
|
||||||
if (key != mapped_key)
|
if (raw_key != mapped_key)
|
||||||
{
|
{
|
||||||
LOG_NOTICE(HLE, "basic_keyboard_handler: converted key %s (%d) to (%d)", keyEvent->text().toStdString(), key, mapped_key);
|
if (mapped_key > 0x80000000) // diacritics
|
||||||
key = mapped_key;
|
{
|
||||||
|
mapped_key -= 0x80000000;
|
||||||
|
}
|
||||||
|
raw_key = mapped_key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return key;
|
return static_cast<s32>(raw_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void basic_keyboard_handler::LoadSettings()
|
void basic_keyboard_handler::LoadSettings()
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
bool eventFilter(QObject* obj, QEvent* ev) override;
|
bool eventFilter(QObject* obj, QEvent* ev) override;
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
void keyReleaseEvent(QKeyEvent* event);
|
void keyReleaseEvent(QKeyEvent* event);
|
||||||
int getUnmodifiedKey(QKeyEvent* event);
|
s32 getUnmodifiedKey(QKeyEvent* event);
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
private:
|
private:
|
||||||
QWindow* m_target = nullptr;
|
QWindow* m_target = nullptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue