Commit ba8794f6 authored by spang's avatar spang Committed by Commit bot

events: keycodes: Remove the stateless singleton instance of KeycodeConverter

All methods can be safely made static and the singleton
removed.

TBR=ben@chromium.org

Review URL: https://codereview.chromium.org/494813002

Cr-Commit-Position: refs/heads/master@{#292070}
parent 0e014b9a
......@@ -137,8 +137,7 @@ void GetExtensionKeyboardEventFromKeyEvent(
ext_event->type = (event.type() == ui::ET_KEY_RELEASED) ? "keyup" : "keydown";
std::string dom_code = event.code();
if (dom_code ==
ui::KeycodeConverter::GetInstance()->InvalidKeyboardEventCode())
if (dom_code == ui::KeycodeConverter::InvalidKeyboardEventCode())
dom_code = ui::KeyboardCodeToDomKeycode(event.key_code());
ext_event->code = dom_code;
ext_event->key_code = static_cast<int>(event.key_code());
......
......@@ -322,8 +322,7 @@ void SimulateKeyPressWithCode(WebContents* web_contents,
bool shift,
bool alt,
bool command) {
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
int native_key_code = key_converter->CodeToNativeKeycode(code);
int native_key_code = ui::KeycodeConverter::CodeToNativeKeycode(code);
int modifiers = 0;
......@@ -331,42 +330,38 @@ void SimulateKeyPressWithCode(WebContents* web_contents,
// For our simulation we can use either the left keys or the right keys.
if (control) {
modifiers |= blink::WebInputEvent::ControlKey;
InjectRawKeyEvent(
web_contents,
blink::WebInputEvent::RawKeyDown,
ui::VKEY_CONTROL,
key_converter->CodeToNativeKeycode("ControlLeft"),
modifiers);
InjectRawKeyEvent(web_contents,
blink::WebInputEvent::RawKeyDown,
ui::VKEY_CONTROL,
ui::KeycodeConverter::CodeToNativeKeycode("ControlLeft"),
modifiers);
}
if (shift) {
modifiers |= blink::WebInputEvent::ShiftKey;
InjectRawKeyEvent(
web_contents,
blink::WebInputEvent::RawKeyDown,
ui::VKEY_SHIFT,
key_converter->CodeToNativeKeycode("ShiftLeft"),
modifiers);
InjectRawKeyEvent(web_contents,
blink::WebInputEvent::RawKeyDown,
ui::VKEY_SHIFT,
ui::KeycodeConverter::CodeToNativeKeycode("ShiftLeft"),
modifiers);
}
if (alt) {
modifiers |= blink::WebInputEvent::AltKey;
InjectRawKeyEvent(
web_contents,
blink::WebInputEvent::RawKeyDown,
ui::VKEY_MENU,
key_converter->CodeToNativeKeycode("AltLeft"),
modifiers);
InjectRawKeyEvent(web_contents,
blink::WebInputEvent::RawKeyDown,
ui::VKEY_MENU,
ui::KeycodeConverter::CodeToNativeKeycode("AltLeft"),
modifiers);
}
if (command) {
modifiers |= blink::WebInputEvent::MetaKey;
InjectRawKeyEvent(
web_contents,
blink::WebInputEvent::RawKeyDown,
ui::VKEY_COMMAND,
key_converter->CodeToNativeKeycode("OSLeft"),
modifiers);
InjectRawKeyEvent(web_contents,
blink::WebInputEvent::RawKeyDown,
ui::VKEY_COMMAND,
ui::KeycodeConverter::CodeToNativeKeycode("OSLeft"),
modifiers);
}
InjectRawKeyEvent(
......@@ -393,42 +388,38 @@ void SimulateKeyPressWithCode(WebContents* web_contents,
// The order of these key releases shouldn't matter for our simulation.
if (control) {
modifiers &= ~blink::WebInputEvent::ControlKey;
InjectRawKeyEvent(
web_contents,
blink::WebInputEvent::KeyUp,
ui::VKEY_CONTROL,
key_converter->CodeToNativeKeycode("ControlLeft"),
modifiers);
InjectRawKeyEvent(web_contents,
blink::WebInputEvent::KeyUp,
ui::VKEY_CONTROL,
ui::KeycodeConverter::CodeToNativeKeycode("ControlLeft"),
modifiers);
}
if (shift) {
modifiers &= ~blink::WebInputEvent::ShiftKey;
InjectRawKeyEvent(
web_contents,
blink::WebInputEvent::KeyUp,
ui::VKEY_SHIFT,
key_converter->CodeToNativeKeycode("ShiftLeft"),
modifiers);
InjectRawKeyEvent(web_contents,
blink::WebInputEvent::KeyUp,
ui::VKEY_SHIFT,
ui::KeycodeConverter::CodeToNativeKeycode("ShiftLeft"),
modifiers);
}
if (alt) {
modifiers &= ~blink::WebInputEvent::AltKey;
InjectRawKeyEvent(
web_contents,
blink::WebInputEvent::KeyUp,
ui::VKEY_MENU,
key_converter->CodeToNativeKeycode("AltLeft"),
modifiers);
InjectRawKeyEvent(web_contents,
blink::WebInputEvent::KeyUp,
ui::VKEY_MENU,
ui::KeycodeConverter::CodeToNativeKeycode("AltLeft"),
modifiers);
}
if (command) {
modifiers &= ~blink::WebInputEvent::MetaKey;
InjectRawKeyEvent(
web_contents,
blink::WebInputEvent::KeyUp,
ui::VKEY_COMMAND,
key_converter->CodeToNativeKeycode("OSLeft"),
modifiers);
InjectRawKeyEvent(web_contents,
blink::WebInputEvent::KeyUp,
ui::VKEY_COMMAND,
ui::KeycodeConverter::CodeToNativeKeycode("OSLeft"),
modifiers);
}
ASSERT_EQ(modifiers, 0);
......
......@@ -17,13 +17,12 @@ uint32_t UsbKeyCodeForKeyboardEvent(const WebKeyboardEvent& key_event) {
// the XKB driver. We should detect between "XKB", "kbd" and "evdev" at
// run-time and re-map accordingly, but that's not possible here, inside the
// sandbox.
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
return key_converter->NativeKeycodeToUsbKeycode(key_event.nativeKeyCode);
return ui::KeycodeConverter::NativeKeycodeToUsbKeycode(
key_event.nativeKeyCode);
}
const char* CodeForKeyboardEvent(const WebKeyboardEvent& key_event) {
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
return key_converter->NativeKeycodeToCode(key_event.nativeKeyCode);
return ui::KeycodeConverter::NativeKeycodeToCode(key_event.nativeKeyCode);
}
} // namespace content
......@@ -13,13 +13,12 @@ using blink::WebKeyboardEvent;
namespace content {
uint32_t UsbKeyCodeForKeyboardEvent(const WebKeyboardEvent& key_event) {
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
return key_converter->NativeKeycodeToUsbKeycode(key_event.nativeKeyCode);
return ui::KeycodeConverter::NativeKeycodeToUsbKeycode(
key_event.nativeKeyCode);
}
const char* CodeForKeyboardEvent(const WebKeyboardEvent& key_event) {
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
return key_converter->NativeKeycodeToCode(key_event.nativeKeyCode);
return ui::KeycodeConverter::NativeKeycodeToCode(key_event.nativeKeyCode);
}
} // namespace content
......@@ -18,8 +18,7 @@ uint32_t UsbKeyCodeForKeyboardEvent(const WebKeyboardEvent& key_event) {
if ((key_event.nativeKeyCode & (1 << 24)) != 0)
scancode |= 0xe000;
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
return key_converter->NativeKeycodeToUsbKeycode(scancode);
return ui::KeycodeConverter::NativeKeycodeToUsbKeycode(scancode);
}
const char* CodeForKeyboardEvent(const WebKeyboardEvent& key_event) {
......@@ -28,8 +27,7 @@ const char* CodeForKeyboardEvent(const WebKeyboardEvent& key_event) {
if ((key_event.nativeKeyCode & (1 << 24)) != 0)
scancode |= 0xe000;
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
return key_converter->NativeKeycodeToCode(scancode);
return ui::KeycodeConverter::NativeKeycodeToCode(scancode);
}
} // namespace content
......@@ -39,8 +39,7 @@ uint32_t GetUsbKeyCode(pp::KeyboardInputEvent pp_key_event) {
std::string codestr = pp_key_event.GetCode().AsString();
// Convert the |code| string into a USB keycode.
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
return key_converter->CodeToUsbKeycode(codestr.c_str());
return ui::KeycodeConverter::CodeToUsbKeycode(codestr.c_str());
}
bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
......
......@@ -276,14 +276,14 @@ void InputInjectorLinux::Core::InjectKeyEvent(const KeyEvent& event) {
return;
}
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
int keycode = key_converter->UsbKeycodeToNativeKeycode(event.usb_keycode());
int keycode =
ui::KeycodeConverter::UsbKeycodeToNativeKeycode(event.usb_keycode());
VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
<< " to keycode: " << keycode << std::dec;
// Ignore events which can't be mapped.
if (keycode == key_converter->InvalidNativeKeycode())
if (keycode == ui::KeycodeConverter::InvalidNativeKeycode())
return;
if (event.pressed()) {
......
......@@ -179,14 +179,14 @@ void InputInjectorMac::Core::InjectKeyEvent(const KeyEvent& event) {
if (!event.has_pressed() || !event.has_usb_keycode())
return;
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
int keycode = key_converter->UsbKeycodeToNativeKeycode(event.usb_keycode());
int keycode =
ui::KeycodeConverter::UsbKeycodeToNativeKeycode(event.usb_keycode());
VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
<< " to keycode: " << keycode << std::dec;
// If we couldn't determine the Mac virtual key code then ignore the event.
if (keycode == key_converter->InvalidNativeKeycode())
if (keycode == ui::KeycodeConverter::InvalidNativeKeycode())
return;
// If this is a modifier key, remember its new state so that it can be
......
......@@ -221,13 +221,13 @@ void InputInjectorWin::Core::HandleKey(const KeyEvent& event) {
// Reset the system idle suspend timeout.
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
int scancode = key_converter->UsbKeycodeToNativeKeycode(event.usb_keycode());
int scancode =
ui::KeycodeConverter::UsbKeycodeToNativeKeycode(event.usb_keycode());
VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
<< " to scancode: " << scancode << std::dec;
// Ignore events which can't be mapped.
if (scancode == key_converter->InvalidNativeKeycode())
if (scancode == ui::KeycodeConverter::InvalidNativeKeycode())
return;
uint32_t flags = KEYEVENTF_SCANCODE | (event.pressed() ? 0 : KEYEVENTF_KEYUP);
......
......@@ -329,11 +329,10 @@ TEST(EventTest, KeyEventCopy) {
}
TEST(EventTest, KeyEventCode) {
KeycodeConverter* conv = KeycodeConverter::GetInstance();
const char kCodeForSpace[] = "Space";
const uint16 kNativeCodeSpace = conv->CodeToNativeKeycode(kCodeForSpace);
ASSERT_NE(conv->InvalidNativeKeycode(), kNativeCodeSpace);
const uint16 kNativeCodeSpace =
ui::KeycodeConverter::CodeToNativeKeycode(kCodeForSpace);
ASSERT_NE(ui::KeycodeConverter::InvalidNativeKeycode(), kNativeCodeSpace);
{
KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, kCodeForSpace, EF_NONE);
......@@ -392,10 +391,8 @@ TEST(EventTest, KeyEventCode) {
#if defined(USE_X11) || defined(OS_WIN)
TEST(EventTest, AutoRepeat) {
KeycodeConverter* conv = KeycodeConverter::GetInstance();
const uint16 kNativeCodeA = conv->CodeToNativeKeycode("KeyA");
const uint16 kNativeCodeB = conv->CodeToNativeKeycode("KeyB");
const uint16 kNativeCodeA = ui::KeycodeConverter::CodeToNativeKeycode("KeyA");
const uint16 kNativeCodeB = ui::KeycodeConverter::CodeToNativeKeycode("KeyB");
#if defined(USE_X11)
ScopedXI2Event native_event_a_pressed;
native_event_a_pressed.InitKeyEvent(ET_KEY_PRESSED, VKEY_A, kNativeCodeA);
......
......@@ -23,29 +23,27 @@ const size_t kKeycodeMapEntries = arraysize(usb_keycode_map);
} // namespace
KeycodeConverter::KeycodeConverter() {
}
KeycodeConverter* KeycodeConverter::GetInstance() {
return Singleton<KeycodeConverter>::get();
}
// static
size_t KeycodeConverter::NumKeycodeMapEntriesForTest() {
return kKeycodeMapEntries;
}
// static
const KeycodeMapEntry* KeycodeConverter::GetKeycodeMapForTest() {
return &usb_keycode_map[0];
}
// static
uint16_t KeycodeConverter::InvalidNativeKeycode() {
return usb_keycode_map[0].native_keycode;
}
// static
const char* KeycodeConverter::InvalidKeyboardEventCode() {
return "Unidentified";
}
// static
const char* KeycodeConverter::NativeKeycodeToCode(uint16_t native_keycode) {
for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
if (usb_keycode_map[i].native_keycode == native_keycode) {
......@@ -57,6 +55,7 @@ const char* KeycodeConverter::NativeKeycodeToCode(uint16_t native_keycode) {
return InvalidKeyboardEventCode();
}
// static
uint16_t KeycodeConverter::CodeToNativeKeycode(const char* code) {
if (!code ||
strcmp(code, InvalidKeyboardEventCode()) == 0) {
......@@ -76,10 +75,12 @@ uint16_t KeycodeConverter::CodeToNativeKeycode(const char* code) {
// Note that USB keycodes are not part of any web standard.
// Please don't use USB keycodes in new code.
// static
uint16_t KeycodeConverter::InvalidUsbKeycode() {
return usb_keycode_map[0].usb_keycode;
}
// static
uint16_t KeycodeConverter::UsbKeycodeToNativeKeycode(uint32_t usb_keycode) {
// Deal with some special-cases that don't fit the 1:1 mapping.
if (usb_keycode == 0x070032) // non-US hash.
......@@ -96,6 +97,7 @@ uint16_t KeycodeConverter::UsbKeycodeToNativeKeycode(uint32_t usb_keycode) {
return InvalidNativeKeycode();
}
// static
uint32_t KeycodeConverter::NativeKeycodeToUsbKeycode(uint16_t native_keycode) {
for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
if (usb_keycode_map[i].native_keycode == native_keycode)
......@@ -104,6 +106,7 @@ uint32_t KeycodeConverter::NativeKeycodeToUsbKeycode(uint16_t native_keycode) {
return InvalidUsbKeycode();
}
// static
const char* KeycodeConverter::UsbKeycodeToCode(uint32_t usb_keycode) {
for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
if (usb_keycode_map[i].usb_keycode == usb_keycode)
......@@ -112,6 +115,7 @@ const char* KeycodeConverter::UsbKeycodeToCode(uint32_t usb_keycode) {
return InvalidKeyboardEventCode();
}
// static
uint32_t KeycodeConverter::CodeToUsbKeycode(const char* code) {
if (!code ||
strcmp(code, InvalidKeyboardEventCode()) == 0) {
......
......@@ -7,7 +7,6 @@
#include <stdint.h>
#include "base/basictypes.h"
#include "base/memory/singleton.h"
// For reference, the W3C UI Event spec is located at:
// http://www.w3.org/TR/uievents/
......@@ -38,50 +37,45 @@ typedef struct {
// spec (http://www.w3.org/TR/uievents/).
class KeycodeConverter {
public:
static KeycodeConverter* GetInstance();
// Return the value that identifies an invalid native keycode.
uint16_t InvalidNativeKeycode();
static uint16_t InvalidNativeKeycode();
// Return the string that indentifies an invalid UI Event |code|.
// The returned pointer references a static global string.
const char* InvalidKeyboardEventCode();
static const char* InvalidKeyboardEventCode();
// Convert a native (Mac/Win/Linux) keycode into the |code| string.
// The returned pointer references a static global string.
const char* NativeKeycodeToCode(uint16_t native_keycode);
static const char* NativeKeycodeToCode(uint16_t native_keycode);
// Convert a UI Events |code| string value into a native keycode.
uint16_t CodeToNativeKeycode(const char* code);
static uint16_t CodeToNativeKeycode(const char* code);
// The following methods relate to USB keycodes.
// Note that USB keycodes are not part of any web standard.
// Please don't use USB keycodes in new code.
// Return the value that identifies an invalid USB keycode.
uint16_t InvalidUsbKeycode();
static uint16_t InvalidUsbKeycode();
// Convert a USB keycode into an equivalent platform native keycode.
uint16_t UsbKeycodeToNativeKeycode(uint32_t usb_keycode);
static uint16_t UsbKeycodeToNativeKeycode(uint32_t usb_keycode);
// Convert a platform native keycode into an equivalent USB keycode.
uint32_t NativeKeycodeToUsbKeycode(uint16_t native_keycode);
static uint32_t NativeKeycodeToUsbKeycode(uint16_t native_keycode);
// Convert a USB keycode into the string with the DOM3 |code| value.
// The returned pointer references a static global string.
const char* UsbKeycodeToCode(uint32_t usb_keycode);
static const char* UsbKeycodeToCode(uint32_t usb_keycode);
// Convert a DOM3 Event |code| string into a USB keycode value.
uint32_t CodeToUsbKeycode(const char* code);
static uint32_t CodeToUsbKeycode(const char* code);
// Static methods to support testing.
size_t NumKeycodeMapEntriesForTest();
const KeycodeMapEntry* GetKeycodeMapForTest();
static size_t NumKeycodeMapEntriesForTest();
static const KeycodeMapEntry* GetKeycodeMapForTest();
private:
KeycodeConverter();
friend struct DefaultSingletonTraits<KeycodeConverter>;
DISALLOW_COPY_AND_ASSIGN(KeycodeConverter);
};
......
......@@ -28,41 +28,44 @@ const uint32_t kUsbUsBackslash = 0x070031;
const uint32_t kUsbNonUsHash = 0x070032;
TEST(UsbKeycodeMap, Basic) {
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
// Verify that the first element in the table is the "invalid" code.
const ui::KeycodeMapEntry* keycode_map =
key_converter->GetKeycodeMapForTest();
EXPECT_EQ(key_converter->InvalidUsbKeycode(), keycode_map[0].usb_keycode);
EXPECT_EQ(key_converter->InvalidNativeKeycode(),
ui::KeycodeConverter::GetKeycodeMapForTest();
EXPECT_EQ(ui::KeycodeConverter::InvalidUsbKeycode(),
keycode_map[0].usb_keycode);
EXPECT_EQ(ui::KeycodeConverter::InvalidNativeKeycode(),
keycode_map[0].native_keycode);
EXPECT_STREQ(key_converter->InvalidKeyboardEventCode(), "Unidentified");
EXPECT_EQ(key_converter->InvalidNativeKeycode(),
key_converter->CodeToNativeKeycode("Unidentified"));
EXPECT_STREQ(ui::KeycodeConverter::InvalidKeyboardEventCode(),
"Unidentified");
EXPECT_EQ(ui::KeycodeConverter::InvalidNativeKeycode(),
ui::KeycodeConverter::CodeToNativeKeycode("Unidentified"));
// Verify that there are no duplicate entries in the mapping.
std::map<uint32_t, uint16_t> usb_to_native;
std::map<uint16_t, uint32_t> native_to_usb;
size_t numEntries = key_converter->NumKeycodeMapEntriesForTest();
size_t numEntries = ui::KeycodeConverter::NumKeycodeMapEntriesForTest();
for (size_t i = 0; i < numEntries; ++i) {
const ui::KeycodeMapEntry* entry = &keycode_map[i];
// Don't test keys with no native keycode mapping on this platform.
if (entry->native_keycode == key_converter->InvalidNativeKeycode())
if (entry->native_keycode == ui::KeycodeConverter::InvalidNativeKeycode())
continue;
// Verify UsbKeycodeToNativeKeycode works for this key.
EXPECT_EQ(entry->native_keycode,
key_converter->UsbKeycodeToNativeKeycode(entry->usb_keycode));
EXPECT_EQ(
entry->native_keycode,
ui::KeycodeConverter::UsbKeycodeToNativeKeycode(entry->usb_keycode));
// Verify CodeToNativeKeycode and NativeKeycodeToCode work correctly.
if (entry->code) {
EXPECT_EQ(entry->native_keycode,
key_converter->CodeToNativeKeycode(entry->code));
EXPECT_STREQ(entry->code,
key_converter->NativeKeycodeToCode(entry->native_keycode));
ui::KeycodeConverter::CodeToNativeKeycode(entry->code));
EXPECT_STREQ(
entry->code,
ui::KeycodeConverter::NativeKeycodeToCode(entry->native_keycode));
}
else {
EXPECT_EQ(key_converter->InvalidNativeKeycode(),
key_converter->CodeToNativeKeycode(entry->code));
EXPECT_EQ(ui::KeycodeConverter::InvalidNativeKeycode(),
ui::KeycodeConverter::CodeToNativeKeycode(entry->code));
}
// Verify that the USB or native codes aren't duplicated.
......@@ -94,17 +97,16 @@ TEST(UsbKeycodeMap, Basic) {
TEST(UsbKeycodeMap, NonExistent) {
// Verify that UsbKeycodeToNativeKeycode works for a non-existent USB keycode.
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
EXPECT_EQ(key_converter->InvalidNativeKeycode(),
key_converter->UsbKeycodeToNativeKeycode(kUsbNonExistentKeycode));
EXPECT_EQ(
ui::KeycodeConverter::InvalidNativeKeycode(),
ui::KeycodeConverter::UsbKeycodeToNativeKeycode(kUsbNonExistentKeycode));
}
TEST(UsbKeycodeMap, UsBackslashIsNonUsHash) {
// Verify that UsbKeycodeToNativeKeycode treats the non-US "hash" key
// as equivalent to the US "backslash" key.
ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance();
EXPECT_EQ(key_converter->UsbKeycodeToNativeKeycode(kUsbUsBackslash),
key_converter->UsbKeycodeToNativeKeycode(kUsbNonUsHash));
EXPECT_EQ(ui::KeycodeConverter::UsbKeycodeToNativeKeycode(kUsbUsBackslash),
ui::KeycodeConverter::UsbKeycodeToNativeKeycode(kUsbNonUsHash));
}
} // namespace
......@@ -545,8 +545,7 @@ KeyboardCode KeyboardCodeFromNSEvent(NSEvent* event) {
}
const char* CodeFromNSEvent(NSEvent* event) {
return KeycodeConverter::GetInstance()->NativeKeycodeToCode(
[event keyCode]);
return ui::KeycodeConverter::NativeKeycodeToCode([event keyCode]);
}
} // namespace ui
......@@ -16,8 +16,7 @@ KeyboardCode KeyboardCodeForWindowsKeyCode(WORD keycode) {
}
const char* CodeForWindowsScanCode(WORD scan_code) {
return KeycodeConverter::GetInstance()->NativeKeycodeToCode(
scan_code);
return ui::KeycodeConverter::NativeKeycodeToCode(scan_code);
}
} // namespace ui
......@@ -838,7 +838,7 @@ const char* CodeFromXEvent(const XEvent* xev) {
int keycode = (xev->type == GenericEvent)
? static_cast<XIDeviceEvent*>(xev->xcookie.data)->detail
: xev->xkey.keycode;
return KeycodeConverter::GetInstance()->NativeKeycodeToCode(keycode);
return ui::KeycodeConverter::NativeKeycodeToCode(keycode);
}
uint16 GetCharacterFromXEvent(const XEvent* xev) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment