initial button injection implementation
This commit is contained in:
parent
e30db459c6
commit
4e265958eb
@ -158,7 +158,7 @@ int main(int argc, char *argv[])
|
||||
qDebug() << "[WebSocket] Disconnected. Will retry...";
|
||||
reconnectTimer.start(3000); });
|
||||
|
||||
QObject::connect(&webSocket, &QWebSocket::textMessageReceived, [&mainWindow, &connectDialog](const QString &message)
|
||||
QObject::connect(&webSocket, &QWebSocket::textMessageReceived, [&mainWindow, &connectDialog, &serviceFactory](const QString &message)
|
||||
{
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8(), &error);
|
||||
@ -172,7 +172,10 @@ int main(int argc, char *argv[])
|
||||
connectDialog.connectToAddress(ipAddr);
|
||||
}
|
||||
else if (rootObj.contains("button")) {
|
||||
|
||||
QJsonObject btnObj = rootObj["button"].toObject();
|
||||
QString btn = btnObj["btn"].toString();
|
||||
int state = btnObj["state"].toInt();
|
||||
serviceFactory.sendButtonPressFromString(btn.toStdString(), state);
|
||||
}
|
||||
else{
|
||||
mainWindow.handleIncomingMessage(rootObj);
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
void sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection = projection::WheelDirection::NONE, projection::ButtonEventType buttonEventType = projection::ButtonEventType::NONE);
|
||||
void sendKeyEvent(QKeyEvent* event);
|
||||
void setAndroidAutoInterface(IAndroidAutoInterface* aa_interface);
|
||||
void sendButtonPressFromString(const std::string& btn, const int state);
|
||||
static QRect mapActiveAreaToGlobal(QWidget* activeArea);
|
||||
#ifdef USE_OMX
|
||||
static projection::DestRect QRectToDestRect(QRect rect);
|
||||
|
@ -257,7 +257,7 @@ bool Configuration::getWhitescreenWorkaround() const
|
||||
|
||||
bool Configuration::getTouchscreenEnabled() const
|
||||
{
|
||||
return enableTouchscreen_;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Configuration::setTouchscreenEnabled(bool value)
|
||||
|
@ -262,6 +262,52 @@ void ServiceFactory::setNightMode(bool nightMode)
|
||||
}
|
||||
}
|
||||
|
||||
void ServiceFactory::sendButtonPressFromString(const std::string& btn, const int state)
|
||||
{
|
||||
aasdk::proto::enums::ButtonCode::Enum buttonCode;
|
||||
projection::WheelDirection wheelDirection = projection::WheelDirection::NONE;
|
||||
projection::ButtonEventType buttonEventType = state == 0 ? projection::ButtonEventType::PRESS : projection::ButtonEventType::RELEASE;
|
||||
|
||||
if (btn == "ENTER") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::ENTER;
|
||||
} else if (btn == "LEFT") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::LEFT;
|
||||
} else if (btn == "RIGHT") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::RIGHT;
|
||||
} else if (btn == "UP") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::UP;
|
||||
} else if (btn == "DOWN") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::DOWN;
|
||||
} else if (btn == "BACK") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::BACK;
|
||||
} else if (btn == "HOME") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::HOME;
|
||||
} else if (btn == "PHONE") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::PHONE;
|
||||
} else if (btn == "CALL_END") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::CALL_END;
|
||||
} else if (btn == "PLAY") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::PLAY;
|
||||
} else if (btn == "PAUSE") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::PAUSE;
|
||||
} else if (btn == "PREV_TRACK") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::PREV;
|
||||
} else if (btn == "NEXT_TRACK") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::NEXT;
|
||||
} else if (btn == "TOGGLE_PLAY") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::TOGGLE_PLAY;
|
||||
} else if (btn == "VOICE") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::MICROPHONE_1;
|
||||
} else if (btn == "WHEEL_LEFT" || btn == "WHEEL_RIGHT") {
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::SCROLL_WHEEL;
|
||||
wheelDirection = btn == "WHEEL_LEFT" ? projection::WheelDirection::LEFT : projection::WheelDirection::RIGHT;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
sendButtonPress(buttonCode, wheelDirection, buttonEventType);
|
||||
}
|
||||
|
||||
void ServiceFactory::sendButtonPress(aasdk::proto::enums::ButtonCode::Enum buttonCode, projection::WheelDirection wheelDirection, projection::ButtonEventType buttonEventType)
|
||||
{
|
||||
if(std::shared_ptr<InputService> inputService = inputService_.lock())
|
||||
|
Loading…
x
Reference in New Issue
Block a user