mirror of
https://github.com/ARMSX2/ARMSX3.git
synced 2026-08-24 16:58:52 -07:00
The keyboard setting, the on-screen keyboard hotkey, the touch button and the
IME plumbing all worked. Nothing behind them did, in three separate places:
- init_kb_handler installed NullKeyboardHandler unconditionally, so cellKb --
the API games actually read a keyboard through -- reported none attached no
matter what the UI said.
- NativeApp.usbKeyboardKey and usbSetKeyboardEnabled were Unsupported.note()
stubs. Every keystroke went into a no-op that returned false.
- The setting wrote [USB1] Type = hidkbd, which is PCSX2's emulated USB HID
keyboard. There is no such device in this core -- "hidkbd" appears nowhere
in it -- so that write only ever reached Unsupported.note("USB1/Type").
All three are inherited from the UI port, which is why the feature looked whole.
The desktop handler is a QObject that installs an event filter on a QWindow, so
none of it survives the port. It does not need to: everything that turns a key
into cellKb data already lives in KeyboardHandlerBase::HandleKey, and a concrete
handler owes it exactly one thing, a populated qt_code -> CELL_KEYC map.
virtual_keyboard_handler builds that map with the Qt key codes as literals, and
translates Android keycodes onto it -- including left/right modifiers, which have
to come back in the native_key encoding get_out_key_code compares against or
every modifier reads as the right-hand one.
The setting now writes Input/Output/Keyboard, which is what the core reads. That
happens once, in Emulator::Load, so it applies on the next boot rather than to a
game already running; the description says so now, because the old comment
claimed a live attach that never existed.
KeyEvent.getUnicodeChar() is carried through as well. cellKb derives its own
character from the raw code plus the live modifier state and does not need it,
but the emulator's own overlay text entry matches on the string.
40 lines
1.6 KiB
C++
40 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "util/types.hpp"
|
|
#include "Emu/Io/KeyboardHandler.h"
|
|
|
|
// Keyboard handler for the Android front end.
|
|
//
|
|
// The desktop handler is a QObject that installs an event filter on a QWindow, so
|
|
// none of it survives the port. It does not need to: everything that turns a key
|
|
// into cellKb data already lives in KeyboardHandlerBase::HandleKey, and a concrete
|
|
// handler owes it exactly one thing -- a populated qt_code -> CELL_KEYC map. This
|
|
// builds that map and nothing else.
|
|
//
|
|
// Keys arrive from the UI (a physical/Bluetooth keyboard, or the Android IME the
|
|
// On-Screen Keyboard hotkey raises) through _rpcsx_keyboardKey.
|
|
class virtual_keyboard_handler final : public KeyboardHandlerBase
|
|
{
|
|
using KeyboardHandlerBase::KeyboardHandlerBase;
|
|
|
|
public:
|
|
void Init(keyboard_consumer& consumer, const u32 max_connect) override;
|
|
|
|
// Android KeyEvent keycode -> the Qt key code the shared map is keyed on.
|
|
// Returns 0 for keys a PS3 keyboard has no equivalent of.
|
|
static u32 qt_code_from_android(s32 android_key_code);
|
|
|
|
// Left/right modifier discrimination, in the native_key encoding that
|
|
// keyboard_consumer::get_out_key_code expects. 0 for everything else.
|
|
static u32 native_code_from_android(s32 android_key_code);
|
|
|
|
private:
|
|
static void load_settings(Keyboard& keyboard);
|
|
};
|
|
|
|
// Feed one key transition to the running keyboard handler.
|
|
//
|
|
// Safe to call at any time: with no game booted, or with the handler set to Null,
|
|
// there is nothing to consume the key and this returns false.
|
|
bool handle_android_key(s32 android_key_code, char32_t unicode, bool pressed, bool is_auto_repeat);
|