qt: Fix some Haiku keycodes, move them to a header and add key name comments

This commit is contained in:
RichardG867
2023-04-09 18:08:03 -03:00
parent b904636fe1
commit 660856d6ec
3 changed files with 115 additions and 112 deletions

112
src/qt/be_keyboard.hpp Normal file
View File

@@ -0,0 +1,112 @@
static std::unordered_map<uint8_t, uint16_t> be_keycodes = {
{B_F1_KEY, 0x3b},
{B_F2_KEY, 0x3c},
{B_F3_KEY, 0x3d},
{B_F4_KEY, 0x3e},
{B_F5_KEY, 0x3f},
{B_F6_KEY, 0x40},
{B_F7_KEY, 0x41},
{B_F8_KEY, 0x42},
{B_F9_KEY, 0x43},
{B_F10_KEY, 0x44},
{B_F11_KEY, 0x57},
{B_F12_KEY, 0x58},
{B_PRINT_KEY, 0x137},
{B_SCROLL_KEY, 0x46},
{B_PAUSE_KEY, 0x145},
{B_KATAKANA_HIRAGANA, 0x70},
{B_HANKAKU_ZENKAKU, 0x76},
{0x01, 0x01}, /* Escape */
{0x11, 0x29},
{0x12, 0x02},
{0x13, 0x03},
{0x14, 0x04},
{0x15, 0x05},
{0x16, 0x06},
{0x17, 0x07},
{0x18, 0x08},
{0x19, 0x09},
{0x1a, 0x0a},
{0x1b, 0x0b},
{0x1c, 0x0c},
{0x1d, 0x0d},
{0x1e, 0x0e}, /* Backspace */
{0x1f, 0x152}, /* Insert */
{0x20, 0x147}, /* Home */
{0x21, 0x149}, /* Page Up */
{0x22, 0x45},
{0x23, 0x135},
{0x24, 0x37},
{0x25, 0x4a},
{0x26, 0x0f}, /* Tab */
{0x27, 0x10},
{0x28, 0x11},
{0x29, 0x12},
{0x2a, 0x13},
{0x2b, 0x14},
{0x2c, 0x15},
{0x2d, 0x16},
{0x2e, 0x17},
{0x2f, 0x18},
{0x30, 0x19},
{0x31, 0x1a},
{0x32, 0x1b},
{0x33, 0x2b},
{0x34, 0x153}, /* Delete */
{0x35, 0x14f}, /* End */
{0x36, 0x151}, /* Page Down */
{0x37, 0x47},
{0x38, 0x48},
{0x39, 0x49},
{0x3a, 0x4e},
{0x3b, 0x3a},
{0x3c, 0x1e},
{0x3d, 0x1f},
{0x3e, 0x20},
{0x3f, 0x21},
{0x40, 0x22},
{0x41, 0x23},
{0x42, 0x24},
{0x43, 0x25},
{0x44, 0x26},
{0x45, 0x27},
{0x46, 0x28},
{0x47, 0x1c}, /* Enter */
{0x48, 0x4b},
{0x49, 0x4c},
{0x4a, 0x4d},
{0x4b, 0x2a},
{0x4c, 0x2c},
{0x4d, 0x2d},
{0x4e, 0x2e},
{0x4f, 0x2f},
{0x50, 0x30},
{0x51, 0x31},
{0x52, 0x32},
{0x53, 0x33},
{0x54, 0x34},
{0x55, 0x35},
{0x56, 0x36},
{0x57, 0x148}, /* up arrow */
{0x58, 0x51},
{0x59, 0x50},
{0x5a, 0x4f},
{0x5b, 0x11c},
{0x5c, 0x1d},
{0x5d, 0x38},
{0x5e, 0x39}, /* space bar */
{0x5f, 0x138},
{0x60, 0x11d},
{0x61, 0x14b}, /* left arrow */
{0x62, 0x150}, /* down arrow */
{0x63, 0x14d}, /* right arrow */
{0x64, 0x52},
{0x65, 0x53},
{0x66, 0x15b},
{0x67, 0x15c},
{0x68, 0x15d},
{0x69, 0x56},
{0x7e, 0x137}, /* System Request */
{0x7f, 0x145}, /* Break */
};

View File

