Skip to content

Commit 19b76d3

Browse files
committed
kb test
1 parent 927e249 commit 19b76d3

5 files changed

Lines changed: 25 additions & 14 deletions

File tree

rpcs3/Emu/Cell/Modules/cellKb.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode)
160160
{
161161
cellKb.trace("cellKbCnvRawCode(arrange=%d, mkey=%d, led=%d, rawcode=0x%x)", arrange, mkey, led, rawcode);
162162

163+
const auto proc = [&]() -> u16
164+
{
163165
// CELL_KB_RAWDAT
164166
if (rawcode <= CELL_KEYC_E_UNDEF ||
165167
rawcode == CELL_KEYC_ESCAPE ||
@@ -304,6 +306,11 @@ u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode)
304306
// TODO: Add more keys and layouts
305307

306308
return 0x0000;
309+
};
310+
311+
u16 res = proc();
312+
cellKb.always()("Conv key (arrange=0x%x, mkey=0x%x, led=0x%x, rawcode=0x%x, res=0x%x)", arrange, mkey, led, rawcode, res);
313+
return res;
307314
}
308315

309316
error_code cellKbGetInfo(vm::ptr<CellKbInfo> info)
@@ -379,9 +386,10 @@ error_code cellKbRead(u32 port_no, vm::ptr<CellKbData> data)
379386
for (s32 i = 0; i < current_data.len; i++)
380387
{
381388
data->keycode[i] = current_data.buttons[i].m_keyCode;
389+
if (data->keycode[i]) cellKb.always()("Read key (mkey=0x%x, kcode=0x%x)", data->mkey, data->keycode[i]);
382390
}
383391

384-
KbConfig& current_config = consumer.GetConfig(port_no);
392+
const KbConfig& current_config = consumer.GetConfig(port_no);
385393

386394
// For single character mode to work properly we need to "flush" the buffer after reading or else we'll constantly get the same key presses with each call.
387395
// Actual key repeats are handled by adding a new key code to the buffer periodically. Key releases are handled in a similar fashion.

rpcs3/Emu/Io/KeyboardHandler.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void KeyboardHandlerBase::RemoveConsumer(keyboard_consumer::identifier id)
9393
}
9494
}
9595

96-
bool KeyboardHandlerBase::HandleKey(u32 qt_code, u32 native_code, bool pressed, bool is_auto_repeat, const std::u32string& key)
96+
bool KeyboardHandlerBase::HandleKey(u32 qt_code, u32 native_code, bool pressed, bool is_auto_repeat, const std::string& key)
9797
{
9898
bool consumed = false;
9999

@@ -107,7 +107,7 @@ bool KeyboardHandlerBase::HandleKey(u32 qt_code, u32 native_code, bool pressed,
107107
return consumed;
108108
}
109109

110-
bool keyboard_consumer::ConsumeKey(u32 qt_code, u32 native_code, bool pressed, bool is_auto_repeat, const std::u32string& key)
110+
bool keyboard_consumer::ConsumeKey(u32 qt_code, u32 native_code, bool pressed, bool is_auto_repeat, const std::string& key)
111111
{
112112
bool consumed = false;
113113

@@ -144,6 +144,9 @@ bool keyboard_consumer::ConsumeKey(u32 qt_code, u32 native_code, bool pressed, b
144144
}
145145
}
146146

147+
if (pressed)
148+
input_log.always()("Consuming key (key=%s, toRaw=%d, qt=0x%x, native=0x%x, out_key_code=0x%x, kcode=0x%x)", key, config.code_type == CELL_KB_CODETYPE_RAW, qt_code, native_code, out_key_code, kcode);
149+
147150
if (pressed)
148151
{
149152
if (data.len == 1 && data.buttons[0].m_keyCode == CELL_KEYC_NO_EVENT)
@@ -345,7 +348,7 @@ void keyboard_consumer::ReleaseAllKeys()
345348
}
346349
}
347350

348-
for (const std::u32string& key : keyboard.m_extra_data.pressed_keys)
351+
for (const std::string& key : keyboard.m_extra_data.pressed_keys)
349352
{
350353
ConsumeKey(CELL_KEYC_NO_EVENT, 0, false, false, key);
351354
}

rpcs3/Emu/Io/KeyboardHandler.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct KbData
8989

