diff --git a/crosbot_ui/src/joystick.cpp b/crosbot_ui/src/joystick.cpp index f90e41ffbfe688c71d2f605886e09ae0553cc3fe..2e9adf9551a63d40bdabce1eb7fb19baff44cf0d 100644 --- a/crosbot_ui/src/joystick.cpp +++ b/crosbot_ui/src/joystick.cpp @@ -214,7 +214,7 @@ void Joystick::buttonReleased(int) {} void Joystick::run() { int device = -1; - Time lastOpenAttempt; + Time lastOpenAttempt, lastRepeat = Time::now(); char deviceName[MAX_JOYSTICK_NAME]; int deviceAxesCount = 0, deviceButtonCount = 0; @@ -329,6 +329,18 @@ void Joystick::run() { break; } + if (Time::now() > lastRepeat + Duration(0, 100000000LL)) { + bool repeat = false; + for (int n = 0; n < MAX_JOYSTICK_BUTTONS; ++n) { + if (buttonState[n]) { + repeat = true; + buttonPressed(n); + } + } + if (repeat) + lastRepeat = Time::now(); + } + usleep(10000); } diff --git a/crosbot_ui/src/renders/robot/joystick.cpp b/crosbot_ui/src/renders/robot/joystick.cpp index 88b9915fe727bb4d281d05a8002138fee7fe194f..f87091364aa7359edd29d45740f21e66d4567c72 100644 --- a/crosbot_ui/src/renders/robot/joystick.cpp +++ b/crosbot_ui/src/renders/robot/joystick.cpp @@ -93,7 +93,7 @@ void JoystickRender::RenderJoystick::buttonReleased(int b) { QKeyEvent keyEvent(QEvent::KeyRelease, buttonKeys[b], 0); RobotWidget* widget = dynamic_cast < RobotWidget* > (render.panel.getWidget()); if (widget != NULL) { - widget->keyPressEvent(&keyEvent); + widget->keyReleaseEvent(&keyEvent); } } }