@@ -1,4 +1,4 @@
std::array<uint32_t, 127> cocoa_keycodes = { /* key names in parentheses are not declared by Apple headers */
static std::array<uint32_t, 127> cocoa_keycodes = { /* key names in parentheses are not declared by Apple headers */
0x1e, /* ANSI_A */
0x1f, /* ANSI_S */
0x20, /* ANSI_D */

View File

@@ -126,6 +126,7 @@ namespace IOKit {
#ifdef __HAIKU__
# include <os/AppKit.h>
# include <os/InterfaceKit.h>
# include "be_keyboard.hpp"
extern MainWindow *main_window;
@@ -906,116 +907,6 @@ MainWindow::on_actionSettings_triggered()
plat_pause(currentPause);
}
#ifdef __HAIKU__
static std::unordered_map<uint8_t, uint16_t> be_to_xt = {
{0x01, 0x01 },
{ B_F1_KEY, 0x3B },
{ B_F2_KEY, 0x3C },
{ B_F3_KEY, 0x3D },
{ B_F4_KEY, 0x3E },
{ B_F5_KEY, 0x3F },
{ B_F6_KEY, 0x40 },
{ B_F7_KEY, 0x41 },
{ B_F8_KEY, 0x42 },
{ B_F9_KEY, 0x43 },
{ B_F10_KEY, 0x44 },
{ B_F11_KEY, 0x57 },
{ B_F12_KEY, 0x58 },
{ 0x11, 0x29 },
{ 0x12, 0x02 },
{ 0x13, 0x03 },
{ 0x14, 0x04 },
{ 0x15, 0x05 },
{ 0x16, 0x06 },
{ 0x17, 0x07 },
{ 0x18, 0x08 },
{ 0x19, 0x09 },
{ 0x1A, 0x0A },
{ 0x1B, 0x0B },
{ 0x1C, 0x0C },
{ 0x1D, 0x0D },
{ 0x1E, 0x0E },
{ 0x1F, 0x152},
{ 0x20, 0x147},
{ 0x21, 0x149},
{ 0x22, 0x45 },
{ 0x23, 0x135},
{ 0x24, 0x37 },
{ 0x25, 0x4A },
{ 0x26, 0x0F },
{ 0x27, 0x10 },
{ 0x28, 0x11 },
{ 0x29, 0x12 },
{ 0x2A, 0x13 },
{ 0x2B, 0x14 },
{ 0x2C, 0x15 },
{ 0x2D, 0x16 },
{ 0x2E, 0x17 },
{ 0x2F, 0x18 },
{ 0x30, 0x19 },
{ 0x31, 0x1A },
{ 0x32, 0x1B },
{ 0x33, 0x2B },
{ 0x34, 0x153},
{ 0x35, 0x14F},
{ 0x36, 0x151},
{ 0x37, 0x47 },
{ 0x38, 0x48 },
{ 0x39, 0x49 },
{ 0x3A, 0x4E },
{ 0x3B, 0x3A },
{ 0x3C, 0x1E },
{ 0x3D, 0x1F },
{ 0x3E, 0x20 },
{ 0x3F, 0x21 },
{ 0x40, 0x22 },
{ 0x41, 0x23 },
{ 0x42, 0x24 },
{ 0x43, 0x25 },
{ 0x44, 0x26 },
{ 0x45, 0x27 },
{ 0x46, 0x28 },
{ 0x47, 0x1C },
{ 0x48, 0x4B },
{ 0x49, 0x4C },
{ 0x4A, 0x4D },
{ 0x4B, 0x2A },
{ 0x4C, 0x2C },
{ 0x4D, 0x2D },
{ 0x4E, 0x2E },
{ 0x4F, 0x2F },
{ 0x50, 0x30 },
{ 0x51, 0x31 },
{ 0x52, 0x32 },
{ 0x53, 0x33 },
{ 0x54, 0x34 },
{ 0x55, 0x35 },
{ 0x56, 0x36 },
{ 0x57, 0x148},
{ 0x58, 0x51 },
{ 0x59, 0x50 },
{ 0x5A, 0x4F },
{ 0x5B, 0x11C},
{ 0x5C, 0x1D },
{ 0x5D, 0x38 },
{ 0x5E, 0x39 },
{ 0x5F, 0x138},
{ 0x60, 0x11D},
{ 0x61, 0x14B},
{ 0x62, 0x150},
{ 0x63, 0x14D},
{ 0x64, 0x52 },
{ 0x65, 0x53 },
{ 0x0e, 0x137},
{ 0x0f, 0x46 },
{ 0x66, 0x15B},
{ 0x67, 0x15C},
{ 0x68, 0x15D},
{ 0x69, 0x56 }
};
#endif
uint16_t
x11_keycode_to_keysym(uint32_t keycode)
{
@@ -1025,7 +916,7 @@ x11_keycode_to_keysym(uint32_t keycode)
#elif defined(Q_OS_MACOS)
finalkeycode = (keycode < 127) ? cocoa_keycodes[keycode] : 0;
#elif defined(__HAIKU__)
finalkeycode = be_to_xt[keycode];
finalkeycode = be_keycodes[keycode];
#else
# ifdef XKBCOMMON
if (xkbcommon_keymap)