Qt: Fix input crashes when no game was loaded

This commit is contained in:
Vicki Pfau 2017-07-12 20:20:04 -07:00
parent bcb1617a69
commit 298d5e9689
4 changed files with 6 additions and 3 deletions

View File

@ -20,7 +20,7 @@ GamepadAxisEvent::GamepadAxisEvent(int axis, Direction direction, bool isNew, in
, m_key(GBA_KEY_NONE)
{
ignore();
if (controller) {
if (controller && controller->map()) {
m_key = static_cast<GBAKey>(mInputMapAxis(controller->map(), type, axis, direction * INT_MAX));
}
}

View File

@ -19,7 +19,7 @@ GamepadButtonEvent::GamepadButtonEvent(QEvent::Type pressType, int button, int t
, m_key(GBA_KEY_NONE)
{
ignore();
if (controller) {
if (controller && controller->map()) {
m_key = static_cast<GBAKey>(mInputMapKey(controller->map(), type, button));
}
}

View File

@ -20,7 +20,7 @@ GamepadHatEvent::GamepadHatEvent(QEvent::Type pressType, int hatId, Direction di
, m_key(GBA_KEY_NONE)
{
ignore();
if (controller) {
if (controller && controller->map()) {
m_key = static_cast<GBAKey>(mInputMapHat(controller->map(), type, hatId, direction));
}
}

View File

@ -366,6 +366,9 @@ void InputController::updateJoysticks() {
}
const mInputMap* InputController::map() {
if (!m_activeKeyInfo) {
return nullptr;
}
return &m_inputMap;
}