mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix input crashes when no game was loaded
This commit is contained in:
parent
bcb1617a69
commit
298d5e9689
|
@ -20,7 +20,7 @@ GamepadAxisEvent::GamepadAxisEvent(int axis, Direction direction, bool isNew, in
|
||||||
, m_key(GBA_KEY_NONE)
|
, m_key(GBA_KEY_NONE)
|
||||||
{
|
{
|
||||||
ignore();
|
ignore();
|
||||||
if (controller) {
|
if (controller && controller->map()) {
|
||||||
m_key = static_cast<GBAKey>(mInputMapAxis(controller->map(), type, axis, direction * INT_MAX));
|
m_key = static_cast<GBAKey>(mInputMapAxis(controller->map(), type, axis, direction * INT_MAX));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ GamepadButtonEvent::GamepadButtonEvent(QEvent::Type pressType, int button, int t
|
||||||
, m_key(GBA_KEY_NONE)
|
, m_key(GBA_KEY_NONE)
|
||||||
{
|
{
|
||||||
ignore();
|
ignore();
|
||||||
if (controller) {
|
if (controller && controller->map()) {
|
||||||
m_key = static_cast<GBAKey>(mInputMapKey(controller->map(), type, button));
|
m_key = static_cast<GBAKey>(mInputMapKey(controller->map(), type, button));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ GamepadHatEvent::GamepadHatEvent(QEvent::Type pressType, int hatId, Direction di
|
||||||
, m_key(GBA_KEY_NONE)
|
, m_key(GBA_KEY_NONE)
|
||||||
{
|
{
|
||||||
ignore();
|
ignore();
|
||||||
if (controller) {
|
if (controller && controller->map()) {
|
||||||
m_key = static_cast<GBAKey>(mInputMapHat(controller->map(), type, hatId, direction));
|
m_key = static_cast<GBAKey>(mInputMapHat(controller->map(), type, hatId, direction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,6 +366,9 @@ void InputController::updateJoysticks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const mInputMap* InputController::map() {
|
const mInputMap* InputController::map() {
|
||||||
|
if (!m_activeKeyInfo) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return &m_inputMap;
|
return &m_inputMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue