mac,x11: propagate win/sdl mouse/keyboard changes

This commit is contained in:
Flyinghead 2021-05-10 13:48:12 +02:00
parent 71fb024061
commit e07977eea9
8 changed files with 365 additions and 541 deletions

View File

@ -56,6 +56,304 @@ protected:
if (!find_mapping())
input_mapper = std::make_shared<KeyboardInputMapping>();
}
public:
virtual const char *get_button_name(u32 code) override
{
switch (code)
{
case 0x04:
return "A";
case 0x05:
return "B";
case 0x06:
return "C";
case 0x07:
return "D";
case 0x08:
return "E";
case 0x09:
return "F";
case 0x0A:
return "G";
case 0x0B:
return "H";
case 0x0C:
return "I";
case 0x0D:
return "J";
case 0x0E:
return "K";
case 0x0F:
return "L";
case 0x10:
return "M";
case 0x11:
return "N";
case 0x12:
return "O";
case 0x13:
return "P";
case 0x14:
return "Q";
case 0x15:
return "R";
case 0x16:
return "S";
case 0x17:
return "T";
case 0x18:
return "U";
case 0x19:
return "V";
case 0x1A:
return "W";
case 0x1B:
return "X";
case 0x1C:
return "Y";
case 0x1D:
return "Z";
case 0x1E:
return "1";
case 0x1F:
return "2";
case 0x20:
return "3";
case 0x21:
return "4";
case 0x22:
return "5";
case 0x23:
return "6";
case 0x24:
return "7";
case 0x25:
return "8";
case 0x26:
return "9";
case 0x27:
return "0";
case 0x28:
return "Return";
case 0x29:
return "Escape";
case 0x2A:
return "Backspace";
case 0x2B:
return "Tab";
case 0x2C:
return "Space";
case 0x2D:
return "-";
case 0x2E:
return "=";
case 0x2F:
return "[";
case 0x30:
return "]";
case 0x31:
return "\\";
case 0x32:
return "#"; // non-US
case 0x33:
return ";";
case 0x34:
return "'";
case 0x35:
return "`";
case 0x36:
return ",";
case 0x37:
return ".";
case 0x38:
return "/";
case 0x39:
return "CapsLock";
case 0x3A:
return "F1";
case 0x3B:
return "F2";
case 0x3C:
return "F3";
case 0x3D:
return "F4";
case 0x3E:
return "F5";
case 0x3F:
return "F6";
case 0x40:
return "F7";
case 0x41:
return "F8";
case 0x42:
return "F9";
case 0x43:
return "F10";
case 0x44:
return "F11";
case 0x45:
return "F12";
case 0x46:
return "PrintScreen";
case 0x47:
return "ScrollLock";
case 0x48:
return "Pause";
case 0x49:
return "Insert";
case 0x4A:
return "Home";
case 0x4B:
return "Page Up";
case 0x4C:
return "Delete";
case 0x4D:
return "End";
case 0x4E:
return "Page Down";
case 0x4F:
return "Right";
case 0x50:
return "Left";
case 0x51:
return "Down";
case 0x52:
return "Up";
case 0x53:
return "NumLock";
case 0x54:
return "Num /";
case 0x55:
return "Num *";
case 0x56:
return "Num -";
case 0x57:
return "Num +";
case 0x58:
return "Num Enter";
case 0x59:
return "Num 1";
case 0x5A:
return "Num 2";
case 0x5B:
return "Num 3";
case 0x5C:
return "Num 4";
case 0x5D:
return "Num 5";
case 0x5E:
return "Num 6";
case 0x5F:
return "Num 7";
case 0x60:
return "Num 8";
case 0x61:
return "Num 9";
case 0x62:
return "Num 0";
case 0x63:
return "Num .";
case 0x64:
return "\\"; // non-US
case 0x65:
return "Application";
case 0x66:
return "Power";
case 0x67:
return "Num =";
case 0x68:
return "F13";
case 0x69:
return "F14";
case 0x6A:
return "F15";
case 0x6B:
return "F16";
case 0x6C:
return "F17";
case 0x6D:
return "F18";
case 0x6E:
return "F19";
case 0x6F:
return "F20";
case 0x70:
return "F21";
case 0x71:
return "F22";
case 0x72:
return "F23";
case 0x73:
return "F24";
case 0x87:
return "Int1";
case 0x88:
return "Int2";
case 0x89:
return "Yen";
case 0x8A:
return "Int4";
case 0x8B:
return "Int5";
case 0x8C:
return "Int6";
case 0x8D:
return "Int7";
case 0x8E:
return "Int8";
case 0x8F:
return "Int9";
case 0x90:
return "Hangul";
case 0x91:
return "Hanja";
case 0x92:
return "Katakana";
case 0x93:
return "Hiragana";
case 0x94:
return "Zenkaku/Hankaku";
case 0x95:
return "Lang6";
case 0x96:
return "Lang7";
case 0x97:
return "Lang8";
case 0x98:
return "Lang9";
case 0xE0:
return "Left Ctrl";
case 0xE1:
return "Left Shift";
case 0xE2:
return "Left Alt";
case 0xE3:
return "Left Meta";
case 0xE4:
return "Right Ctrl";
case 0xE5:
return "Right Shift";
case 0xE6:
return "Right Alt";
case 0xE7:
return "Right Meta";
default:
return nullptr;
}
}
};
template <typename Keycode>