9090
struct KbExtraData
9191
{
92-
std::set<std::u32string> pressed_keys{};
92+
std::set<std::string> pressed_keys{};
9393
};
9494

9595
struct KbConfig
@@ -121,16 +121,16 @@ class keyboard_consumer
121121
keyboard_consumer() {}
122122
keyboard_consumer(identifier id) : m_id(id) {}
123123

124-
bool ConsumeKey(u32 qt_code, u32 native_code, bool pressed, bool is_auto_repeat, const std::u32string& key);
124+
bool ConsumeKey(u32 qt_code, u32 native_code, bool pressed, bool is_auto_repeat, const std::string& key);
125125
void SetIntercepted(bool intercepted);
126126

127127
static bool IsMetaKey(u32 code);
128128

129129
KbInfo& GetInfo() { return m_info; }
130130
std::vector<Keyboard>& GetKeyboards() { return m_keyboards; }
131-
KbData& GetData(const u32 keyboard) { return m_keyboards[keyboard].m_data; }
132-
KbExtraData& GetExtraData(const u32 keyboard) { return m_keyboards[keyboard].m_extra_data; }
133-
KbConfig& GetConfig(const u32 keyboard) { return m_keyboards[keyboard].m_config; }
131+
KbData& GetData(const u32 keyboard) { return ::at32(m_keyboards, keyboard).m_data; }
132+
KbExtraData& GetExtraData(const u32 keyboard) { return ::at32(m_keyboards, keyboard).m_extra_data; }
133+
KbConfig& GetConfig(const u32 keyboard) { return ::at32(m_keyboards, keyboard).m_config; }
134134
identifier id() const { return m_id; }
135135

136136
void ReleaseAllKeys();
@@ -161,7 +161,7 @@ class KeyboardHandlerBase
161161
keyboard_consumer& GetConsumer(keyboard_consumer::identifier id);
162162
void RemoveConsumer(keyboard_consumer::identifier id);
163163

164-
bool HandleKey(u32 qt_code, u32 native_code, bool pressed, bool is_auto_repeat, const std::u32string& key);
164+
bool HandleKey(u32 qt_code, u32 native_code, bool pressed, bool is_auto_repeat, const std::string& key);
165165
void SetIntercepted(bool intercepted);
166166

167167
stx::init_mutex init;

rpcs3/Emu/RSX/Overlays/overlays.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ namespace rsx
201201
on_key_pressed(current_data.led, current_data.mkey, key.m_keyCode, key.m_outKeyCode, key.m_pressed, {});
202202
}
203203

204-
for (const std::u32string& key : extra_data.pressed_keys)
204+
for (const std::string& key : extra_data.pressed_keys)
205205
{
206-
on_key_pressed(0, 0, 0, 0, true, key);
206+
on_key_pressed(0, 0, 0, 0, true, utf8_to_u32string(key));
207207
}
208208

209209
// Flush buffer unconditionally. Otherwise we get a flood of key events.

rpcs3/Input/basic_keyboard_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void basic_keyboard_handler::keyPressEvent(QKeyEvent* keyEvent)
121121

122122
const int key = getUnmodifiedKey(keyEvent);
123123

124-
if (key < 0 || !HandleKey(static_cast<u32>(key), keyEvent->nativeScanCode(), true, keyEvent->isAutoRepeat(), keyEvent->text().toStdU32String()))
124+
if (key < 0 || !HandleKey(static_cast<u32>(key), keyEvent->nativeScanCode(), true, keyEvent->isAutoRepeat(), keyEvent->text().toStdString()))
125125
{
126126
keyEvent->ignore();
127127
}
@@ -142,7 +142,7 @@ void basic_keyboard_handler::keyReleaseEvent(QKeyEvent* keyEvent)
142142

143143
const int key = getUnmodifiedKey(keyEvent);
144144

145-
if (key < 0 || !HandleKey(static_cast<u32>(key), keyEvent->nativeScanCode(), false, keyEvent->isAutoRepeat(), keyEvent->text().toStdU32String()))
145+
if (key < 0 || !HandleKey(static_cast<u32>(key), keyEvent->nativeScanCode(), false, keyEvent->isAutoRepeat(), keyEvent->text().toStdString()))
146146
{
147147
keyEvent->ignore();
148148
}

0 commit comments

Comments
 (0)