diff options
author | BogDan Vatra <bogdan@kde.org> | 2015-10-14 17:13:51 +0300 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2015-10-15 08:49:40 +0000 |
commit | 5b96c19f6eb01dc438e1e5bc8dc28504769d2f1d (patch) | |
tree | 37032729621d8fe8523f7bb910aef234296efcf8 /src/gamepad/qgamepadmanager.cpp | |
parent | fe6040df4bed9851c2ac2d8cca3b129b3e507828 (diff) |
Rename index -> deviceId
index is not the smartest way to uniquely identify a device, let's use something that doesn't change.
Change-Id: Idf925b13efc8dd604f185ea8de44659509d11054
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/gamepad/qgamepadmanager.cpp')
-rw-r--r-- | src/gamepad/qgamepadmanager.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/gamepad/qgamepadmanager.cpp b/src/gamepad/qgamepadmanager.cpp index e58298b..91ca70f 100644 --- a/src/gamepad/qgamepadmanager.cpp +++ b/src/gamepad/qgamepadmanager.cpp @@ -97,41 +97,48 @@ QGamepadManager *QGamepadManager::instance() return &instance; } -bool QGamepadManager::isGamepadConnected(int index) +bool QGamepadManager::isGamepadConnected(int deviceId) { - return m_connectedGamepads.contains(index); + return m_connectedGamepads.contains(deviceId); } -void QGamepadManager::forwardGamepadConnected(int index) +const QList<int> QGamepadManager::connectedGamepads() const +{ + return m_connectedGamepads.toList(); +} + +void QGamepadManager::forwardGamepadConnected(int deviceId) { //qDebug() << "gamepad connected: " << index; - m_connectedGamepads.append(index); - emit gamepadConnected(index); + m_connectedGamepads.insert(deviceId); + emit gamepadConnected(deviceId); + emit connectedGamepadsChanged(); } -void QGamepadManager::forwardGamepadDisconnected(int index) +void QGamepadManager::forwardGamepadDisconnected(int deviceId) { //qDebug() << "gamepad disconnected: " << index; - m_connectedGamepads.removeAll(index); - emit gamepadDisconnected(index); + m_connectedGamepads.remove(deviceId); + emit gamepadDisconnected(deviceId); + emit connectedGamepadsChanged(); } -void QGamepadManager::forwardGamepadAxisEvent(int index, QGamepadManager::GamepadAxis axis, double value) +void QGamepadManager::forwardGamepadAxisEvent(int deviceId, QGamepadManager::GamepadAxis axis, double value) { //qDebug() << "gamepad axis event: " << index << axis << value; - emit gamepadAxisEvent(index, axis, value); + emit gamepadAxisEvent(deviceId, axis, value); } -void QGamepadManager::forwardGamepadButtonPressEvent(int index, QGamepadManager::GamepadButton button, double value) +void QGamepadManager::forwardGamepadButtonPressEvent(int deviceId, QGamepadManager::GamepadButton button, double value) { //qDebug() << "gamepad button press event: " << index << button << value; - emit gamepadButtonPressEvent(index, button, value); + emit gamepadButtonPressEvent(deviceId, button, value); } -void QGamepadManager::forwardGamepadButtonReleaseEvent(int index, QGamepadManager::GamepadButton button) +void QGamepadManager::forwardGamepadButtonReleaseEvent(int deviceId, QGamepadManager::GamepadButton button) { //qDebug() << "gamepad button release event: " << index << button; - emit gamepadButtonReleaseEvent(index, button); + emit gamepadButtonReleaseEvent(deviceId, button); } QT_END_NAMESPACE |