Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for macOS scancode implementation #2243

Merged
merged 20 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2485b89
Fix some comments placement
kimci86 Sep 21, 2022
0c0f49e
Describe keys in separate words when applicable on macOS
kimci86 Sep 21, 2022
2b2fda9
Use "Option" instead of "Alt" to describe keys on macOS
kimci86 Sep 21, 2022
dbb4122
Handle Unknown in (de)localize methods on macOS
kimci86 Sep 21, 2022
77c476d
Name magic number for undefined scanToVirtualCode return value
kimci86 Sep 21, 2022
d17512f
Filter key up events like key down events
kimci86 Sep 25, 2022
8cfeb5d
Remember the first scancode mapped to each key
kimci86 Sep 25, 2022
1aadc3e
HIDInputManager little bits of documentation
kimci86 Nov 11, 2022
7507d48
Move buildMappings to be consistent with the corresponding source file
kimci86 Nov 11, 2022
d37841d
Order HIDInputManager method definitions like declarations
kimci86 Nov 11, 2022
b902e97
Use localize to generate keyboard events
kimci86 Nov 11, 2022
330d337
Replace deprecated key values
kimci86 Nov 11, 2022
079b83f
Do not translate some virtual key codes to avoid collisions
kimci86 Nov 11, 2022
dddc751
Remove offset in numpad number scancode translation to key
kimci86 Nov 11, 2022
11a27ea
Add fallback mapping for NumpadEnter
kimci86 Nov 11, 2022
74b44bc
Remove redundant sf:: namespace specifiers
kimci86 Nov 11, 2022
74f486f
Remove trailing spaces
kimci86 Nov 12, 2022
12d7c1d
Put back sf:: namespace specifier in initializeKeyboard comment
kimci86 Nov 12, 2022
f542d64
Handle swapped virtual key codes with ISO keyboard
kimci86 Nov 19, 2022
1706749
Generate key events for caps lock when the modifier state changes
kimci86 Dec 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/SFML/Window/OSX/HIDInputManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class HIDInputManager : NonCopyable
static CFDictionaryRef copyDevicesMask(UInt32 page, UInt32 usage);

////////////////////////////////////////////////////////////
/// Try to convert a character into a SFML key code.
/// \brief Try to convert a character into a SFML key code
///
/// Return sf::Keyboard::Unknown if it doesn't match any 'localized' keys.
///
Expand All @@ -102,7 +102,7 @@ class HIDInputManager : NonCopyable
static Keyboard::Key localizedKey(UniChar ch);

////////////////////////////////////////////////////////////
/// Opposite transformation as localizedKeys
/// \brief Opposite transformation as localizedKeys
///
/// Return 0x00 (NULL) for non-convertible keys/numpad numbers.
/// For letters, uppercase codes are returned.
Expand All @@ -112,7 +112,7 @@ class HIDInputManager : NonCopyable
static UniChar toUnicode(Keyboard::Key key);

////////////////////////////////////////////////////////////
/// Try to convert a virtual keycode (HID level) into a
/// \brief Try to convert a virtual keycode (HID level) into a
/// SFML scancode.
///
/// Return sf::Keyboard::Scan::Unknown if the keycode is unknown.
Expand Down Expand Up @@ -152,14 +152,6 @@ class HIDInputManager : NonCopyable
////////////////////////////////////////////////////////////
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:

////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -213,6 +205,19 @@ class HIDInputManager : NonCopyable
////////////////////////////////////////////////////////////
void loadKey(IOHIDElementRef key);

////////////////////////////////////////////////////////////
/// \brief Regenerate the mappings from/to Key and Scancode
///
////////////////////////////////////////////////////////////
void buildMappings();

////////////////////////////////////////////////////////////
/// \brief Callback to regenerate mappings from/to Key and
/// Scancode when there's a keyboard layout change
///
////////////////////////////////////////////////////////////
static void keyboardChanged(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef);

////////////////////////////////////////////////////////////
/// \brief Release all resources
///
Expand Down Expand Up @@ -275,9 +280,9 @@ class HIDInputManager : NonCopyable
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
IOHIDManagerRef m_manager; ///< Underlying HID Manager
IOHIDManagerRef m_manager; ///< Underlying HID Manager
IOHIDElements m_keys[Keyboard::Scan::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::Scan::ScancodeCount]; ///< Mapping from Scancode to Key

////////////////////////////////////////////////////////////
Expand All @@ -288,7 +293,7 @@ class HIDInputManager : NonCopyable
/// HID keys.
///
/// The mappings (both directions) get invalidated when the
/// keyboard layout changes. They both default to (s)Unknown.
/// keyboard layout changes. They both default to (Scan::)Unknown.
///
////////////////////////////////////////////////////////////
};
Expand Down