Add more special key codes to keyboard keys

ref T404
This commit is contained in:
Roland Winklmeier
2018-10-22 12:14:48 +02:00
committed by Klaus Basan
parent 6cb0ed583e
commit 0f140cb155
6 changed files with 80 additions and 9 deletions

View File

@@ -67,6 +67,14 @@ namespace BlackInput
{ XK_Control_R, Key_ControlRight },
{ XK_Alt_L, Key_AltLeft },
{ XK_Alt_R, Key_AltRight },
{ XK_KP_Add, Key_Plus },
{ XK_plus, Key_Plus },
{ XK_KP_Subtract, Key_Minus },
{ XK_minus, Key_Minus },
{ XK_period, Key_Period },
{ XK_KP_Divide, Key_Divide },
{ XK_KP_Multiply, Key_Multiply },
{ XK_comma, Key_Comma },
};
CKeyboardLinux::CKeyboardLinux(QObject *parent) :

View File

@@ -61,6 +61,23 @@ namespace BlackInput
{ kVK_ANSI_X, Key_X },
{ kVK_ANSI_Y, Key_Y },
{ kVK_ANSI_Z, Key_Z },
{ kVK_ANSI_KeypadPlus, Key_Plus },
{ kVK_ANSI_KeypadMinus, Key_Minus },
{ kVK_ANSI_Minus, Key_Minus },
{ kVK_ANSI_Period, Key_Period },
{ kVK_ANSI_KeypadDivide, Key_Divide },
{ kVK_ANSI_KeypadMultiply, Key_Multiply },
{ kVK_ANSI_Comma, Key_Comma },
{ kVK_ANSI_Keypad0, Key_Numpad0 },
{ kVK_ANSI_Keypad1, Key_Numpad1 },
{ kVK_ANSI_Keypad2, Key_Numpad2 },
{ kVK_ANSI_Keypad3, Key_Numpad3 },
{ kVK_ANSI_Keypad4, Key_Numpad4 },
{ kVK_ANSI_Keypad5, Key_Numpad5 },
{ kVK_ANSI_Keypad6, Key_Numpad6 },
{ kVK_ANSI_Keypad7, Key_Numpad7 },
{ kVK_ANSI_Keypad8, Key_Numpad8 },
{ kVK_ANSI_Keypad9, Key_Numpad9 },
};
CKeyboardMacOS::CKeyboardMacOS(QObject *parent) :

View File

@@ -59,6 +59,24 @@ namespace BlackInput
{ VK_RCONTROL, Key_ControlRight },
{ VK_LMENU, Key_AltLeft },
{ VK_RMENU, Key_AltRight },
{ VK_ADD, Key_Plus },
{ VK_OEM_PLUS, Key_Plus },
{ VK_SUBTRACT, Key_Minus },
{ VK_OEM_MINUS, Key_Minus },
{ VK_OEM_PERIOD, Key_Period },
{ VK_DIVIDE, Key_Divide },
{ VK_MULTIPLY, Key_Multiply },
{ VK_OEM_COMMA, Key_Comma },
{ VK_NUMPAD0, Key_Numpad0 },
{ VK_NUMPAD1, Key_Numpad1 },
{ VK_NUMPAD2, Key_Numpad2 },
{ VK_NUMPAD3, Key_Numpad3 },
{ VK_NUMPAD4, Key_Numpad4 },
{ VK_NUMPAD5, Key_Numpad5 },
{ VK_NUMPAD6, Key_Numpad6 },
{ VK_NUMPAD7, Key_Numpad7 },
{ VK_NUMPAD8, Key_Numpad8 },
{ VK_NUMPAD9, Key_Numpad9 },
};
return hash;
}

View File

@@ -7,9 +7,7 @@
* contained in the LICENSE file.
*/
/*!
\file
*/
//! \file
#ifndef BLACKINPUT_KEYBOARD_WINDOWS_H
#define BLACKINPUT_KEYBOARD_WINDOWS_H
@@ -23,7 +21,7 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#include <Windows.h>
namespace BlackInput
{

View File

@@ -55,8 +55,22 @@ namespace BlackMisc
if (isModifier()) { return keyStrings.value(m_keyCode); }
QChar key = QChar::fromLatin1(static_cast<char>(m_keyCode));
return key;
switch (m_keyCode)
{
case Key_Multiply: return QStringLiteral("×");
case Key_Divide: return QStringLiteral("÷");
case Key_Numpad0: return QStringLiteral("Num0");
case Key_Numpad1: return QStringLiteral("Num1");
case Key_Numpad2: return QStringLiteral("Num2");
case Key_Numpad3: return QStringLiteral("Num3");
case Key_Numpad4: return QStringLiteral("Num4");
case Key_Numpad5: return QStringLiteral("Num5");
case Key_Numpad6: return QStringLiteral("Num6");
case Key_Numpad7: return QStringLiteral("Num7");
case Key_Numpad8: return QStringLiteral("Num8");
case Key_Numpad9: return QStringLiteral("Num9");
default: return QChar::fromLatin1(static_cast<char>(m_keyCode));
}
}
const QList<KeyCode> &CKeyboardKey::allModifiers()

View File

@@ -22,15 +22,18 @@ namespace BlackMisc
enum KeyCode
{
Key_Unknown,
// Modifiers
Key_ShiftLeft,
Key_ShiftRight,
Key_ControlLeft,
Key_ControlRight,
Key_AltLeft,
Key_AltRight,
Key_Plus = 43,
Key_Comma,
Key_Minus,
Key_Period,
// 0 - 9
Key_0 = 0x30,
Key_0 = 48,
Key_1,
Key_2,
Key_3,
@@ -41,7 +44,7 @@ namespace BlackMisc
Key_8,
Key_9,
// A - Z
Key_A = 0x41,
Key_A = 65,
Key_B,
Key_C,
Key_D,
@@ -67,6 +70,19 @@ namespace BlackMisc
Key_X,
Key_Y,
Key_Z,
// Numpad
Key_Multiply,
Key_Divide,
Key_Numpad0,
Key_Numpad1,
Key_Numpad2,
Key_Numpad3,
Key_Numpad4,
Key_Numpad5,
Key_Numpad6,
Key_Numpad7,
Key_Numpad8,
Key_Numpad9,
};
} //namespace