diff --git a/src/inputdaemon.cpp b/src/inputdaemon.cpp index dc5408a5..41a5a616 100644 --- a/src/inputdaemon.cpp +++ b/src/inputdaemon.cpp @@ -372,6 +372,34 @@ void InputDaemon::quit() eventWorker = 0; } +void InputDaemon::resetMouseTimers() +{ + if (joysticks->size() > 0) + { + #ifdef USE_SDL_2 + QHashIterator iter(*joysticks); + #else + QHashIterator iter(*joysticks); + #endif + while (iter.hasNext()) + { + InputDevice *joystick = iter.next().value(); + if (joystick && joystick->getNumberButtons() > 0) + { + // Find first button of first joystick and use it for the + // psuedo-static QTimer calls. + SetJoystick *set = joystick->getActiveSetJoystick(); + JoyButton *button = set->getJoyButton(0); + if (button) + { + set->getJoyButton(0)->establishMouseTimerConnections(); + iter.toBack(); + } + } + } + } +} + #ifdef USE_SDL_2 void InputDaemon::refreshMapping(QString mapping, InputDevice *device) { @@ -428,6 +456,7 @@ void InputDaemon::removeDevice(InputDevice *device) trackjoysticks.remove(deviceID); trackcontrollers.remove(deviceID); + resetMouseTimers(); refreshIndexes(); emit deviceRemoved(deviceID); diff --git a/src/inputdaemon.h b/src/inputdaemon.h index f5b3ce3c..d0edb8d3 100644 --- a/src/inputdaemon.h +++ b/src/inputdaemon.h @@ -31,6 +31,8 @@ public: ~InputDaemon(); protected: + void resetMouseTimers(); + #ifdef USE_SDL_2 QHash *joysticks; QHash trackjoysticks; diff --git a/src/joybutton.cpp b/src/joybutton.cpp index de50ec41..a0e90abb 100644 --- a/src/joybutton.cpp +++ b/src/joybutton.cpp @@ -46,13 +46,7 @@ JoyButton::JoyButton(int index, int originset, SetJoystick *parentSet, QObject * connect(&mouseWheelHorizontalEventTimer, SIGNAL(timeout()), this, SLOT(wheelEventHorizontal())); connect(&setChangeTimer, SIGNAL(timeout()), this, SLOT(checkForSetChange())); - // Workaround to have a static QTimer - disconnect(&cursorDelayTimer, 0, 0, 0); - connect(&cursorDelayTimer, SIGNAL(timeout()), this, SLOT(moveMouseCursor())); - - // Workaround to have a static QTimer - disconnect(&springDelayTimer, 0, 0, 0); - connect(&springDelayTimer, SIGNAL(timeout()), this, SLOT(moveSpringMouse())); + establishMouseTimerConnections(); this->reset(); this->index = index; @@ -2928,3 +2922,14 @@ unsigned int JoyButton::getPreferredKeyDelay() return tempDelay; } + +void JoyButton::establishMouseTimerConnections() +{ + // Workaround to have a static QTimer + disconnect(&cursorDelayTimer, 0, 0, 0); + connect(&cursorDelayTimer, SIGNAL(timeout()), this, SLOT(moveMouseCursor())); + + // Workaround to have a static QTimer + disconnect(&springDelayTimer, 0, 0, 0); + connect(&springDelayTimer, SIGNAL(timeout()), this, SLOT(moveSpringMouse())); +} diff --git a/src/joybutton.h b/src/joybutton.h index c9c85258..4c3a40a9 100644 --- a/src/joybutton.h +++ b/src/joybutton.h @@ -257,6 +257,7 @@ public slots: void moveMouseCursor(); void moveSpringMouse(); + void establishMouseTimerConnections(); private slots: void turboEvent(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e1b703c9..3fa68064 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -382,7 +382,7 @@ void MainWindow::saveAppConfig() temptabwidget->isDisplayingNames() ? "1" : "0"); settings->beginGroup("Controllers"); - settings->remove(""); + //settings->remove(""); QStringList tempGUIDHolder; QStringList tempNameHolder;