Handle layout changes on macOS
This commit is contained in:
parent
e806048904
commit
cabf1a3c34
@ -206,10 +206,15 @@ private:
|
||||
void loadKey(IOHIDElementRef key);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Regenerate the mappings from/to Key and Scancode
|
||||
/// 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
|
||||
|
@ -30,6 +30,15 @@
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
void keyboardChanged(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
|
||||
{
|
||||
sf::priv::HIDInputManager* manager = static_cast<sf::priv::HIDInputManager*>(observer);
|
||||
manager->buildMappings();
|
||||
}
|
||||
}
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
@ -228,8 +237,19 @@ m_manager(0)
|
||||
return;
|
||||
}
|
||||
|
||||
// Build up our knownledge of the hardware
|
||||
initializeKeyboard();
|
||||
buildMappings();
|
||||
|
||||
// Register for notification on keyboard layout changes
|
||||
CFNotificationCenterAddObserver(
|
||||
CFNotificationCenterGetDistributedCenter(),
|
||||
this,
|
||||
keyboardChanged, // callback
|
||||
kTISNotifySelectedKeyboardInputSourceChanged,
|
||||
NULL, // use callback
|
||||
CFNotificationSuspensionBehaviorDeliverImmediately
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -237,6 +257,8 @@ m_manager(0)
|
||||
HIDInputManager::~HIDInputManager()
|
||||
{
|
||||
freeUp();
|
||||
|
||||
CFNotificationCenterRemoveEveryObserver(CFNotificationCenterGetDistributedCenter(), this);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user