mirror of https://github.com/mgba-emu/mgba.git
Qt: These return multiple keys
This commit is contained in:
parent
0cfec878c8
commit
6b63e42146
|
@ -495,15 +495,15 @@ void InputController::testGamepad(uint32_t type) {
|
|||
|
||||
for (auto& hat : activeHats) {
|
||||
GamepadHatEvent* event = new GamepadHatEvent(GamepadHatEvent::Down(), hat.first, hat.second, type, this);
|
||||
postPendingEvent(event->platformKey());
|
||||
postPendingEvents(event->platformKeys());
|
||||
sendGamepadEvent(event);
|
||||
if (!event->isAccepted()) {
|
||||
clearPendingEvent(event->platformKey());
|
||||
clearPendingEvents(event->platformKeys());
|
||||
}
|
||||
}
|
||||
for (auto& hat : oldHats) {
|
||||
GamepadHatEvent* event = new GamepadHatEvent(GamepadHatEvent::Up(), hat.first, hat.second, type, this);
|
||||
clearPendingEvent(event->platformKey());
|
||||
clearPendingEvents(event->platformKeys());
|
||||
sendGamepadEvent(event);
|
||||
}
|
||||
}
|
||||
|
@ -529,6 +529,22 @@ void InputController::clearPendingEvent(int key) {
|
|||
m_pendingEvents.remove(key);
|
||||
}
|
||||
|
||||
void InputController::postPendingEvents(int keys) {
|
||||
for (int i = 0; keys; ++i, keys >>= 1) {
|
||||
if (keys & 1) {
|
||||
m_pendingEvents.insert(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputController::clearPendingEvents(int keys) {
|
||||
for (int i = 0; keys; ++i, keys >>= 1) {
|
||||
if (keys & 1) {
|
||||
m_pendingEvents.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool InputController::hasPendingEvent(int key) const {
|
||||
return m_pendingEvents.contains(key);
|
||||
}
|
||||
|
|
|
@ -128,9 +128,11 @@ private slots:
|
|||
void teardownCam();
|
||||
|
||||
private:
|
||||
void postPendingEvent(int);
|
||||
void clearPendingEvent(int);
|
||||
bool hasPendingEvent(int) const;
|
||||
void postPendingEvent(int key);
|
||||
void clearPendingEvent(int key);
|
||||
void postPendingEvents(int keys);
|
||||
void clearPendingEvents(int keys);
|
||||
bool hasPendingEvent(int key) const;
|
||||
void sendGamepadEvent(QEvent*);
|
||||
|
||||
Gamepad* gamepad(uint32_t type);
|
||||
|
|
|
@ -16,11 +16,11 @@ GamepadHatEvent::GamepadHatEvent(QEvent::Type pressType, int hatId, Direction di
|
|||
: QEvent(pressType)
|
||||
, m_hatId(hatId)
|
||||
, m_direction(direction)
|
||||
, m_key(-1)
|
||||
, m_keys(0)
|
||||
{
|
||||
ignore();
|
||||
if (controller) {
|
||||
m_key = mInputMapHat(controller->map(), type, hatId, direction);
|
||||
m_keys = mInputMapHat(controller->map(), type, hatId, direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
int hatId() const { return m_hatId; }
|
||||
Direction direction() const { return m_direction; }
|
||||
int platformKey() const { return m_key; }
|
||||
int platformKeys() const { return m_keys; }
|
||||
|
||||
static Type Down();
|
||||
static Type Up();
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
|
||||
int m_hatId;
|
||||
Direction m_direction;
|
||||
int m_key;
|
||||
int m_keys;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue