mirror of
https://github.com/SFML/SFML.git
synced 2025-01-31 13:45:13 +08:00
Fixed crash with application messing hardware detection
This prevents crashes & reduces the amount of logging but does not actually make isKeyPressed work when using e.g. TeamViewer.
This commit is contained in:
parent
c352f5228b
commit
dd307cc23e
@ -152,6 +152,7 @@ void HIDInputManager::initializeKeyboard()
|
|||||||
CFSetRef keyboards = copyDevices(kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard);
|
CFSetRef keyboards = copyDevices(kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard);
|
||||||
if (keyboards == NULL)
|
if (keyboards == NULL)
|
||||||
{
|
{
|
||||||
|
sf::err() << "No keyboard detected by the HID manager!" << std::endl;
|
||||||
freeUp();
|
freeUp();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -313,9 +314,11 @@ void HIDInputManager::freeUp()
|
|||||||
|
|
||||||
if (m_layoutData != 0)
|
if (m_layoutData != 0)
|
||||||
CFRelease(m_layoutData);
|
CFRelease(m_layoutData);
|
||||||
|
m_layoutData = 0;
|
||||||
// Do not release m_layout! It is owned by m_layoutData.
|
// Do not release m_layout! It is owned by m_layoutData.
|
||||||
if (m_manager != 0)
|
if (m_manager != 0)
|
||||||
CFRelease(m_manager);
|
CFRelease(m_manager);
|
||||||
|
m_manager = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < Keyboard::KeyCount; ++i)
|
for (unsigned int i = 0; i < Keyboard::KeyCount; ++i)
|
||||||
{
|
{
|
||||||
@ -355,11 +358,8 @@ CFSetRef HIDInputManager::copyDevices(UInt32 page, UInt32 usage)
|
|||||||
|
|
||||||
bool HIDInputManager::isPressed(IOHIDElements& elements)
|
bool HIDInputManager::isPressed(IOHIDElements& elements)
|
||||||
{
|
{
|
||||||
if (!m_isValid)
|
if (!m_isValid)
|
||||||
{
|
|
||||||
sf::err() << "HIDInputManager is invalid." << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
// state = true if at least one corresponding HID button is pressed
|
// state = true if at least one corresponding HID button is pressed
|
||||||
bool state = false;
|
bool state = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user