mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Align and fix mappings and general logic
- Aligned mappings - ScanDash -> ScanHyphen - Numpad keys include Numpad - *Equals -> *Equal - Key 29/42 are Backslash - Key 45 is Non-US Backslash - Add additional media & more scancodes - Rename ScanAgain to ScanRedo - Rename ScanMute to ScanVolumeMute - Add the missing F-key mappings for macOS - Fix mapping in Windows code - Correctly handle numpad keys on Windows for isKeyPressed - Refactorings - Use mapping for Linux from different key config - Refactor some mapping code - Fix map initialization - Layout independent keys also don't have unicode characters, so it makes more sense to translate them first and use unicode as fallback - Fix iteration limits on Windows - Consistently use 'Scancode' instead of 'ScanCode' everywhere - Use 'delocalize' instead of 'unlocalize' - Fix conversion warnings - Remove unused mapping function - Hide parameters for non-applicable iOS functions - Update documentation - Add Android InputImpl scancode function stubs
This commit is contained in:
parent
5bf4982239
commit
39b8d67262
@ -94,18 +94,18 @@ public:
|
|||||||
LControl, //!< The left Control key
|
LControl, //!< The left Control key
|
||||||
LShift, //!< The left Shift key
|
LShift, //!< The left Shift key
|
||||||
LAlt, //!< The left Alt key
|
LAlt, //!< The left Alt key
|
||||||
LSystem, //!< The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
|
LSystem, //!< The left OS specific key: window (Windows and Linux), apple (macOS), ...
|
||||||
RControl, //!< The right Control key
|
RControl, //!< The right Control key
|
||||||
RShift, //!< The right Shift key
|
RShift, //!< The right Shift key
|
||||||
RAlt, //!< The right Alt key
|
RAlt, //!< The right Alt key
|
||||||
RSystem, //!< The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
|
RSystem, //!< The right OS specific key: window (Windows and Linux), apple (macOS), ...
|
||||||
Menu, //!< The Menu key
|
Menu, //!< The Menu key
|
||||||
LBracket, //!< The [ key
|
LBracket, //!< The [ key
|
||||||
RBracket, //!< The ] key
|
RBracket, //!< The ] key
|
||||||
Semicolon, //!< The ; key
|
Semicolon, //!< The ; key
|
||||||
Comma, //!< The , key
|
Comma, //!< The , key
|
||||||
Period, //!< The . key
|
Period, //!< The . key
|
||||||
Quote, //!< The ' key
|
Apostrophe, //!< The ' key
|
||||||
Slash, //!< The / key
|
Slash, //!< The / key
|
||||||
Backslash, //!< The \ key
|
Backslash, //!< The \ key
|
||||||
Tilde, //!< The ~ key
|
Tilde, //!< The ~ key
|
||||||
@ -164,7 +164,8 @@ public:
|
|||||||
BackSpace = Backspace, //!< \deprecated Use Backspace instead
|
BackSpace = Backspace, //!< \deprecated Use Backspace instead
|
||||||
BackSlash = Backslash, //!< \deprecated Use Backslash instead
|
BackSlash = Backslash, //!< \deprecated Use Backslash instead
|
||||||
SemiColon = Semicolon, //!< \deprecated Use Semicolon instead
|
SemiColon = Semicolon, //!< \deprecated Use Semicolon instead
|
||||||
Return = Enter //!< \deprecated Use Enter instead
|
Return = Enter, //!< \deprecated Use Enter instead
|
||||||
|
Quote = Apostrophe //!< \deprecated Use Apostrophe instead
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -174,147 +175,164 @@ public:
|
|||||||
/// the keyboard layout used by the operating system. Usually, the AT-101
|
/// the keyboard layout used by the operating system. Usually, the AT-101
|
||||||
/// keyboard can be used as reference for the physical position of the keys.
|
/// keyboard can be used as reference for the physical position of the keys.
|
||||||
///
|
///
|
||||||
/// The scancodes are based on a subset of Table 12: Keyboard/Keypad Page
|
|
||||||
/// of Universal Serial Bus (USB): HID Usage Tables, v1.12.
|
|
||||||
///
|
|
||||||
/// \todo When porting this for SFML 3, remove the `Scan` prefix and use
|
|
||||||
/// enum class.
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
enum Scancode
|
enum Scancode
|
||||||
{
|
{
|
||||||
ScanUnknown = -1, ///< Represents any scancode not present in this enum
|
ScanUnknown = -1, //!< Represents any scancode not present in this enum
|
||||||
ScanA = 0, ///< Keyboard a and A key
|
ScanA = 0, //!< Keyboard a and A key
|
||||||
ScanB, ///< Keyboard b and B key
|
ScanB, //!< Keyboard b and B key
|
||||||
ScanC, ///< Keyboard c and C key
|
ScanC, //!< Keyboard c and C key
|
||||||
ScanD, ///< Keyboard d and D key
|
ScanD, //!< Keyboard d and D key
|
||||||
ScanE, ///< Keyboard e and E key
|
ScanE, //!< Keyboard e and E key
|
||||||
ScanF, ///< Keyboard f and F key
|
ScanF, //!< Keyboard f and F key
|
||||||
ScanG, ///< Keyboard g and G key
|
ScanG, //!< Keyboard g and G key
|
||||||
ScanH, ///< Keyboard h and H key
|
ScanH, //!< Keyboard h and H key
|
||||||
ScanI, ///< Keyboard i and I key
|
ScanI, //!< Keyboard i and I key
|
||||||
ScanJ, ///< Keyboard j and J key
|
ScanJ, //!< Keyboard j and J key
|
||||||
ScanK, ///< Keyboard k and K key
|
ScanK, //!< Keyboard k and K key
|
||||||
ScanL, ///< Keyboard l and L key
|
ScanL, //!< Keyboard l and L key
|
||||||
ScanM, ///< Keyboard m and M key
|
ScanM, //!< Keyboard m and M key
|
||||||
ScanN, ///< Keyboard n and N key
|
ScanN, //!< Keyboard n and N key
|
||||||
ScanO, ///< Keyboard o and O key
|
ScanO, //!< Keyboard o and O key
|
||||||
ScanP, ///< Keyboard p and P key
|
ScanP, //!< Keyboard p and P key
|
||||||
ScanQ, ///< Keyboard q and Q key
|
ScanQ, //!< Keyboard q and Q key
|
||||||
ScanR, ///< Keyboard r and R key
|
ScanR, //!< Keyboard r and R key
|
||||||
ScanS, ///< Keyboard s and S key
|
ScanS, //!< Keyboard s and S key
|
||||||
ScanT, ///< Keyboard t and T key
|
ScanT, //!< Keyboard t and T key
|
||||||
ScanU, ///< Keyboard u and U key
|
ScanU, //!< Keyboard u and U key
|
||||||
ScanV, ///< Keyboard v and V key
|
ScanV, //!< Keyboard v and V key
|
||||||
ScanW, ///< Keyboard w and W key
|
ScanW, //!< Keyboard w and W key
|
||||||
ScanX, ///< Keyboard x and X key
|
ScanX, //!< Keyboard x and X key
|
||||||
ScanY, ///< Keyboard y and Y key
|
ScanY, //!< Keyboard y and Y key
|
||||||
ScanZ, ///< Keyboard z and Z key
|
ScanZ, //!< Keyboard z and Z key
|
||||||
ScanNum1, ///< Keyboard 1 and ! key
|
ScanNum1, //!< Keyboard 1 and ! key
|
||||||
ScanNum2, ///< Keyboard 2 and @ key
|
ScanNum2, //!< Keyboard 2 and @ key
|
||||||
ScanNum3, ///< Keyboard 3 and # key
|
ScanNum3, //!< Keyboard 3 and # key
|
||||||
ScanNum4, ///< Keyboard 4 and $ key
|
ScanNum4, //!< Keyboard 4 and $ key
|
||||||
ScanNum5, ///< Keyboard 5 and % key
|
ScanNum5, //!< Keyboard 5 and % key
|
||||||
ScanNum6, ///< Keyboard 6 and ^ key
|
ScanNum6, //!< Keyboard 6 and ^ key
|
||||||
ScanNum7, ///< Keyboard 7 and & key
|
ScanNum7, //!< Keyboard 7 and & key
|
||||||
ScanNum8, ///< Keyboard 8 and * key
|
ScanNum8, //!< Keyboard 8 and * key
|
||||||
ScanNum9, ///< Keyboard 9 and ) key
|
ScanNum9, //!< Keyboard 9 and ) key
|
||||||
ScanNum0, ///< Keyboard 0 and ) key
|
ScanNum0, //!< Keyboard 0 and ) key
|
||||||
ScanEnter, ///< Keyboard Enter/Return key
|
ScanEnter, //!< Keyboard Enter/Return key
|
||||||
ScanEscape, ///< Keyboard Escape key
|
ScanEscape, //!< Keyboard Escape key
|
||||||
ScanBackspace, ///< Keyboard Backspace key
|
ScanBackspace, //!< Keyboard Backspace key
|
||||||
ScanTab, ///< Keyboard Tab key
|
ScanTab, //!< Keyboard Tab key
|
||||||
ScanSpace, ///< Keyboard Space key
|
ScanSpace, //!< Keyboard Space key
|
||||||
ScanHyphen, ///< Keyboard - and _ key
|
ScanHyphen, //!< Keyboard - and _ key
|
||||||
ScanEquals, ///< Keyboard = and +
|
ScanEqual, //!< Keyboard = and +
|
||||||
ScanLBracket, ///< Keyboard [ and { key
|
ScanLBracket, //!< Keyboard [ and { key
|
||||||
ScanRBracket, ///< Keyboard ] and } key
|
ScanRBracket, //!< Keyboard ] and } key
|
||||||
ScanBackslash, ///< Keyboard \ and | key
|
// For US keyboards mapped to key 29 (Microsoft Keyboard Scan Code Specification)
|
||||||
ScanDash, ///< Keyboard Non-US # and ~
|
// For Non-US keyboards mapped to key 42 (Microsoft Keyboard Scan Code Specification)
|
||||||
// TODO hyphen vs minus vs dash
|
// Typical language mappings: Belg:£µ` FrCa:<>} Dan:*' Dutch:`´ Fren:µ* Ger:'# Ital:§ù LatAm:[}` Nor:*@ Span:ç} Swed:*' Swiss:$£} UK:~# Brazil:}]
|
||||||
ScanSemicolon, ///< Keyboard ; and : key
|
ScanBackslash, //!< Keyboard \ and | key OR various keys for Non-US keyboards
|
||||||
ScanQuote, ///< Keyboard ' and " key
|
ScanSemicolon, //!< Keyboard ; and : key
|
||||||
ScanGraveAccent, ///< Keyboard ` and ~ key
|
ScanApostrophe, //!< Keyboard ' and " key
|
||||||
ScanComma, ///< Keyboard , and < key
|
ScanGrave, //!< Keyboard ` and ~ key
|
||||||
ScanPeriod, ///< Keyboard . and > key
|
ScanComma, //!< Keyboard , and < key
|
||||||
ScanSlash, ///< Keyboard / and ? key
|
ScanPeriod, //!< Keyboard . and > key
|
||||||
ScanF1, ///< Keyboard F1 key
|
ScanSlash, //!< Keyboard / and ? key
|
||||||
ScanF2, ///< Keyboard F2 key
|
ScanF1, //!< Keyboard F1 key
|
||||||
ScanF3, ///< Keyboard F3 key
|
ScanF2, //!< Keyboard F2 key
|
||||||
ScanF4, ///< Keyboard F4 key
|
ScanF3, //!< Keyboard F3 key
|
||||||
ScanF5, ///< Keyboard F5 key
|
ScanF4, //!< Keyboard F4 key
|
||||||
ScanF6, ///< Keyboard F6 key
|
ScanF5, //!< Keyboard F5 key
|
||||||
ScanF7, ///< Keyboard F7 key
|
ScanF6, //!< Keyboard F6 key
|
||||||
ScanF8, ///< Keyboard F8 key
|
ScanF7, //!< Keyboard F7 key
|
||||||
ScanF9, ///< Keyboard F9 key
|
ScanF8, //!< Keyboard F8 key
|
||||||
ScanF10, ///< Keyboard F10 key
|
ScanF9, //!< Keyboard F9 key
|
||||||
ScanF11, ///< Keyboard F11 key
|
ScanF10, //!< Keyboard F10 key
|
||||||
ScanF12, ///< Keyboard F12 key
|
ScanF11, //!< Keyboard F11 key
|
||||||
ScanF13, ///< Keyboard F13 key
|
ScanF12, //!< Keyboard F12 key
|
||||||
ScanF14, ///< Keyboard F14 key
|
ScanF13, //!< Keyboard F13 key
|
||||||
ScanF15, ///< Keyboard F15 key
|
ScanF14, //!< Keyboard F14 key
|
||||||
ScanCapsLock, ///< Keyboard Caps Lock key
|
ScanF15, //!< Keyboard F15 key
|
||||||
ScanPrintScreen, ///< Keyboard Print Screen key
|
ScanF16, //!< Keyboard F16 key
|
||||||
ScanScrollLock, ///< Keyboard Scroll Lock key
|
ScanF17, //!< Keyboard F17 key
|
||||||
ScanPause, ///< Keyboard Pause key
|
ScanF18, //!< Keyboard F18 key
|
||||||
ScanInsert, ///< Keyboard Insert key
|
ScanF19, //!< Keyboard F19 key
|
||||||
ScanHome, ///< Keyboard Home key
|
ScanF20, //!< Keyboard F20 key
|
||||||
ScanPageUp, ///< Keyboard Page Up key
|
ScanF21, //!< Keyboard F21 key
|
||||||
ScanDelete, ///< Keyboard Delete Forward key
|
ScanF22, //!< Keyboard F22 key
|
||||||
ScanEnd, ///< Keyboard End key
|
ScanF23, //!< Keyboard F23 key
|
||||||
ScanPageDown, ///< Keyboard Page Down key
|
ScanF24, //!< Keyboard F24 key
|
||||||
ScanRight, ///< Keyboard Right Arrow key
|
ScanCapsLock, //!< Keyboard Caps %Lock key
|
||||||
ScanLeft, ///< Keyboard Left Arrow key
|
ScanPrintScreen, //!< Keyboard Print Screen key
|
||||||
ScanDown, ///< Keyboard Down Arrow key
|
ScanScrollLock, //!< Keyboard Scroll %Lock key
|
||||||
ScanUp, ///< Keyboard Up Arrow key
|
ScanPause, //!< Keyboard Pause key
|
||||||
ScanNumLock, ///< Keypad Num Lock and Clear key
|
ScanInsert, //!< Keyboard Insert key
|
||||||
ScanDivide, ///< Keypad / key
|
ScanHome, //!< Keyboard Home key
|
||||||
ScanMultiply, ///< Keypad * key
|
ScanPageUp, //!< Keyboard Page Up key
|
||||||
ScanMinus, ///< Keypad - key
|
ScanDelete, //!< Keyboard Delete Forward key
|
||||||
ScanPlus, ///< Keypad + key
|
ScanEnd, //!< Keyboard End key
|
||||||
ScanNumpadEquals, ///< keypad = key, probably Mac only
|
ScanPageDown, //!< Keyboard Page Down key
|
||||||
ScanNumpadEnter, ///< Keypad Enter/Return key
|
ScanRight, //!< Keyboard Right Arrow key
|
||||||
ScanDecimal, ///< Keypad . and Delete key
|
ScanLeft, //!< Keyboard Left Arrow key
|
||||||
ScanNumpad1, ///< Keypad 1 and End key
|
ScanDown, //!< Keyboard Down Arrow key
|
||||||
ScanNumpad2, ///< Keypad 2 and Down Arrow key
|
ScanUp, //!< Keyboard Up Arrow key
|
||||||
ScanNumpad3, ///< Keypad 3 and Page Down key
|
ScanNumLock, //!< Keypad Num %Lock and Clear key
|
||||||
ScanNumpad4, ///< Keypad 4 and Left Arrow key
|
ScanNumpadDivide, //!< Keypad / key
|
||||||
ScanNumpad5, ///< Keypad 5 key
|
ScanNumpadMultiply, //!< Keypad * key
|
||||||
ScanNumpad6, ///< Keypad 6 and Right Arrow key
|
ScanNumpadMinus, //!< Keypad - key
|
||||||
ScanNumpad7, ///< Keypad 7 and Home key
|
ScanNumpadPlus, //!< Keypad + key
|
||||||
ScanNumpad8, ///< Keypad 8 and Up Arrow key
|
ScanNumpadEqual, //!< keypad = key
|
||||||
ScanNumpad9, ///< Keypad 9 and Page Up key
|
ScanNumpadEnter, //!< Keypad Enter/Return key
|
||||||
ScanNumpad0, ///< Keypad 0 and Insert key
|
ScanNumpadDecimal, //!< Keypad . and Delete key
|
||||||
ScanReverseSolidus, ///< Keyboard Non-US \ and | key
|
ScanNumpad1, //!< Keypad 1 and End key
|
||||||
// FIXME what is this one? Might need better name. The doc says:
|
ScanNumpad2, //!< Keypad 2 and Down Arrow key
|
||||||
// - Typically near the Left-Shift key in AT-102 implementations.
|
ScanNumpad3, //!< Keypad 3 and Page Down key
|
||||||
// - Typical language mappings: Belg:<\> FrCa:«°» Dan:<\> Dutch:]|[ Fren:<> Ger:<|> Ital:<> LatAm:<> Nor:<> Span:<> Swed:<|> Swiss:<\> UK:\| Brazil: \|.
|
ScanNumpad4, //!< Keypad 4 and Left Arrow key
|
||||||
// What is the difference with "regular" \ and | key?
|
ScanNumpad5, //!< Keypad 5 key
|
||||||
ScanApplication, ///< Keyboard Application key
|
ScanNumpad6, //!< Keypad 6 and Right Arrow key
|
||||||
ScanExecute, ///< Keyboard Execute key
|
ScanNumpad7, //!< Keypad 7 and Home key
|
||||||
ScanHelp, ///< Keyboard Help key
|
ScanNumpad8, //!< Keypad 8 and Up Arrow key
|
||||||
ScanMenu, ///< Keyboard Menu key
|
ScanNumpad9, //!< Keypad 9 and Page Up key
|
||||||
ScanSelect, ///< Keyboard Select key
|
ScanNumpad0, //!< Keypad 0 and Insert key
|
||||||
ScanStop, ///< Keyboard Stop key
|
// For US keyboards doesn't exist
|
||||||
ScanAgain, ///< Keyboard Again key
|
// For Non-US keyboards mapped to key 45 (Microsoft Keyboard Scan Code Specification)
|
||||||
ScanUndo, ///< Keyboard Undo key
|
// Typical language mappings: Belg:<\> FrCa:«°» Dan:<\> Dutch:]|[ Fren:<> Ger:<|> Ital:<> LatAm:<> Nor:<> Span:<> Swed:<|> Swiss:<\> UK:\| Brazil: \|.
|
||||||
ScanCut, ///< Keyboard Cut key
|
ScanNonUsBackslash, //!< Keyboard Non-US \ and | key
|
||||||
ScanCopy, ///< Keyboard Copy key
|
ScanApplication, //!< Keyboard Application key
|
||||||
ScanPaste, ///< Keyboard Paste key
|
ScanExecute, //!< Keyboard Execute key
|
||||||
ScanFind, ///< Keyboard Find key
|
ScanModeChange, //!< Keyboard Mode Change key
|
||||||
ScanMute, ///< Keyboard Mute key
|
ScanHelp, //!< Keyboard Help key
|
||||||
ScanVolumeUp, ///< Keyboard Volume Up key
|
ScanMenu, //!< Keyboard Menu key
|
||||||
ScanVolumeDown, ///< Keyboard Volume Down key
|
ScanSelect, //!< Keyboard Select key
|
||||||
ScanLControl, ///< Keyboard Left Control key
|
ScanRedo, //!< Keyboard Redo key
|
||||||
ScanLShift, ///< Keyboard Left Shift key
|
ScanUndo, //!< Keyboard Undo key
|
||||||
ScanLAlt, ///< Keyboard Left Alt key
|
ScanCut, //!< Keyboard Cut key
|
||||||
ScanLSystem, ///< Keyboard Left System key
|
ScanCopy, //!< Keyboard Copy key
|
||||||
ScanRControl, ///< Keyboard Right Control key
|
ScanPaste, //!< Keyboard Paste key
|
||||||
ScanRShift, ///< Keyboard Right Shift key
|
ScanVolumeMute, //!< Keyboard Volume Mute key
|
||||||
ScanRAlt, ///< Keyboard Right Alt key
|
ScanVolumeUp, //!< Keyboard Volume Up key
|
||||||
ScanRSystem, ///< Keyboard Right System key
|
ScanVolumeDown, //!< Keyboard Volume Down key
|
||||||
|
ScanMediaPlayPause, //!< Keyboard Media Play Pause key
|
||||||
|
ScanMediaStop, //!< Keyboard Media Stop key
|
||||||
|
ScanMediaNextTrack, //!< Keyboard Media Next Track key
|
||||||
|
ScanMediaPreviousTrack, //!< Keyboard Media Previous Track key
|
||||||
|
ScanLControl, //!< Keyboard Left Control key
|
||||||
|
ScanLShift, //!< Keyboard Left Shift key
|
||||||
|
ScanLAlt, //!< Keyboard Left Alt key
|
||||||
|
ScanLSystem, //!< Keyboard Left System key
|
||||||
|
ScanRControl, //!< Keyboard Right Control key
|
||||||
|
ScanRShift, //!< Keyboard Right Shift key
|
||||||
|
ScanRAlt, //!< Keyboard Right Alt key
|
||||||
|
ScanRSystem, //!< Keyboard Right System key
|
||||||
|
ScanBack, //!< Keyboard Back key
|
||||||
|
ScanForward, //!< Keyboard Forward key
|
||||||
|
ScanRefresh, //!< Keyboard Refresh key
|
||||||
|
ScanStop, //!< Keyboard Stop key
|
||||||
|
ScanSearch, //!< Keyboard Search key
|
||||||
|
ScanFavorites, //!< Keyboard Favorites key
|
||||||
|
ScanHomePage, //!< Keyboard Home Page key
|
||||||
|
ScanLaunchApplication1, //!< Keyboard Launch Application 1 key
|
||||||
|
ScanLaunchApplication2, //!< Keyboard Launch Application 2 key
|
||||||
|
ScanLaunchMail, //!< Keyboard Launch Mail key
|
||||||
|
ScanLaunchMediaSelect, //!< Keyboard Launch Media Select key
|
||||||
|
|
||||||
ScanCodeCount ///< Keep last -- the total number of scancodes
|
ScancodeCount //!< Keep last -- the total number of scancodes
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -347,7 +365,7 @@ public:
|
|||||||
/// sf::Keyboard::Unknown when the scancode cannot be mapped
|
/// sf::Keyboard::Unknown when the scancode cannot be mapped
|
||||||
/// to a Key.
|
/// to a Key.
|
||||||
///
|
///
|
||||||
/// \see unlocalize
|
/// \see delocalize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Key localize(Scancode code);
|
static Key localize(Scancode code);
|
||||||
@ -355,25 +373,25 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Identify the physical key corresponding to a logical one
|
/// \brief Identify the physical key corresponding to a logical one
|
||||||
///
|
///
|
||||||
/// \param key Key to "unlocalize"
|
/// \param key Key to "delocalize"
|
||||||
///
|
///
|
||||||
/// \return The scancode corresponding to the key under the current
|
/// \return The scancode corresponding to the key under the current
|
||||||
/// keyboard layout used by the operating system, or
|
/// keyboard layout used by the operating system, or
|
||||||
/// sf::Keyboard::ScanUnknown when the key cannot be mapped
|
/// sf::Keyboard::ScanUnknown when the key cannot be mapped
|
||||||
/// to a Keyboard::Scancode.
|
/// to a sf::Keyboard::Scancode.
|
||||||
///
|
///
|
||||||
/// \see localize
|
/// \see localize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Scancode unlocalize(Key key);
|
static Scancode delocalize(Key key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Provide a string representation for a given scancode
|
/// \brief Provide a string representation for a given scancode
|
||||||
///
|
///
|
||||||
/// From a high level point of view, this conversion corresponds
|
/// The returned string is a short, non-technical description of
|
||||||
/// somewhat to the string available through sf::Event::TextEvent
|
/// the key represented with the given scancode. Most effectively
|
||||||
/// when the given physical key is pressed by the user, when no
|
/// used in user interfaces, as the description for the key takes
|
||||||
/// modifiers are involved.
|
/// the users keyboard layout into consideration.
|
||||||
///
|
///
|
||||||
/// \warning The result is OS-dependent: for example, sf::Keyboard::ScanLSystem
|
/// \warning The result is OS-dependent: for example, sf::Keyboard::ScanLSystem
|
||||||
/// is "Left Meta" on Linux, "Left Windows" on Windows and
|
/// is "Left Meta" on Linux, "Left Windows" on Windows and
|
||||||
@ -442,6 +460,10 @@ public:
|
|||||||
/// {
|
/// {
|
||||||
/// // quit...
|
/// // quit...
|
||||||
/// }
|
/// }
|
||||||
|
/// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::ScanGrave))
|
||||||
|
/// {
|
||||||
|
/// // open in-game command line (if it's not already open)
|
||||||
|
/// }
|
||||||
/// \endcode
|
/// \endcode
|
||||||
///
|
///
|
||||||
/// \see sf::Joystick, sf::Mouse, sf::Touch
|
/// \see sf::Joystick, sf::Mouse, sf::Touch
|
||||||
|
@ -43,6 +43,30 @@ bool InputImpl::isKeyPressed(Keyboard::Key /* key */)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InputImpl::isKeyPressed(Keyboard::Scancode /* codes */)
|
||||||
|
{
|
||||||
|
// Not applicable
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keyboard::Key InputImpl::localize(Keyboard::Scancode /* code */)
|
||||||
|
{
|
||||||
|
// Not applicable
|
||||||
|
return Keyboard::Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keyboard::Scancode InputImpl::delocalize(Keyboard::Key /* key */)
|
||||||
|
{
|
||||||
|
// Not applicable
|
||||||
|
return Keyboard::ScanUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
String InputImpl::getDescription(Keyboard::Scancode /* code */)
|
||||||
|
{
|
||||||
|
// Not applicable
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void InputImpl::setVirtualKeyboardVisible(bool visible)
|
void InputImpl::setVirtualKeyboardVisible(bool visible)
|
||||||
{
|
{
|
||||||
|
@ -63,13 +63,13 @@ public:
|
|||||||
static Keyboard::Key localize(Keyboard::Scancode code);
|
static Keyboard::Key localize(Keyboard::Scancode code);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::unlocalize
|
/// \copydoc sf::Keyboard::delocalize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode unlocalize(Keyboard::Key key);
|
static Keyboard::Scancode delocalize(Keyboard::Key key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::localizedRepresentation
|
/// \copydoc sf::Keyboard::getDescription
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static String getDescription(Keyboard::Scancode code);
|
static String getDescription(Keyboard::Scancode code);
|
||||||
|
@ -51,9 +51,9 @@ Keyboard::Key Keyboard::localize(Scancode code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode Keyboard::unlocalize(Key key)
|
Keyboard::Scancode Keyboard::delocalize(Key key)
|
||||||
{
|
{
|
||||||
return priv::InputImpl::unlocalize(key);
|
return priv::InputImpl::delocalize(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -141,17 +141,25 @@ public:
|
|||||||
Keyboard::Key localize(Keyboard::Scancode code);
|
Keyboard::Key localize(Keyboard::Scancode code);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::unlocalize
|
/// \copydoc sf::Keyboard::delocalize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode unlocalize(Keyboard::Key key);
|
Keyboard::Scancode delocalize(Keyboard::Key key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::localizedRepresentation
|
/// \copydoc sf::Keyboard::getDescription
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
String localizedRepresentation(Keyboard::Scancode code);
|
String getDescription(Keyboard::Scancode code);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Regenerate the mappings from/to Key and Scancode.
|
||||||
|
///
|
||||||
|
/// This function is public to allow regular update calls
|
||||||
|
/// from the manager in case there's a keyboard layout change.
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void buildMappings();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -205,17 +213,6 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void loadKey(IOHIDElementRef key);
|
void loadKey(IOHIDElementRef key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
/// Regenerate the mappings from/to Key and Scancode.
|
|
||||||
///
|
|
||||||
/// It is public to allow regular callback to forward the
|
|
||||||
/// information to the manager.
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
public:
|
|
||||||
void buildMappings();
|
|
||||||
private:
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Release all resources
|
/// \brief Release all resources
|
||||||
///
|
///
|
||||||
@ -233,7 +230,7 @@ private:
|
|||||||
///
|
///
|
||||||
/// \param page HID page like kHIDPage_GenericDesktop
|
/// \param page HID page like kHIDPage_GenericDesktop
|
||||||
/// \param usage HID usage page like kHIDUsage_GD_Keyboard or kHIDUsage_GD_Mouse
|
/// \param usage HID usage page like kHIDUsage_GD_Keyboard or kHIDUsage_GD_Mouse
|
||||||
/// \return a retained, non-emtpy CFSetRef of IOHIDDeviceRef or NULL
|
/// \return a retained, non-empty CFSetRef of IOHIDDeviceRef or NULL
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CFSetRef copyDevices(UInt32 page, UInt32 usage);
|
CFSetRef copyDevices(UInt32 page, UInt32 usage);
|
||||||
@ -254,8 +251,8 @@ private:
|
|||||||
/// \brief Convert a HID key usage to its corresponding scancode
|
/// \brief Convert a HID key usage to its corresponding scancode
|
||||||
///
|
///
|
||||||
/// \param usage Any kHIDUsage_Keyboard* usage
|
/// \param usage Any kHIDUsage_Keyboard* usage
|
||||||
/// \return the scancode associate with the given HID key usage
|
/// \return the scancode associated with the given HID key usage
|
||||||
/// or sUnknown if it is associate with no scancode.
|
/// or ScanUnknown if it is associated with no scancode.
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode usageToScancode(UInt32 usage);
|
static Keyboard::Scancode usageToScancode(UInt32 usage);
|
||||||
@ -267,7 +264,7 @@ private:
|
|||||||
static UInt8 scanToVirtualCode(Keyboard::Scancode code);
|
static UInt8 scanToVirtualCode(Keyboard::Scancode code);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Fallback convertion for key that aren't expected to be impacted
|
/// Fallback convertion for keys which aren't expected to be impacted
|
||||||
/// by the layout. Can return Unknown.
|
/// by the layout. Can return Unknown.
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -279,9 +276,9 @@ private:
|
|||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
IOHIDManagerRef m_manager; ///< Underlying HID Manager
|
IOHIDManagerRef m_manager; ///< Underlying HID Manager
|
||||||
IOHIDElements m_keys[Keyboard::ScanCodeCount]; ///< All the keys on any connected keyboard
|
IOHIDElements m_keys[Keyboard::ScancodeCount]; ///< All the keys on any connected keyboard
|
||||||
Keyboard::Scancode m_keyToScancodeMapping[Keyboard::KeyCount]; ///< Mapping from Key to Scancode
|
Keyboard::Scancode m_keyToScancodeMapping[Keyboard::KeyCount]; ///< Mapping from Key to Scancode
|
||||||
Keyboard::Key m_scancodeToKeyMapping[Keyboard::ScanCodeCount]; ///< Mapping from Scancode to Key
|
Keyboard::Key m_scancodeToKeyMapping[Keyboard::ScancodeCount]; ///< Mapping from Scancode to Key
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// m_keys' index corresponds to sf::Keyboard::Scancode enum.
|
/// m_keys' index corresponds to sf::Keyboard::Scancode enum.
|
||||||
|
@ -96,7 +96,7 @@ CFDictionaryRef HIDInputManager::copyDevicesMask(UInt32 page, UInt32 usage)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool HIDInputManager::isKeyPressed(Keyboard::Key key)
|
bool HIDInputManager::isKeyPressed(Keyboard::Key key)
|
||||||
{
|
{
|
||||||
return isKeyPressed(unlocalize(key));
|
return isKeyPressed(delocalize(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ Keyboard::Key HIDInputManager::localize(Keyboard::Scancode code)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode HIDInputManager::unlocalize(Keyboard::Key key)
|
Keyboard::Scancode HIDInputManager::delocalize(Keyboard::Key key)
|
||||||
{
|
{
|
||||||
// TODO ensure mapping is still valid
|
// TODO ensure mapping is still valid
|
||||||
return m_keyToScancodeMapping[key];
|
return m_keyToScancodeMapping[key];
|
||||||
@ -124,13 +124,9 @@ Keyboard::Scancode HIDInputManager::unlocalize(Keyboard::Key key)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
String HIDInputManager::localizedRepresentation(Keyboard::Scancode code)
|
String HIDInputManager::getDescription(Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
UniChar unicode = toUnicode(localize(code));
|
// Phase 1: Get names for layout independent keys
|
||||||
if (unicode != 0x00)
|
|
||||||
return sf::String(static_cast<Uint32>(unicode));
|
|
||||||
|
|
||||||
// Fallback to our best guess for the keys that are known to be independent of the layout.
|
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case sf::Keyboard::ScanEnter: return "Enter";
|
case sf::Keyboard::ScanEnter: return "Enter";
|
||||||
@ -154,6 +150,15 @@ String HIDInputManager::localizedRepresentation(Keyboard::Scancode code)
|
|||||||
case sf::Keyboard::ScanF13: return "F13";
|
case sf::Keyboard::ScanF13: return "F13";
|
||||||
case sf::Keyboard::ScanF14: return "F14";
|
case sf::Keyboard::ScanF14: return "F14";
|
||||||
case sf::Keyboard::ScanF15: return "F15";
|
case sf::Keyboard::ScanF15: return "F15";
|
||||||
|
case sf::Keyboard::ScanF16: return "F16";
|
||||||
|
case sf::Keyboard::ScanF17: return "F17";
|
||||||
|
case sf::Keyboard::ScanF18: return "F18";
|
||||||
|
case sf::Keyboard::ScanF19: return "F19";
|
||||||
|
case sf::Keyboard::ScanF20: return "F20";
|
||||||
|
case sf::Keyboard::ScanF21: return "F21";
|
||||||
|
case sf::Keyboard::ScanF22: return "F22";
|
||||||
|
case sf::Keyboard::ScanF23: return "F23";
|
||||||
|
case sf::Keyboard::ScanF24: return "F24";
|
||||||
|
|
||||||
case sf::Keyboard::ScanCapsLock: return "CapsLock";
|
case sf::Keyboard::ScanCapsLock: return "CapsLock";
|
||||||
case sf::Keyboard::ScanPrintScreen: return "PrintScreen";
|
case sf::Keyboard::ScanPrintScreen: return "PrintScreen";
|
||||||
@ -173,13 +178,13 @@ String HIDInputManager::localizedRepresentation(Keyboard::Scancode code)
|
|||||||
case sf::Keyboard::ScanUp: return "Up Arrow";
|
case sf::Keyboard::ScanUp: return "Up Arrow";
|
||||||
|
|
||||||
case sf::Keyboard::ScanNumLock: return "NumLock";
|
case sf::Keyboard::ScanNumLock: return "NumLock";
|
||||||
case sf::Keyboard::ScanDivide: return "Divide (Numpad)";
|
case sf::Keyboard::ScanNumpadDivide: return "Divide (Numpad)";
|
||||||
case sf::Keyboard::ScanMultiply: return "Multiply (Numpad)";
|
case sf::Keyboard::ScanNumpadMultiply: return "Multiply (Numpad)";
|
||||||
case sf::Keyboard::ScanMinus: return "Minux (Numpad)";
|
case sf::Keyboard::ScanNumpadMinus: return "Minus (Numpad)";
|
||||||
case sf::Keyboard::ScanPlus: return "Plus (Numpad)";
|
case sf::Keyboard::ScanNumpadPlus: return "Plus (Numpad)";
|
||||||
case sf::Keyboard::ScanNumpadEquals: return "Equals (Numpad)";
|
case sf::Keyboard::ScanNumpadEqual: return "Equal (Numpad)";
|
||||||
case sf::Keyboard::ScanNumpadEnter: return "Enter (Numpad)";
|
case sf::Keyboard::ScanNumpadEnter: return "Enter (Numpad)";
|
||||||
case sf::Keyboard::ScanDecimal: return "Decimal (Numpad)";
|
case sf::Keyboard::ScanNumpadDecimal: return "Decimal (Numpad)";
|
||||||
|
|
||||||
case sf::Keyboard::ScanNumpad0: return "0 (Numpad)";
|
case sf::Keyboard::ScanNumpad0: return "0 (Numpad)";
|
||||||
case sf::Keyboard::ScanNumpad1: return "1 (Numpad)";
|
case sf::Keyboard::ScanNumpad1: return "1 (Numpad)";
|
||||||
@ -198,26 +203,35 @@ String HIDInputManager::localizedRepresentation(Keyboard::Scancode code)
|
|||||||
case sf::Keyboard::ScanMenu: return "Menu";
|
case sf::Keyboard::ScanMenu: return "Menu";
|
||||||
case sf::Keyboard::ScanSelect: return "Select";
|
case sf::Keyboard::ScanSelect: return "Select";
|
||||||
case sf::Keyboard::ScanStop: return "Stop";
|
case sf::Keyboard::ScanStop: return "Stop";
|
||||||
case sf::Keyboard::ScanAgain: return "Again";
|
case sf::Keyboard::ScanRedo: return "Redo";
|
||||||
case sf::Keyboard::ScanUndo: return "Undo";
|
case sf::Keyboard::ScanUndo: return "Undo";
|
||||||
case sf::Keyboard::ScanCut: return "Cut";
|
case sf::Keyboard::ScanCut: return "Cut";
|
||||||
case sf::Keyboard::ScanCopy: return "Copy";
|
case sf::Keyboard::ScanCopy: return "Copy";
|
||||||
case sf::Keyboard::ScanPaste: return "Paste";
|
case sf::Keyboard::ScanPaste: return "Paste";
|
||||||
case sf::Keyboard::ScanFind: return "Find";
|
case sf::Keyboard::ScanSearch: return "Search";
|
||||||
case sf::Keyboard::ScanMute: return "Mute";
|
case sf::Keyboard::ScanVolumeMute: return "Volume Mute";
|
||||||
case sf::Keyboard::ScanVolumeUp: return "Volume Up";
|
case sf::Keyboard::ScanVolumeUp: return "Volume Up";
|
||||||
case sf::Keyboard::ScanVolumeDown: return "Volume Down";
|
case sf::Keyboard::ScanVolumeDown: return "Volume Down";
|
||||||
|
|
||||||
case sf::Keyboard::ScanLControl: return "Control (Left)";
|
case sf::Keyboard::ScanLControl: return "Left Control";
|
||||||
case sf::Keyboard::ScanLShift: return "Shift (Left)";
|
case sf::Keyboard::ScanLShift: return "Left Shift";
|
||||||
case sf::Keyboard::ScanLAlt: return "Alt (Left)";
|
case sf::Keyboard::ScanLAlt: return "Left Alt";
|
||||||
case sf::Keyboard::ScanLSystem: return "Command (Left)";
|
case sf::Keyboard::ScanLSystem: return "Left Command";
|
||||||
case sf::Keyboard::ScanRControl: return "Control (Right)";
|
case sf::Keyboard::ScanRControl: return "Right Control";
|
||||||
case sf::Keyboard::ScanRShift: return "Shift (Right)";
|
case sf::Keyboard::ScanRShift: return "Right Shift";
|
||||||
case sf::Keyboard::ScanRAlt: return "Alt (Right)";
|
case sf::Keyboard::ScanRAlt: return "Right Alt";
|
||||||
case sf::Keyboard::ScanRSystem: return "Command (Right)";
|
case sf::Keyboard::ScanRSystem: return "Right Command";
|
||||||
|
|
||||||
default: return "Unknown Scancode"; // no guess good enough possible.
|
default:
|
||||||
|
{
|
||||||
|
// Phase 2: Try to convert the key to unicode
|
||||||
|
UniChar unicode = toUnicode(localize(code));
|
||||||
|
if (unicode != 0x00)
|
||||||
|
return sf::String(static_cast<Uint32>(unicode));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Phase 3: Return final fallback
|
||||||
|
return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +344,7 @@ void HIDInputManager::buildMappings()
|
|||||||
// Reset the mappings
|
// Reset the mappings
|
||||||
for (int i = 0; i < Keyboard::KeyCount; ++i)
|
for (int i = 0; i < Keyboard::KeyCount; ++i)
|
||||||
m_keyToScancodeMapping[i] = Keyboard::ScanUnknown;
|
m_keyToScancodeMapping[i] = Keyboard::ScanUnknown;
|
||||||
for (int i = 0; i < Keyboard::ScanCodeCount; ++i)
|
for (int i = 0; i < Keyboard::ScancodeCount; ++i)
|
||||||
m_scancodeToKeyMapping[i] = Keyboard::Unknown;
|
m_scancodeToKeyMapping[i] = Keyboard::Unknown;
|
||||||
|
|
||||||
// Get the current keyboard layout
|
// Get the current keyboard layout
|
||||||
@ -344,11 +358,11 @@ void HIDInputManager::buildMappings()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UCKeyboardLayout* layout = reinterpret_cast<UCKeyboardLayout*>(CFDataGetBytePtr(layoutData));
|
UCKeyboardLayout* layout = reinterpret_cast<UCKeyboardLayout*>(const_cast<UInt8*>(CFDataGetBytePtr(layoutData)));
|
||||||
|
|
||||||
// For each scancode having a IOHIDElement, we translate the corresponding
|
// For each scancode having a IOHIDElement, we translate the corresponding
|
||||||
// virtual code to a localized Key.
|
// virtual code to a localized Key.
|
||||||
for (int i = 0; i < Keyboard::ScanCodeCount; ++i)
|
for (int i = 0; i < Keyboard::ScancodeCount; ++i)
|
||||||
{
|
{
|
||||||
Keyboard::Scancode scan = static_cast<Keyboard::Scancode>(i);
|
Keyboard::Scancode scan = static_cast<Keyboard::Scancode>(i);
|
||||||
UInt8 virtualCode = scanToVirtualCode(scan);
|
UInt8 virtualCode = scanToVirtualCode(scan);
|
||||||
@ -375,9 +389,11 @@ void HIDInputManager::buildMappings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Keyboard::Key code = (length > 0) ? localizedKey(string[0]) : Keyboard::Unknown;
|
Keyboard::Key code = (length > 0) ? localizedKey(string[0]) : Keyboard::Unknown;
|
||||||
if (code == Keyboard::Unknown) code = localizedKeyFallback(scan);
|
|
||||||
|
|
||||||
if (code == Keyboard::Unknown) continue;
|
if (code == Keyboard::Unknown)
|
||||||
|
code = localizedKeyFallback(scan);
|
||||||
|
if (code == Keyboard::Unknown)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Register the bi-mapping
|
// Register the bi-mapping
|
||||||
m_keyToScancodeMapping[code] = scan;
|
m_keyToScancodeMapping[code] = scan;
|
||||||
@ -513,14 +529,14 @@ sf::Keyboard::Scancode HIDInputManager::usageToScancode(UInt32 usage)
|
|||||||
case kHIDUsage_KeyboardTab: return sf::Keyboard::ScanTab;
|
case kHIDUsage_KeyboardTab: return sf::Keyboard::ScanTab;
|
||||||
case kHIDUsage_KeyboardSpacebar: return sf::Keyboard::ScanSpace;
|
case kHIDUsage_KeyboardSpacebar: return sf::Keyboard::ScanSpace;
|
||||||
case kHIDUsage_KeyboardHyphen: return sf::Keyboard::ScanHyphen;
|
case kHIDUsage_KeyboardHyphen: return sf::Keyboard::ScanHyphen;
|
||||||
case kHIDUsage_KeyboardEqualSign: return sf::Keyboard::ScanEquals;
|
case kHIDUsage_KeyboardEqualSign: return sf::Keyboard::ScanEqual;
|
||||||
case kHIDUsage_KeyboardOpenBracket: return sf::Keyboard::ScanLBracket;
|
case kHIDUsage_KeyboardOpenBracket: return sf::Keyboard::ScanLBracket;
|
||||||
case kHIDUsage_KeyboardCloseBracket: return sf::Keyboard::ScanRBracket;
|
case kHIDUsage_KeyboardCloseBracket: return sf::Keyboard::ScanRBracket;
|
||||||
case kHIDUsage_KeyboardBackslash: return sf::Keyboard::ScanBackslash;
|
case kHIDUsage_KeyboardBackslash: return sf::Keyboard::ScanBackslash;
|
||||||
case kHIDUsage_KeyboardNonUSPound: return sf::Keyboard::ScanDash;
|
case kHIDUsage_KeyboardNonUSPound: return sf::Keyboard::ScanBackslash;
|
||||||
case kHIDUsage_KeyboardSemicolon: return sf::Keyboard::ScanSemicolon;
|
case kHIDUsage_KeyboardSemicolon: return sf::Keyboard::ScanSemicolon;
|
||||||
case kHIDUsage_KeyboardQuote: return sf::Keyboard::ScanQuote;
|
case kHIDUsage_KeyboardQuote: return sf::Keyboard::ScanApostrophe;
|
||||||
case kHIDUsage_KeyboardGraveAccentAndTilde: return sf::Keyboard::ScanGraveAccent;
|
case kHIDUsage_KeyboardGraveAccentAndTilde: return sf::Keyboard::ScanGrave;
|
||||||
case kHIDUsage_KeyboardComma: return sf::Keyboard::ScanComma;
|
case kHIDUsage_KeyboardComma: return sf::Keyboard::ScanComma;
|
||||||
case kHIDUsage_KeyboardPeriod: return sf::Keyboard::ScanPeriod;
|
case kHIDUsage_KeyboardPeriod: return sf::Keyboard::ScanPeriod;
|
||||||
case kHIDUsage_KeyboardSlash: return sf::Keyboard::ScanSlash;
|
case kHIDUsage_KeyboardSlash: return sf::Keyboard::ScanSlash;
|
||||||
@ -555,11 +571,13 @@ sf::Keyboard::Scancode HIDInputManager::usageToScancode(UInt32 usage)
|
|||||||
case kHIDUsage_KeyboardUpArrow: return sf::Keyboard::ScanUp;
|
case kHIDUsage_KeyboardUpArrow: return sf::Keyboard::ScanUp;
|
||||||
|
|
||||||
case kHIDUsage_KeypadNumLock: return sf::Keyboard::ScanNumLock;
|
case kHIDUsage_KeypadNumLock: return sf::Keyboard::ScanNumLock;
|
||||||
case kHIDUsage_KeypadSlash: return sf::Keyboard::ScanDivide;
|
case kHIDUsage_KeypadSlash: return sf::Keyboard::ScanNumpadDivide;
|
||||||
case kHIDUsage_KeypadAsterisk: return sf::Keyboard::ScanMultiply;
|
case kHIDUsage_KeypadAsterisk: return sf::Keyboard::ScanNumpadMultiply;
|
||||||
case kHIDUsage_KeypadHyphen: return sf::Keyboard::ScanMinus;
|
case kHIDUsage_KeypadHyphen: return sf::Keyboard::ScanNumpadMinus;
|
||||||
case kHIDUsage_KeypadPlus: return sf::Keyboard::ScanPlus;
|
case kHIDUsage_KeypadPlus: return sf::Keyboard::ScanNumpadPlus;
|
||||||
case kHIDUsage_KeypadEnter: return sf::Keyboard::ScanEnter;
|
case kHIDUsage_KeypadEqualSign: return sf::Keyboard::ScanNumpadEqual;
|
||||||
|
case kHIDUsage_KeypadEnter: return sf::Keyboard::ScanNumpadEnter;
|
||||||
|
case kHIDUsage_KeypadPeriod: return sf::Keyboard::ScanNumpadDecimal;
|
||||||
|
|
||||||
case kHIDUsage_Keypad1: return sf::Keyboard::ScanNumpad1;
|
case kHIDUsage_Keypad1: return sf::Keyboard::ScanNumpad1;
|
||||||
case kHIDUsage_Keypad2: return sf::Keyboard::ScanNumpad2;
|
case kHIDUsage_Keypad2: return sf::Keyboard::ScanNumpad2;
|
||||||
@ -572,38 +590,36 @@ sf::Keyboard::Scancode HIDInputManager::usageToScancode(UInt32 usage)
|
|||||||
case kHIDUsage_Keypad9: return sf::Keyboard::ScanNumpad9;
|
case kHIDUsage_Keypad9: return sf::Keyboard::ScanNumpad9;
|
||||||
case kHIDUsage_Keypad0: return sf::Keyboard::ScanNumpad0;
|
case kHIDUsage_Keypad0: return sf::Keyboard::ScanNumpad0;
|
||||||
|
|
||||||
case kHIDUsage_KeypadPeriod: return sf::Keyboard::ScanDecimal;
|
case kHIDUsage_KeyboardNonUSBackslash: return sf::Keyboard::ScanNonUsBackslash;
|
||||||
case kHIDUsage_KeyboardNonUSBackslash: return sf::Keyboard::ScanReverseSolidus;
|
|
||||||
case kHIDUsage_KeyboardApplication: return sf::Keyboard::ScanApplication;
|
case kHIDUsage_KeyboardApplication: return sf::Keyboard::ScanApplication;
|
||||||
case kHIDUsage_KeyboardPower: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardPower: return sf::Keyboard::ScanUnknown;
|
||||||
case kHIDUsage_KeypadEqualSign: return sf::Keyboard::ScanNumpadEquals;
|
|
||||||
|
|
||||||
case kHIDUsage_KeyboardF13: return sf::Keyboard::ScanF13;
|
case kHIDUsage_KeyboardF13: return sf::Keyboard::ScanF13;
|
||||||
case kHIDUsage_KeyboardF14: return sf::Keyboard::ScanF14;
|
case kHIDUsage_KeyboardF14: return sf::Keyboard::ScanF14;
|
||||||
case kHIDUsage_KeyboardF15: return sf::Keyboard::ScanF15;
|
case kHIDUsage_KeyboardF15: return sf::Keyboard::ScanF15;
|
||||||
case kHIDUsage_KeyboardF16: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF16: return sf::Keyboard::ScanF16;
|
||||||
case kHIDUsage_KeyboardF17: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF17: return sf::Keyboard::ScanF17;
|
||||||
case kHIDUsage_KeyboardF18: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF18: return sf::Keyboard::ScanF18;
|
||||||
case kHIDUsage_KeyboardF19: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF19: return sf::Keyboard::ScanF19;
|
||||||
case kHIDUsage_KeyboardF20: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF20: return sf::Keyboard::ScanF20;
|
||||||
case kHIDUsage_KeyboardF21: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF21: return sf::Keyboard::ScanF21;
|
||||||
case kHIDUsage_KeyboardF22: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF22: return sf::Keyboard::ScanF22;
|
||||||
case kHIDUsage_KeyboardF23: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF23: return sf::Keyboard::ScanF23;
|
||||||
case kHIDUsage_KeyboardF24: return sf::Keyboard::ScanUnknown;
|
case kHIDUsage_KeyboardF24: return sf::Keyboard::ScanF24;
|
||||||
|
|
||||||
case kHIDUsage_KeyboardExecute: return sf::Keyboard::ScanExecute;
|
case kHIDUsage_KeyboardExecute: return sf::Keyboard::ScanExecute;
|
||||||
case kHIDUsage_KeyboardHelp: return sf::Keyboard::ScanHelp;
|
case kHIDUsage_KeyboardHelp: return sf::Keyboard::ScanHelp;
|
||||||
case kHIDUsage_KeyboardMenu: return sf::Keyboard::ScanMenu;
|
case kHIDUsage_KeyboardMenu: return sf::Keyboard::ScanMenu;
|
||||||
case kHIDUsage_KeyboardSelect: return sf::Keyboard::ScanSelect;
|
case kHIDUsage_KeyboardSelect: return sf::Keyboard::ScanSelect;
|
||||||
case kHIDUsage_KeyboardStop: return sf::Keyboard::ScanStop;
|
case kHIDUsage_KeyboardStop: return sf::Keyboard::ScanStop;
|
||||||
case kHIDUsage_KeyboardAgain: return sf::Keyboard::ScanAgain;
|
case kHIDUsage_KeyboardAgain: return sf::Keyboard::ScanRedo;
|
||||||
case kHIDUsage_KeyboardUndo: return sf::Keyboard::ScanUndo;
|
case kHIDUsage_KeyboardUndo: return sf::Keyboard::ScanUndo;
|
||||||
case kHIDUsage_KeyboardCut: return sf::Keyboard::ScanCut;
|
case kHIDUsage_KeyboardCut: return sf::Keyboard::ScanCut;
|
||||||
case kHIDUsage_KeyboardCopy: return sf::Keyboard::ScanCopy;
|
case kHIDUsage_KeyboardCopy: return sf::Keyboard::ScanCopy;
|
||||||
case kHIDUsage_KeyboardPaste: return sf::Keyboard::ScanPaste;
|
case kHIDUsage_KeyboardPaste: return sf::Keyboard::ScanPaste;
|
||||||
case kHIDUsage_KeyboardFind: return sf::Keyboard::ScanFind;
|
case kHIDUsage_KeyboardFind: return sf::Keyboard::ScanSearch;
|
||||||
|
|
||||||
case kHIDUsage_KeyboardMute: return sf::Keyboard::ScanMute;
|
case kHIDUsage_KeyboardMute: return sf::Keyboard::ScanVolumeMute;
|
||||||
case kHIDUsage_KeyboardVolumeUp: return sf::Keyboard::ScanVolumeUp;
|
case kHIDUsage_KeyboardVolumeUp: return sf::Keyboard::ScanVolumeUp;
|
||||||
case kHIDUsage_KeyboardVolumeDown: return sf::Keyboard::ScanVolumeDown;
|
case kHIDUsage_KeyboardVolumeDown: return sf::Keyboard::ScanVolumeDown;
|
||||||
|
|
||||||
@ -1000,15 +1016,15 @@ Keyboard::Scancode HIDInputManager::nonLocalizedKey(UniChar virtualKeycode)
|
|||||||
case 0x33: return sf::Keyboard::ScanBackspace;
|
case 0x33: return sf::Keyboard::ScanBackspace;
|
||||||
case 0x30: return sf::Keyboard::ScanTab;
|
case 0x30: return sf::Keyboard::ScanTab;
|
||||||
case 0x31: return sf::Keyboard::ScanSpace;
|
case 0x31: return sf::Keyboard::ScanSpace;
|
||||||
// case 0x27: return sf::Keyboard::ScanHyphen; // TODO 0x27 is for Quote
|
|
||||||
case 0x18: return sf::Keyboard::ScanEquals;
|
case 0x18: return sf::Keyboard::ScanEqual;
|
||||||
case 0x21: return sf::Keyboard::ScanLBracket;
|
case 0x21: return sf::Keyboard::ScanLBracket;
|
||||||
case 0x1e: return sf::Keyboard::ScanRBracket;
|
case 0x1e: return sf::Keyboard::ScanRBracket;
|
||||||
case 0x2a: return sf::Keyboard::ScanBackslash;
|
case 0x2a: return sf::Keyboard::ScanBackslash;
|
||||||
case 0x1b: return sf::Keyboard::ScanDash;
|
case 0x1b: return sf::Keyboard::ScanHyphen;
|
||||||
case 0x29: return sf::Keyboard::ScanSemicolon;
|
case 0x29: return sf::Keyboard::ScanSemicolon;
|
||||||
case 0x27: return sf::Keyboard::ScanQuote;
|
case 0x27: return sf::Keyboard::ScanApostrophe;
|
||||||
case 0x32: return sf::Keyboard::ScanGraveAccent;
|
case 0x32: return sf::Keyboard::ScanGrave;
|
||||||
case 0x2b: return sf::Keyboard::ScanComma;
|
case 0x2b: return sf::Keyboard::ScanComma;
|
||||||
case 0x2f: return sf::Keyboard::ScanPeriod;
|
case 0x2f: return sf::Keyboard::ScanPeriod;
|
||||||
case 0x2c: return sf::Keyboard::ScanSlash;
|
case 0x2c: return sf::Keyboard::ScanSlash;
|
||||||
@ -1029,6 +1045,19 @@ Keyboard::Scancode HIDInputManager::nonLocalizedKey(UniChar virtualKeycode)
|
|||||||
case 0x6b: return sf::Keyboard::ScanF14;
|
case 0x6b: return sf::Keyboard::ScanF14;
|
||||||
case 0x71: return sf::Keyboard::ScanF15;
|
case 0x71: return sf::Keyboard::ScanF15;
|
||||||
|
|
||||||
|
case 0x6A: return sf::Keyboard::ScanF16;
|
||||||
|
case 0x40: return sf::Keyboard::ScanF17;
|
||||||
|
case 0x4F: return sf::Keyboard::ScanF18;
|
||||||
|
case 0x50: return sf::Keyboard::ScanF19;
|
||||||
|
case 0x5A: return sf::Keyboard::ScanF20;
|
||||||
|
|
||||||
|
/* TODO Those are missing:
|
||||||
|
* case 0x: return sf::Keyboard::ScanF21;
|
||||||
|
* case 0x: return sf::Keyboard::ScanF22;
|
||||||
|
* case 0x: return sf::Keyboard::ScanF23;
|
||||||
|
* case 0x: return sf::Keyboard::ScanF24;
|
||||||
|
*/
|
||||||
|
|
||||||
case 0x39: return sf::Keyboard::ScanCapsLock;
|
case 0x39: return sf::Keyboard::ScanCapsLock;
|
||||||
|
|
||||||
/* TODO Those are missing:
|
/* TODO Those are missing:
|
||||||
@ -1050,13 +1079,13 @@ Keyboard::Scancode HIDInputManager::nonLocalizedKey(UniChar virtualKeycode)
|
|||||||
case 0x7e: return sf::Keyboard::ScanUp;
|
case 0x7e: return sf::Keyboard::ScanUp;
|
||||||
|
|
||||||
case 0x47: return sf::Keyboard::ScanNumLock;
|
case 0x47: return sf::Keyboard::ScanNumLock;
|
||||||
case 0x4b: return sf::Keyboard::ScanDivide;
|
case 0x4b: return sf::Keyboard::ScanNumpadDivide;
|
||||||
case 0x43: return sf::Keyboard::ScanMultiply;
|
case 0x43: return sf::Keyboard::ScanNumpadMultiply;
|
||||||
case 0x4e: return sf::Keyboard::ScanMinus;
|
case 0x4e: return sf::Keyboard::ScanNumpadMinus;
|
||||||
case 0x45: return sf::Keyboard::ScanPlus;
|
case 0x45: return sf::Keyboard::ScanNumpadPlus;
|
||||||
case 0x51: return sf::Keyboard::ScanNumpadEquals;
|
case 0x51: return sf::Keyboard::ScanNumpadEqual;
|
||||||
case 0x4c: return sf::Keyboard::ScanNumpadEnter;
|
case 0x4c: return sf::Keyboard::ScanNumpadEnter;
|
||||||
case 0x41: return sf::Keyboard::ScanDecimal;
|
case 0x41: return sf::Keyboard::ScanNumpadDecimal;
|
||||||
|
|
||||||
case 0x53: return sf::Keyboard::ScanNumpad1;
|
case 0x53: return sf::Keyboard::ScanNumpad1;
|
||||||
case 0x54: return sf::Keyboard::ScanNumpad2;
|
case 0x54: return sf::Keyboard::ScanNumpad2;
|
||||||
@ -1070,22 +1099,22 @@ Keyboard::Scancode HIDInputManager::nonLocalizedKey(UniChar virtualKeycode)
|
|||||||
case 0x52: return sf::Keyboard::ScanNumpad0;
|
case 0x52: return sf::Keyboard::ScanNumpad0;
|
||||||
|
|
||||||
/* TODO Those are missing:
|
/* TODO Those are missing:
|
||||||
* case 0x: return sf::Keyboard::ScanReverseSolidus;
|
* case 0x: return sf::Keyboard::ScanNonUsBackslash;
|
||||||
* case 0x: return sf::Keyboard::ScanApplication;
|
* case 0x: return sf::Keyboard::ScanApplication;
|
||||||
* case 0x: return sf::Keyboard::ScanExecute;
|
* case 0x: return sf::Keyboard::ScanExecute;
|
||||||
* case 0x72: return sf::Keyboard::ScanHelp; // 0x72 is for Insert
|
* case 0x: return sf::Keyboard::ScanHelp;
|
||||||
* case 0x: return sf::Keyboard::ScanMenu;
|
* case 0x: return sf::Keyboard::ScanMenu;
|
||||||
* case 0x: return sf::Keyboard::ScanSelect;
|
* case 0x: return sf::Keyboard::ScanSelect;
|
||||||
* case 0x: return sf::Keyboard::ScanStop;
|
* case 0x: return sf::Keyboard::ScanStop;
|
||||||
* case 0x: return sf::Keyboard::ScanAgain;
|
* case 0x: return sf::Keyboard::ScanRedo;
|
||||||
* case 0x: return sf::Keyboard::ScanUndo;
|
* case 0x: return sf::Keyboard::ScanUndo;
|
||||||
* case 0x: return sf::Keyboard::ScanCut;
|
* case 0x: return sf::Keyboard::ScanCut;
|
||||||
* case 0x: return sf::Keyboard::ScanCopy;
|
* case 0x: return sf::Keyboard::ScanCopy;
|
||||||
* case 0x: return sf::Keyboard::ScanPaste;
|
* case 0x: return sf::Keyboard::ScanPaste;
|
||||||
* case 0x: return sf::Keyboard::ScanFind;
|
* case 0x: return sf::Keyboard::ScanSearch;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case 0x4a: return sf::Keyboard::ScanMute;
|
case 0x4a: return sf::Keyboard::ScanVolumeMute;
|
||||||
case 0x48: return sf::Keyboard::ScanVolumeUp;
|
case 0x48: return sf::Keyboard::ScanVolumeUp;
|
||||||
case 0x49: return sf::Keyboard::ScanVolumeDown;
|
case 0x49: return sf::Keyboard::ScanVolumeDown;
|
||||||
|
|
||||||
@ -1155,16 +1184,14 @@ UInt8 HIDInputManager::scanToVirtualCode(Keyboard::Scancode code)
|
|||||||
case sf::Keyboard::ScanTab: return 0x30;
|
case sf::Keyboard::ScanTab: return 0x30;
|
||||||
case sf::Keyboard::ScanSpace: return 0x31;
|
case sf::Keyboard::ScanSpace: return 0x31;
|
||||||
|
|
||||||
// case sf::Keyboard::ScanHyphen: return 0; // 0x27 is for Quote
|
case sf::Keyboard::ScanEqual: return 0x18;
|
||||||
|
|
||||||
case sf::Keyboard::ScanEquals: return 0x18;
|
|
||||||
case sf::Keyboard::ScanLBracket: return 0x21;
|
case sf::Keyboard::ScanLBracket: return 0x21;
|
||||||
case sf::Keyboard::ScanRBracket: return 0x1e;
|
case sf::Keyboard::ScanRBracket: return 0x1e;
|
||||||
case sf::Keyboard::ScanBackslash: return 0x2a;
|
case sf::Keyboard::ScanBackslash: return 0x2a;
|
||||||
case sf::Keyboard::ScanDash: return 0x1b;
|
case sf::Keyboard::ScanHyphen: return 0x1b;
|
||||||
case sf::Keyboard::ScanSemicolon: return 0x29;
|
case sf::Keyboard::ScanSemicolon: return 0x29;
|
||||||
case sf::Keyboard::ScanQuote: return 0x27;
|
case sf::Keyboard::ScanApostrophe: return 0x27;
|
||||||
case sf::Keyboard::ScanGraveAccent: return 0x32;
|
case sf::Keyboard::ScanGrave: return 0x32;
|
||||||
case sf::Keyboard::ScanComma: return 0x2b;
|
case sf::Keyboard::ScanComma: return 0x2b;
|
||||||
case sf::Keyboard::ScanPeriod: return 0x2f;
|
case sf::Keyboard::ScanPeriod: return 0x2f;
|
||||||
case sf::Keyboard::ScanSlash: return 0x2c;
|
case sf::Keyboard::ScanSlash: return 0x2c;
|
||||||
@ -1205,13 +1232,13 @@ UInt8 HIDInputManager::scanToVirtualCode(Keyboard::Scancode code)
|
|||||||
case sf::Keyboard::ScanUp: return 0x7e;
|
case sf::Keyboard::ScanUp: return 0x7e;
|
||||||
|
|
||||||
case sf::Keyboard::ScanNumLock: return 0x47;
|
case sf::Keyboard::ScanNumLock: return 0x47;
|
||||||
case sf::Keyboard::ScanDivide: return 0x4b;
|
case sf::Keyboard::ScanNumpadDivide: return 0x4b;
|
||||||
case sf::Keyboard::ScanMultiply: return 0x43;
|
case sf::Keyboard::ScanNumpadMultiply: return 0x43;
|
||||||
case sf::Keyboard::ScanMinus: return 0x4e;
|
case sf::Keyboard::ScanNumpadMinus: return 0x4e;
|
||||||
case sf::Keyboard::ScanPlus: return 0x45;
|
case sf::Keyboard::ScanNumpadPlus: return 0x45;
|
||||||
case sf::Keyboard::ScanNumpadEquals: return 0x51;
|
case sf::Keyboard::ScanNumpadEqual: return 0x51;
|
||||||
case sf::Keyboard::ScanNumpadEnter: return 0x4c;
|
case sf::Keyboard::ScanNumpadEnter: return 0x4c;
|
||||||
case sf::Keyboard::ScanDecimal: return 0x41;
|
case sf::Keyboard::ScanNumpadDecimal: return 0x41;
|
||||||
|
|
||||||
case sf::Keyboard::ScanNumpad1: return 0x53;
|
case sf::Keyboard::ScanNumpad1: return 0x53;
|
||||||
case sf::Keyboard::ScanNumpad2: return 0x54;
|
case sf::Keyboard::ScanNumpad2: return 0x54;
|
||||||
@ -1225,22 +1252,22 @@ UInt8 HIDInputManager::scanToVirtualCode(Keyboard::Scancode code)
|
|||||||
case sf::Keyboard::ScanNumpad0: return 0x52;
|
case sf::Keyboard::ScanNumpad0: return 0x52;
|
||||||
|
|
||||||
/* TODO Those are missing:
|
/* TODO Those are missing:
|
||||||
* case sf::Keyboard::ScanReverseSolidus: return 0;
|
* case sf::Keyboard::ScanNonUsBackslash: return 0;
|
||||||
* case sf::Keyboard::ScanApplication: return 0;
|
* case sf::Keyboard::ScanApplication: return 0;
|
||||||
* case sf::Keyboard::ScanExecute: return 0;
|
* case sf::Keyboard::ScanExecute: return 0;
|
||||||
* case sf::Keyboard::ScanHelp: return 0;
|
* case sf::Keyboard::ScanHelp: return 0;
|
||||||
* case sf::Keyboard::ScanMenu: return 0;
|
* case sf::Keyboard::ScanMenu: return 0;
|
||||||
* case sf::Keyboard::ScanSelect: return 0;
|
* case sf::Keyboard::ScanSelect: return 0;
|
||||||
* case sf::Keyboard::ScanStop: return 0;
|
* case sf::Keyboard::ScanStop: return 0;
|
||||||
* case sf::Keyboard::ScanAgain: return 0;
|
* case sf::Keyboard::ScanRedo: return 0;
|
||||||
* case sf::Keyboard::ScanUndo: return 0;
|
* case sf::Keyboard::ScanUndo: return 0;
|
||||||
* case sf::Keyboard::ScanCut: return 0;
|
* case sf::Keyboard::ScanCut: return 0;
|
||||||
* case sf::Keyboard::ScanCopy: return 0;
|
* case sf::Keyboard::ScanCopy: return 0;
|
||||||
* case sf::Keyboard::ScanPaste: return 0;
|
* case sf::Keyboard::ScanPaste: return 0;
|
||||||
* case sf::Keyboard::ScanFind: return 0;
|
* case sf::Keyboard::ScanSearch: return 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
case sf::Keyboard::ScanMute: return 0x4a;
|
case sf::Keyboard::ScanVolumeMute: return 0x4a;
|
||||||
case sf::Keyboard::ScanVolumeUp: return 0x48;
|
case sf::Keyboard::ScanVolumeUp: return 0x48;
|
||||||
case sf::Keyboard::ScanVolumeDown: return 0x49;
|
case sf::Keyboard::ScanVolumeDown: return 0x49;
|
||||||
|
|
||||||
@ -1298,10 +1325,10 @@ Keyboard::Key HIDInputManager::localizedKeyFallback(Keyboard::Scancode code)
|
|||||||
case sf::Keyboard::ScanDown: return sf::Keyboard::Down;
|
case sf::Keyboard::ScanDown: return sf::Keyboard::Down;
|
||||||
case sf::Keyboard::ScanUp: return sf::Keyboard::Up;
|
case sf::Keyboard::ScanUp: return sf::Keyboard::Up;
|
||||||
|
|
||||||
case sf::Keyboard::ScanDivide: return sf::Keyboard::Divide;
|
case sf::Keyboard::ScanNumpadDivide: return sf::Keyboard::Divide;
|
||||||
case sf::Keyboard::ScanMultiply: return sf::Keyboard::Multiply;
|
case sf::Keyboard::ScanNumpadMultiply: return sf::Keyboard::Multiply;
|
||||||
case sf::Keyboard::ScanMinus: return sf::Keyboard::Subtract;
|
case sf::Keyboard::ScanNumpadMinus: return sf::Keyboard::Subtract;
|
||||||
case sf::Keyboard::ScanPlus: return sf::Keyboard::Add;
|
case sf::Keyboard::ScanNumpadPlus: return sf::Keyboard::Add;
|
||||||
|
|
||||||
case sf::Keyboard::ScanNumpad0: return sf::Keyboard::Numpad1;
|
case sf::Keyboard::ScanNumpad0: return sf::Keyboard::Numpad1;
|
||||||
case sf::Keyboard::ScanNumpad1: return sf::Keyboard::Numpad2;
|
case sf::Keyboard::ScanNumpad1: return sf::Keyboard::Numpad2;
|
||||||
|
@ -64,13 +64,13 @@ public:
|
|||||||
static Keyboard::Key localize(Keyboard::Scancode code);
|
static Keyboard::Key localize(Keyboard::Scancode code);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::unlocalize
|
/// \copydoc sf::Keyboard::delocalize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode unlocalize(Keyboard::Key key);
|
static Keyboard::Scancode delocalize(Keyboard::Key key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::localizedRepresentation
|
/// \copydoc sf::Keyboard::getDescription
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static String getDescription(Keyboard::Scancode code);
|
static String getDescription(Keyboard::Scancode code);
|
||||||
|
@ -144,16 +144,16 @@ Keyboard::Key InputImpl::localize(Keyboard::Scancode code)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode InputImpl::unlocalize(Keyboard::Key key)
|
Keyboard::Scancode InputImpl::delocalize(Keyboard::Key key)
|
||||||
{
|
{
|
||||||
return HIDInputManager::getInstance().unlocalize(key);
|
return HIDInputManager::getInstance().delocalize(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
String InputImpl::getDescription(Keyboard::Scancode code)
|
String InputImpl::getDescription(Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
return HIDInputManager::getInstance().localizedRepresentation(code);
|
return HIDInputManager::getInstance().getDescription(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,14 +42,13 @@ bool InputImpl::isKeyPressed(Keyboard::Key key)
|
|||||||
return KeyboardImpl::isKeyPressed(key);
|
return KeyboardImpl::isKeyPressed(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool InputImpl::isKeyPressed(Keyboard::Scancode code)
|
bool InputImpl::isKeyPressed(Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
return KeyboardImpl::isKeyPressed(code);
|
return KeyboardImpl::isKeyPressed(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open a connection with the X server
|
|
||||||
Display* display = OpenDisplay();
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Key InputImpl::localize(Keyboard::Scancode code)
|
Keyboard::Key InputImpl::localize(Keyboard::Scancode code)
|
||||||
@ -57,13 +56,11 @@ Keyboard::Key InputImpl::localize(Keyboard::Scancode code)
|
|||||||
return KeyboardImpl::localize(code);
|
return KeyboardImpl::localize(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the connection with the X server
|
|
||||||
CloseDisplay(display);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode InputImpl::unlocalize(Keyboard::Key key)
|
Keyboard::Scancode InputImpl::delocalize(Keyboard::Key key)
|
||||||
{
|
{
|
||||||
return KeyboardImpl::unlocalize(key);
|
return KeyboardImpl::delocalize(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,13 +63,13 @@ public:
|
|||||||
static Keyboard::Key localize(Keyboard::Scancode code);
|
static Keyboard::Key localize(Keyboard::Scancode code);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::unlocalize
|
/// \copydoc sf::Keyboard::delocalize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode unlocalize(Keyboard::Key key);
|
static Keyboard::Scancode delocalize(Keyboard::Key key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::localizedRepresentation
|
/// \copydoc sf::Keyboard::getDescription
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static String getDescription(Keyboard::Scancode code);
|
static String getDescription(Keyboard::Scancode code);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SFML - Simple and Fast Multimedia Library
|
// SFML - Simple and Fast Multimedia Library
|
||||||
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
|
// Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org)
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SFML - Simple and Fast Multimedia Library
|
// SFML - Simple and Fast Multimedia Library
|
||||||
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
|
// Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org)
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SFML - Simple and Fast Multimedia Library
|
// SFML - Simple and Fast Multimedia Library
|
||||||
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
|
// Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org)
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SFML - Simple and Fast Multimedia Library
|
// SFML - Simple and Fast Multimedia Library
|
||||||
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
|
// Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org)
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SFML - Simple and Fast Multimedia Library
|
// SFML - Simple and Fast Multimedia Library
|
||||||
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
|
// Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org)
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
@ -34,21 +34,24 @@
|
|||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <cstring> // strcmp
|
#include <cstring>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
const KeyCode NullKeyCode = 0;
|
const KeyCode NullKeyCode = 0;
|
||||||
KeyCode scancodeToKeycode[sf::Keyboard::ScanCodeCount]; ///< Mapping of SFML scancode to X11 KeyCode
|
const int MaxKeyCode = 256;
|
||||||
sf::Keyboard::Scancode keycodeToScancode[256]; ///< Mapping of X11 KeyCode to SFML scancode
|
KeyCode scancodeToKeycode[sf::Keyboard::ScancodeCount]; ///< Mapping of SFML scancode to X11 KeyCode
|
||||||
bool isMappingInitialized = false;
|
sf::Keyboard::Scancode keycodeToScancode[MaxKeyCode]; ///< Mapping of X11 KeyCode to SFML scancode
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool isValidKeycode(KeyCode keycode)
|
bool isValidKeycode(KeyCode keycode)
|
||||||
{
|
{
|
||||||
// Valid key code range is [8,255], according to the Xlib manual
|
// Valid key code range is [8,255], according to the Xlib manual
|
||||||
return (keycode >= 8) || (keycode <= 255);
|
return (keycode >= 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,8 +63,7 @@ sf::Keyboard::Scancode translateKeyCode(Display* display, KeyCode keycode)
|
|||||||
|
|
||||||
// Try secondary keysym, for numeric keypad keys
|
// Try secondary keysym, for numeric keypad keys
|
||||||
// Note: This way we always force "NumLock = ON", which is intentional
|
// Note: This way we always force "NumLock = ON", which is intentional
|
||||||
// since the returned key code should correspond to a physical
|
// since the returned key code should correspond to a physical location.
|
||||||
// location.
|
|
||||||
KeySym keySym = XkbKeycodeToKeysym(display, keycode, 0, 1);
|
KeySym keySym = XkbKeycodeToKeysym(display, keycode, 0, 1);
|
||||||
|
|
||||||
switch (keySym)
|
switch (keySym)
|
||||||
@ -76,10 +78,10 @@ sf::Keyboard::Scancode translateKeyCode(Display* display, KeyCode keycode)
|
|||||||
case XK_KP_7: return sf::Keyboard::ScanNumpad7;
|
case XK_KP_7: return sf::Keyboard::ScanNumpad7;
|
||||||
case XK_KP_8: return sf::Keyboard::ScanNumpad8;
|
case XK_KP_8: return sf::Keyboard::ScanNumpad8;
|
||||||
case XK_KP_9: return sf::Keyboard::ScanNumpad9;
|
case XK_KP_9: return sf::Keyboard::ScanNumpad9;
|
||||||
case XK_KP_Separator: return sf::Keyboard::ScanDecimal;
|
case XK_KP_Separator: return sf::Keyboard::ScanNumpadDecimal;
|
||||||
case XK_KP_Decimal: return sf::Keyboard::ScanDecimal;
|
case XK_KP_Decimal: return sf::Keyboard::ScanNumpadDecimal;
|
||||||
case XK_KP_Equal: return sf::Keyboard::ScanPadEquals;
|
case XK_KP_Equal: return sf::Keyboard::ScanNumpadEqual;
|
||||||
case XK_KP_Enter: return sf::Keyboard::ScanReturn;
|
case XK_KP_Enter: return sf::Keyboard::ScanNumpadEnter;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,38 +91,52 @@ sf::Keyboard::Scancode translateKeyCode(Display* display, KeyCode keycode)
|
|||||||
|
|
||||||
switch (keySym)
|
switch (keySym)
|
||||||
{
|
{
|
||||||
|
case XK_Return: return sf::Keyboard::ScanEnter;
|
||||||
case XK_Escape: return sf::Keyboard::ScanEscape;
|
case XK_Escape: return sf::Keyboard::ScanEscape;
|
||||||
|
case XK_BackSpace: return sf::Keyboard::ScanBackspace;
|
||||||
case XK_Tab: return sf::Keyboard::ScanTab;
|
case XK_Tab: return sf::Keyboard::ScanTab;
|
||||||
case XK_Shift_L: return sf::Keyboard::ScanLShift;
|
case XK_Shift_L: return sf::Keyboard::ScanLShift;
|
||||||
case XK_Shift_R: return sf::Keyboard::ScanRShift;
|
case XK_Shift_R: return sf::Keyboard::ScanRShift;
|
||||||
case XK_Control_L: return sf::Keyboard::ScanLControl;
|
case XK_Control_L: return sf::Keyboard::ScanLControl;
|
||||||
case XK_Control_R: return sf::Keyboard::ScanRControl;
|
case XK_Control_R: return sf::Keyboard::ScanRControl;
|
||||||
case XK_Meta_L: return sf::Keyboard::ScanLAlt;
|
|
||||||
case XK_Alt_L: return sf::Keyboard::ScanLAlt;
|
case XK_Alt_L: return sf::Keyboard::ScanLAlt;
|
||||||
case XK_Mode_switch: return sf::Keyboard::ScanRAlt; // Mapped to Alt_R on many keyboards
|
case XK_ISO_Level3_Shift: // AltGr on at least some machines
|
||||||
case XK_ISO_Level3_Shift: return sf::Keyboard::ScanRAlt; // AltGr on at least some machines
|
|
||||||
case XK_Meta_R: return sf::Keyboard::ScanRAlt;
|
|
||||||
case XK_Alt_R: return sf::Keyboard::ScanRAlt;
|
case XK_Alt_R: return sf::Keyboard::ScanRAlt;
|
||||||
|
case XK_Meta_L:
|
||||||
case XK_Super_L: return sf::Keyboard::ScanLSystem;
|
case XK_Super_L: return sf::Keyboard::ScanLSystem;
|
||||||
|
case XK_Meta_R:
|
||||||
case XK_Super_R: return sf::Keyboard::ScanRSystem;
|
case XK_Super_R: return sf::Keyboard::ScanRSystem;
|
||||||
case XK_Menu: return sf::Keyboard::ScanMenu;
|
case XK_Menu: return sf::Keyboard::ScanMenu;
|
||||||
|
|
||||||
case XK_Num_Lock: return sf::Keyboard::ScanNumLock;
|
case XK_Num_Lock: return sf::Keyboard::ScanNumLock;
|
||||||
case XK_Caps_Lock: return sf::Keyboard::ScanCapsLock;
|
case XK_Caps_Lock: return sf::Keyboard::ScanCapsLock;
|
||||||
|
case XK_Execute: return sf::Keyboard::ScanExecute;
|
||||||
|
case XK_Hyper_R: return sf::Keyboard::ScanApplication;
|
||||||
|
case XK_Select: return sf::Keyboard::ScanSelect;
|
||||||
|
case XK_Cancel: return sf::Keyboard::ScanStop;
|
||||||
|
case XK_Redo: return sf::Keyboard::ScanRedo;
|
||||||
|
case XK_Undo: return sf::Keyboard::ScanUndo;
|
||||||
|
case XK_Find: return sf::Keyboard::ScanSearch;
|
||||||
|
case XK_Mode_switch: return sf::Keyboard::ScanModeChange;
|
||||||
|
|
||||||
case XK_Print: return sf::Keyboard::ScanPrintScreen;
|
case XK_Print: return sf::Keyboard::ScanPrintScreen;
|
||||||
case XK_Scroll_Lock: return sf::Keyboard::ScanScrollLock;
|
case XK_Scroll_Lock: return sf::Keyboard::ScanScrollLock;
|
||||||
case XK_Pause: return sf::Keyboard::ScanPause;
|
case XK_Pause:
|
||||||
case XK_Delete: return sf::Keyboard::ScanDelete;
|
case XK_Break: return sf::Keyboard::ScanPause;
|
||||||
case XK_BackSpace: return sf::Keyboard::ScanBackspace;
|
|
||||||
case XK_Return: return sf::Keyboard::ScanEnter;
|
case XK_Delete:
|
||||||
|
case XK_Clear: return sf::Keyboard::ScanDelete;
|
||||||
case XK_Home: return sf::Keyboard::ScanHome;
|
case XK_Home: return sf::Keyboard::ScanHome;
|
||||||
case XK_End: return sf::Keyboard::ScanEnd;
|
case XK_End: return sf::Keyboard::ScanEnd;
|
||||||
case XK_Page_Up: return sf::Keyboard::ScanPageUp;
|
case XK_Page_Up: return sf::Keyboard::ScanPageUp;
|
||||||
case XK_Page_Down: return sf::Keyboard::ScanPageDown;
|
case XK_Page_Down: return sf::Keyboard::ScanPageDown;
|
||||||
case XK_Insert: return sf::Keyboard::ScanInsert;
|
case XK_Insert: return sf::Keyboard::ScanInsert;
|
||||||
|
|
||||||
case XK_Left: return sf::Keyboard::ScanLeft;
|
case XK_Left: return sf::Keyboard::ScanLeft;
|
||||||
case XK_Right: return sf::Keyboard::ScanRight;
|
case XK_Right: return sf::Keyboard::ScanRight;
|
||||||
case XK_Down: return sf::Keyboard::ScanDown;
|
case XK_Down: return sf::Keyboard::ScanDown;
|
||||||
case XK_Up: return sf::Keyboard::ScanUp;
|
case XK_Up: return sf::Keyboard::ScanUp;
|
||||||
|
|
||||||
case XK_F1: return sf::Keyboard::ScanF1;
|
case XK_F1: return sf::Keyboard::ScanF1;
|
||||||
case XK_F2: return sf::Keyboard::ScanF2;
|
case XK_F2: return sf::Keyboard::ScanF2;
|
||||||
case XK_F3: return sf::Keyboard::ScanF3;
|
case XK_F3: return sf::Keyboard::ScanF3;
|
||||||
@ -136,13 +152,21 @@ sf::Keyboard::Scancode translateKeyCode(Display* display, KeyCode keycode)
|
|||||||
case XK_F13: return sf::Keyboard::ScanF13;
|
case XK_F13: return sf::Keyboard::ScanF13;
|
||||||
case XK_F14: return sf::Keyboard::ScanF14;
|
case XK_F14: return sf::Keyboard::ScanF14;
|
||||||
case XK_F15: return sf::Keyboard::ScanF15;
|
case XK_F15: return sf::Keyboard::ScanF15;
|
||||||
// TODO: add scancodes for F16-F25 when they're added in Scancode enum
|
case XK_F16: return sf::Keyboard::ScanF16;
|
||||||
|
case XK_F17: return sf::Keyboard::ScanF17;
|
||||||
|
case XK_F18: return sf::Keyboard::ScanF18;
|
||||||
|
case XK_F19: return sf::Keyboard::ScanF19;
|
||||||
|
case XK_F20: return sf::Keyboard::ScanF20;
|
||||||
|
case XK_F21: return sf::Keyboard::ScanF21;
|
||||||
|
case XK_F22: return sf::Keyboard::ScanF22;
|
||||||
|
case XK_F23: return sf::Keyboard::ScanF23;
|
||||||
|
case XK_F24: return sf::Keyboard::ScanF24;
|
||||||
|
|
||||||
// Numeric keypad
|
// Numeric keypad
|
||||||
case XK_KP_Divide: return sf::Keyboard::ScanDivide;
|
case XK_KP_Divide: return sf::Keyboard::ScanNumpadDivide;
|
||||||
case XK_KP_Multiply: return sf::Keyboard::ScanMultiply;
|
case XK_KP_Multiply: return sf::Keyboard::ScanNumpadMultiply;
|
||||||
case XK_KP_Subtract: return sf::Keyboard::ScanMinus;
|
case XK_KP_Subtract: return sf::Keyboard::ScanNumpadMinus;
|
||||||
case XK_KP_Add: return sf::Keyboard::ScanPlus;
|
case XK_KP_Add: return sf::Keyboard::ScanNumpadPlus;
|
||||||
|
|
||||||
// These should have been detected in secondary keysym test above!
|
// These should have been detected in secondary keysym test above!
|
||||||
case XK_KP_Insert: return sf::Keyboard::ScanNumpad0;
|
case XK_KP_Insert: return sf::Keyboard::ScanNumpad0;
|
||||||
@ -154,40 +178,67 @@ sf::Keyboard::Scancode translateKeyCode(Display* display, KeyCode keycode)
|
|||||||
case XK_KP_Home: return sf::Keyboard::ScanNumpad7;
|
case XK_KP_Home: return sf::Keyboard::ScanNumpad7;
|
||||||
case XK_KP_Up: return sf::Keyboard::ScanNumpad8;
|
case XK_KP_Up: return sf::Keyboard::ScanNumpad8;
|
||||||
case XK_KP_Page_Up: return sf::Keyboard::ScanNumpad9;
|
case XK_KP_Page_Up: return sf::Keyboard::ScanNumpad9;
|
||||||
case XK_KP_Delete: return sf::Keyboard::ScanDecimal;
|
case XK_KP_Delete: return sf::Keyboard::ScanNumpadDecimal;
|
||||||
case XK_KP_Equal: return sf::Keyboard::ScanPadEquals;
|
case XK_KP_Equal: return sf::Keyboard::ScanNumpadEqual;
|
||||||
case XK_KP_Enter: return sf::Keyboard::ScanReturn;
|
case XK_KP_Enter: return sf::Keyboard::ScanNumpadEnter;
|
||||||
|
|
||||||
// Last resort: Check for printable keys (should not happen if the XKB
|
// Last resort: Check for printable keys (should not happen if the XKB
|
||||||
// extension is available). This will give a layout dependent mapping
|
// extension is available). This will give a layout dependent mapping
|
||||||
// (which is wrong, and we may miss some keys, especially on non-US
|
// (which is wrong, and we may miss some keys, especially on non-US
|
||||||
// keyboards), but it's better than nothing...
|
// keyboards), but it's better than nothing...
|
||||||
case XK_a: return sf::Keyboard::ScanA;
|
case XK_a:
|
||||||
case XK_b: return sf::Keyboard::ScanB;
|
case XK_A: return sf::Keyboard::ScanA;
|
||||||
case XK_c: return sf::Keyboard::ScanC;
|
case XK_b:
|
||||||
case XK_d: return sf::Keyboard::ScanD;
|
case XK_B: return sf::Keyboard::ScanB;
|
||||||
case XK_e: return sf::Keyboard::ScanE;
|
case XK_c:
|
||||||
case XK_f: return sf::Keyboard::ScanF;
|
case XK_C: return sf::Keyboard::ScanC;
|
||||||
case XK_g: return sf::Keyboard::ScanG;
|
case XK_d:
|
||||||
case XK_h: return sf::Keyboard::ScanH;
|
case XK_D: return sf::Keyboard::ScanD;
|
||||||
case XK_i: return sf::Keyboard::ScanI;
|
case XK_e:
|
||||||
case XK_j: return sf::Keyboard::ScanJ;
|
case XK_E: return sf::Keyboard::ScanE;
|
||||||
case XK_k: return sf::Keyboard::ScanK;
|
case XK_f:
|
||||||
case XK_l: return sf::Keyboard::ScanL;
|
case XK_F: return sf::Keyboard::ScanF;
|
||||||
case XK_m: return sf::Keyboard::ScanM;
|
case XK_g:
|
||||||
case XK_n: return sf::Keyboard::ScanN;
|
case XK_G: return sf::Keyboard::ScanG;
|
||||||
case XK_o: return sf::Keyboard::ScanO;
|
case XK_h:
|
||||||
case XK_p: return sf::Keyboard::ScanP;
|
case XK_H: return sf::Keyboard::ScanH;
|
||||||
case XK_q: return sf::Keyboard::ScanQ;
|
case XK_i:
|
||||||
case XK_r: return sf::Keyboard::ScanR;
|
case XK_I: return sf::Keyboard::ScanI;
|
||||||
case XK_s: return sf::Keyboard::ScanS;
|
case XK_j:
|
||||||
case XK_t: return sf::Keyboard::ScanT;
|
case XK_J: return sf::Keyboard::ScanJ;
|
||||||
case XK_u: return sf::Keyboard::ScanU;
|
case XK_k:
|
||||||
case XK_v: return sf::Keyboard::ScanV;
|
case XK_K: return sf::Keyboard::ScanK;
|
||||||
case XK_w: return sf::Keyboard::ScanW;
|
case XK_l:
|
||||||
case XK_x: return sf::Keyboard::ScanX;
|
case XK_L: return sf::Keyboard::ScanL;
|
||||||
case XK_y: return sf::Keyboard::ScanY;
|
case XK_m:
|
||||||
case XK_z: return sf::Keyboard::ScanZ;
|
case XK_M: return sf::Keyboard::ScanM;
|
||||||
|
case XK_n:
|
||||||
|
case XK_N: return sf::Keyboard::ScanN;
|
||||||
|
case XK_o:
|
||||||
|
case XK_O: return sf::Keyboard::ScanO;
|
||||||
|
case XK_p:
|
||||||
|
case XK_P: return sf::Keyboard::ScanP;
|
||||||
|
case XK_q:
|
||||||
|
case XK_Q: return sf::Keyboard::ScanQ;
|
||||||
|
case XK_r:
|
||||||
|
case XK_R: return sf::Keyboard::ScanR;
|
||||||
|
case XK_s:
|
||||||
|
case XK_S: return sf::Keyboard::ScanS;
|
||||||
|
case XK_t:
|
||||||
|
case XK_T: return sf::Keyboard::ScanT;
|
||||||
|
case XK_u:
|
||||||
|
case XK_U: return sf::Keyboard::ScanU;
|
||||||
|
case XK_v:
|
||||||
|
case XK_V: return sf::Keyboard::ScanV;
|
||||||
|
case XK_w:
|
||||||
|
case XK_W: return sf::Keyboard::ScanW;
|
||||||
|
case XK_x:
|
||||||
|
case XK_X: return sf::Keyboard::ScanX;
|
||||||
|
case XK_y:
|
||||||
|
case XK_Y: return sf::Keyboard::ScanY;
|
||||||
|
case XK_z:
|
||||||
|
case XK_Z: return sf::Keyboard::ScanZ;
|
||||||
|
|
||||||
case XK_1: return sf::Keyboard::ScanNum1;
|
case XK_1: return sf::Keyboard::ScanNum1;
|
||||||
case XK_2: return sf::Keyboard::ScanNum2;
|
case XK_2: return sf::Keyboard::ScanNum2;
|
||||||
case XK_3: return sf::Keyboard::ScanNum3;
|
case XK_3: return sf::Keyboard::ScanNum3;
|
||||||
@ -198,119 +249,258 @@ sf::Keyboard::Scancode translateKeyCode(Display* display, KeyCode keycode)
|
|||||||
case XK_8: return sf::Keyboard::ScanNum8;
|
case XK_8: return sf::Keyboard::ScanNum8;
|
||||||
case XK_9: return sf::Keyboard::ScanNum9;
|
case XK_9: return sf::Keyboard::ScanNum9;
|
||||||
case XK_0: return sf::Keyboard::ScanNum0;
|
case XK_0: return sf::Keyboard::ScanNum0;
|
||||||
|
|
||||||
case XK_space: return sf::Keyboard::ScanSpace;
|
case XK_space: return sf::Keyboard::ScanSpace;
|
||||||
case XK_minus: return sf::Keyboard::ScanHyphen;
|
case XK_minus: return sf::Keyboard::ScanHyphen;
|
||||||
case XK_equal: return sf::Keyboard::ScanEquals;
|
case XK_equal: return sf::Keyboard::ScanEqual;
|
||||||
case XK_bracketleft: return sf::Keyboard::ScanLBracket;
|
case XK_bracketleft: return sf::Keyboard::ScanLBracket;
|
||||||
case XK_bracketright: return sf::Keyboard::ScanRBracket;
|
case XK_bracketright: return sf::Keyboard::ScanRBracket;
|
||||||
case XK_backslash: return sf::Keyboard::ScanBackslash;
|
case XK_backslash: return sf::Keyboard::ScanBackslash;
|
||||||
case XK_semicolon: return sf::Keyboard::ScanSemicolon;
|
case XK_semicolon: return sf::Keyboard::ScanSemicolon;
|
||||||
case XK_apostrophe: return sf::Keyboard::ScanQuote;
|
case XK_apostrophe: return sf::Keyboard::ScanApostrophe;
|
||||||
case XK_grave: return sf::Keyboard::ScanGraveAccent;
|
case XK_grave: return sf::Keyboard::ScanGrave;
|
||||||
case XK_comma: return sf::Keyboard::ScanComma;
|
case XK_comma: return sf::Keyboard::ScanComma;
|
||||||
case XK_period: return sf::Keyboard::ScanPeriod;
|
case XK_period: return sf::Keyboard::ScanPeriod;
|
||||||
case XK_slash: return sf::Keyboard::ScanForwardSlash;
|
case XK_slash: return sf::Keyboard::ScanSlash;
|
||||||
case XK_less: return sf::Keyboard::ScanReverseSolidus;
|
case XK_less: return sf::Keyboard::ScanNonUsBackslash;
|
||||||
|
|
||||||
default: return sf::Keyboard::ScanUnknown;
|
default: return sf::Keyboard::ScanUnknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
std::map<std::string, sf::Keyboard::Scancode> GetNameScancodeMap()
|
||||||
|
{
|
||||||
|
std::map<std::string, sf::Keyboard::Scancode> mapping;
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("LSGT", sf::Keyboard::ScanNonUsBackslash));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("TLDE", sf::Keyboard::ScanGrave));
|
||||||
|
mapping.insert(std::make_pair("AE01", sf::Keyboard::ScanNum1));
|
||||||
|
mapping.insert(std::make_pair("AE02", sf::Keyboard::ScanNum2));
|
||||||
|
mapping.insert(std::make_pair("AE03", sf::Keyboard::ScanNum3));
|
||||||
|
mapping.insert(std::make_pair("AE04", sf::Keyboard::ScanNum4));
|
||||||
|
mapping.insert(std::make_pair("AE05", sf::Keyboard::ScanNum5));
|
||||||
|
mapping.insert(std::make_pair("AE06", sf::Keyboard::ScanNum6));
|
||||||
|
mapping.insert(std::make_pair("AE07", sf::Keyboard::ScanNum7));
|
||||||
|
mapping.insert(std::make_pair("AE08", sf::Keyboard::ScanNum8));
|
||||||
|
mapping.insert(std::make_pair("AE09", sf::Keyboard::ScanNum9));
|
||||||
|
mapping.insert(std::make_pair("AE10", sf::Keyboard::ScanNum0));
|
||||||
|
mapping.insert(std::make_pair("AE11", sf::Keyboard::ScanHyphen));
|
||||||
|
mapping.insert(std::make_pair("AE12", sf::Keyboard::ScanEqual));
|
||||||
|
mapping.insert(std::make_pair("BKSP", sf::Keyboard::ScanBackspace));
|
||||||
|
mapping.insert(std::make_pair("TAB", sf::Keyboard::ScanTab));
|
||||||
|
mapping.insert(std::make_pair("AD01", sf::Keyboard::ScanQ));
|
||||||
|
mapping.insert(std::make_pair("AD02", sf::Keyboard::ScanW));
|
||||||
|
mapping.insert(std::make_pair("AD03", sf::Keyboard::ScanE));
|
||||||
|
mapping.insert(std::make_pair("AD04", sf::Keyboard::ScanR));
|
||||||
|
mapping.insert(std::make_pair("AD05", sf::Keyboard::ScanT));
|
||||||
|
mapping.insert(std::make_pair("AD06", sf::Keyboard::ScanY));
|
||||||
|
mapping.insert(std::make_pair("AD07", sf::Keyboard::ScanU));
|
||||||
|
mapping.insert(std::make_pair("AD08", sf::Keyboard::ScanI));
|
||||||
|
mapping.insert(std::make_pair("AD09", sf::Keyboard::ScanO));
|
||||||
|
mapping.insert(std::make_pair("AD10", sf::Keyboard::ScanP));
|
||||||
|
mapping.insert(std::make_pair("AD11", sf::Keyboard::ScanLBracket));
|
||||||
|
mapping.insert(std::make_pair("AD12", sf::Keyboard::ScanRBracket));
|
||||||
|
mapping.insert(std::make_pair("BKSL", sf::Keyboard::ScanBackslash));
|
||||||
|
mapping.insert(std::make_pair("RTRN", sf::Keyboard::ScanEnter));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("CAPS", sf::Keyboard::ScanCapsLock));
|
||||||
|
mapping.insert(std::make_pair("AC01", sf::Keyboard::ScanA));
|
||||||
|
mapping.insert(std::make_pair("AC02", sf::Keyboard::ScanS));
|
||||||
|
mapping.insert(std::make_pair("AC03", sf::Keyboard::ScanD));
|
||||||
|
mapping.insert(std::make_pair("AC04", sf::Keyboard::ScanF));
|
||||||
|
mapping.insert(std::make_pair("AC05", sf::Keyboard::ScanG));
|
||||||
|
mapping.insert(std::make_pair("AC06", sf::Keyboard::ScanH));
|
||||||
|
mapping.insert(std::make_pair("AC07", sf::Keyboard::ScanJ));
|
||||||
|
mapping.insert(std::make_pair("AC08", sf::Keyboard::ScanK));
|
||||||
|
mapping.insert(std::make_pair("AC09", sf::Keyboard::ScanL));
|
||||||
|
mapping.insert(std::make_pair("AC10", sf::Keyboard::ScanSemicolon));
|
||||||
|
mapping.insert(std::make_pair("AC11", sf::Keyboard::ScanApostrophe));
|
||||||
|
mapping.insert(std::make_pair("AC12", sf::Keyboard::ScanBackslash));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("LFSH", sf::Keyboard::ScanLShift));
|
||||||
|
mapping.insert(std::make_pair("AB01", sf::Keyboard::ScanZ));
|
||||||
|
mapping.insert(std::make_pair("AB02", sf::Keyboard::ScanX));
|
||||||
|
mapping.insert(std::make_pair("AB03", sf::Keyboard::ScanC));
|
||||||
|
mapping.insert(std::make_pair("AB04", sf::Keyboard::ScanV));
|
||||||
|
mapping.insert(std::make_pair("AB05", sf::Keyboard::ScanB));
|
||||||
|
mapping.insert(std::make_pair("AB06", sf::Keyboard::ScanN));
|
||||||
|
mapping.insert(std::make_pair("AB07", sf::Keyboard::ScanM));
|
||||||
|
mapping.insert(std::make_pair("AB08", sf::Keyboard::ScanComma));
|
||||||
|
mapping.insert(std::make_pair("AB09", sf::Keyboard::ScanPeriod));
|
||||||
|
mapping.insert(std::make_pair("AB10", sf::Keyboard::ScanSlash));
|
||||||
|
mapping.insert(std::make_pair("RTSH", sf::Keyboard::ScanRShift));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("LCTL", sf::Keyboard::ScanLControl));
|
||||||
|
mapping.insert(std::make_pair("LALT", sf::Keyboard::ScanLAlt));
|
||||||
|
mapping.insert(std::make_pair("SPCE", sf::Keyboard::ScanSpace));
|
||||||
|
mapping.insert(std::make_pair("RCTL", sf::Keyboard::ScanRControl));
|
||||||
|
mapping.insert(std::make_pair("RALT", sf::Keyboard::ScanRAlt));
|
||||||
|
mapping.insert(std::make_pair("LVL3", sf::Keyboard::ScanRAlt));
|
||||||
|
mapping.insert(std::make_pair("ALGR", sf::Keyboard::ScanRAlt));
|
||||||
|
mapping.insert(std::make_pair("LWIN", sf::Keyboard::ScanLSystem));
|
||||||
|
mapping.insert(std::make_pair("RWIN", sf::Keyboard::ScanRSystem));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("HYPR", sf::Keyboard::ScanApplication));
|
||||||
|
mapping.insert(std::make_pair("EXEC", sf::Keyboard::ScanExecute));
|
||||||
|
mapping.insert(std::make_pair("MDSW", sf::Keyboard::ScanModeChange));
|
||||||
|
mapping.insert(std::make_pair("MENU", sf::Keyboard::ScanMenu));
|
||||||
|
mapping.insert(std::make_pair("COMP", sf::Keyboard::ScanMenu));
|
||||||
|
mapping.insert(std::make_pair("SELE", sf::Keyboard::ScanSelect));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("ESC", sf::Keyboard::ScanEscape));
|
||||||
|
mapping.insert(std::make_pair("FK01", sf::Keyboard::ScanF1));
|
||||||
|
mapping.insert(std::make_pair("FK02", sf::Keyboard::ScanF2));
|
||||||
|
mapping.insert(std::make_pair("FK03", sf::Keyboard::ScanF3));
|
||||||
|
mapping.insert(std::make_pair("FK04", sf::Keyboard::ScanF4));
|
||||||
|
mapping.insert(std::make_pair("FK05", sf::Keyboard::ScanF5));
|
||||||
|
mapping.insert(std::make_pair("FK06", sf::Keyboard::ScanF6));
|
||||||
|
mapping.insert(std::make_pair("FK07", sf::Keyboard::ScanF7));
|
||||||
|
mapping.insert(std::make_pair("FK08", sf::Keyboard::ScanF8));
|
||||||
|
mapping.insert(std::make_pair("FK09", sf::Keyboard::ScanF9));
|
||||||
|
mapping.insert(std::make_pair("FK10", sf::Keyboard::ScanF10));
|
||||||
|
mapping.insert(std::make_pair("FK11", sf::Keyboard::ScanF11));
|
||||||
|
mapping.insert(std::make_pair("FK12", sf::Keyboard::ScanF12));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("PRSC", sf::Keyboard::ScanPrintScreen));
|
||||||
|
mapping.insert(std::make_pair("SCLK", sf::Keyboard::ScanScrollLock));
|
||||||
|
mapping.insert(std::make_pair("PAUS", sf::Keyboard::ScanPause));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("INS", sf::Keyboard::ScanInsert));
|
||||||
|
mapping.insert(std::make_pair("HOME", sf::Keyboard::ScanHome));
|
||||||
|
mapping.insert(std::make_pair("PGUP", sf::Keyboard::ScanPageUp));
|
||||||
|
mapping.insert(std::make_pair("DELE", sf::Keyboard::ScanDelete));
|
||||||
|
mapping.insert(std::make_pair("END", sf::Keyboard::ScanEnd));
|
||||||
|
mapping.insert(std::make_pair("PGDN", sf::Keyboard::ScanPageDown));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("UP", sf::Keyboard::ScanUp));
|
||||||
|
mapping.insert(std::make_pair("RGHT", sf::Keyboard::ScanRight));
|
||||||
|
mapping.insert(std::make_pair("DOWN", sf::Keyboard::ScanDown));
|
||||||
|
mapping.insert(std::make_pair("LEFT", sf::Keyboard::ScanLeft));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("NMLK", sf::Keyboard::ScanNumLock));
|
||||||
|
mapping.insert(std::make_pair("KPDV", sf::Keyboard::ScanNumpadDivide));
|
||||||
|
mapping.insert(std::make_pair("KPMU", sf::Keyboard::ScanNumpadMultiply));
|
||||||
|
mapping.insert(std::make_pair("KPSU", sf::Keyboard::ScanNumpadMinus));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("KP7", sf::Keyboard::ScanNumpad7));
|
||||||
|
mapping.insert(std::make_pair("KP8", sf::Keyboard::ScanNumpad8));
|
||||||
|
mapping.insert(std::make_pair("KP9", sf::Keyboard::ScanNumpad9));
|
||||||
|
mapping.insert(std::make_pair("KPAD", sf::Keyboard::ScanNumpadPlus));
|
||||||
|
mapping.insert(std::make_pair("KP4", sf::Keyboard::ScanNumpad4));
|
||||||
|
mapping.insert(std::make_pair("KP5", sf::Keyboard::ScanNumpad5));
|
||||||
|
mapping.insert(std::make_pair("KP6", sf::Keyboard::ScanNumpad6));
|
||||||
|
mapping.insert(std::make_pair("KP1", sf::Keyboard::ScanNumpad1));
|
||||||
|
mapping.insert(std::make_pair("KP2", sf::Keyboard::ScanNumpad2));
|
||||||
|
mapping.insert(std::make_pair("KP3", sf::Keyboard::ScanNumpad3));
|
||||||
|
mapping.insert(std::make_pair("KPEN", sf::Keyboard::ScanNumpadEnter));
|
||||||
|
mapping.insert(std::make_pair("KP0", sf::Keyboard::ScanNumpad0));
|
||||||
|
mapping.insert(std::make_pair("KPDL", sf::Keyboard::ScanNumpadDecimal));
|
||||||
|
mapping.insert(std::make_pair("KPEQ", sf::Keyboard::ScanNumpadEqual));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("FK13", sf::Keyboard::ScanF13));
|
||||||
|
mapping.insert(std::make_pair("FK14", sf::Keyboard::ScanF14));
|
||||||
|
mapping.insert(std::make_pair("FK15", sf::Keyboard::ScanF15));
|
||||||
|
mapping.insert(std::make_pair("FK16", sf::Keyboard::ScanF16));
|
||||||
|
mapping.insert(std::make_pair("FK17", sf::Keyboard::ScanF17));
|
||||||
|
mapping.insert(std::make_pair("FK18", sf::Keyboard::ScanF18));
|
||||||
|
mapping.insert(std::make_pair("FK19", sf::Keyboard::ScanF19));
|
||||||
|
mapping.insert(std::make_pair("FK20", sf::Keyboard::ScanF20));
|
||||||
|
mapping.insert(std::make_pair("FK21", sf::Keyboard::ScanF21));
|
||||||
|
mapping.insert(std::make_pair("FK22", sf::Keyboard::ScanF22));
|
||||||
|
mapping.insert(std::make_pair("FK23", sf::Keyboard::ScanF23));
|
||||||
|
mapping.insert(std::make_pair("FK24", sf::Keyboard::ScanF24));
|
||||||
|
mapping.insert(std::make_pair("LMTA", sf::Keyboard::ScanLSystem));
|
||||||
|
mapping.insert(std::make_pair("RMTA", sf::Keyboard::ScanRSystem));
|
||||||
|
mapping.insert(std::make_pair("MUTE", sf::Keyboard::ScanVolumeMute));
|
||||||
|
mapping.insert(std::make_pair("VOL-", sf::Keyboard::ScanVolumeDown));
|
||||||
|
mapping.insert(std::make_pair("VOL+", sf::Keyboard::ScanVolumeUp));
|
||||||
|
mapping.insert(std::make_pair("STOP", sf::Keyboard::ScanStop));
|
||||||
|
mapping.insert(std::make_pair("REDO", sf::Keyboard::ScanRedo));
|
||||||
|
mapping.insert(std::make_pair("AGAI", sf::Keyboard::ScanRedo));
|
||||||
|
mapping.insert(std::make_pair("UNDO", sf::Keyboard::ScanUndo));
|
||||||
|
mapping.insert(std::make_pair("COPY", sf::Keyboard::ScanCopy));
|
||||||
|
mapping.insert(std::make_pair("PAST", sf::Keyboard::ScanPaste));
|
||||||
|
mapping.insert(std::make_pair("FIND", sf::Keyboard::ScanSearch));
|
||||||
|
mapping.insert(std::make_pair("CUT", sf::Keyboard::ScanCut));
|
||||||
|
mapping.insert(std::make_pair("HELP", sf::Keyboard::ScanHelp));
|
||||||
|
|
||||||
|
mapping.insert(std::make_pair("I156", sf::Keyboard::ScanLaunchApplication1));
|
||||||
|
mapping.insert(std::make_pair("I157", sf::Keyboard::ScanLaunchApplication2));
|
||||||
|
mapping.insert(std::make_pair("I164", sf::Keyboard::ScanFavorites));
|
||||||
|
mapping.insert(std::make_pair("I166", sf::Keyboard::ScanBack));
|
||||||
|
mapping.insert(std::make_pair("I167", sf::Keyboard::ScanForward));
|
||||||
|
mapping.insert(std::make_pair("I171", sf::Keyboard::ScanMediaNextTrack));
|
||||||
|
mapping.insert(std::make_pair("I172", sf::Keyboard::ScanMediaPlayPause));
|
||||||
|
mapping.insert(std::make_pair("I173", sf::Keyboard::ScanMediaPreviousTrack));
|
||||||
|
mapping.insert(std::make_pair("I174", sf::Keyboard::ScanMediaStop));
|
||||||
|
mapping.insert(std::make_pair("I180", sf::Keyboard::ScanHomePage));
|
||||||
|
mapping.insert(std::make_pair("I181", sf::Keyboard::ScanRefresh));
|
||||||
|
mapping.insert(std::make_pair("I223", sf::Keyboard::ScanLaunchMail));
|
||||||
|
mapping.insert(std::make_pair("I234", sf::Keyboard::ScanLaunchMediaSelect));
|
||||||
|
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void initMapping()
|
void ensureMapping()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 256; ++i)
|
static bool isMappingInitialized = false;
|
||||||
|
|
||||||
|
if (isMappingInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Phase 1: Initialize mappings with default values
|
||||||
|
for (int i = 0; i < sf::Keyboard::ScancodeCount; ++i)
|
||||||
scancodeToKeycode[i] = NullKeyCode;
|
scancodeToKeycode[i] = NullKeyCode;
|
||||||
|
|
||||||
for (int i = 0; i < sf::Keyboard::ScanCodeCount; ++i)
|
for (int i = 0; i < MaxKeyCode; ++i)
|
||||||
keycodeToScancode[i] = sf::Keyboard::ScanUnknown;
|
keycodeToScancode[i] = sf::Keyboard::ScanUnknown;
|
||||||
|
|
||||||
|
// Phase 2: Get XKB names with key code
|
||||||
Display* display = sf::priv::OpenDisplay();
|
Display* display = sf::priv::OpenDisplay();
|
||||||
|
|
||||||
// Find the X11 key code -> SFML key code mapping
|
|
||||||
// This code was inspired by GLFW implementation
|
|
||||||
|
|
||||||
char name[XkbKeyNameLength + 1];
|
char name[XkbKeyNameLength + 1];
|
||||||
XkbDescPtr desc = XkbGetMap(display, 0, XkbUseCoreKbd);
|
XkbDescPtr descriptor = XkbGetMap(display, 0, XkbUseCoreKbd);
|
||||||
XkbGetNames(display, XkbKeyNamesMask, desc);
|
XkbGetNames(display, XkbKeyNamesMask, descriptor);
|
||||||
|
|
||||||
sf::Keyboard::Scancode sc;
|
std::map<std::string, sf::Keyboard::Scancode> nameScancodeMap = GetNameScancodeMap();
|
||||||
|
sf::Keyboard::Scancode scancode = sf::Keyboard::ScanUnknown;
|
||||||
|
|
||||||
for (int keycode = desc->min_key_code; keycode <= desc->max_key_code; ++keycode)
|
for (int keycode = descriptor->min_key_code; keycode <= descriptor->max_key_code; ++keycode)
|
||||||
{
|
{
|
||||||
std::memcpy(name, desc->names->keys[keycode].name, XkbKeyNameLength);
|
if (!isValidKeycode(static_cast<KeyCode>(keycode)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::memcpy(name, descriptor->names->keys[keycode].name, XkbKeyNameLength);
|
||||||
name[XkbKeyNameLength] = '\0';
|
name[XkbKeyNameLength] = '\0';
|
||||||
|
|
||||||
if (strcmp(name, "TLDE") == 0) sc = sf::Keyboard::ScanGraveAccent;
|
std::map<std::string, sf::Keyboard::Scancode>::iterator mappedScancode = nameScancodeMap.find(std::string(name));
|
||||||
else if (strcmp(name, "AE01") == 0) sc = sf::Keyboard::ScanNum1;
|
scancode = sf::Keyboard::ScanUnknown;
|
||||||
else if (strcmp(name, "AE02") == 0) sc = sf::Keyboard::ScanNum2;
|
|
||||||
else if (strcmp(name, "AE03") == 0) sc = sf::Keyboard::ScanNum3;
|
|
||||||
else if (strcmp(name, "AE04") == 0) sc = sf::Keyboard::ScanNum4;
|
|
||||||
else if (strcmp(name, "AE05") == 0) sc = sf::Keyboard::ScanNum5;
|
|
||||||
else if (strcmp(name, "AE06") == 0) sc = sf::Keyboard::ScanNum6;
|
|
||||||
else if (strcmp(name, "AE07") == 0) sc = sf::Keyboard::ScanNum7;
|
|
||||||
else if (strcmp(name, "AE08") == 0) sc = sf::Keyboard::ScanNum8;
|
|
||||||
else if (strcmp(name, "AE09") == 0) sc = sf::Keyboard::ScanNum9;
|
|
||||||
else if (strcmp(name, "AE10") == 0) sc = sf::Keyboard::ScanNum0;
|
|
||||||
else if (strcmp(name, "AE11") == 0) sc = sf::Keyboard::ScanDash;
|
|
||||||
else if (strcmp(name, "AE12") == 0) sc = sf::Keyboard::ScanEquals;
|
|
||||||
else if (strcmp(name, "TAB" ) == 0) sc = sf::Keyboard::ScanTab;
|
|
||||||
else if (strcmp(name, "AD01") == 0) sc = sf::Keyboard::ScanQ;
|
|
||||||
else if (strcmp(name, "AD02") == 0) sc = sf::Keyboard::ScanW;
|
|
||||||
else if (strcmp(name, "AD03") == 0) sc = sf::Keyboard::ScanE;
|
|
||||||
else if (strcmp(name, "AD04") == 0) sc = sf::Keyboard::ScanR;
|
|
||||||
else if (strcmp(name, "AD05") == 0) sc = sf::Keyboard::ScanT;
|
|
||||||
else if (strcmp(name, "AD06") == 0) sc = sf::Keyboard::ScanY;
|
|
||||||
else if (strcmp(name, "AD07") == 0) sc = sf::Keyboard::ScanU;
|
|
||||||
else if (strcmp(name, "AD08") == 0) sc = sf::Keyboard::ScanI;
|
|
||||||
else if (strcmp(name, "AD09") == 0) sc = sf::Keyboard::ScanO;
|
|
||||||
else if (strcmp(name, "AD10") == 0) sc = sf::Keyboard::ScanP;
|
|
||||||
else if (strcmp(name, "AD11") == 0) sc = sf::Keyboard::ScanLBracket;
|
|
||||||
else if (strcmp(name, "AD12") == 0) sc = sf::Keyboard::ScanRBracket;
|
|
||||||
else if (strcmp(name, "BKSL") == 0) sc = sf::Keyboard::ScanBackslash;
|
|
||||||
else if (strcmp(name, "AC01") == 0) sc = sf::Keyboard::ScanA;
|
|
||||||
else if (strcmp(name, "AC02") == 0) sc = sf::Keyboard::ScanS;
|
|
||||||
else if (strcmp(name, "AC03") == 0) sc = sf::Keyboard::ScanD;
|
|
||||||
else if (strcmp(name, "AC04") == 0) sc = sf::Keyboard::ScanF;
|
|
||||||
else if (strcmp(name, "AC05") == 0) sc = sf::Keyboard::ScanG;
|
|
||||||
else if (strcmp(name, "AC06") == 0) sc = sf::Keyboard::ScanH;
|
|
||||||
else if (strcmp(name, "AC07") == 0) sc = sf::Keyboard::ScanJ;
|
|
||||||
else if (strcmp(name, "AC08") == 0) sc = sf::Keyboard::ScanK;
|
|
||||||
else if (strcmp(name, "AC09") == 0) sc = sf::Keyboard::ScanL;
|
|
||||||
else if (strcmp(name, "AC10") == 0) sc = sf::Keyboard::ScanSemicolon;
|
|
||||||
else if (strcmp(name, "AC11") == 0) sc = sf::Keyboard::ScanQuote;
|
|
||||||
else if (strcmp(name, "AB01") == 0) sc = sf::Keyboard::ScanZ;
|
|
||||||
else if (strcmp(name, "AB02") == 0) sc = sf::Keyboard::ScanX;
|
|
||||||
else if (strcmp(name, "AB03") == 0) sc = sf::Keyboard::ScanC;
|
|
||||||
else if (strcmp(name, "AB04") == 0) sc = sf::Keyboard::ScanV;
|
|
||||||
else if (strcmp(name, "AB05") == 0) sc = sf::Keyboard::ScanB;
|
|
||||||
else if (strcmp(name, "AB06") == 0) sc = sf::Keyboard::ScanN;
|
|
||||||
else if (strcmp(name, "AB07") == 0) sc = sf::Keyboard::ScanM;
|
|
||||||
else if (strcmp(name, "AB08") == 0) sc = sf::Keyboard::ScanComma;
|
|
||||||
else if (strcmp(name, "AB09") == 0) sc = sf::Keyboard::ScanPeriod;
|
|
||||||
else if (strcmp(name, "AB10") == 0) sc = sf::Keyboard::ScanForwardSlash;
|
|
||||||
else if (strcmp(name, "LSGT") == 0) sc = sf::Keyboard::ScanReverseSolidus;
|
|
||||||
else sc = sf::Keyboard::ScanUnknown;
|
|
||||||
|
|
||||||
if (isValidKeycode(keycode))
|
if (mappedScancode != nameScancodeMap.end())
|
||||||
{
|
scancode = mappedScancode->second;
|
||||||
scancodeToKeycode[sc] = keycode;
|
|
||||||
keycodeToScancode[keycode] = sc;
|
if (scancode != sf::Keyboard::ScanUnknown)
|
||||||
}
|
scancodeToKeycode[scancode] = static_cast<KeyCode>(keycode);
|
||||||
|
|
||||||
|
keycodeToScancode[keycode] = scancode;
|
||||||
}
|
}
|
||||||
|
|
||||||
XkbFreeNames(desc, XkbKeyNamesMask, True);
|
XkbFreeNames(descriptor, XkbKeyNamesMask, True);
|
||||||
XkbFreeKeyboard(desc, 0, True);
|
XkbFreeKeyboard(descriptor, 0, True);
|
||||||
|
|
||||||
// Translate un-translated keycodes using traditional X11 KeySym lookups
|
// Phase 3: Translate un-translated keycodes using traditional X11 KeySym lookups
|
||||||
// Valid keycodes are [8;255], so we only initialize them
|
for (int keycode = 8; keycode < MaxKeyCode; ++keycode)
|
||||||
for (int keycode = 8; keycode < 256; ++keycode)
|
|
||||||
{
|
{
|
||||||
if (keycodeToScancode[keycode] == sf::Keyboard::ScanUnknown)
|
if (keycodeToScancode[static_cast<KeyCode>(keycode)] == sf::Keyboard::ScanUnknown)
|
||||||
{
|
{
|
||||||
sf::Keyboard::Scancode sc = translateKeyCode(display, keycode);
|
scancode = translateKeyCode(display, static_cast<KeyCode>(keycode));
|
||||||
scancodeToKeycode[sc] = keycode;
|
scancodeToKeycode[scancode] = static_cast<KeyCode>(keycode);
|
||||||
keycodeToScancode[keycode] = sc;
|
keycodeToScancode[keycode] = scancode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,18 +513,19 @@ void initMapping()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
KeyCode scancodeToKeyCode(sf::Keyboard::Scancode code)
|
KeyCode scancodeToKeyCode(sf::Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
if (!isMappingInitialized)
|
ensureMapping();
|
||||||
initMapping();
|
|
||||||
|
|
||||||
|
if (code != sf::Keyboard::ScanUnknown)
|
||||||
return scancodeToKeycode[code];
|
return scancodeToKeycode[code];
|
||||||
|
|
||||||
|
return NullKeyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
sf::Keyboard::Scancode keyCodeToScancode(KeyCode code)
|
sf::Keyboard::Scancode keyCodeToScancode(KeyCode code)
|
||||||
{
|
{
|
||||||
if (!isMappingInitialized)
|
ensureMapping();
|
||||||
initMapping();
|
|
||||||
|
|
||||||
if (isValidKeycode(code))
|
if (isValidKeycode(code))
|
||||||
return keycodeToScancode[code];
|
return keycodeToScancode[code];
|
||||||
@ -421,7 +612,7 @@ bool KeyboardImpl::isKeyPressed(Keyboard::Scancode code)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode KeyboardImpl::unlocalize(Keyboard::Key key)
|
Keyboard::Scancode KeyboardImpl::delocalize(Keyboard::Key key)
|
||||||
{
|
{
|
||||||
KeyCode keycode = keyToKeyCode(key);
|
KeyCode keycode = keyToKeyCode(key);
|
||||||
return keyCodeToScancode(keycode);
|
return keyCodeToScancode(keycode);
|
||||||
@ -443,13 +634,21 @@ String KeyboardImpl::getDescription(Keyboard::Scancode code)
|
|||||||
|
|
||||||
// these scancodes actually correspond to keys with input
|
// these scancodes actually correspond to keys with input
|
||||||
// but we want to return their description, not their behaviour
|
// but we want to return their description, not their behaviour
|
||||||
if (code == Keyboard::ScanEscape ||
|
if (code == Keyboard::ScanEnter ||
|
||||||
code == Keyboard::ScanEnter ||
|
code == Keyboard::ScanEscape ||
|
||||||
code == Keyboard::ScanReturn ||
|
|
||||||
code == Keyboard::ScanTab ||
|
|
||||||
code == Keyboard::ScanDelete ||
|
|
||||||
code == Keyboard::ScanBackspace ||
|
code == Keyboard::ScanBackspace ||
|
||||||
code == Keyboard::ScanSpace)
|
code == Keyboard::ScanTab ||
|
||||||
|
code == Keyboard::ScanSpace ||
|
||||||
|
code == Keyboard::ScanScrollLock ||
|
||||||
|
code == Keyboard::ScanPause ||
|
||||||
|
code == Keyboard::ScanDelete ||
|
||||||
|
code == Keyboard::ScanNumpadDivide ||
|
||||||
|
code == Keyboard::ScanNumpadMultiply ||
|
||||||
|
code == Keyboard::ScanNumpadMinus ||
|
||||||
|
code == Keyboard::ScanNumpadPlus ||
|
||||||
|
code == Keyboard::ScanNumpadEqual ||
|
||||||
|
code == Keyboard::ScanNumpadEnter ||
|
||||||
|
code == Keyboard::ScanNumpadDecimal)
|
||||||
{
|
{
|
||||||
checkInput = false;
|
checkInput = false;
|
||||||
}
|
}
|
||||||
@ -487,33 +686,41 @@ String KeyboardImpl::getDescription(Keyboard::Scancode code)
|
|||||||
case Keyboard::ScanF13: return "F13";
|
case Keyboard::ScanF13: return "F13";
|
||||||
case Keyboard::ScanF14: return "F14";
|
case Keyboard::ScanF14: return "F14";
|
||||||
case Keyboard::ScanF15: return "F15";
|
case Keyboard::ScanF15: return "F15";
|
||||||
// TODO: add F16-F25 once they're added in Scancode enum
|
case Keyboard::ScanF16: return "F16";
|
||||||
|
case Keyboard::ScanF17: return "F17";
|
||||||
|
case Keyboard::ScanF18: return "F18";
|
||||||
|
case Keyboard::ScanF19: return "F19";
|
||||||
|
case Keyboard::ScanF20: return "F20";
|
||||||
|
case Keyboard::ScanF21: return "F21";
|
||||||
|
case Keyboard::ScanF22: return "F22";
|
||||||
|
case Keyboard::ScanF23: return "F23";
|
||||||
|
case Keyboard::ScanF24: return "F24";
|
||||||
|
|
||||||
case Keyboard::ScanCapsLock: return "CapsLock";
|
case Keyboard::ScanCapsLock: return "Caps Lock";
|
||||||
case Keyboard::ScanPrintScreen: return "PrintScreen";
|
case Keyboard::ScanPrintScreen: return "Print Screen";
|
||||||
case Keyboard::ScanScrollLock: return "ScrollLock";
|
case Keyboard::ScanScrollLock: return "Scroll Lock";
|
||||||
|
|
||||||
case Keyboard::ScanPause: return "Pause";
|
case Keyboard::ScanPause: return "Pause";
|
||||||
case Keyboard::ScanInsert: return "Insert";
|
case Keyboard::ScanInsert: return "Insert";
|
||||||
case Keyboard::ScanHome: return "Home";
|
case Keyboard::ScanHome: return "Home";
|
||||||
case Keyboard::ScanPageUp: return "PageUp";
|
case Keyboard::ScanPageUp: return "Page Up";
|
||||||
case Keyboard::ScanDelete: return "Delete";
|
case Keyboard::ScanDelete: return "Delete";
|
||||||
case Keyboard::ScanEnd: return "End";
|
case Keyboard::ScanEnd: return "End";
|
||||||
case Keyboard::ScanPageDown: return "PageDown";
|
case Keyboard::ScanPageDown: return "Page Down";
|
||||||
|
|
||||||
case Keyboard::ScanLeft: return "Left Arrow";
|
case Keyboard::ScanLeft: return "Left Arrow";
|
||||||
case Keyboard::ScanRight: return "Right Arrow";
|
case Keyboard::ScanRight: return "Right Arrow";
|
||||||
case Keyboard::ScanDown: return "Down Arrow";
|
case Keyboard::ScanDown: return "Down Arrow";
|
||||||
case Keyboard::ScanUp: return "Up Arrow";
|
case Keyboard::ScanUp: return "Up Arrow";
|
||||||
|
|
||||||
case Keyboard::ScanNumLock: return "NumLock";
|
case Keyboard::ScanNumLock: return "Num Lock";
|
||||||
case Keyboard::ScanDivide: return "Divide (Numpad)";
|
case Keyboard::ScanNumpadDivide: return "Divide (Numpad)";
|
||||||
case Keyboard::ScanMultiply: return "Multiply (Numpad)";
|
case Keyboard::ScanNumpadMultiply: return "Multiply (Numpad)";
|
||||||
case Keyboard::ScanMinus: return "Minux (Numpad)";
|
case Keyboard::ScanNumpadMinus: return "Minus (Numpad)";
|
||||||
case Keyboard::ScanPlus: return "Plus (Numpad)";
|
case Keyboard::ScanNumpadPlus: return "Plus (Numpad)";
|
||||||
case Keyboard::ScanPadEquals: return "Equals (Numpad)";
|
case Keyboard::ScanNumpadEqual: return "Equal (Numpad)";
|
||||||
case Keyboard::ScanReturn: return "Enter (Numpad)";
|
case Keyboard::ScanNumpadEnter: return "Enter (Numpad)";
|
||||||
case Keyboard::ScanDecimal: return "Decimal (Numpad)";
|
case Keyboard::ScanNumpadDecimal: return "Decimal (Numpad)";
|
||||||
|
|
||||||
case Keyboard::ScanNumpad0: return "0 (Numpad)";
|
case Keyboard::ScanNumpad0: return "0 (Numpad)";
|
||||||
case Keyboard::ScanNumpad1: return "1 (Numpad)";
|
case Keyboard::ScanNumpad1: return "1 (Numpad)";
|
||||||
@ -532,25 +739,41 @@ String KeyboardImpl::getDescription(Keyboard::Scancode code)
|
|||||||
case Keyboard::ScanMenu: return "Menu";
|
case Keyboard::ScanMenu: return "Menu";
|
||||||
case Keyboard::ScanSelect: return "Select";
|
case Keyboard::ScanSelect: return "Select";
|
||||||
case Keyboard::ScanStop: return "Stop";
|
case Keyboard::ScanStop: return "Stop";
|
||||||
case Keyboard::ScanAgain: return "Again";
|
case Keyboard::ScanRedo: return "Redo";
|
||||||
case Keyboard::ScanUndo: return "Undo";
|
case Keyboard::ScanUndo: return "Undo";
|
||||||
case Keyboard::ScanCut: return "Cut";
|
case Keyboard::ScanCut: return "Cut";
|
||||||
case Keyboard::ScanCopy: return "Copy";
|
case Keyboard::ScanCopy: return "Copy";
|
||||||
case Keyboard::ScanPaste: return "Paste";
|
case Keyboard::ScanPaste: return "Paste";
|
||||||
case Keyboard::ScanFind: return "Find";
|
case Keyboard::ScanSearch: return "Search";
|
||||||
case Keyboard::ScanMute: return "Mute";
|
|
||||||
|
case Keyboard::ScanVolumeMute: return "Volume Mute";
|
||||||
case Keyboard::ScanVolumeUp: return "Volume Up";
|
case Keyboard::ScanVolumeUp: return "Volume Up";
|
||||||
case Keyboard::ScanVolumeDown: return "Volume Down";
|
case Keyboard::ScanVolumeDown: return "Volume Down";
|
||||||
|
|
||||||
case Keyboard::ScanLControl: return "Left Control";
|
case Keyboard::ScanLControl: return "Left Control";
|
||||||
case Keyboard::ScanLShift: return "Left Shift";
|
case Keyboard::ScanLShift: return "Left Shift";
|
||||||
case Keyboard::ScanLAlt: return "Left Meta";
|
case Keyboard::ScanLAlt: return "Left Alt";
|
||||||
case Keyboard::ScanLSystem: return "Left Super";
|
case Keyboard::ScanLSystem: return "Left System";
|
||||||
case Keyboard::ScanRControl: return "Right Control";
|
case Keyboard::ScanRControl: return "Right Control";
|
||||||
case Keyboard::ScanRShift: return "Right Shift";
|
case Keyboard::ScanRShift: return "Right Shift";
|
||||||
case Keyboard::ScanRAlt: return "Right Meta";
|
case Keyboard::ScanRAlt: return "Right Alt";
|
||||||
case Keyboard::ScanRSystem: return "Right Super";
|
case Keyboard::ScanRSystem: return "Right System";
|
||||||
default: return "Unknown Scancode"; // no guess good enough possible.
|
|
||||||
|
case Keyboard::ScanLaunchApplication1: return "Launch Application 1";
|
||||||
|
case Keyboard::ScanLaunchApplication2: return "Launch Application 2";
|
||||||
|
case Keyboard::ScanFavorites: return "Favorites";
|
||||||
|
case Keyboard::ScanBack: return "Back";
|
||||||
|
case Keyboard::ScanForward: return "Forward";
|
||||||
|
case Keyboard::ScanMediaNextTrack: return "Media Next Track";
|
||||||
|
case Keyboard::ScanMediaPlayPause: return "Media Play Pause";
|
||||||
|
case Keyboard::ScanMediaPreviousTrack: return "Media Previous Track";
|
||||||
|
case Keyboard::ScanMediaStop: return "Media Stop";
|
||||||
|
case Keyboard::ScanHomePage: return "Home Page";
|
||||||
|
case Keyboard::ScanRefresh: return "Refresh";
|
||||||
|
case Keyboard::ScanLaunchMail: return "Launch Mail";
|
||||||
|
case Keyboard::ScanLaunchMediaSelect: return "Launch Media Select";
|
||||||
|
|
||||||
|
default: return "Unknown Scancode";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +801,7 @@ Keyboard::Key KeyboardImpl::getKeyFromEvent(XKeyEvent& event)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode KeyboardImpl::getScancodeFromEvent(XKeyEvent& event)
|
Keyboard::Scancode KeyboardImpl::getScancodeFromEvent(XKeyEvent& event)
|
||||||
{
|
{
|
||||||
return keyCodeToScancode(event.keycode);
|
return keyCodeToScancode(static_cast<KeyCode>(event.keycode));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SFML - Simple and Fast Multimedia Library
|
// SFML - Simple and Fast Multimedia Library
|
||||||
// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
|
// Copyright (C) 2007-2021 Laurent Gomila (laurent@sfml-dev.org)
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
@ -62,10 +62,10 @@ public:
|
|||||||
/// \copydoc sf::Keyboard::localize
|
/// \copydoc sf::Keyboard::localize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode unlocalize(Keyboard::Key key);
|
static Keyboard::Scancode delocalize(Keyboard::Key key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::unlocalize
|
/// \copydoc sf::Keyboard::delocalize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Key localize(Keyboard::Scancode code);
|
static Keyboard::Key localize(Keyboard::Scancode code);
|
||||||
|
@ -364,117 +364,6 @@ namespace
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Keyboard::Key keysymToSF(KeySym symbol)
|
|
||||||
{
|
|
||||||
switch (symbol)
|
|
||||||
{
|
|
||||||
case XK_Shift_L: return sf::Keyboard::LShift;
|
|
||||||
case XK_Shift_R: return sf::Keyboard::RShift;
|
|
||||||
case XK_Control_L: return sf::Keyboard::LControl;
|
|
||||||
case XK_Control_R: return sf::Keyboard::RControl;
|
|
||||||
case XK_Alt_L: return sf::Keyboard::LAlt;
|
|
||||||
case XK_Alt_R: return sf::Keyboard::RAlt;
|
|
||||||
case XK_Super_L: return sf::Keyboard::LSystem;
|
|
||||||
case XK_Super_R: return sf::Keyboard::RSystem;
|
|
||||||
case XK_Menu: return sf::Keyboard::Menu;
|
|
||||||
case XK_Escape: return sf::Keyboard::Escape;
|
|
||||||
case XK_semicolon: return sf::Keyboard::Semicolon;
|
|
||||||
case XK_slash: return sf::Keyboard::Slash;
|
|
||||||
case XK_equal: return sf::Keyboard::Equal;
|
|
||||||
case XK_minus: return sf::Keyboard::Hyphen;
|
|
||||||
case XK_bracketleft: return sf::Keyboard::LBracket;
|
|
||||||
case XK_bracketright: return sf::Keyboard::RBracket;
|
|
||||||
case XK_comma: return sf::Keyboard::Comma;
|
|
||||||
case XK_period: return sf::Keyboard::Period;
|
|
||||||
case XK_apostrophe: return sf::Keyboard::Quote;
|
|
||||||
case XK_backslash: return sf::Keyboard::Backslash;
|
|
||||||
case XK_grave: return sf::Keyboard::Tilde;
|
|
||||||
case XK_space: return sf::Keyboard::Space;
|
|
||||||
case XK_Return: return sf::Keyboard::Enter;
|
|
||||||
case XK_KP_Enter: return sf::Keyboard::Enter;
|
|
||||||
case XK_BackSpace: return sf::Keyboard::Backspace;
|
|
||||||
case XK_Tab: return sf::Keyboard::Tab;
|
|
||||||
case XK_Prior: return sf::Keyboard::PageUp;
|
|
||||||
case XK_Next: return sf::Keyboard::PageDown;
|
|
||||||
case XK_End: return sf::Keyboard::End;
|
|
||||||
case XK_Home: return sf::Keyboard::Home;
|
|
||||||
case XK_Insert: return sf::Keyboard::Insert;
|
|
||||||
case XK_Delete: return sf::Keyboard::Delete;
|
|
||||||
case XK_KP_Add: return sf::Keyboard::Add;
|
|
||||||
case XK_KP_Subtract: return sf::Keyboard::Subtract;
|
|
||||||
case XK_KP_Multiply: return sf::Keyboard::Multiply;
|
|
||||||
case XK_KP_Divide: return sf::Keyboard::Divide;
|
|
||||||
case XK_Pause: return sf::Keyboard::Pause;
|
|
||||||
case XK_F1: return sf::Keyboard::F1;
|
|
||||||
case XK_F2: return sf::Keyboard::F2;
|
|
||||||
case XK_F3: return sf::Keyboard::F3;
|
|
||||||
case XK_F4: return sf::Keyboard::F4;
|
|
||||||
case XK_F5: return sf::Keyboard::F5;
|
|
||||||
case XK_F6: return sf::Keyboard::F6;
|
|
||||||
case XK_F7: return sf::Keyboard::F7;
|
|
||||||
case XK_F8: return sf::Keyboard::F8;
|
|
||||||
case XK_F9: return sf::Keyboard::F9;
|
|
||||||
case XK_F10: return sf::Keyboard::F10;
|
|
||||||
case XK_F11: return sf::Keyboard::F11;
|
|
||||||
case XK_F12: return sf::Keyboard::F12;
|
|
||||||
case XK_F13: return sf::Keyboard::F13;
|
|
||||||
case XK_F14: return sf::Keyboard::F14;
|
|
||||||
case XK_F15: return sf::Keyboard::F15;
|
|
||||||
case XK_Left: return sf::Keyboard::Left;
|
|
||||||
case XK_Right: return sf::Keyboard::Right;
|
|
||||||
case XK_Up: return sf::Keyboard::Up;
|
|
||||||
case XK_Down: return sf::Keyboard::Down;
|
|
||||||
case XK_KP_Insert: return sf::Keyboard::Numpad0;
|
|
||||||
case XK_KP_End: return sf::Keyboard::Numpad1;
|
|
||||||
case XK_KP_Down: return sf::Keyboard::Numpad2;
|
|
||||||
case XK_KP_Page_Down: return sf::Keyboard::Numpad3;
|
|
||||||
case XK_KP_Left: return sf::Keyboard::Numpad4;
|
|
||||||
case XK_KP_Begin: return sf::Keyboard::Numpad5;
|
|
||||||
case XK_KP_Right: return sf::Keyboard::Numpad6;
|
|
||||||
case XK_KP_Home: return sf::Keyboard::Numpad7;
|
|
||||||
case XK_KP_Up: return sf::Keyboard::Numpad8;
|
|
||||||
case XK_KP_Page_Up: return sf::Keyboard::Numpad9;
|
|
||||||
case XK_a: return sf::Keyboard::A;
|
|
||||||
case XK_b: return sf::Keyboard::B;
|
|
||||||
case XK_c: return sf::Keyboard::C;
|
|
||||||
case XK_d: return sf::Keyboard::D;
|
|
||||||
case XK_e: return sf::Keyboard::E;
|
|
||||||
case XK_f: return sf::Keyboard::F;
|
|
||||||
case XK_g: return sf::Keyboard::G;
|
|
||||||
case XK_h: return sf::Keyboard::H;
|
|
||||||
case XK_i: return sf::Keyboard::I;
|
|
||||||
case XK_j: return sf::Keyboard::J;
|
|
||||||
case XK_k: return sf::Keyboard::K;
|
|
||||||
case XK_l: return sf::Keyboard::L;
|
|
||||||
case XK_m: return sf::Keyboard::M;
|
|
||||||
case XK_n: return sf::Keyboard::N;
|
|
||||||
case XK_o: return sf::Keyboard::O;
|
|
||||||
case XK_p: return sf::Keyboard::P;
|
|
||||||
case XK_q: return sf::Keyboard::Q;
|
|
||||||
case XK_r: return sf::Keyboard::R;
|
|
||||||
case XK_s: return sf::Keyboard::S;
|
|
||||||
case XK_t: return sf::Keyboard::T;
|
|
||||||
case XK_u: return sf::Keyboard::U;
|
|
||||||
case XK_v: return sf::Keyboard::V;
|
|
||||||
case XK_w: return sf::Keyboard::W;
|
|
||||||
case XK_x: return sf::Keyboard::X;
|
|
||||||
case XK_y: return sf::Keyboard::Y;
|
|
||||||
case XK_z: return sf::Keyboard::Z;
|
|
||||||
case XK_0: return sf::Keyboard::Num0;
|
|
||||||
case XK_1: return sf::Keyboard::Num1;
|
|
||||||
case XK_2: return sf::Keyboard::Num2;
|
|
||||||
case XK_3: return sf::Keyboard::Num3;
|
|
||||||
case XK_4: return sf::Keyboard::Num4;
|
|
||||||
case XK_5: return sf::Keyboard::Num5;
|
|
||||||
case XK_6: return sf::Keyboard::Num6;
|
|
||||||
case XK_7: return sf::Keyboard::Num7;
|
|
||||||
case XK_8: return sf::Keyboard::Num8;
|
|
||||||
case XK_9: return sf::Keyboard::Num9;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sf::Keyboard::Unknown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,20 +37,19 @@
|
|||||||
#include <SFML/Window/Win32/InputImpl.hpp>
|
#include <SFML/Window/Win32/InputImpl.hpp>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode InputImpl::m_keyToScancodeMapping[Keyboard::KeyCount]; ///< Mapping from Key to Scancode
|
Keyboard::Scancode InputImpl::m_keyToScancodeMapping[Keyboard::KeyCount]; ///< Mapping from Key to Scancode
|
||||||
Keyboard::Key InputImpl::m_scancodeToKeyMapping[Keyboard::ScanCodeCount]; ///< Mapping from Scancode to Key
|
Keyboard::Key InputImpl::m_scancodeToKeyMapping[Keyboard::ScancodeCount]; ///< Mapping from Scancode to Key
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Key winKeyToSfKey(int vkey)
|
Keyboard::Key virtualKeyToSfKey(UINT virtualKey)
|
||||||
{
|
{
|
||||||
Keyboard::Key key;
|
Keyboard::Key key;
|
||||||
switch (vkey)
|
switch (virtualKey)
|
||||||
{
|
{
|
||||||
default: key = Keyboard::Unknown; break;
|
default: key = Keyboard::Unknown; break;
|
||||||
case 'A': key = Keyboard::A; break;
|
case 'A': key = Keyboard::A; break;
|
||||||
@ -103,8 +102,8 @@ Keyboard::Key winKeyToSfKey(int vkey)
|
|||||||
case VK_OEM_6: key = Keyboard::RBracket; break;
|
case VK_OEM_6: key = Keyboard::RBracket; break;
|
||||||
case VK_OEM_1: key = Keyboard::Semicolon; break;
|
case VK_OEM_1: key = Keyboard::Semicolon; break;
|
||||||
case VK_OEM_COMMA: key = Keyboard::Comma; break;
|
case VK_OEM_COMMA: key = Keyboard::Comma; break;
|
||||||
case VK_OEM_PERIOD: key = Keyboard::Period; ;
|
case VK_OEM_PERIOD: key = Keyboard::Period; break;
|
||||||
case VK_OEM_7: key = Keyboard::Quote; break;
|
case VK_OEM_7: key = Keyboard::Apostrophe; break;
|
||||||
case VK_OEM_2: key = Keyboard::Slash; break;
|
case VK_OEM_2: key = Keyboard::Slash; break;
|
||||||
case VK_OEM_5: key = Keyboard::Backslash; break;
|
case VK_OEM_5: key = Keyboard::Backslash; break;
|
||||||
case VK_OEM_3: key = Keyboard::Tilde; break;
|
case VK_OEM_3: key = Keyboard::Tilde; break;
|
||||||
@ -157,317 +156,462 @@ Keyboard::Key winKeyToSfKey(int vkey)
|
|||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
int sfKeyToWin(Keyboard::Key key)
|
int sfKeyToVirtualKey(Keyboard::Key key)
|
||||||
{
|
{
|
||||||
int vkey = 0;
|
int virtualKey = 0;
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
default: vkey = 0; break;
|
default: virtualKey = 0; break;
|
||||||
case Keyboard::A: vkey = 'A'; break;
|
case Keyboard::A: virtualKey = 'A'; break;
|
||||||
case Keyboard::B: vkey = 'B'; break;
|
case Keyboard::B: virtualKey = 'B'; break;
|
||||||
case Keyboard::C: vkey = 'C'; break;
|
case Keyboard::C: virtualKey = 'C'; break;
|
||||||
case Keyboard::D: vkey = 'D'; break;
|
case Keyboard::D: virtualKey = 'D'; break;
|
||||||
case Keyboard::E: vkey = 'E'; break;
|
case Keyboard::E: virtualKey = 'E'; break;
|
||||||
case Keyboard::F: vkey = 'F'; break;
|
case Keyboard::F: virtualKey = 'F'; break;
|
||||||
case Keyboard::G: vkey = 'G'; break;
|
case Keyboard::G: virtualKey = 'G'; break;
|
||||||
case Keyboard::H: vkey = 'H'; break;
|
case Keyboard::H: virtualKey = 'H'; break;
|
||||||
case Keyboard::I: vkey = 'I'; break;
|
case Keyboard::I: virtualKey = 'I'; break;
|
||||||
case Keyboard::J: vkey = 'J'; break;
|
case Keyboard::J: virtualKey = 'J'; break;
|
||||||
case Keyboard::K: vkey = 'K'; break;
|
case Keyboard::K: virtualKey = 'K'; break;
|
||||||
case Keyboard::L: vkey = 'L'; break;
|
case Keyboard::L: virtualKey = 'L'; break;
|
||||||
case Keyboard::M: vkey = 'M'; break;
|
case Keyboard::M: virtualKey = 'M'; break;
|
||||||
case Keyboard::N: vkey = 'N'; break;
|
case Keyboard::N: virtualKey = 'N'; break;
|
||||||
case Keyboard::O: vkey = 'O'; break;
|
case Keyboard::O: virtualKey = 'O'; break;
|
||||||
case Keyboard::P: vkey = 'P'; break;
|
case Keyboard::P: virtualKey = 'P'; break;
|
||||||
case Keyboard::Q: vkey = 'Q'; break;
|
case Keyboard::Q: virtualKey = 'Q'; break;
|
||||||
case Keyboard::R: vkey = 'R'; break;
|
case Keyboard::R: virtualKey = 'R'; break;
|
||||||
case Keyboard::S: vkey = 'S'; break;
|
case Keyboard::S: virtualKey = 'S'; break;
|
||||||
case Keyboard::T: vkey = 'T'; break;
|
case Keyboard::T: virtualKey = 'T'; break;
|
||||||
case Keyboard::U: vkey = 'U'; break;
|
case Keyboard::U: virtualKey = 'U'; break;
|
||||||
case Keyboard::V: vkey = 'V'; break;
|
case Keyboard::V: virtualKey = 'V'; break;
|
||||||
case Keyboard::W: vkey = 'W'; break;
|
case Keyboard::W: virtualKey = 'W'; break;
|
||||||
case Keyboard::X: vkey = 'X'; break;
|
case Keyboard::X: virtualKey = 'X'; break;
|
||||||
case Keyboard::Y: vkey = 'Y'; break;
|
case Keyboard::Y: virtualKey = 'Y'; break;
|
||||||
case Keyboard::Z: vkey = 'Z'; break;
|
case Keyboard::Z: virtualKey = 'Z'; break;
|
||||||
case Keyboard::Num0: vkey = '0'; break;
|
case Keyboard::Num0: virtualKey = '0'; break;
|
||||||
case Keyboard::Num1: vkey = '1'; break;
|
case Keyboard::Num1: virtualKey = '1'; break;
|
||||||
case Keyboard::Num2: vkey = '2'; break;
|
case Keyboard::Num2: virtualKey = '2'; break;
|
||||||
case Keyboard::Num3: vkey = '3'; break;
|
case Keyboard::Num3: virtualKey = '3'; break;
|
||||||
case Keyboard::Num4: vkey = '4'; break;
|
case Keyboard::Num4: virtualKey = '4'; break;
|
||||||
case Keyboard::Num5: vkey = '5'; break;
|
case Keyboard::Num5: virtualKey = '5'; break;
|
||||||
case Keyboard::Num6: vkey = '6'; break;
|
case Keyboard::Num6: virtualKey = '6'; break;
|
||||||
case Keyboard::Num7: vkey = '7'; break;
|
case Keyboard::Num7: virtualKey = '7'; break;
|
||||||
case Keyboard::Num8: vkey = '8'; break;
|
case Keyboard::Num8: virtualKey = '8'; break;
|
||||||
case Keyboard::Num9: vkey = '9'; break;
|
case Keyboard::Num9: virtualKey = '9'; break;
|
||||||
case Keyboard::Escape: vkey = VK_ESCAPE; break;
|
case Keyboard::Escape: virtualKey = VK_ESCAPE; break;
|
||||||
case Keyboard::LControl: vkey = VK_LCONTROL; break;
|
case Keyboard::LControl: virtualKey = VK_LCONTROL; break;
|
||||||
case Keyboard::LShift: vkey = VK_LSHIFT; break;
|
case Keyboard::LShift: virtualKey = VK_LSHIFT; break;
|
||||||
case Keyboard::LAlt: vkey = VK_LMENU; break;
|
case Keyboard::LAlt: virtualKey = VK_LMENU; break;
|
||||||
case Keyboard::LSystem: vkey = VK_LWIN; break;
|
case Keyboard::LSystem: virtualKey = VK_LWIN; break;
|
||||||
case Keyboard::RControl: vkey = VK_RCONTROL; break;
|
case Keyboard::RControl: virtualKey = VK_RCONTROL; break;
|
||||||
case Keyboard::RShift: vkey = VK_RSHIFT; break;
|
case Keyboard::RShift: virtualKey = VK_RSHIFT; break;
|
||||||
case Keyboard::RAlt: vkey = VK_RMENU; break;
|
case Keyboard::RAlt: virtualKey = VK_RMENU; break;
|
||||||
case Keyboard::RSystem: vkey = VK_RWIN; break;
|
case Keyboard::RSystem: virtualKey = VK_RWIN; break;
|
||||||
case Keyboard::Menu: vkey = VK_APPS; break;
|
case Keyboard::Menu: virtualKey = VK_APPS; break;
|
||||||
case Keyboard::LBracket: vkey = VK_OEM_4; break;
|
case Keyboard::LBracket: virtualKey = VK_OEM_4; break;
|
||||||
case Keyboard::RBracket: vkey = VK_OEM_6; break;
|
case Keyboard::RBracket: virtualKey = VK_OEM_6; break;
|
||||||
case Keyboard::Semicolon: vkey = VK_OEM_1; break;
|
case Keyboard::Semicolon: virtualKey = VK_OEM_1; break;
|
||||||
case Keyboard::Comma: vkey = VK_OEM_COMMA; break;
|
case Keyboard::Comma: virtualKey = VK_OEM_COMMA; break;
|
||||||
case Keyboard::Period: vkey = VK_OEM_PERIOD; break;
|
case Keyboard::Period: virtualKey = VK_OEM_PERIOD; break;
|
||||||
case Keyboard::Quote: vkey = VK_OEM_7; break;
|
case Keyboard::Apostrophe: virtualKey = VK_OEM_7; break;
|
||||||
case Keyboard::Slash: vkey = VK_OEM_2; break;
|
case Keyboard::Slash: virtualKey = VK_OEM_2; break;
|
||||||
case Keyboard::Backslash: vkey = VK_OEM_5; break;
|
case Keyboard::Backslash: virtualKey = VK_OEM_5; break;
|
||||||
case Keyboard::Tilde: vkey = VK_OEM_3; break;
|
case Keyboard::Tilde: virtualKey = VK_OEM_3; break;
|
||||||
case Keyboard::Equal: vkey = VK_OEM_PLUS; break;
|
case Keyboard::Equal: virtualKey = VK_OEM_PLUS; break;
|
||||||
case Keyboard::Hyphen: vkey = VK_OEM_MINUS; break;
|
case Keyboard::Hyphen: virtualKey = VK_OEM_MINUS; break;
|
||||||
case Keyboard::Space: vkey = VK_SPACE; break;
|
case Keyboard::Space: virtualKey = VK_SPACE; break;
|
||||||
case Keyboard::Enter: vkey = VK_RETURN; break;
|
case Keyboard::Enter: virtualKey = VK_RETURN; break;
|
||||||
case Keyboard::Backspace: vkey = VK_BACK; break;
|
case Keyboard::Backspace: virtualKey = VK_BACK; break;
|
||||||
case Keyboard::Tab: vkey = VK_TAB; break;
|
case Keyboard::Tab: virtualKey = VK_TAB; break;
|
||||||
case Keyboard::PageUp: vkey = VK_PRIOR; break;
|
case Keyboard::PageUp: virtualKey = VK_PRIOR; break;
|
||||||
case Keyboard::PageDown: vkey = VK_NEXT; break;
|
case Keyboard::PageDown: virtualKey = VK_NEXT; break;
|
||||||
case Keyboard::End: vkey = VK_END; break;
|
case Keyboard::End: virtualKey = VK_END; break;
|
||||||
case Keyboard::Home: vkey = VK_HOME; break;
|
case Keyboard::Home: virtualKey = VK_HOME; break;
|
||||||
case Keyboard::Insert: vkey = VK_INSERT; break;
|
case Keyboard::Insert: virtualKey = VK_INSERT; break;
|
||||||
case Keyboard::Delete: vkey = VK_DELETE; break;
|
case Keyboard::Delete: virtualKey = VK_DELETE; break;
|
||||||
case Keyboard::Add: vkey = VK_ADD; break;
|
case Keyboard::Add: virtualKey = VK_ADD; break;
|
||||||
case Keyboard::Subtract: vkey = VK_SUBTRACT; break;
|
case Keyboard::Subtract: virtualKey = VK_SUBTRACT; break;
|
||||||
case Keyboard::Multiply: vkey = VK_MULTIPLY; break;
|
case Keyboard::Multiply: virtualKey = VK_MULTIPLY; break;
|
||||||
case Keyboard::Divide: vkey = VK_DIVIDE; break;
|
case Keyboard::Divide: virtualKey = VK_DIVIDE; break;
|
||||||
case Keyboard::Left: vkey = VK_LEFT; break;
|
case Keyboard::Left: virtualKey = VK_LEFT; break;
|
||||||
case Keyboard::Right: vkey = VK_RIGHT; break;
|
case Keyboard::Right: virtualKey = VK_RIGHT; break;
|
||||||
case Keyboard::Up: vkey = VK_UP; break;
|
case Keyboard::Up: virtualKey = VK_UP; break;
|
||||||
case Keyboard::Down: vkey = VK_DOWN; break;
|
case Keyboard::Down: virtualKey = VK_DOWN; break;
|
||||||
case Keyboard::Numpad0: vkey = VK_NUMPAD0; break;
|
case Keyboard::Numpad0: virtualKey = VK_NUMPAD0; break;
|
||||||
case Keyboard::Numpad1: vkey = VK_NUMPAD1; break;
|
case Keyboard::Numpad1: virtualKey = VK_NUMPAD1; break;
|
||||||
case Keyboard::Numpad2: vkey = VK_NUMPAD2; break;
|
case Keyboard::Numpad2: virtualKey = VK_NUMPAD2; break;
|
||||||
case Keyboard::Numpad3: vkey = VK_NUMPAD3; break;
|
case Keyboard::Numpad3: virtualKey = VK_NUMPAD3; break;
|
||||||
case Keyboard::Numpad4: vkey = VK_NUMPAD4; break;
|
case Keyboard::Numpad4: virtualKey = VK_NUMPAD4; break;
|
||||||
case Keyboard::Numpad5: vkey = VK_NUMPAD5; break;
|
case Keyboard::Numpad5: virtualKey = VK_NUMPAD5; break;
|
||||||
case Keyboard::Numpad6: vkey = VK_NUMPAD6; break;
|
case Keyboard::Numpad6: virtualKey = VK_NUMPAD6; break;
|
||||||
case Keyboard::Numpad7: vkey = VK_NUMPAD7; break;
|
case Keyboard::Numpad7: virtualKey = VK_NUMPAD7; break;
|
||||||
case Keyboard::Numpad8: vkey = VK_NUMPAD8; break;
|
case Keyboard::Numpad8: virtualKey = VK_NUMPAD8; break;
|
||||||
case Keyboard::Numpad9: vkey = VK_NUMPAD9; break;
|
case Keyboard::Numpad9: virtualKey = VK_NUMPAD9; break;
|
||||||
case Keyboard::F1: vkey = VK_F1; break;
|
case Keyboard::F1: virtualKey = VK_F1; break;
|
||||||
case Keyboard::F2: vkey = VK_F2; break;
|
case Keyboard::F2: virtualKey = VK_F2; break;
|
||||||
case Keyboard::F3: vkey = VK_F3; break;
|
case Keyboard::F3: virtualKey = VK_F3; break;
|
||||||
case Keyboard::F4: vkey = VK_F4; break;
|
case Keyboard::F4: virtualKey = VK_F4; break;
|
||||||
case Keyboard::F5: vkey = VK_F5; break;
|
case Keyboard::F5: virtualKey = VK_F5; break;
|
||||||
case Keyboard::F6: vkey = VK_F6; break;
|
case Keyboard::F6: virtualKey = VK_F6; break;
|
||||||
case Keyboard::F7: vkey = VK_F7; break;
|
case Keyboard::F7: virtualKey = VK_F7; break;
|
||||||
case Keyboard::F8: vkey = VK_F8; break;
|
case Keyboard::F8: virtualKey = VK_F8; break;
|
||||||
case Keyboard::F9: vkey = VK_F9; break;
|
case Keyboard::F9: virtualKey = VK_F9; break;
|
||||||
case Keyboard::F10: vkey = VK_F10; break;
|
case Keyboard::F10: virtualKey = VK_F10; break;
|
||||||
case Keyboard::F11: vkey = VK_F11; break;
|
case Keyboard::F11: virtualKey = VK_F11; break;
|
||||||
case Keyboard::F12: vkey = VK_F12; break;
|
case Keyboard::F12: virtualKey = VK_F12; break;
|
||||||
case Keyboard::F13: vkey = VK_F13; break;
|
case Keyboard::F13: virtualKey = VK_F13; break;
|
||||||
case Keyboard::F14: vkey = VK_F14; break;
|
case Keyboard::F14: virtualKey = VK_F14; break;
|
||||||
case Keyboard::F15: vkey = VK_F15; break;
|
case Keyboard::F15: virtualKey = VK_F15; break;
|
||||||
case Keyboard::Pause: vkey = VK_PAUSE; break;
|
case Keyboard::Pause: virtualKey = VK_PAUSE; break;
|
||||||
}
|
}
|
||||||
return vkey;
|
return virtualKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WORD sfScanToWin(Keyboard::Scancode code)
|
WORD sfScanToWinScan(Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
// Convert an SFML scancode to a windows scancode
|
// Convert an SFML scancode to a Windows scancode
|
||||||
// Reference: https://msdn.microsoft.com/en-us/library/aa299374(v=vs.60).aspx
|
// Reference: https://msdn.microsoft.com/en-us/library/aa299374(v=vs.60).aspx
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case Keyboard::ScanA: return 30;
|
case Keyboard::ScanA: return 0x1E;
|
||||||
case Keyboard::ScanB: return 48;
|
case Keyboard::ScanB: return 0x30;
|
||||||
case Keyboard::ScanC: return 46;
|
case Keyboard::ScanC: return 0x2E;
|
||||||
case Keyboard::ScanD: return 32;
|
case Keyboard::ScanD: return 0x20;
|
||||||
case Keyboard::ScanE: return 18;
|
case Keyboard::ScanE: return 0x12;
|
||||||
case Keyboard::ScanF: return 33;
|
case Keyboard::ScanF: return 0x21;
|
||||||
case Keyboard::ScanG: return 34;
|
case Keyboard::ScanG: return 0x22;
|
||||||
case Keyboard::ScanH: return 35;
|
case Keyboard::ScanH: return 0x23;
|
||||||
case Keyboard::ScanI: return 23;
|
case Keyboard::ScanI: return 0x17;
|
||||||
case Keyboard::ScanJ: return 36;
|
case Keyboard::ScanJ: return 0x24;
|
||||||
case Keyboard::ScanK: return 37;
|
case Keyboard::ScanK: return 0x25;
|
||||||
case Keyboard::ScanL: return 38;
|
case Keyboard::ScanL: return 0x26;
|
||||||
case Keyboard::ScanM: return 50;
|
case Keyboard::ScanM: return 0x32;
|
||||||
case Keyboard::ScanN: return 49;
|
case Keyboard::ScanN: return 0x31;
|
||||||
case Keyboard::ScanO: return 24;
|
case Keyboard::ScanO: return 0x18;
|
||||||
case Keyboard::ScanP: return 25;
|
case Keyboard::ScanP: return 0x19;
|
||||||
case Keyboard::ScanQ: return 16;
|
case Keyboard::ScanQ: return 0x10;
|
||||||
case Keyboard::ScanR: return 19;
|
case Keyboard::ScanR: return 0x13;
|
||||||
case Keyboard::ScanS: return 31;
|
case Keyboard::ScanS: return 0x1F;
|
||||||
case Keyboard::ScanT: return 20;
|
case Keyboard::ScanT: return 0x14;
|
||||||
case Keyboard::ScanU: return 22;
|
case Keyboard::ScanU: return 0x16;
|
||||||
case Keyboard::ScanV: return 47;
|
case Keyboard::ScanV: return 0x2F;
|
||||||
case Keyboard::ScanW: return 17;
|
case Keyboard::ScanW: return 0x11;
|
||||||
case Keyboard::ScanX: return 45;
|
case Keyboard::ScanX: return 0x2D;
|
||||||
case Keyboard::ScanY: return 21;
|
case Keyboard::ScanY: return 0x15;
|
||||||
case Keyboard::ScanZ: return 44;
|
case Keyboard::ScanZ: return 0x2C;
|
||||||
|
|
||||||
case Keyboard::ScanNum1: return 2;
|
case Keyboard::ScanNum1: return 0x02;
|
||||||
case Keyboard::ScanNum2: return 3;
|
case Keyboard::ScanNum2: return 0x03;
|
||||||
case Keyboard::ScanNum3: return 4;
|
case Keyboard::ScanNum3: return 0x04;
|
||||||
case Keyboard::ScanNum4: return 5;
|
case Keyboard::ScanNum4: return 0x05;
|
||||||
case Keyboard::ScanNum5: return 6;
|
case Keyboard::ScanNum5: return 0x06;
|
||||||
case Keyboard::ScanNum6: return 7;
|
case Keyboard::ScanNum6: return 0x07;
|
||||||
case Keyboard::ScanNum7: return 8;
|
case Keyboard::ScanNum7: return 0x08;
|
||||||
case Keyboard::ScanNum8: return 9;
|
case Keyboard::ScanNum8: return 0x09;
|
||||||
case Keyboard::ScanNum9: return 10;
|
case Keyboard::ScanNum9: return 0x0A;
|
||||||
case Keyboard::ScanNum0: return 11;
|
case Keyboard::ScanNum0: return 0x0B;
|
||||||
|
|
||||||
case Keyboard::ScanEnter: return 28;
|
case Keyboard::ScanEnter: return 0x1C;
|
||||||
case Keyboard::ScanEscape: return 1;
|
case Keyboard::ScanEscape: return 0x01;
|
||||||
case Keyboard::ScanBackspace: return 14;
|
case Keyboard::ScanBackspace: return 0x0E;
|
||||||
case Keyboard::ScanTab: return 15;
|
case Keyboard::ScanTab: return 0x0F;
|
||||||
case Keyboard::ScanSpace: return 57;
|
case Keyboard::ScanSpace: return 0x39;
|
||||||
case Keyboard::ScanHyphen: return 12;
|
case Keyboard::ScanHyphen: return 0x0C;
|
||||||
case Keyboard::ScanEquals: return 13;
|
case Keyboard::ScanEqual: return 0x0D;
|
||||||
case Keyboard::ScanLBracket: return 26;
|
case Keyboard::ScanLBracket: return 0x1A;
|
||||||
case Keyboard::ScanRBracket: return 27;
|
case Keyboard::ScanRBracket: return 0x1B;
|
||||||
case Keyboard::ScanBackslash: return 43;
|
case Keyboard::ScanBackslash: return 0x2B;
|
||||||
case Keyboard::ScanDash: return 41;
|
case Keyboard::ScanSemicolon: return 0x27;
|
||||||
case Keyboard::ScanSemicolon: return 39;
|
case Keyboard::ScanApostrophe: return 0x28;
|
||||||
case Keyboard::ScanQuote: return 40;
|
case Keyboard::ScanGrave: return 0x29;
|
||||||
//case Keyboard::ScanGraveAccent: return ? ? ?
|
case Keyboard::ScanComma: return 0x33;
|
||||||
case Keyboard::ScanComma: return 51;
|
case Keyboard::ScanPeriod: return 0x34;
|
||||||
case Keyboard::ScanPeriod: return 52;
|
case Keyboard::ScanSlash: return 0x35;
|
||||||
case Keyboard::ScanSlash: return 53;
|
|
||||||
|
|
||||||
case Keyboard::ScanF1: return 59;
|
case Keyboard::ScanF1: return 0x3B;
|
||||||
case Keyboard::ScanF2: return 60;
|
case Keyboard::ScanF2: return 0x3C;
|
||||||
case Keyboard::ScanF3: return 61;
|
case Keyboard::ScanF3: return 0x3D;
|
||||||
case Keyboard::ScanF4: return 62;
|
case Keyboard::ScanF4: return 0x3E;
|
||||||
case Keyboard::ScanF5: return 63;
|
case Keyboard::ScanF5: return 0x3F;
|
||||||
case Keyboard::ScanF6: return 64;
|
case Keyboard::ScanF6: return 0x40;
|
||||||
case Keyboard::ScanF7: return 65;
|
case Keyboard::ScanF7: return 0x41;
|
||||||
case Keyboard::ScanF8: return 66;
|
case Keyboard::ScanF8: return 0x42;
|
||||||
case Keyboard::ScanF9: return 67;
|
case Keyboard::ScanF9: return 0x43;
|
||||||
case Keyboard::ScanF10: return 68;
|
case Keyboard::ScanF10: return 0x44;
|
||||||
case Keyboard::ScanF11: return KF_EXTENDED | 87;
|
case Keyboard::ScanF11: return 0x57;
|
||||||
case Keyboard::ScanF12: return KF_EXTENDED | 88;
|
case Keyboard::ScanF12: return 0x58;
|
||||||
//case Keyboard::ScanF13: return ???
|
case Keyboard::ScanF13: return 0x64;
|
||||||
//case Keyboard::ScanF14: return ???
|
case Keyboard::ScanF14: return 0x65;
|
||||||
//case Keyboard::ScanF15: return ???
|
case Keyboard::ScanF15: return 0x66;
|
||||||
|
case Keyboard::ScanF16: return 0x67;
|
||||||
|
case Keyboard::ScanF17: return 0x68;
|
||||||
|
case Keyboard::ScanF18: return 0x69;
|
||||||
|
case Keyboard::ScanF19: return 0x6A;
|
||||||
|
case Keyboard::ScanF20: return 0x6B;
|
||||||
|
case Keyboard::ScanF21: return 0x6C;
|
||||||
|
case Keyboard::ScanF22: return 0x6D;
|
||||||
|
case Keyboard::ScanF23: return 0x6E;
|
||||||
|
case Keyboard::ScanF24: return 0x76;
|
||||||
|
|
||||||
case Keyboard::ScanCapsLock: return 58;
|
case Keyboard::ScanCapsLock: return 0x3A;
|
||||||
case Keyboard::ScanPrintScreen: return 55 | KF_EXTENDED;
|
case Keyboard::ScanPrintScreen: return 0xE037;
|
||||||
case Keyboard::ScanScrollLock: return 70;
|
case Keyboard::ScanScrollLock: return 0x46;
|
||||||
case Keyboard::ScanPause: return 69;
|
case Keyboard::ScanPause: return 0x45;
|
||||||
case Keyboard::ScanInsert: return 82 | KF_EXTENDED;
|
case Keyboard::ScanInsert: return 0xE052;
|
||||||
case Keyboard::ScanHome: return 71 | KF_EXTENDED;
|
case Keyboard::ScanHome: return 0xE047;
|
||||||
case Keyboard::ScanPageUp: return 73 | KF_EXTENDED;
|
case Keyboard::ScanPageUp: return 0xE049;
|
||||||
case Keyboard::ScanDelete: return 83 | KF_EXTENDED;
|
case Keyboard::ScanDelete: return 0xE053;
|
||||||
case Keyboard::ScanEnd: return 79 | KF_EXTENDED;
|
case Keyboard::ScanEnd: return 0xE04F;
|
||||||
case Keyboard::ScanPageDown: return 81 | KF_EXTENDED;
|
case Keyboard::ScanPageDown: return 0xE051;
|
||||||
case Keyboard::ScanRight: return 77 | KF_EXTENDED;
|
case Keyboard::ScanRight: return 0xE04D;
|
||||||
case Keyboard::ScanLeft: return 75 | KF_EXTENDED;
|
case Keyboard::ScanLeft: return 0xE04B;
|
||||||
case Keyboard::ScanDown: return 80 | KF_EXTENDED;
|
case Keyboard::ScanDown: return 0xE050;
|
||||||
case Keyboard::ScanUp: return 72 | KF_EXTENDED;
|
case Keyboard::ScanUp: return 0xE048;
|
||||||
case Keyboard::ScanNumLock: return 69 | KF_EXTENDED;
|
case Keyboard::ScanNumLock: return 0xE045;
|
||||||
case Keyboard::ScanDivide: return 53;
|
|
||||||
case Keyboard::ScanMultiply: return 55;
|
|
||||||
case Keyboard::ScanMinus: return 74;
|
|
||||||
case Keyboard::ScanPlus: return 78;
|
|
||||||
//case Keyboard::ScanPadEquals: return ???;
|
|
||||||
case Keyboard::ScanNumpadEnter: return KF_EXTENDED | 28;
|
|
||||||
case Keyboard::ScanDecimal: return 83;
|
|
||||||
|
|
||||||
case Keyboard::ScanNumpad1: return 79;
|
case Keyboard::ScanNumpadDivide: return 0xE035;
|
||||||
case Keyboard::ScanNumpad2: return 80;
|
case Keyboard::ScanNumpadMultiply: return 0x37;
|
||||||
case Keyboard::ScanNumpad3: return 81 ;
|
case Keyboard::ScanNumpadMinus: return 0xA4;
|
||||||
case Keyboard::ScanNumpad4: return 75 ;
|
case Keyboard::ScanNumpadPlus: return 0x4E;
|
||||||
case Keyboard::ScanNumpad5: return 76;
|
case Keyboard::ScanNumpadEqual: return 0x7E;
|
||||||
case Keyboard::ScanNumpad6: return 77 ;
|
case Keyboard::ScanNumpadEnter: return 0xE01C;
|
||||||
case Keyboard::ScanNumpad7: return 71 ;
|
case Keyboard::ScanNumpadDecimal: return 0x53;
|
||||||
case Keyboard::ScanNumpad8: return 72 ;
|
|
||||||
case Keyboard::ScanNumpad9: return 73 ;
|
|
||||||
case Keyboard::ScanNumpad0: return 82 ;
|
|
||||||
|
|
||||||
//case Keyboard::ScanReverseSolidus: return ? ? ? ;
|
case Keyboard::ScanNumpad1: return 0x4F;
|
||||||
//case Keyboard::ScanApplication: return ? ? ? ;
|
case Keyboard::ScanNumpad2: return 0x50;
|
||||||
//case Keyboard::ScanExecute: return ? ? ? ;
|
case Keyboard::ScanNumpad3: return 0x51;
|
||||||
//case Keyboard::ScanHelp: return ? ? ? ;
|
case Keyboard::ScanNumpad4: return 0x4B;
|
||||||
case Keyboard::ScanMenu: return 93 | KF_EXTENDED;
|
case Keyboard::ScanNumpad5: return 0x4C;
|
||||||
//case Keyboard::ScanSelect: return ? ? ? ;
|
case Keyboard::ScanNumpad6: return 0x4D;
|
||||||
//case Keyboard::ScanStop: return ? ? ? ;
|
case Keyboard::ScanNumpad7: return 0x47;
|
||||||
//case Keyboard::ScanAgain: return ? ? ? ;
|
case Keyboard::ScanNumpad8: return 0x48;
|
||||||
//case Keyboard::ScanUndo: return ? ? ? ;
|
case Keyboard::ScanNumpad9: return 0x49;
|
||||||
//case Keyboard::ScanCut: return ? ? ? ;
|
case Keyboard::ScanNumpad0: return 0x52;
|
||||||
//case Keyboard::ScanCopy: return ? ? ? ;
|
|
||||||
//case Keyboard::ScanPaste: return ? ? ? ;
|
|
||||||
//case Keyboard::ScanFind: return ? ? ? ;
|
|
||||||
//case Keyboard::ScanMute: return ? ? ? ;
|
|
||||||
//case Keyboard::ScanVolumeUp: return ? ? ? ;
|
|
||||||
//case Keyboard::ScanVolumeDown: return ? ? ? ;
|
|
||||||
case Keyboard::ScanLControl: return 29;
|
|
||||||
case Keyboard::ScanLShift: return 42;
|
|
||||||
case Keyboard::ScanLAlt: return 56;
|
|
||||||
case Keyboard::ScanLSystem: return 91 | KF_EXTENDED ;
|
|
||||||
case Keyboard::ScanRControl: return KF_EXTENDED | 29;
|
|
||||||
case Keyboard::ScanRShift: return 54;
|
|
||||||
case Keyboard::ScanRAlt: return 56;
|
|
||||||
//case Keyboard::ScanRSystem: return ? ? ? ;
|
|
||||||
|
|
||||||
default: return 0; // Not sure what to return here?
|
case Keyboard::ScanNonUsBackslash: return 0x56;
|
||||||
|
// No known scancode for Keyboard::ScanApplication
|
||||||
|
// No known scancode for Keyboard::ScanExecute
|
||||||
|
// No known scancode for Keyboard::ScanModeChange
|
||||||
|
case Keyboard::ScanHelp: return 0xE061;
|
||||||
|
case Keyboard::ScanMenu: return 0xE05D;
|
||||||
|
case Keyboard::ScanSelect: return 0xE01E;
|
||||||
|
// No known scancode for Keyboard::ScanRedo
|
||||||
|
// No known scancode for Keyboard::ScanUndo
|
||||||
|
// No known scancode for Keyboard::ScanCut
|
||||||
|
// No known scancode for Keyboard::ScanCopy
|
||||||
|
// No known scancode for Keyboard::ScanPaste
|
||||||
|
|
||||||
|
case Keyboard::ScanVolumeMute: return 0xE020;
|
||||||
|
case Keyboard::ScanVolumeUp: return 0xE02E;
|
||||||
|
case Keyboard::ScanVolumeDown: return 0xE02C;
|
||||||
|
case Keyboard::ScanMediaPlayPause: return 0xE022;
|
||||||
|
case Keyboard::ScanMediaStop: return 0xE024;
|
||||||
|
case Keyboard::ScanMediaNextTrack: return 0xE019;
|
||||||
|
case Keyboard::ScanMediaPreviousTrack: return 0xE010;
|
||||||
|
|
||||||
|
case Keyboard::ScanLControl: return 0x1D;
|
||||||
|
case Keyboard::ScanLShift: return 0x2A;
|
||||||
|
case Keyboard::ScanLAlt: return 0x38;
|
||||||
|
case Keyboard::ScanLSystem: return 0xE05B;
|
||||||
|
case Keyboard::ScanRControl: return 0xE01D;
|
||||||
|
case Keyboard::ScanRShift: return 0x36;
|
||||||
|
case Keyboard::ScanRAlt: return 0xE038;
|
||||||
|
case Keyboard::ScanRSystem: return 0xE05C;
|
||||||
|
|
||||||
|
case Keyboard::ScanBack: return 0xE06A;
|
||||||
|
case Keyboard::ScanForward: return 0xE069;
|
||||||
|
case Keyboard::ScanRefresh: return 0xE067;
|
||||||
|
case Keyboard::ScanStop: return 0xE068;
|
||||||
|
case Keyboard::ScanSearch: return 0xE065;
|
||||||
|
case Keyboard::ScanFavorites: return 0xE066;
|
||||||
|
case Keyboard::ScanHomePage: return 0xE030;
|
||||||
|
|
||||||
|
case Keyboard::ScanLaunchApplication1: return 0xE06B;
|
||||||
|
case Keyboard::ScanLaunchApplication2: return 0xE021;
|
||||||
|
case Keyboard::ScanLaunchMail: return 0xE06C;
|
||||||
|
case Keyboard::ScanLaunchMediaSelect: return 0xE06D;
|
||||||
|
|
||||||
|
// Unable to map to a scancode
|
||||||
|
default: return 0x0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
InputImpl::InputImpl()
|
WORD sfScanToWinScanExtended(Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
buildMappings();
|
// Convert an SFML scancode to a Windows scancode
|
||||||
|
// Reference: https://msdn.microsoft.com/en-us/library/aa299374(v=vs.60).aspx
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case Keyboard::ScanPrintScreen: return 55 | 0xE100;
|
||||||
|
case Keyboard::ScanInsert: return 82 | 0xE100;
|
||||||
|
case Keyboard::ScanHome: return 71 | 0xE100;
|
||||||
|
case Keyboard::ScanPageUp: return 73 | 0xE100;
|
||||||
|
case Keyboard::ScanDelete: return 83 | 0xE100;
|
||||||
|
case Keyboard::ScanEnd: return 79 | 0xE100;
|
||||||
|
case Keyboard::ScanPageDown: return 81 | 0xE100;
|
||||||
|
case Keyboard::ScanRight: return 77 | 0xE100;
|
||||||
|
case Keyboard::ScanLeft: return 75 | 0xE100;
|
||||||
|
case Keyboard::ScanDown: return 80 | 0xE100;
|
||||||
|
case Keyboard::ScanUp: return 72 | 0xE100;
|
||||||
|
case Keyboard::ScanNumLock: return 69 | 0xE100;
|
||||||
|
case Keyboard::ScanNumpadEnter: return 28 | 0xE100;
|
||||||
|
case Keyboard::ScanHelp: return 97 | 0xE100;
|
||||||
|
case Keyboard::ScanMenu: return 93 | 0xE100;
|
||||||
|
case Keyboard::ScanSelect: return 30 | 0xE100;
|
||||||
|
case Keyboard::ScanVolumeMute: return 32 | 0xE100;
|
||||||
|
case Keyboard::ScanVolumeUp: return 46 | 0xE100;
|
||||||
|
case Keyboard::ScanVolumeDown: return 44 | 0xE100;
|
||||||
|
case Keyboard::ScanMediaPlayPause: return 34 | 0xE100;
|
||||||
|
case Keyboard::ScanMediaStop: return 36 | 0xE100;
|
||||||
|
case Keyboard::ScanMediaNextTrack: return 25 | 0xE100;
|
||||||
|
case Keyboard::ScanMediaPreviousTrack: return 16 | 0xE100;
|
||||||
|
case Keyboard::ScanLSystem: return 91 | 0xE100;
|
||||||
|
case Keyboard::ScanRControl: return 29 | 0xE100;
|
||||||
|
case Keyboard::ScanRAlt: return 56 | 0xE100;
|
||||||
|
case Keyboard::ScanRSystem: return 92 | 0xE100;
|
||||||
|
case Keyboard::ScanBack: return 106 | 0xE100;
|
||||||
|
case Keyboard::ScanForward: return 105 | 0xE100;
|
||||||
|
case Keyboard::ScanRefresh: return 103 | 0xE100;
|
||||||
|
case Keyboard::ScanStop: return 104 | 0xE100;
|
||||||
|
case Keyboard::ScanSearch: return 101 | 0xE100;
|
||||||
|
case Keyboard::ScanFavorites: return 102 | 0xE100;
|
||||||
|
case Keyboard::ScanHomePage: return 48 | 0xE100;
|
||||||
|
case Keyboard::ScanLaunchApplication1: return 107 | 0xE100;
|
||||||
|
case Keyboard::ScanLaunchApplication2: return 33 | 0xE100;
|
||||||
|
case Keyboard::ScanLaunchMail: return 108 | 0xE100;
|
||||||
|
case Keyboard::ScanLaunchMediaSelect: return 109 | 0xE100;
|
||||||
|
|
||||||
|
// Use non-extended mapping
|
||||||
|
default: return sfScanToWinScan(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT sfScanToVirtualKey(Keyboard::Scancode code)
|
||||||
|
{
|
||||||
|
WORD winScancode = sfScanToWinScan(code);
|
||||||
|
|
||||||
|
// Manually map non-extended key codes
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case Keyboard::ScanNumpad0:
|
||||||
|
return VK_NUMPAD0;
|
||||||
|
case Keyboard::ScanNumpad1:
|
||||||
|
return VK_NUMPAD1;
|
||||||
|
case Keyboard::ScanNumpad2:
|
||||||
|
return VK_NUMPAD2;
|
||||||
|
case Keyboard::ScanNumpad3:
|
||||||
|
return VK_NUMPAD3;
|
||||||
|
case Keyboard::ScanNumpad4:
|
||||||
|
return VK_NUMPAD4;
|
||||||
|
case Keyboard::ScanNumpad5:
|
||||||
|
return VK_NUMPAD5;
|
||||||
|
case Keyboard::ScanNumpad6:
|
||||||
|
return VK_NUMPAD6;
|
||||||
|
case Keyboard::ScanNumpad7:
|
||||||
|
return VK_NUMPAD7;
|
||||||
|
case Keyboard::ScanNumpad8:
|
||||||
|
return VK_NUMPAD8;
|
||||||
|
case Keyboard::ScanNumpad9:
|
||||||
|
return VK_NUMPAD9;
|
||||||
|
case Keyboard::ScanNumpadMinus:
|
||||||
|
return VK_SUBTRACT;
|
||||||
|
case Keyboard::ScanNumpadDecimal:
|
||||||
|
return VK_DECIMAL;
|
||||||
|
case Keyboard::ScanNumpadDivide:
|
||||||
|
return VK_DIVIDE;
|
||||||
|
case Keyboard::ScanPause:
|
||||||
|
return VK_PAUSE;
|
||||||
|
case Keyboard::ScanRControl:
|
||||||
|
return VK_RCONTROL;
|
||||||
|
case Keyboard::ScanRAlt:
|
||||||
|
return VK_RMENU;
|
||||||
|
default:
|
||||||
|
return MapVirtualKey(winScancode, MAPVK_VSC_TO_VK_EX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValidScancode(Keyboard::Scancode code)
|
||||||
|
{
|
||||||
|
return code > Keyboard::ScanUnknown && code < Keyboard::ScancodeCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValidKey(Keyboard::Key key)
|
||||||
|
{
|
||||||
|
return key > Keyboard::Unknown && key < Keyboard::KeyCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void InputImpl::buildMappings()
|
void InputImpl::ensureMappings()
|
||||||
{
|
{
|
||||||
// Reset the mappings
|
static bool isMappingInitialized = false;
|
||||||
|
|
||||||
|
if (isMappingInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Phase 1: Initialize mappings with default values
|
||||||
for (int i = 0; i < Keyboard::KeyCount; ++i)
|
for (int i = 0; i < Keyboard::KeyCount; ++i)
|
||||||
m_keyToScancodeMapping[i] = Keyboard::ScanUnknown;
|
m_keyToScancodeMapping[i] = Keyboard::ScanUnknown;
|
||||||
for (int i = 0; i < Keyboard::ScanCodeCount; ++i)
|
|
||||||
|
for (int i = 0; i < Keyboard::ScancodeCount; ++i)
|
||||||
m_scancodeToKeyMapping[i] = Keyboard::Unknown;
|
m_scancodeToKeyMapping[i] = Keyboard::Unknown;
|
||||||
|
|
||||||
for (int i = 0; i < Keyboard::ScanCodeCount; ++i)
|
// Phase 2: Translate scancode to virtual code to key names
|
||||||
|
for (int i = 0; i < Keyboard::ScancodeCount; ++i)
|
||||||
{
|
{
|
||||||
Keyboard::Scancode scan = static_cast<Keyboard::Scancode>(i);
|
Keyboard::Scancode scan = static_cast<Keyboard::Scancode>(i);
|
||||||
WORD winScanCode = sfScanToWin(scan);
|
UINT virtualKey = sfScanToVirtualKey(scan);
|
||||||
UINT vkey = MapVirtualKey(winScanCode, MAPVK_VSC_TO_VK_EX);
|
Keyboard::Key key = virtualKeyToSfKey(virtualKey);
|
||||||
Keyboard::Key key = winKeyToSfKey(vkey);
|
|
||||||
m_keyToScancodeMapping[key] = scan;
|
m_keyToScancodeMapping[key] = scan;
|
||||||
m_scancodeToKeyMapping[scan] = key;
|
m_scancodeToKeyMapping[scan] = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isMappingInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool InputImpl::isKeyPressed(Keyboard::Key key)
|
bool InputImpl::isKeyPressed(Keyboard::Key key)
|
||||||
{
|
{
|
||||||
int vkey = sfKeyToWin(key);
|
int virtualKey = sfKeyToVirtualKey(key);
|
||||||
return (GetAsyncKeyState(vkey) & 0x8000) != 0;
|
return (GetAsyncKeyState(virtualKey) & 0x8000) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool InputImpl::isKeyPressed(Keyboard::Scancode code)
|
bool InputImpl::isKeyPressed(Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
WORD winScanCode = sfScanToWin(code);
|
UINT virtualKey = sfScanToVirtualKey(code);
|
||||||
UINT vkey = MapVirtualKey(winScanCode, MAPVK_VSC_TO_VK_EX);
|
return (GetAsyncKeyState(static_cast<int>(virtualKey)) & KF_UP) != 0;
|
||||||
return (GetAsyncKeyState(vkey) & 0x8000) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Key InputImpl::localize(Keyboard::Scancode code)
|
Keyboard::Key InputImpl::localize(Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
|
if (!isValidScancode(code))
|
||||||
|
return Keyboard::Unknown;
|
||||||
|
|
||||||
|
ensureMappings();
|
||||||
|
|
||||||
return m_scancodeToKeyMapping[code];
|
return m_scancodeToKeyMapping[code];
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode InputImpl::unlocalize(Keyboard::Key key)
|
Keyboard::Scancode InputImpl::delocalize(Keyboard::Key key)
|
||||||
{
|
{
|
||||||
|
if (!isValidKey(key))
|
||||||
|
return Keyboard::ScanUnknown;
|
||||||
|
|
||||||
|
ensureMappings();
|
||||||
|
|
||||||
return m_keyToScancodeMapping[key];
|
return m_keyToScancodeMapping[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
String InputImpl::getDescription(Keyboard::Scancode code)
|
String InputImpl::getDescription(Keyboard::Scancode code)
|
||||||
{
|
{
|
||||||
WORD winCode = sfScanToWin(code);
|
WORD winCode = sfScanToWinScanExtended(code);
|
||||||
const int bufSize(1024);
|
const int bufSize(1024);
|
||||||
WCHAR name[bufSize];
|
WCHAR name[bufSize];
|
||||||
int result = GetKeyNameText(winCode << 16, name, bufSize);
|
int result = GetKeyNameText(winCode << 16, name, bufSize);
|
||||||
@ -488,18 +632,18 @@ void InputImpl::setVirtualKeyboardVisible(bool /*visible*/)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool InputImpl::isMouseButtonPressed(Mouse::Button button)
|
bool InputImpl::isMouseButtonPressed(Mouse::Button button)
|
||||||
{
|
{
|
||||||
int vkey = 0;
|
int virtualKey = 0;
|
||||||
switch (button)
|
switch (button)
|
||||||
{
|
{
|
||||||
case Mouse::Left: vkey = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON; break;
|
case Mouse::Left: virtualKey = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON; break;
|
||||||
case Mouse::Right: vkey = GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON; break;
|
case Mouse::Right: virtualKey = GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON; break;
|
||||||
case Mouse::Middle: vkey = VK_MBUTTON; break;
|
case Mouse::Middle: virtualKey = VK_MBUTTON; break;
|
||||||
case Mouse::XButton1: vkey = VK_XBUTTON1; break;
|
case Mouse::XButton1: virtualKey = VK_XBUTTON1; break;
|
||||||
case Mouse::XButton2: vkey = VK_XBUTTON2; break;
|
case Mouse::XButton2: virtualKey = VK_XBUTTON2; break;
|
||||||
default: vkey = 0; break;
|
default: virtualKey = 0; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (GetAsyncKeyState(vkey) & 0x8000) != 0;
|
return (GetAsyncKeyState(virtualKey) & 0x8000) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,12 +42,6 @@ namespace priv
|
|||||||
class InputImpl
|
class InputImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
/// \brief Default constructor
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
InputImpl();
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::isKeyPressed(Key)
|
/// \copydoc sf::Keyboard::isKeyPressed(Key)
|
||||||
///
|
///
|
||||||
@ -67,10 +61,10 @@ public:
|
|||||||
static Keyboard::Key localize(Keyboard::Scancode code);
|
static Keyboard::Key localize(Keyboard::Scancode code);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::unlocalize
|
/// \copydoc sf::Keyboard::delocalize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode unlocalize(Keyboard::Key key);
|
static Keyboard::Scancode delocalize(Keyboard::Key key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::getDescription
|
/// \copydoc sf::Keyboard::getDescription
|
||||||
@ -184,16 +178,16 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Regenerate the mappings from/to Key and Scancode.
|
/// Ensure the mappings are generated from/to Key and Scancode.
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void buildMappings();
|
static void ensureMappings();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode m_keyToScancodeMapping[Keyboard::KeyCount]; ///< Mapping from Key to Scancode
|
static Keyboard::Scancode m_keyToScancodeMapping[Keyboard::KeyCount]; ///< Mapping from Key to Scancode
|
||||||
static Keyboard::Key m_scancodeToKeyMapping[Keyboard::ScanCodeCount]; ///< Mapping from Scancode to Key
|
static Keyboard::Key m_scancodeToKeyMapping[Keyboard::ScancodeCount]; ///< Mapping from Scancode to Key
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -47,6 +47,8 @@
|
|||||||
#include <dbt.h>
|
#include <dbt.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
// MinGW lacks the definition of some Win32 constants
|
// MinGW lacks the definition of some Win32 constants
|
||||||
#ifndef XBUTTON1
|
#ifndef XBUTTON1
|
||||||
@ -566,11 +568,17 @@ void WindowImplWin32::grabCursor(bool grabbed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Keyboard::Scancode WindowImplWin32::toScancode(LPARAM flags)
|
Keyboard::Scancode WindowImplWin32::toScancode(WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int code = ((flags & (0xFF << 16)) >> 16);
|
int code = (lParam & (0xFF << 16)) >> 16;
|
||||||
|
|
||||||
// Windows scan codes
|
// Retrieve the scancode from the VirtualKey for synthetic key messages
|
||||||
|
if (code == 0)
|
||||||
|
{
|
||||||
|
code = static_cast<int>(MapVirtualKey(static_cast<UINT>(wParam), MAPVK_VK_TO_VSC));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Windows scancodes
|
||||||
// Reference: https://msdn.microsoft.com/en-us/library/aa299374(v=vs.60).aspx
|
// Reference: https://msdn.microsoft.com/en-us/library/aa299374(v=vs.60).aspx
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
@ -586,10 +594,10 @@ Keyboard::Scancode WindowImplWin32::toScancode(LPARAM flags)
|
|||||||
case 10: return Keyboard::ScanNum9;
|
case 10: return Keyboard::ScanNum9;
|
||||||
case 11: return Keyboard::ScanNum0;
|
case 11: return Keyboard::ScanNum0;
|
||||||
case 12: return Keyboard::ScanHyphen;
|
case 12: return Keyboard::ScanHyphen;
|
||||||
case 13: return Keyboard::ScanEquals;
|
case 13: return Keyboard::ScanEqual;
|
||||||
case 14: return Keyboard::ScanBackspace;
|
case 14: return Keyboard::ScanBackspace;
|
||||||
case 15: return Keyboard::ScanTab;
|
case 15: return Keyboard::ScanTab;
|
||||||
case 16: return Keyboard::ScanQ;
|
case 16: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanMediaPreviousTrack : Keyboard::ScanQ;
|
||||||
case 17: return Keyboard::ScanW;
|
case 17: return Keyboard::ScanW;
|
||||||
case 18: return Keyboard::ScanE;
|
case 18: return Keyboard::ScanE;
|
||||||
case 19: return Keyboard::ScanR;
|
case 19: return Keyboard::ScanR;
|
||||||
@ -598,38 +606,38 @@ Keyboard::Scancode WindowImplWin32::toScancode(LPARAM flags)
|
|||||||
case 22: return Keyboard::ScanU;
|
case 22: return Keyboard::ScanU;
|
||||||
case 23: return Keyboard::ScanI;
|
case 23: return Keyboard::ScanI;
|
||||||
case 24: return Keyboard::ScanO;
|
case 24: return Keyboard::ScanO;
|
||||||
case 25: return Keyboard::ScanP;
|
case 25: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanMediaNextTrack : Keyboard::ScanP;
|
||||||
case 26: return Keyboard::ScanLBracket;
|
case 26: return Keyboard::ScanLBracket;
|
||||||
case 27: return Keyboard::ScanRBracket;
|
case 27: return Keyboard::ScanRBracket;
|
||||||
case 28: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanEnter : Keyboard::ScanNumpadEnter;
|
case 28: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanNumpadEnter : Keyboard::ScanEnter;
|
||||||
case 29: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanRControl : Keyboard::ScanLControl;
|
case 29: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanRControl : Keyboard::ScanLControl;
|
||||||
case 30: return Keyboard::ScanA;
|
case 30: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanSelect : Keyboard::ScanA;
|
||||||
case 31: return Keyboard::ScanS;
|
case 31: return Keyboard::ScanS;
|
||||||
case 32: return Keyboard::ScanD;
|
case 32: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanVolumeMute : Keyboard::ScanD;
|
||||||
case 33: return Keyboard::ScanF;
|
case 33: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanLaunchApplication1 : Keyboard::ScanF;
|
||||||
case 34: return Keyboard::ScanG;
|
case 34: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanMediaPlayPause : Keyboard::ScanG;
|
||||||
case 35: return Keyboard::ScanH;
|
case 35: return Keyboard::ScanH;
|
||||||
case 36: return Keyboard::ScanJ;
|
case 36: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanMediaStop : Keyboard::ScanJ;
|
||||||
case 37: return Keyboard::ScanK;
|
case 37: return Keyboard::ScanK;
|
||||||
case 38: return Keyboard::ScanL;
|
case 38: return Keyboard::ScanL;
|
||||||
case 39: return Keyboard::ScanSemicolon;
|
case 39: return Keyboard::ScanSemicolon;
|
||||||
case 40: return Keyboard::ScanQuote;
|
case 40: return Keyboard::ScanApostrophe;
|
||||||
case 41: return Keyboard::ScanBackslash;
|
case 41: return Keyboard::ScanGrave;
|
||||||
case 42: return Keyboard::ScanLShift;
|
case 42: return Keyboard::ScanLShift;
|
||||||
case 43: return Keyboard::ScanDash;
|
case 43: return Keyboard::ScanBackslash;
|
||||||
case 44: return Keyboard::ScanZ;
|
case 44: return Keyboard::ScanZ;
|
||||||
case 45: return Keyboard::ScanX;
|
case 45: return Keyboard::ScanX;
|
||||||
case 46: return Keyboard::ScanC;
|
case 46: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanVolumeDown : Keyboard::ScanC;
|
||||||
case 47: return Keyboard::ScanV;
|
case 47: return Keyboard::ScanV;
|
||||||
case 48: return Keyboard::ScanB;
|
case 48: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanVolumeUp : Keyboard::ScanB;
|
||||||
case 49: return Keyboard::ScanN;
|
case 49: return Keyboard::ScanN;
|
||||||
case 50: return Keyboard::ScanM;
|
case 50: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanHomePage : Keyboard::ScanM;
|
||||||
case 51: return Keyboard::ScanComma;
|
case 51: return Keyboard::ScanComma;
|
||||||
case 52: return Keyboard::ScanPeriod;
|
case 52: return Keyboard::ScanPeriod;
|
||||||
case 53: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanDivide : Keyboard::ScanSlash;
|
case 53: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanNumpadDivide : Keyboard::ScanSlash;
|
||||||
case 54: return Keyboard::ScanRShift;
|
case 54: return Keyboard::ScanRShift;
|
||||||
case 55: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanPrintScreen : Keyboard::ScanMultiply;
|
case 55: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanPrintScreen : Keyboard::ScanNumpadMultiply;
|
||||||
case 56: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanRAlt : Keyboard::ScanLAlt;
|
case 56: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanRAlt : Keyboard::ScanLAlt;
|
||||||
case 57: return Keyboard::ScanSpace;
|
case 57: return Keyboard::ScanSpace;
|
||||||
case 58: return Keyboard::ScanCapsLock;
|
case 58: return Keyboard::ScanCapsLock;
|
||||||
case 59: return Keyboard::ScanF1;
|
case 59: return Keyboard::ScanF1;
|
||||||
@ -642,26 +650,44 @@ Keyboard::Scancode WindowImplWin32::toScancode(LPARAM flags)
|
|||||||
case 66: return Keyboard::ScanF8;
|
case 66: return Keyboard::ScanF8;
|
||||||
case 67: return Keyboard::ScanF9;
|
case 67: return Keyboard::ScanF9;
|
||||||
case 68: return Keyboard::ScanF10;
|
case 68: return Keyboard::ScanF10;
|
||||||
case 87: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanUnknown : Keyboard::ScanF11;
|
case 69: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanNumLock : Keyboard::ScanPause;
|
||||||
case 88: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanUnknown : Keyboard::ScanF12;
|
|
||||||
case 69: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanNumLock : Keyboard::ScanPause;
|
|
||||||
case 70: return Keyboard::ScanScrollLock;
|
case 70: return Keyboard::ScanScrollLock;
|
||||||
case 71: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanHome : Keyboard::ScanNumpad7;
|
case 71: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanHome : Keyboard::ScanNumpad7;
|
||||||
case 72: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanUp : Keyboard::ScanNumpad8;
|
case 72: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanUp : Keyboard::ScanNumpad8;
|
||||||
case 73: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanPageUp : Keyboard::ScanNumpad9;
|
case 73: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanPageUp : Keyboard::ScanNumpad9;
|
||||||
case 74: return Keyboard::ScanMinus;
|
case 74: return Keyboard::ScanNumpadMinus;
|
||||||
case 75: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanLeft : Keyboard::ScanNumpad4;
|
case 75: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanLeft : Keyboard::ScanNumpad4;
|
||||||
case 76: return Keyboard::ScanNumpad5;
|
case 76: return Keyboard::ScanNumpad5;
|
||||||
case 77: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanRight : Keyboard::ScanNumpad6;
|
case 77: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanRight : Keyboard::ScanNumpad6;
|
||||||
case 78: return Keyboard::ScanPlus;
|
case 78: return Keyboard::ScanNumpadPlus;
|
||||||
case 79: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanEnd : Keyboard::ScanNumpad1;
|
case 79: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanEnd : Keyboard::ScanNumpad1;
|
||||||
case 80: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanDown : Keyboard::ScanNumpad2;
|
case 80: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanDown : Keyboard::ScanNumpad2;
|
||||||
case 81: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanPageDown : Keyboard::ScanNumpad3;
|
case 81: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanPageDown : Keyboard::ScanNumpad3;
|
||||||
case 82: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanInsert : Keyboard::ScanNumpad0;
|
case 82: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanInsert : Keyboard::ScanNumpad0;
|
||||||
case 83: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanDelete : Keyboard::ScanDecimal;
|
case 83: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanDelete : Keyboard::ScanNumpadDecimal;
|
||||||
|
|
||||||
case 91: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanLSystem : Keyboard::ScanUnknown;
|
case 86: return Keyboard::ScanNonUsBackslash;
|
||||||
case 93: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanMenu : Keyboard::ScanUnknown;
|
case 87: return Keyboard::ScanF11;
|
||||||
|
case 88: return Keyboard::ScanF12;
|
||||||
|
|
||||||
|
case 91: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanLSystem : Keyboard::ScanUnknown;
|
||||||
|
case 92: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanRSystem : Keyboard::ScanUnknown;
|
||||||
|
case 93: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanMenu : Keyboard::ScanUnknown;
|
||||||
|
|
||||||
|
case 99: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanHelp : Keyboard::ScanUnknown;
|
||||||
|
case 100: return Keyboard::ScanF13;
|
||||||
|
case 101: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanSearch : Keyboard::ScanF14;
|
||||||
|
case 102: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanFavorites : Keyboard::ScanF15;
|
||||||
|
case 103: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanRefresh : Keyboard::ScanF16;
|
||||||
|
case 104: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanStop : Keyboard::ScanF17;
|
||||||
|
case 105: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanForward : Keyboard::ScanF18;
|
||||||
|
case 106: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanBack : Keyboard::ScanF19;
|
||||||
|
case 107: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanLaunchApplication1 : Keyboard::ScanF20;
|
||||||
|
case 108: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanLaunchMail : Keyboard::ScanF21;
|
||||||
|
case 109: return (HIWORD(lParam) & KF_EXTENDED) ? Keyboard::ScanLaunchMediaSelect : Keyboard::ScanF22;
|
||||||
|
case 110: return Keyboard::ScanF23;
|
||||||
|
|
||||||
|
case 118: return Keyboard::ScanF24;
|
||||||
|
|
||||||
default: return Keyboard::ScanUnknown;
|
default: return Keyboard::ScanUnknown;
|
||||||
}
|
}
|
||||||
@ -841,6 +867,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
event.key.shift = HIWORD(GetKeyState(VK_SHIFT)) != 0;
|
event.key.shift = HIWORD(GetKeyState(VK_SHIFT)) != 0;
|
||||||
event.key.system = HIWORD(GetKeyState(VK_LWIN)) || HIWORD(GetKeyState(VK_RWIN));
|
event.key.system = HIWORD(GetKeyState(VK_LWIN)) || HIWORD(GetKeyState(VK_RWIN));
|
||||||
event.key.code = virtualKeyCodeToSF(wParam, lParam);
|
event.key.code = virtualKeyCodeToSF(wParam, lParam);
|
||||||
|
event.key.scancode = toScancode(wParam, lParam);
|
||||||
pushEvent(event);
|
pushEvent(event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -857,6 +884,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
event.key.shift = HIWORD(GetKeyState(VK_SHIFT)) != 0;
|
event.key.shift = HIWORD(GetKeyState(VK_SHIFT)) != 0;
|
||||||
event.key.system = HIWORD(GetKeyState(VK_LWIN)) || HIWORD(GetKeyState(VK_RWIN));
|
event.key.system = HIWORD(GetKeyState(VK_LWIN)) || HIWORD(GetKeyState(VK_RWIN));
|
||||||
event.key.code = virtualKeyCodeToSF(wParam, lParam);
|
event.key.code = virtualKeyCodeToSF(wParam, lParam);
|
||||||
|
event.key.scancode = toScancode(wParam, lParam);
|
||||||
pushEvent(event);
|
pushEvent(event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1139,7 +1167,7 @@ Keyboard::Key WindowImplWin32::virtualKeyCodeToSF(WPARAM key, LPARAM flags)
|
|||||||
case VK_OEM_6: return Keyboard::RBracket;
|
case VK_OEM_6: return Keyboard::RBracket;
|
||||||
case VK_OEM_COMMA: return Keyboard::Comma;
|
case VK_OEM_COMMA: return Keyboard::Comma;
|
||||||
case VK_OEM_PERIOD: return Keyboard::Period;
|
case VK_OEM_PERIOD: return Keyboard::Period;
|
||||||
case VK_OEM_7: return Keyboard::Quote;
|
case VK_OEM_7: return Keyboard::Apostrophe;
|
||||||
case VK_OEM_5: return Keyboard::Backslash;
|
case VK_OEM_5: return Keyboard::Backslash;
|
||||||
case VK_OEM_3: return Keyboard::Tilde;
|
case VK_OEM_3: return Keyboard::Tilde;
|
||||||
case VK_ESCAPE: return Keyboard::Escape;
|
case VK_ESCAPE: return Keyboard::Escape;
|
||||||
|
@ -277,7 +277,7 @@ private:
|
|||||||
/// \return SFML scancode corresponding to the key
|
/// \return SFML scancode corresponding to the key
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode toScancode(LPARAM flags);
|
static Keyboard::Scancode toScancode(WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
|
@ -63,13 +63,13 @@ public:
|
|||||||
static Keyboard::Key localize(Keyboard::Scancode code);
|
static Keyboard::Key localize(Keyboard::Scancode code);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::unlocalize
|
/// \copydoc sf::Keyboard::delocalize
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static Keyboard::Scancode unlocalize(Keyboard::Key key);
|
static Keyboard::Scancode delocalize(Keyboard::Key key);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \copydoc sf::Keyboard::localizedRepresentation
|
/// \copydoc sf::Keyboard::getDescription
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static String getDescription(Keyboard::Scancode code);
|
static String getDescription(Keyboard::Scancode code);
|
||||||
|
@ -43,6 +43,29 @@ bool InputImpl::isKeyPressed(Keyboard::Key /* key */)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InputImpl::isKeyPressed(Keyboard::Scancode /* codes */)
|
||||||
|
{
|
||||||
|
// Not applicable
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keyboard::Key InputImpl::localize(Keyboard::Scancode /* code */)
|
||||||
|
{
|
||||||
|
// Not applicable
|
||||||
|
return Keyboard::Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keyboard::Scancode InputImpl::delocalize(Keyboard::Key /* key */)
|
||||||
|
{
|
||||||
|
// Not applicable
|
||||||
|
return Keyboard::ScanUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
String InputImpl::getDescription(Keyboard::Scancode /* code */)
|
||||||
|
{
|
||||||
|
// Not applicable
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void InputImpl::setVirtualKeyboardVisible(bool visible)
|
void InputImpl::setVirtualKeyboardVisible(bool visible)
|
||||||
|
Loading…
Reference in New Issue
Block a user