View File

@ -41,10 +41,10 @@ public:
}
};
class X11MouseGamepadDevice : public GamepadDevice
class X11Mouse : public GamepadDevice
{
public:
X11MouseGamepadDevice(int maple_port) : GamepadDevice(maple_port, "X11")
X11Mouse(int maple_port) : GamepadDevice(maple_port, "X11")
{
_name = "Mouse";
_unique_id = "x11_mouse";
@ -91,10 +91,8 @@ public:
}
};
static int x11_keyboard_input = 0;
static std::shared_ptr<X11KeyboardDevice> x11_keyboard;
static std::shared_ptr<X11KbGamepadDevice> kb_gamepad;
static std::shared_ptr<X11MouseGamepadDevice> mouse_gamepad;
static std::shared_ptr<X11Keyboard> x11Keyboard;
static std::shared_ptr<X11Mouse> x11Mouse;
int x11_width;
int x11_height;
@ -239,10 +237,7 @@ void input_x11_handle()
// Key wasnt actually released: auto repeat
continue;
}
// Dreamcast keyboard emulation
x11_keyboard->keyboard_input(e.xkey.keycode, e.type == KeyPress);
// keyboard-based emulated gamepad
kb_gamepad->gamepad_btn_input(e.xkey.keycode, e.type == KeyPress);
x11Keyboard->keyboard_input(e.xkey.keycode, e.type == KeyPress);
// Start/stop mouse capture with Left Ctrl + Left Alt
if (e.type == KeyPress
@ -256,18 +251,18 @@ void input_x11_handle()
x11_uncapture_mouse();
}
// TODO Move this to bindable keys or in the gui menu
if (x11_keyboard_input)
#if 0
if (e.xkey.keycode == KEY_F10)
{
if (e.xkey.keycode == KEY_F10)
{
// Dump the next frame into a file
dump_frame_switch = e.type == KeyPress;
}
else if (e.type == KeyPress && e.xkey.keycode == KEY_F11)
{
x11_fullscreen = !x11_fullscreen;
x11_window_set_fullscreen(x11_fullscreen);
}
// Dump the next frame into a file
dump_frame_switch = e.type == KeyPress;
}
else
#endif
if (e.type == KeyPress && e.xkey.keycode == KEY_F11)
{
x11_fullscreen = !x11_fullscreen;
x11_window_set_fullscreen(x11_fullscreen);
}
}
break;
@ -282,24 +277,30 @@ void input_x11_handle()
case ButtonPress:
case ButtonRelease:
mouse_gamepad->gamepad_btn_input(e.xbutton.button, e.type == ButtonPress);
gui_set_mouse_position(e.xbutton.x, e.xbutton.y);
x11Mouse->gamepad_btn_input(e.xbutton.button, e.type == ButtonPress);
{
u32 button_mask = 0;
switch (e.xbutton.button)
{
case Button1: // Left button
gui_set_mouse_button(0, e.type == ButtonPress);
button_mask = 1 << 2;
break;
case Button2: // Middle button
gui_set_mouse_button(2, e.type == ButtonPress);
button_mask = 1 << 3;
break;
case Button3: // Right button
gui_set_mouse_button(1, e.type == ButtonPress);
button_mask = 1 << 1;
break;
case Button4: // Mouse wheel up
gui_set_mouse_wheel(-16);
mo_wheel_delta[0] -= 16;
break;
case Button5: // Mouse wheel down
gui_set_mouse_wheel(16);
mo_wheel_delta[0] += 16;
break;
default:
@ -317,6 +318,7 @@ void input_x11_handle()
/* no break */
case MotionNotify:
gui_set_mouse_position(e.xmotion.x, e.xmotion.y);
// For Light gun
SetMousePosition(e.xmotion.x, e.xmotion.y, x11_width, x11_height);
// For mouse
@ -342,15 +344,10 @@ void input_x11_handle()
void input_x11_init()
{
x11_keyboard = std::make_shared<X11KeyboardDevice>(0);
kb_gamepad = std::make_shared<X11KbGamepadDevice>(0);
GamepadDevice::Register(kb_gamepad);
mouse_gamepad = std::make_shared<X11MouseGamepadDevice>(0);
GamepadDevice::Register(mouse_gamepad);
x11_keyboard_input = (cfgLoadInt("input", "enable_x11_keyboard", 1) >= 1);
if (!x11_keyboard_input)
INFO_LOG(INPUT, "X11 Keyboard input disabled by config.");
x11Keyboard = std::make_shared<X11Keyboard>(0);
GamepadDevice::Register(x11Keyboard);
x11Mouse = std::make_shared<X11Mouse>(0);
GamepadDevice::Register(x11Mouse);
}
void x11_window_create()

View File

@ -3,10 +3,10 @@
#include "input/keyboard_device.h"
#include "x11.h"
class X11KeyboardDevice : public KeyboardDeviceTemplate<int>
class X11Keyboard : public KeyboardDeviceTemplate<int>
{
public:
X11KeyboardDevice(int maple_port) : KeyboardDeviceTemplate(maple_port)
X11Keyboard(int maple_port) : KeyboardDeviceTemplate(maple_port, "X11")
{
//04-1D Letter keys A-Z (in alphabetic order)
kb_map[KEY_A] = 0x04;
@ -125,275 +125,36 @@ public:
kb_map[90] = 0x62;
//63 "." (Numeric keypad)
kb_map[91] = 0x63;
//64 #| (non-US)
//kb_map[94] = 0x64;
//65 S3 key
//66-A4 Not used
//A5-DF Reserved
kb_map[KEY_LCTRL] = 0xE0; // Left Control
kb_map[KEY_LSHIFT] = 0xE1; // Left Shift
//E2 Left Alt
kb_map[KEY_LALT] = 0xE2; // Left Alt
//E3 Left S1
kb_map[KEY_RCTRL] = 0xE4; // Right Control
kb_map[KEY_RSHIFT] = 0xE5; // Right Shift
//E6 Right Alt
// AltGr
kb_map[108] = 0xE6; // Right Alt
kb_map[135] = 0x65; // Menu / S3
//E7 Right S3
//E8-FF Reserved
_unique_id = "x11_keyboard";
if (!find_mapping())
input_mapper = std::make_shared<KeyboardInputMapping>();
}
virtual const char* name() override { return "X11 Keyboard"; }
protected:
virtual u8 convert_keycode(int keycode) override
{
if (kb_map.find(keycode) == kb_map.end()) {
DEBUG_LOG(INPUT, "Unknown key %x", keycode);
return 0;
}
return kb_map[keycode];
}
private:
std::map<int, u8> kb_map;
};
class KbInputMapping : public InputMapping
{
public:
KbInputMapping()
{
name = "X11 Keyboard";
set_button(DC_BTN_A, KEY_X);
set_button(DC_BTN_B, KEY_C);
set_button(DC_BTN_X, KEY_S);
set_button(DC_BTN_Y, KEY_D);
set_button(DC_DPAD_UP, KEY_UP);
set_button(DC_DPAD_DOWN, KEY_DOWN);
set_button(DC_DPAD_LEFT, KEY_LEFT);
set_button(DC_DPAD_RIGHT, KEY_RIGHT);
set_button(DC_BTN_START, KEY_RETURN);
set_button(EMU_BTN_TRIGGER_LEFT, KEY_F);
set_button(EMU_BTN_TRIGGER_RIGHT, KEY_V);
set_button(EMU_BTN_MENU, KEY_TAB);
set_button(EMU_BTN_FFORWARD, KEY_SPACE);
dirty = false;
}
};
class X11KbGamepadDevice : public GamepadDevice
{
public:
X11KbGamepadDevice(int maple_port) : GamepadDevice(maple_port, "X11")
{
_name = "Keyboard";
_unique_id = "x11_keyboard";
if (!find_mapping())
input_mapper = std::make_shared<KbInputMapping>();
}
virtual const char *get_button_name(u32 code) override
{
switch (code)
{
case KEY_A:
return "A";
case KEY_B:
return "B";
case KEY_C:
return "C";
case KEY_D:
return "D";
case KEY_E:
return "E";
case KEY_F:
return "F";
case KEY_G:
return "G";
case KEY_H:
return "H";
case KEY_I:
return "I";
case KEY_J:
return "J";
case KEY_K:
return "K";
case KEY_L:
return "L";
case KEY_M:
return "M";
case KEY_N:
return "N";
case KEY_O:
return "O";
case KEY_P:
return "P";
case KEY_Q:
return "Q";
case KEY_R:
return "R";
case KEY_S:
return "S";
case KEY_T:
return "T";
case KEY_U:
return "U";
case KEY_V:
return "V";
case KEY_W:
return "W";
case KEY_X:
return "X";
case KEY_Y:
return "Y";
case KEY_Z:
return "Z";
case KEY_0:
return "0";
case KEY_1:
return "1";
case KEY_2:
return "2";
case KEY_3:
return "3";
case KEY_4:
return "4";
case KEY_5:
return "5";
case KEY_6:
return "6";
case KEY_7:
return "7";
case KEY_8:
return "8";
case KEY_9:
return "9";
case KEY_BACKSPACE:
return "Backspace";
case KEY_DEL:
return "Delete";
case KEY_DOWN:
return "Down";
case KEY_UP:
return "Up";
case KEY_LEFT:
return "Left";
case KEY_RIGHT:
return "Right";
case KEY_END:
return "End";
case KEY_ESC:
return "Escape";
case KEY_F1:
return "F1";
case KEY_F2:
return "F2";
case KEY_F3:
return "F3";
case KEY_F4:
return "F4";
case KEY_F5:
return "F5";
case KEY_F6:
return "F6";
case KEY_F7:
return "F7";
case KEY_F8:
return "F8";
case KEY_F9:
return "F9";
case KEY_F10:
return "F10";
case KEY_F11:
return "F11";
case KEY_F12:
return "F12";
case KEY_HOME:
return "Home";
case KEY_INS:
return "Insert";
case KEY_RETURN:
return "Return";
case KEY_LALT:
return "Left ALT";
case KEY_LCTRL:
return "Left CTRL";
case KEY_LSHIFT:
return "Left SHIFT";
case KEY_RCTRL:
return "Right CTRL";
case KEY_RSHIFT:
return "Right Shift";
case 108:
return "Right ALT";
case KEY_PGDOWN:
return "Page Down";
case KEY_PGUP:
return "Page Up";
case KEY_SPACE:
return "Space";
case KEY_TAB:
return "Tab";
case 87:
return "Num 1";
case 88:
return "Num 2";
case 89:
return "Num 3";
case 83:
return "Num 4";
case 84:
return "Num 5";
case 85:
return "Num 6";
case 79:
return "Num 7";
case 80:
return "Num 8";
case 81:
return "Num 9";
case 90:
return "Num 0";
case 91:
return "Num .";
case 106:
return "Num /";
case 63:
return "Num *";
case 82:
return "Num -";
case 86:
return "Num +";
case 104:
return "Num Enter";
case 20:
return "-";
case 21:
return "=";
case 34:
return "[";
case 35:
return "]";
case 47:
return ";";
case 48:
return "'";
case 49:
return "`";
case 51:
return "\\";
case 59:
return ",";
case 60:
return ".";
case 61:
return "/";
case 94:
return "102nd";
default:
return nullptr;
}
}
};

View File

@ -139,11 +139,9 @@ class EmuGLView: NSOpenGLView, NSWindowDelegate {
}
override func scrollWheel(with event: NSEvent) {
if (event.hasPreciseScrollingDeltas) {
// 1 per "line"
pmo_wheel_delta[0] -= Float(event.scrollingDeltaY) * 3.2
emu_mouse_wheel(-Float(event.scrollingDeltaY) / 5)
} else {
// 0.1 per wheel notch
pmo_wheel_delta[0] -= Float(event.scrollingDeltaY) * 160
emu_mouse_wheel(-Float(event.scrollingDeltaY) * 10)
}
}

View File

@ -25,10 +25,10 @@ void emu_key_input(UInt16 keyCode, bool pressed, UInt32 modifierFlags);
void emu_character_input(const char *characters);
void emu_mouse_buttons(int button, bool pressed);
void emu_set_mouse_position(int x, int y, int width, int height);
void emu_mouse_wheel(float v);
bool emu_frame_pending();
extern unsigned int *pmo_buttons;
extern float *pmo_wheel_delta;
#ifdef __cplusplus
}

View File

@ -30,11 +30,9 @@
#include "hw/pvr/Renderer_if.h"
#include "rend/mainui.h"
OSXKeyboardDevice keyboard(0);
static std::shared_ptr<OSXKbGamepadDevice> kb_gamepad(0);
static std::shared_ptr<OSXKeyboard> keyboard(0);
static std::shared_ptr<OSXMouseGamepadDevice> mouse_gamepad(0);
unsigned int *pmo_buttons;
float *pmo_wheel_delta;
static UInt32 keyboardModifiers;
int darw_printf(const char* text, ...)
@ -85,8 +83,8 @@ void os_SetupInput()
input_sdl_init();
#endif
kb_gamepad = std::make_shared<OSXKbGamepadDevice>(0);
GamepadDevice::Register(kb_gamepad);
keyboard = std::make_shared<OSXKeyboard>(0);
GamepadDevice::Register(keyboard);
mouse_gamepad = std::make_shared<OSXMouseGamepadDevice>(0);
GamepadDevice::Register(mouse_gamepad);
}
@ -143,7 +141,6 @@ void emu_gles_init(int width, int height)
{
// work around https://bugs.swift.org/browse/SR-12263
pmo_buttons = mo_buttons;
pmo_wheel_delta = mo_wheel_delta;
char *home = getenv("HOME");
if (home != NULL)
@ -241,22 +238,19 @@ int emu_reicast_init()
void emu_key_input(UInt16 keyCode, bool pressed, UInt modifierFlags) {
if (keyCode != 0xFF)
keyboard.keyboard_input(keyCode, pressed, 0);
keyboard->keyboard_input(keyCode, pressed, 0);
else
{
// Modifier keys
UInt32 changes = keyboardModifiers ^ modifierFlags;
if (changes & NSEventModifierFlagShift)
keyboard.keyboard_input(kVK_Shift, modifierFlags & NSEventModifierFlagShift, 0);
keyboard->keyboard_input(kVK_Shift, modifierFlags & NSEventModifierFlagShift, 0);
if (changes & NSEventModifierFlagControl)
keyboard.keyboard_input(kVK_Control, modifierFlags & NSEventModifierFlagControl, 0);
keyboard->keyboard_input(kVK_Control, modifierFlags & NSEventModifierFlagControl, 0);
if (changes & NSEventModifierFlagOption)
keyboard.keyboard_input(kVK_Option, modifierFlags & NSEventModifierFlagOption, 0);
keyboard->keyboard_input(kVK_Option, modifierFlags & NSEventModifierFlagOption, 0);
keyboardModifiers = modifierFlags;
}
if ((modifierFlags
& (NSEventModifierFlagShift | NSEventModifierFlagControl | NSEventModifierFlagOption | NSEventModifierFlagCommand)) == 0)
kb_gamepad->gamepad_btn_input(keyCode, pressed);
}
void emu_character_input(const char *characters) {
if (characters != NULL)
@ -265,11 +259,19 @@ void emu_character_input(const char *characters) {
void emu_mouse_buttons(int button, bool pressed)
{
gui_set_mouse_button(button - 1, pressed);
mouse_gamepad->gamepad_btn_input(button, pressed);
}
void emu_mouse_wheel(float v)
{
mo_wheel_delta[0] += v;
gui_set_mouse_wheel(v);
}
void emu_set_mouse_position(int x, int y, int width, int height)
{
gui_set_mouse_position(x, y);
SetMousePosition(x, y, width, height);
}

View File

@ -7,241 +7,6 @@
//
#include "input/gamepad_device.h"
class KbInputMapping : public InputMapping
{
public:
KbInputMapping()
{
name = "OSX Keyboard";
set_button(DC_BTN_A, kVK_ANSI_X);
set_button(DC_BTN_B, kVK_ANSI_C);
set_button(DC_BTN_X, kVK_ANSI_S);
set_button(DC_BTN_Y, kVK_ANSI_D);
set_button(DC_DPAD_UP, kVK_UpArrow);
set_button(DC_DPAD_DOWN, kVK_DownArrow);
set_button(DC_DPAD_LEFT, kVK_LeftArrow);
set_button(DC_DPAD_RIGHT, kVK_RightArrow);
set_button(DC_BTN_START, kVK_Return);
set_button(EMU_BTN_TRIGGER_LEFT, kVK_ANSI_F);
set_button(EMU_BTN_TRIGGER_RIGHT, kVK_ANSI_V);
set_button(EMU_BTN_MENU, kVK_Tab);
set_button(EMU_BTN_FFORWARD, kVK_Space);
dirty = false;
}
};
class OSXKbGamepadDevice : public GamepadDevice
{
public:
OSXKbGamepadDevice(int maple_port) : GamepadDevice(maple_port, "OSX")
{
_name = "Keyboard";
_unique_id = "osx_keyboard";
if (!find_mapping())
input_mapper = std::make_shared<KbInputMapping>();
}
virtual const char *get_button_name(u32 code) override
{
switch(code)
{
case kVK_ANSI_A:
return "A";
case kVK_ANSI_B:
return "B";
case kVK_ANSI_C:
return "C";
case kVK_ANSI_D:
return "D";
case kVK_ANSI_E:
return "E";
case kVK_ANSI_F:
return "F";
case kVK_ANSI_G:
return "G";
case kVK_ANSI_H:
return "H";
case kVK_ANSI_I:
return "I";
case kVK_ANSI_J:
return "J";
case kVK_ANSI_K:
return "K";
case kVK_ANSI_L:
return "L";
case kVK_ANSI_M:
return "M";
case kVK_ANSI_N:
return "N";
case kVK_ANSI_O:
return "O";
case kVK_ANSI_P:
return "P";
case kVK_ANSI_Q:
return "Q";
case kVK_ANSI_R:
return "R";
case kVK_ANSI_S:
return "S";
case kVK_ANSI_T:
return "T";
case kVK_ANSI_U:
return "U";
case kVK_ANSI_V:
return "V";
case kVK_ANSI_W:
return "W";
case kVK_ANSI_X:
return "X";
case kVK_ANSI_Y:
return "Y";
case kVK_ANSI_Z:
return "Z";
case kVK_UpArrow:
return "Up";
case kVK_DownArrow:
return "Down";
case kVK_LeftArrow:
return "Left";
case kVK_RightArrow:
return "Right";
case kVK_Return:
return "Return";
case kVK_Tab:
return "Tab";
case kVK_Space:
return "Space";
case kVK_Delete:
return "Delete";
case kVK_Escape:
return "Escape";
case kVK_Help:
return "Help";
case kVK_Home:
return "Home";
case kVK_PageUp:
return "Page Up";
case kVK_PageDown:
return "Page Down";
case kVK_ForwardDelete:
return "Fwd Delete";
case kVK_End:
return "End";
case kVK_ANSI_1:
return "1";
case kVK_ANSI_2:
return "2";
case kVK_ANSI_3:
return "3";
case kVK_ANSI_4:
return "4";
case kVK_ANSI_5:
return "5";
case kVK_ANSI_6:
return "6";
case kVK_ANSI_7:
return "7";
case kVK_ANSI_8:
return "8";
case kVK_ANSI_9:
return "9";
case kVK_ANSI_0:
return "0";
case kVK_ANSI_Equal:
return "=";
case kVK_ANSI_Minus:
return "-";
case kVK_ANSI_RightBracket:
return "]";
case kVK_ANSI_LeftBracket:
return "[";
case kVK_ANSI_Quote:
return "'";
case kVK_ANSI_Semicolon:
return ";";
case kVK_ANSI_Backslash:
return "\\";
case kVK_ANSI_Comma:
return ",";
case kVK_ANSI_Slash:
return "/";
case kVK_ANSI_Period:
return ".";
case kVK_ANSI_Grave:
return "`";
case kVK_ANSI_KeypadDecimal:
return "Keypad .";
case kVK_ANSI_KeypadMultiply:
return "Keypad *";
case kVK_ANSI_KeypadPlus:
return "Keypad +";
case kVK_ANSI_KeypadClear:
return "Keypad Clear";
case kVK_ANSI_KeypadDivide:
return "Keypad /";
case kVK_ANSI_KeypadEnter:
return "Keypad Enter";
case kVK_ANSI_KeypadMinus:
return "Keypad -";
case kVK_ANSI_KeypadEquals:
return "Keypad =";
case kVK_ANSI_Keypad0:
return "Keypad 0";
case kVK_ANSI_Keypad1:
return "Keypad 1";
case kVK_ANSI_Keypad2:
return "Keypad 2";
case kVK_ANSI_Keypad3:
return "Keypad 3";
case kVK_ANSI_Keypad4:
return "Keypad 4";
case kVK_ANSI_Keypad5:
return "Keypad 5";
case kVK_ANSI_Keypad6:
return "Keypad 6";
case kVK_ANSI_Keypad7:
return "Keypad 7";
case kVK_ANSI_Keypad8:
return "Keypad 8";
case kVK_ANSI_Keypad9:
return "Keypad 9";
case kVK_F1:
return "F1";
case kVK_F2:
return "F2";
case kVK_F3:
return "F3";
case kVK_F4:
return "F4";
case kVK_F5:
return "F5";
case kVK_F6:
return "F6";
case kVK_F7:
return "F7";
case kVK_F8:
return "F8";
case kVK_F9:
return "F9";
case kVK_F10:
return "F10";
case kVK_F11:
return "F11";
case kVK_F12:
return "F12";
default:
return nullptr;
}
}
};
class MouseInputMapping : public InputMapping
{
public:

View File

@ -8,11 +8,16 @@
#pragma once
#include "input/keyboard_device.h"
class OSXKeyboardDevice : public KeyboardDeviceTemplate<UInt16>
class OSXKeyboard : public KeyboardDeviceTemplate<UInt16>
{
public:
OSXKeyboardDevice(int maple_port) : KeyboardDeviceTemplate(maple_port)
OSXKeyboard(int maple_port) : KeyboardDeviceTemplate(maple_port, "OSX")
{
_name = "Keyboard";
_unique_id = "osx_keyboard";
if (!find_mapping())
input_mapper = std::make_shared<KeyboardInputMapping>();
//04-1D Letter keys A-Z (in alphabetic order)
kb_map[kVK_ANSI_A] = 0x04;
kb_map[kVK_ANSI_B] = 0x05;
@ -160,8 +165,6 @@ public:
kb_map[kVK_JIS_Yen] = 0x89; // I18n keyboard 3
}
virtual const char* name() override { return "OSX Keyboard"; }
protected:
virtual u8 convert_keycode(UInt16 keycode) override
{