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

Disconnecting the keyboard makes SFML crash #467

Closed
mantognini opened this Issue Sep 17, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@mantognini
Member

mantognini commented Sep 17, 2013

Reported here.

I've got SEGFAULT from sf:Keyboard::isKeyPressed. Typically, in normal case, keyboards inputs are well processed and exactly recognize what key is pressed. But after turn off and on my keyboard(apple wireless keyboard), my game is crashed.

The game was stopped at "IOHIDDeviceRef device = IOHIDElementGetDevice(_it);" because "_it" was null.
I think this problem is caused by releasing elements in m_keys[] due to reconnection of keyboard or something else.

To identify what key is pressed, "HIDInputManager::isKeyPressed(Keyboard::Key key)" function is called several times. At every function calls, "value", returned from "IOHIDDeviceGetValue()" might be null and function releases "m_keys[]" as shown above code.

when the number of vector(m_keys[]) becomes zero, game crashes because there is no elements in the vector.

@ghost ghost assigned mantognini Sep 17, 2013

@MarioLiebisch

This comment has been minimized.

Show comment
Hide comment
@MarioLiebisch

MarioLiebisch Sep 18, 2013

Member

Interesting. I've observed similar problems in the Android build with my keyboard dock. Could this be some generic issue in how SFML interacts with keyboard stuff or two similar issues in completely different parts/ports?

Member

MarioLiebisch commented Sep 18, 2013

Interesting. I've observed similar problems in the Android build with my keyboard dock. Could this be some generic issue in how SFML interacts with keyboard stuff or two similar issues in completely different parts/ports?

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Sep 19, 2013

Member

SFML has no generic code related to keyboard, so this is definitely two separate issues.

Member

LaurentGomila commented Sep 19, 2013

SFML has no generic code related to keyboard, so this is definitely two separate issues.

jcowgill added a commit to jcowgill/SFML that referenced this issue Sep 22, 2014

Fix crash related to keyboard / mouse disconnection on OS X (close SF…
…ML#467)

I feel bad about this stupid mistake!

(cherry picked from commit d77f241)

Conflicts:
	src/SFML/Window/OSX/HIDInputManager.mm

@mantognini mantognini removed their assignment Apr 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment