From efb9d8bc6f51bb3ef69d20a14451cf4f735fe788 Mon Sep 17 00:00:00 2001 From: Cole Brinsfield Date: Sun, 25 Jul 2021 18:03:08 -0700 Subject: [PATCH] Allow for scroll wheel injection (#23) * Working on proper resizing of AA * allow for custom aspect ratios * A mess of code to support sending input events from dash * Restructuring input injection to be much nicer * Code Cleanup * Allow for scroll wheel injection --- include/openauto/Service/InputService.hpp | 2 +- include/openauto/Service/ServiceFactory.hpp | 2 +- openauto/Service/InputService.cpp | 15 +++++++++++---- openauto/Service/ServiceFactory.cpp | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/openauto/Service/InputService.hpp b/include/openauto/Service/InputService.hpp index 1240bed..893d2fb 100644 --- a/include/openauto/Service/InputService.hpp +++ b/include/openauto/Service/InputService.hpp @@ -38,7 +38,7 @@ class InputService: public: InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IInputDevice::Pointer inputDevice); - void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode); + void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection = projection::WheelDirection::NONE); void start() override; void stop() override; void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override; diff --git a/include/openauto/Service/ServiceFactory.hpp b/include/openauto/Service/ServiceFactory.hpp index 5567099..8eef8e8 100644 --- a/include/openauto/Service/ServiceFactory.hpp +++ b/include/openauto/Service/ServiceFactory.hpp @@ -41,7 +41,7 @@ public: void setOpacity(unsigned int alpha); void resize(); void setNightMode(bool nightMode); - void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode); + void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection = projection::WheelDirection::NONE); void sendKeyEvent(QKeyEvent* event); static QRect mapActiveAreaToGlobal(QWidget* activeArea); #ifdef USE_OMX diff --git a/openauto/Service/InputService.cpp b/openauto/Service/InputService.cpp index 863ed35..db2982f 100644 --- a/openauto/Service/InputService.cpp +++ b/openauto/Service/InputService.cpp @@ -163,12 +163,19 @@ void InputService::onButtonEvent(const projection::ButtonEvent& event) }); } -void InputService::sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode) +void InputService::sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection) { - OPENAUTO_LOG(error) << "[InputService] injecting button press"; + OPENAUTO_LOG(info) << "[InputService] injecting button press"; + if(buttonCode == aasdk::proto::enums::ButtonCode::SCROLL_WHEEL) + { + onButtonEvent({projection::ButtonEventType::NONE, wheelDirection, buttonCode}); - onButtonEvent({projection::ButtonEventType::PRESS, projection::WheelDirection::NONE, buttonCode}); - onButtonEvent({projection::ButtonEventType::RELEASE, projection::WheelDirection::NONE, buttonCode}); + } + else + { + onButtonEvent({projection::ButtonEventType::PRESS, projection::WheelDirection::NONE, buttonCode}); + onButtonEvent({projection::ButtonEventType::RELEASE, projection::WheelDirection::NONE, buttonCode}); + } } void InputService::onTouchEvent(const projection::TouchEvent& event) diff --git a/openauto/Service/ServiceFactory.cpp b/openauto/Service/ServiceFactory.cpp index bc980a1..afad991 100644 --- a/openauto/Service/ServiceFactory.cpp +++ b/openauto/Service/ServiceFactory.cpp @@ -228,12 +228,12 @@ void ServiceFactory::setNightMode(bool nightMode) } } -void ServiceFactory::sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode) +void ServiceFactory::sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection) { if(std::shared_ptr inputService = inputService_.lock()) { - inputService->sendButtonPress(buttonCode); + inputService->sendButtonPress(buttonCode, wheelDirection); } }