mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Change formatting and implement suggestions
This commit is contained in:
parent
59a93ff737
commit
e82d20c291
@ -175,7 +175,7 @@ private:
|
||||
///
|
||||
/// for each connected keyboard kb:
|
||||
/// for each key k of kb:
|
||||
/// memorise k -> scancode mapping
|
||||
/// memorize k -> scancode mapping
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void initializeKeyboard();
|
||||
@ -216,7 +216,7 @@ private:
|
||||
/// Scancode when there's a keyboard layout change
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void keyboardChanged(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef);
|
||||
static void keyboardChanged(CFNotificationCenterRef /* center */, void* observer, CFStringRef /* name */, const void* /* object */, CFDictionaryRef /* userInfo */);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Release all resources
|
||||
|
@ -30,8 +30,11 @@
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
static const sf::Uint8 UnknownVirtualCode = 0xff;
|
||||
static const bool IsIsoKeyboard = (KBGetLayoutType(LMGetKbdType()) == kKeyboardISO);
|
||||
}
|
||||
|
||||
namespace sf
|
||||
{
|
||||
@ -562,7 +565,6 @@ Keyboard::Key HIDInputManager::localize(Keyboard::Scancode code)
|
||||
if (code == Keyboard::Scan::Unknown)
|
||||
return Keyboard::Unknown;
|
||||
|
||||
// TODO ensure mapping is still valid
|
||||
return m_scancodeToKeyMapping[code];
|
||||
}
|
||||
|
||||
@ -573,7 +575,6 @@ Keyboard::Scancode HIDInputManager::delocalize(Keyboard::Key key)
|
||||
if (key == Keyboard::Unknown)
|
||||
return Keyboard::Scan::Unknown;
|
||||
|
||||
// TODO ensure mapping is still valid
|
||||
return m_keyToScancodeMapping[key];
|
||||
}
|
||||
|
||||
@ -712,13 +713,12 @@ m_manager(0)
|
||||
|
||||
// Register for notification on keyboard layout changes
|
||||
CFNotificationCenterAddObserver(
|
||||
CFNotificationCenterGetDistributedCenter(),
|
||||
this,
|
||||
keyboardChanged, // callback
|
||||
kTISNotifySelectedKeyboardInputSourceChanged,
|
||||
NULL, // use callback
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately
|
||||
);
|
||||
CFNotificationCenterGetDistributedCenter(),
|
||||
this,
|
||||
keyboardChanged, // callback
|
||||
kTISNotifySelectedKeyboardInputSourceChanged,
|
||||
NULL, // use callback
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately);
|
||||
}
|
||||
|
||||
|
||||
@ -773,7 +773,7 @@ void HIDInputManager::loadKeyboard(IOHIDDeviceRef keyboard)
|
||||
{
|
||||
IOHIDElementRef elem = static_cast<IOHIDElementRef>(key);
|
||||
if (IOHIDElementGetUsagePage(elem) == kHIDPage_KeyboardOrKeypad)
|
||||
loadKey(elem);
|
||||
loadKey(elem);
|
||||
}
|
||||
|
||||
CFRelease(underlying);
|
||||
@ -894,7 +894,7 @@ void HIDInputManager::buildMappings()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void HIDInputManager::keyboardChanged(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
|
||||
void HIDInputManager::keyboardChanged(CFNotificationCenterRef /* center */, void* observer, CFStringRef /* name */, const void* /* object */, CFDictionaryRef /* userInfo */)
|
||||
{
|
||||
HIDInputManager* manager = static_cast<HIDInputManager*>(observer);
|
||||
manager->buildMappings();
|
||||
|
@ -51,7 +51,7 @@ sf::Keyboard::Scancode keycodeToScancode[MaxKeyCode]; ///< Mapping of X11 KeyCod
|
||||
bool isValidKeycode(KeyCode keycode)
|
||||
{
|
||||
// Valid key code range is [8,255], according to the Xlib manual
|
||||
return (keycode >= 8);
|
||||
return keycode >= 8;
|
||||
}
|
||||
|
||||
|
||||
@ -790,20 +790,17 @@ String KeyboardImpl::getDescription(Keyboard::Scancode code)
|
||||
////////////////////////////////////////////////////////////
|
||||
Keyboard::Key KeyboardImpl::getKeyFromEvent(XKeyEvent& event)
|
||||
{
|
||||
Keyboard::Key key = Keyboard::Unknown;
|
||||
|
||||
// Try each KeySym index (modifier group) until we get a match
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
// Get the SFML keyboard code from the keysym of the key that has been pressed
|
||||
KeySym keysym = XLookupKeysym(&event, i);
|
||||
key = keySymToKey(keysym);
|
||||
|
||||
Keyboard::Key key = keySymToKey(keysym);
|
||||
if (key != Keyboard::Unknown)
|
||||
break;
|
||||
return key;
|
||||
}
|
||||
|
||||
return key;
|
||||
return Keyboard::Unknown;
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,225 +48,221 @@ Keyboard::Key InputImpl::m_scancodeToKeyMapping[Keyboard::Scan::ScancodeCou
|
||||
////////////////////////////////////////////////////////////
|
||||
Keyboard::Key virtualKeyToSfKey(UINT virtualKey)
|
||||
{
|
||||
Keyboard::Key key;
|
||||
switch (virtualKey)
|
||||
{
|
||||
default: key = Keyboard::Unknown; break;
|
||||
case 'A': key = Keyboard::A; break;
|
||||
case 'B': key = Keyboard::B; break;
|
||||
case 'C': key = Keyboard::C; break;
|
||||
case 'D': key = Keyboard::D; break;
|
||||
case 'E': key = Keyboard::E; break;
|
||||
case 'F': key = Keyboard::F; break;
|
||||
case 'G': key = Keyboard::G; break;
|
||||
case 'H': key = Keyboard::H; break;
|
||||
case 'I': key = Keyboard::I; break;
|
||||
case 'J': key = Keyboard::J; break;
|
||||
case 'K': key = Keyboard::K; break;
|
||||
case 'L': key = Keyboard::L; break;
|
||||
case 'M': key = Keyboard::M; break;
|
||||
case 'N': key = Keyboard::N; break;
|
||||
case 'O': key = Keyboard::O; break;
|
||||
case 'P': key = Keyboard::P; break;
|
||||
case 'Q': key = Keyboard::Q; break;
|
||||
case 'R': key = Keyboard::R; break;
|
||||
case 'S': key = Keyboard::S; break;
|
||||
case 'T': key = Keyboard::T; break;
|
||||
case 'U': key = Keyboard::U; break;
|
||||
case 'V': key = Keyboard::V; break;
|
||||
case 'W': key = Keyboard::W; break;
|
||||
case 'X': key = Keyboard::X; break;
|
||||
case 'Y': key = Keyboard::Y; break;
|
||||
case 'Z': key = Keyboard::Z; break;
|
||||
case '0': key = Keyboard::Num0; break;
|
||||
case '1': key = Keyboard::Num1; break;
|
||||
case '2': key = Keyboard::Num2; break;
|
||||
case '3': key = Keyboard::Num3; break;
|
||||
case '4': key = Keyboard::Num4; break;
|
||||
case '5': key = Keyboard::Num5; break;
|
||||
case '6': key = Keyboard::Num6; break;
|
||||
case '7': key = Keyboard::Num7; break;
|
||||
case '8': key = Keyboard::Num8; break;
|
||||
case '9': key = Keyboard::Num9; break;
|
||||
case VK_ESCAPE: key = Keyboard::Escape; break;
|
||||
case VK_LCONTROL: key = Keyboard::LControl; break;
|
||||
case VK_LSHIFT: key = Keyboard::LShift; break;
|
||||
case VK_LMENU: key = Keyboard::LAlt; break;
|
||||
case VK_LWIN: key = Keyboard::LSystem; break;
|
||||
case VK_RCONTROL: key = Keyboard::RControl; break;
|
||||
case VK_RSHIFT: key = Keyboard::RShift; break;
|
||||
case VK_RMENU: key = Keyboard::RAlt; break;
|
||||
case VK_RWIN: key = Keyboard::RSystem; break;
|
||||
case VK_APPS: key = Keyboard::Menu; break;
|
||||
case VK_OEM_4: key = Keyboard::LBracket; break;
|
||||
case VK_OEM_6: key = Keyboard::RBracket; break;
|
||||
case VK_OEM_1: key = Keyboard::Semicolon; break;
|
||||
case VK_OEM_COMMA: key = Keyboard::Comma; break;
|
||||
case VK_OEM_PERIOD: key = Keyboard::Period; break;
|
||||
case VK_OEM_7: key = Keyboard::Apostrophe; break;
|
||||
case VK_OEM_2: key = Keyboard::Slash; break;
|
||||
case VK_OEM_5: key = Keyboard::Backslash; break;
|
||||
case VK_OEM_3: key = Keyboard::Grave; break;
|
||||
case VK_OEM_PLUS: key = Keyboard::Equal; break;
|
||||
case VK_OEM_MINUS: key = Keyboard::Hyphen; break;
|
||||
case VK_SPACE: key = Keyboard::Space; break;
|
||||
case VK_RETURN: key = Keyboard::Enter; break;
|
||||
case VK_BACK: key = Keyboard::Backspace; break;
|
||||
case VK_TAB: key = Keyboard::Tab; break;
|
||||
case VK_PRIOR: key = Keyboard::PageUp; break;
|
||||
case VK_NEXT: key = Keyboard::PageDown; break;
|
||||
case VK_END: key = Keyboard::End; break;
|
||||
case VK_HOME: key = Keyboard::Home; break;
|
||||
case VK_INSERT: key = Keyboard::Insert; break;
|
||||
case VK_DELETE: key = Keyboard::Delete; break;
|
||||
case VK_ADD: key = Keyboard::Add; break;
|
||||
case VK_SUBTRACT: key = Keyboard::Subtract; break;
|
||||
case VK_MULTIPLY: key = Keyboard::Multiply; break;
|
||||
case VK_DIVIDE: key = Keyboard::Divide; break;
|
||||
case VK_LEFT: key = Keyboard::Left; break;
|
||||
case VK_RIGHT: key = Keyboard::Right; break;
|
||||
case VK_UP: key = Keyboard::Up; break;
|
||||
case VK_DOWN: key = Keyboard::Down; break;
|
||||
case VK_NUMPAD0: key = Keyboard::Numpad0; break;
|
||||
case VK_NUMPAD1: key = Keyboard::Numpad1; break;
|
||||
case VK_NUMPAD2: key = Keyboard::Numpad2; break;
|
||||
case VK_NUMPAD3: key = Keyboard::Numpad3; break;
|
||||
case VK_NUMPAD4: key = Keyboard::Numpad4; break;
|
||||
case VK_NUMPAD5: key = Keyboard::Numpad5; break;
|
||||
case VK_NUMPAD6: key = Keyboard::Numpad6; break;
|
||||
case VK_NUMPAD7: key = Keyboard::Numpad7; break;
|
||||
case VK_NUMPAD8: key = Keyboard::Numpad8; break;
|
||||
case VK_NUMPAD9: key = Keyboard::Numpad9; break;
|
||||
case VK_F1: key = Keyboard::F1; break;
|
||||
case VK_F2: key = Keyboard::F2; break;
|
||||
case VK_F3: key = Keyboard::F3; break;
|
||||
case VK_F4: key = Keyboard::F4; break;
|
||||
case VK_F5: key = Keyboard::F5; break;
|
||||
case VK_F6: key = Keyboard::F6; break;
|
||||
case VK_F7: key = Keyboard::F7; break;
|
||||
case VK_F8: key = Keyboard::F8; break;
|
||||
case VK_F9: key = Keyboard::F9; break;
|
||||
case VK_F10: key = Keyboard::F10; break;
|
||||
case VK_F11: key = Keyboard::F11; break;
|
||||
case VK_F12: key = Keyboard::F12; break;
|
||||
case VK_F13: key = Keyboard::F13; break;
|
||||
case VK_F14: key = Keyboard::F14; break;
|
||||
case VK_F15: key = Keyboard::F15; break;
|
||||
case VK_PAUSE: key = Keyboard::Pause; break;
|
||||
case 'A': return Keyboard::A;
|
||||
case 'B': return Keyboard::B;
|
||||
case 'C': return Keyboard::C;
|
||||
case 'D': return Keyboard::D;
|
||||
case 'E': return Keyboard::E;
|
||||
case 'F': return Keyboard::F;
|
||||
case 'G': return Keyboard::G;
|
||||
case 'H': return Keyboard::H;
|
||||
case 'I': return Keyboard::I;
|
||||
case 'J': return Keyboard::J;
|
||||
case 'K': return Keyboard::K;
|
||||
case 'L': return Keyboard::L;
|
||||
case 'M': return Keyboard::M;
|
||||
case 'N': return Keyboard::N;
|
||||
case 'O': return Keyboard::O;
|
||||
case 'P': return Keyboard::P;
|
||||
case 'Q': return Keyboard::Q;
|
||||
case 'R': return Keyboard::R;
|
||||
case 'S': return Keyboard::S;
|
||||
case 'T': return Keyboard::T;
|
||||
case 'U': return Keyboard::U;
|
||||
case 'V': return Keyboard::V;
|
||||
case 'W': return Keyboard::W;
|
||||
case 'X': return Keyboard::X;
|
||||
case 'Y': return Keyboard::Y;
|
||||
case 'Z': return Keyboard::Z;
|
||||
case '0': return Keyboard::Num0;
|
||||
case '1': return Keyboard::Num1;
|
||||
case '2': return Keyboard::Num2;
|
||||
case '3': return Keyboard::Num3;
|
||||
case '4': return Keyboard::Num4;
|
||||
case '5': return Keyboard::Num5;
|
||||
case '6': return Keyboard::Num6;
|
||||
case '7': return Keyboard::Num7;
|
||||
case '8': return Keyboard::Num8;
|
||||
case '9': return Keyboard::Num9;
|
||||
case VK_ESCAPE: return Keyboard::Escape;
|
||||
case VK_LCONTROL: return Keyboard::LControl;
|
||||
case VK_LSHIFT: return Keyboard::LShift;
|
||||
case VK_LMENU: return Keyboard::LAlt;
|
||||
case VK_LWIN: return Keyboard::LSystem;
|
||||
case VK_RCONTROL: return Keyboard::RControl;
|
||||
case VK_RSHIFT: return Keyboard::RShift;
|
||||
case VK_RMENU: return Keyboard::RAlt;
|
||||
case VK_RWIN: return Keyboard::RSystem;
|
||||
case VK_APPS: return Keyboard::Menu;
|
||||
case VK_OEM_4: return Keyboard::LBracket;
|
||||
case VK_OEM_6: return Keyboard::RBracket;
|
||||
case VK_OEM_1: return Keyboard::Semicolon;
|
||||
case VK_OEM_COMMA: return Keyboard::Comma;
|
||||
case VK_OEM_PERIOD: return Keyboard::Period;
|
||||
case VK_OEM_7: return Keyboard::Apostrophe;
|
||||
case VK_OEM_2: return Keyboard::Slash;
|
||||
case VK_OEM_5: return Keyboard::Backslash;
|
||||
case VK_OEM_3: return Keyboard::Grave;
|
||||
case VK_OEM_PLUS: return Keyboard::Equal;
|
||||
case VK_OEM_MINUS: return Keyboard::Hyphen;
|
||||
case VK_SPACE: return Keyboard::Space;
|
||||
case VK_RETURN: return Keyboard::Enter;
|
||||
case VK_BACK: return Keyboard::Backspace;
|
||||
case VK_TAB: return Keyboard::Tab;
|
||||
case VK_PRIOR: return Keyboard::PageUp;
|
||||
case VK_NEXT: return Keyboard::PageDown;
|
||||
case VK_END: return Keyboard::End;
|
||||
case VK_HOME: return Keyboard::Home;
|
||||
case VK_INSERT: return Keyboard::Insert;
|
||||
case VK_DELETE: return Keyboard::Delete;
|
||||
case VK_ADD: return Keyboard::Add;
|
||||
case VK_SUBTRACT: return Keyboard::Subtract;
|
||||
case VK_MULTIPLY: return Keyboard::Multiply;
|
||||
case VK_DIVIDE: return Keyboard::Divide;
|
||||
case VK_LEFT: return Keyboard::Left;
|
||||
case VK_RIGHT: return Keyboard::Right;
|
||||
case VK_UP: return Keyboard::Up;
|
||||
case VK_DOWN: return Keyboard::Down;
|
||||
case VK_NUMPAD0: return Keyboard::Numpad0;
|
||||
case VK_NUMPAD1: return Keyboard::Numpad1;
|
||||
case VK_NUMPAD2: return Keyboard::Numpad2;
|
||||
case VK_NUMPAD3: return Keyboard::Numpad3;
|
||||
case VK_NUMPAD4: return Keyboard::Numpad4;
|
||||
case VK_NUMPAD5: return Keyboard::Numpad5;
|
||||
case VK_NUMPAD6: return Keyboard::Numpad6;
|
||||
case VK_NUMPAD7: return Keyboard::Numpad7;
|
||||
case VK_NUMPAD8: return Keyboard::Numpad8;
|
||||
case VK_NUMPAD9: return Keyboard::Numpad9;
|
||||
case VK_F1: return Keyboard::F1;
|
||||
case VK_F2: return Keyboard::F2;
|
||||
case VK_F3: return Keyboard::F3;
|
||||
case VK_F4: return Keyboard::F4;
|
||||
case VK_F5: return Keyboard::F5;
|
||||
case VK_F6: return Keyboard::F6;
|
||||
case VK_F7: return Keyboard::F7;
|
||||
case VK_F8: return Keyboard::F8;
|
||||
case VK_F9: return Keyboard::F9;
|
||||
case VK_F10: return Keyboard::F10;
|
||||
case VK_F11: return Keyboard::F11;
|
||||
case VK_F12: return Keyboard::F12;
|
||||
case VK_F13: return Keyboard::F13;
|
||||
case VK_F14: return Keyboard::F14;
|
||||
case VK_F15: return Keyboard::F15;
|
||||
case VK_PAUSE: return Keyboard::Pause;
|
||||
default: return Keyboard::Unknown;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
int sfKeyToVirtualKey(Keyboard::Key key)
|
||||
{
|
||||
int virtualKey = 0;
|
||||
switch (key)
|
||||
{
|
||||
default: virtualKey = 0; break;
|
||||
case Keyboard::A: virtualKey = 'A'; break;
|
||||
case Keyboard::B: virtualKey = 'B'; break;
|
||||
case Keyboard::C: virtualKey = 'C'; break;
|
||||
case Keyboard::D: virtualKey = 'D'; break;
|
||||
case Keyboard::E: virtualKey = 'E'; break;
|
||||
case Keyboard::F: virtualKey = 'F'; break;
|
||||
case Keyboard::G: virtualKey = 'G'; break;
|
||||
case Keyboard::H: virtualKey = 'H'; break;
|
||||
case Keyboard::I: virtualKey = 'I'; break;
|
||||
case Keyboard::J: virtualKey = 'J'; break;
|
||||
case Keyboard::K: virtualKey = 'K'; break;
|
||||
case Keyboard::L: virtualKey = 'L'; break;
|
||||
case Keyboard::M: virtualKey = 'M'; break;
|
||||
case Keyboard::N: virtualKey = 'N'; break;
|
||||
case Keyboard::O: virtualKey = 'O'; break;
|
||||
case Keyboard::P: virtualKey = 'P'; break;
|
||||
case Keyboard::Q: virtualKey = 'Q'; break;
|
||||
case Keyboard::R: virtualKey = 'R'; break;
|
||||
case Keyboard::S: virtualKey = 'S'; break;
|
||||
case Keyboard::T: virtualKey = 'T'; break;
|
||||
case Keyboard::U: virtualKey = 'U'; break;
|
||||
case Keyboard::V: virtualKey = 'V'; break;
|
||||
case Keyboard::W: virtualKey = 'W'; break;
|
||||
case Keyboard::X: virtualKey = 'X'; break;
|
||||
case Keyboard::Y: virtualKey = 'Y'; break;
|
||||
case Keyboard::Z: virtualKey = 'Z'; break;
|
||||
case Keyboard::Num0: virtualKey = '0'; break;
|
||||
case Keyboard::Num1: virtualKey = '1'; break;
|
||||
case Keyboard::Num2: virtualKey = '2'; break;
|
||||
case Keyboard::Num3: virtualKey = '3'; break;
|
||||
case Keyboard::Num4: virtualKey = '4'; break;
|
||||
case Keyboard::Num5: virtualKey = '5'; break;
|
||||
case Keyboard::Num6: virtualKey = '6'; break;
|
||||
case Keyboard::Num7: virtualKey = '7'; break;
|
||||
case Keyboard::Num8: virtualKey = '8'; break;
|
||||
case Keyboard::Num9: virtualKey = '9'; break;
|
||||
case Keyboard::Escape: virtualKey = VK_ESCAPE; break;
|
||||
case Keyboard::LControl: virtualKey = VK_LCONTROL; break;
|
||||
case Keyboard::LShift: virtualKey = VK_LSHIFT; break;
|
||||
case Keyboard::LAlt: virtualKey = VK_LMENU; break;
|
||||
case Keyboard::LSystem: virtualKey = VK_LWIN; break;
|
||||
case Keyboard::RControl: virtualKey = VK_RCONTROL; break;
|
||||
case Keyboard::RShift: virtualKey = VK_RSHIFT; break;
|
||||
case Keyboard::RAlt: virtualKey = VK_RMENU; break;
|
||||
case Keyboard::RSystem: virtualKey = VK_RWIN; break;
|
||||
case Keyboard::Menu: virtualKey = VK_APPS; break;
|
||||
case Keyboard::LBracket: virtualKey = VK_OEM_4; break;
|
||||
case Keyboard::RBracket: virtualKey = VK_OEM_6; break;
|
||||
case Keyboard::Semicolon: virtualKey = VK_OEM_1; break;
|
||||
case Keyboard::Comma: virtualKey = VK_OEM_COMMA; break;
|
||||
case Keyboard::Period: virtualKey = VK_OEM_PERIOD; break;
|
||||
case Keyboard::Apostrophe: virtualKey = VK_OEM_7; break;
|
||||
case Keyboard::Slash: virtualKey = VK_OEM_2; break;
|
||||
case Keyboard::Backslash: virtualKey = VK_OEM_5; break;
|
||||
case Keyboard::Grave: virtualKey = VK_OEM_3; break;
|
||||
case Keyboard::Equal: virtualKey = VK_OEM_PLUS; break;
|
||||
case Keyboard::Hyphen: virtualKey = VK_OEM_MINUS; break;
|
||||
case Keyboard::Space: virtualKey = VK_SPACE; break;
|
||||
case Keyboard::Enter: virtualKey = VK_RETURN; break;
|
||||
case Keyboard::Backspace: virtualKey = VK_BACK; break;
|
||||
case Keyboard::Tab: virtualKey = VK_TAB; break;
|
||||
case Keyboard::PageUp: virtualKey = VK_PRIOR; break;
|
||||
case Keyboard::PageDown: virtualKey = VK_NEXT; break;
|
||||
case Keyboard::End: virtualKey = VK_END; break;
|
||||
case Keyboard::Home: virtualKey = VK_HOME; break;
|
||||
case Keyboard::Insert: virtualKey = VK_INSERT; break;
|
||||
case Keyboard::Delete: virtualKey = VK_DELETE; break;
|
||||
case Keyboard::Add: virtualKey = VK_ADD; break;
|
||||
case Keyboard::Subtract: virtualKey = VK_SUBTRACT; break;
|
||||
case Keyboard::Multiply: virtualKey = VK_MULTIPLY; break;
|
||||
case Keyboard::Divide: virtualKey = VK_DIVIDE; break;
|
||||
case Keyboard::Left: virtualKey = VK_LEFT; break;
|
||||
case Keyboard::Right: virtualKey = VK_RIGHT; break;
|
||||
case Keyboard::Up: virtualKey = VK_UP; break;
|
||||
case Keyboard::Down: virtualKey = VK_DOWN; break;
|
||||
case Keyboard::Numpad0: virtualKey = VK_NUMPAD0; break;
|
||||
case Keyboard::Numpad1: virtualKey = VK_NUMPAD1; break;
|
||||
case Keyboard::Numpad2: virtualKey = VK_NUMPAD2; break;
|
||||
case Keyboard::Numpad3: virtualKey = VK_NUMPAD3; break;
|
||||
case Keyboard::Numpad4: virtualKey = VK_NUMPAD4; break;
|
||||
case Keyboard::Numpad5: virtualKey = VK_NUMPAD5; break;
|
||||
case Keyboard::Numpad6: virtualKey = VK_NUMPAD6; break;
|
||||
case Keyboard::Numpad7: virtualKey = VK_NUMPAD7; break;
|
||||
case Keyboard::Numpad8: virtualKey = VK_NUMPAD8; break;
|
||||
case Keyboard::Numpad9: virtualKey = VK_NUMPAD9; break;
|
||||
case Keyboard::F1: virtualKey = VK_F1; break;
|
||||
case Keyboard::F2: virtualKey = VK_F2; break;
|
||||
case Keyboard::F3: virtualKey = VK_F3; break;
|
||||
case Keyboard::F4: virtualKey = VK_F4; break;
|
||||
case Keyboard::F5: virtualKey = VK_F5; break;
|
||||
case Keyboard::F6: virtualKey = VK_F6; break;
|
||||
case Keyboard::F7: virtualKey = VK_F7; break;
|
||||
case Keyboard::F8: virtualKey = VK_F8; break;
|
||||
case Keyboard::F9: virtualKey = VK_F9; break;
|
||||
case Keyboard::F10: virtualKey = VK_F10; break;
|
||||
case Keyboard::F11: virtualKey = VK_F11; break;
|
||||
case Keyboard::F12: virtualKey = VK_F12; break;
|
||||
case Keyboard::F13: virtualKey = VK_F13; break;
|
||||
case Keyboard::F14: virtualKey = VK_F14; break;
|
||||
case Keyboard::F15: virtualKey = VK_F15; break;
|
||||
case Keyboard::Pause: virtualKey = VK_PAUSE; break;
|
||||
{
|
||||
case Keyboard::A: return 'A';
|
||||
case Keyboard::B: return 'B';
|
||||
case Keyboard::C: return 'C';
|
||||
case Keyboard::D: return 'D';
|
||||
case Keyboard::E: return 'E';
|
||||
case Keyboard::F: return 'F';
|
||||
case Keyboard::G: return 'G';
|
||||
case Keyboard::H: return 'H';
|
||||
case Keyboard::I: return 'I';
|
||||
case Keyboard::J: return 'J';
|
||||
case Keyboard::K: return 'K';
|
||||
case Keyboard::L: return 'L';
|
||||
case Keyboard::M: return 'M';
|
||||
case Keyboard::N: return 'N';
|
||||
case Keyboard::O: return 'O';
|
||||
case Keyboard::P: return 'P';
|
||||
case Keyboard::Q: return 'Q';
|
||||
case Keyboard::R: return 'R';
|
||||
case Keyboard::S: return 'S';
|
||||
case Keyboard::T: return 'T';
|
||||
case Keyboard::U: return 'U';
|
||||
case Keyboard::V: return 'V';
|
||||
case Keyboard::W: return 'W';
|
||||
case Keyboard::X: return 'X';
|
||||
case Keyboard::Y: return 'Y';
|
||||
case Keyboard::Z: return 'Z';
|
||||
case Keyboard::Num0: return '0';
|
||||
case Keyboard::Num1: return '1';
|
||||
case Keyboard::Num2: return '2';
|
||||
case Keyboard::Num3: return '3';
|
||||
case Keyboard::Num4: return '4';
|
||||
case Keyboard::Num5: return '5';
|
||||
case Keyboard::Num6: return '6';
|
||||
case Keyboard::Num7: return '7';
|
||||
case Keyboard::Num8: return '8';
|
||||
case Keyboard::Num9: return '9';
|
||||
case Keyboard::Escape: return VK_ESCAPE;
|
||||
case Keyboard::LControl: return VK_LCONTROL;
|
||||
case Keyboard::LShift: return VK_LSHIFT;
|
||||
case Keyboard::LAlt: return VK_LMENU;
|
||||
case Keyboard::LSystem: return VK_LWIN;
|
||||
case Keyboard::RControl: return VK_RCONTROL;
|
||||
case Keyboard::RShift: return VK_RSHIFT;
|
||||
case Keyboard::RAlt: return VK_RMENU;
|
||||
case Keyboard::RSystem: return VK_RWIN;
|
||||
case Keyboard::Menu: return VK_APPS;
|
||||
case Keyboard::LBracket: return VK_OEM_4;
|
||||
case Keyboard::RBracket: return VK_OEM_6;
|
||||
case Keyboard::Semicolon: return VK_OEM_1;
|
||||
case Keyboard::Comma: return VK_OEM_COMMA;
|
||||
case Keyboard::Period: return VK_OEM_PERIOD;
|
||||
case Keyboard::Apostrophe: return VK_OEM_7;
|
||||
case Keyboard::Slash: return VK_OEM_2;
|
||||
case Keyboard::Backslash: return VK_OEM_5;
|
||||
case Keyboard::Grave: return VK_OEM_3;
|
||||
case Keyboard::Equal: return VK_OEM_PLUS;
|
||||
case Keyboard::Hyphen: return VK_OEM_MINUS;
|
||||
case Keyboard::Space: return VK_SPACE;
|
||||
case Keyboard::Enter: return VK_RETURN;
|
||||
case Keyboard::Backspace: return VK_BACK;
|
||||
case Keyboard::Tab: return VK_TAB;
|
||||
case Keyboard::PageUp: return VK_PRIOR;
|
||||
case Keyboard::PageDown: return VK_NEXT;
|
||||
case Keyboard::End: return VK_END;
|
||||
case Keyboard::Home: return VK_HOME;
|
||||
case Keyboard::Insert: return VK_INSERT;
|
||||
case Keyboard::Delete: return VK_DELETE;
|
||||
case Keyboard::Add: return VK_ADD;
|
||||
case Keyboard::Subtract: return VK_SUBTRACT;
|
||||
case Keyboard::Multiply: return VK_MULTIPLY;
|
||||
case Keyboard::Divide: return VK_DIVIDE;
|
||||
case Keyboard::Left: return VK_LEFT;
|
||||
case Keyboard::Right: return VK_RIGHT;
|
||||
case Keyboard::Up: return VK_UP;
|
||||
case Keyboard::Down: return VK_DOWN;
|
||||
case Keyboard::Numpad0: return VK_NUMPAD0;
|
||||
case Keyboard::Numpad1: return VK_NUMPAD1;
|
||||
case Keyboard::Numpad2: return VK_NUMPAD2;
|
||||
case Keyboard::Numpad3: return VK_NUMPAD3;
|
||||
case Keyboard::Numpad4: return VK_NUMPAD4;
|
||||
case Keyboard::Numpad5: return VK_NUMPAD5;
|
||||
case Keyboard::Numpad6: return VK_NUMPAD6;
|
||||
case Keyboard::Numpad7: return VK_NUMPAD7;
|
||||
case Keyboard::Numpad8: return VK_NUMPAD8;
|
||||
case Keyboard::Numpad9: return VK_NUMPAD9;
|
||||
case Keyboard::F1: return VK_F1;
|
||||
case Keyboard::F2: return VK_F2;
|
||||
case Keyboard::F3: return VK_F3;
|
||||
case Keyboard::F4: return VK_F4;
|
||||
case Keyboard::F5: return VK_F5;
|
||||
case Keyboard::F6: return VK_F6;
|
||||
case Keyboard::F7: return VK_F7;
|
||||
case Keyboard::F8: return VK_F8;
|
||||
case Keyboard::F9: return VK_F9;
|
||||
case Keyboard::F10: return VK_F10;
|
||||
case Keyboard::F11: return VK_F11;
|
||||
case Keyboard::F12: return VK_F12;
|
||||
case Keyboard::F13: return VK_F13;
|
||||
case Keyboard::F14: return VK_F14;
|
||||
case Keyboard::F15: return VK_F15;
|
||||
case Keyboard::Pause: return VK_PAUSE;
|
||||
default: return 0;
|
||||
}
|
||||
return virtualKey;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -614,7 +610,7 @@ Keyboard::Scancode InputImpl::delocalize(Keyboard::Key key)
|
||||
String InputImpl::getDescription(Keyboard::Scancode code)
|
||||
{
|
||||
WORD winCode = sfScanToWinScanExtended(code);
|
||||
const int bufSize(1024);
|
||||
const int bufSize = 1024;
|
||||
WCHAR name[bufSize];
|
||||
int result = GetKeyNameText(winCode << 16, name, bufSize);
|
||||
if (result > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user