mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-20 12:02:21 +00:00
Send input event
This commit is contained in:
parent
a3b7c8d95d
commit
bcff21fcda
@ -5,6 +5,7 @@
|
|||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
#include "SPILock.h"
|
#include "SPILock.h"
|
||||||
|
#include "input/InputBroker.h"
|
||||||
#include "meshUtils.h"
|
#include "meshUtils.h"
|
||||||
#include <FSCommon.h>
|
#include <FSCommon.h>
|
||||||
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH
|
||||||
@ -426,6 +427,11 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case meshtastic_AdminMessage_send_input_event_tag: {
|
||||||
|
LOG_INFO("Client requesting to send input event");
|
||||||
|
handleSendInputEvent(r->send_input_event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
#ifdef ARCH_PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
case meshtastic_AdminMessage_exit_simulator_tag:
|
case meshtastic_AdminMessage_exit_simulator_tag:
|
||||||
LOG_INFO("Exiting simulator");
|
LOG_INFO("Exiting simulator");
|
||||||
@ -1250,6 +1256,38 @@ bool AdminModule::messageIsRequest(const meshtastic_AdminMessage *r)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AdminModule::handleSendInputEvent(const meshtastic_AdminMessage_InputEvent &inputEvent)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("Processing input event: event_code=%u, kb_char=%u, touch_x=%u, touch_y=%u", inputEvent.event_code,
|
||||||
|
inputEvent.kb_char, inputEvent.touch_x, inputEvent.touch_y);
|
||||||
|
|
||||||
|
// Validate input parameters
|
||||||
|
if (inputEvent.event_code > INPUT_BROKER_ANYKEY) {
|
||||||
|
LOG_WARN("Invalid input event code: %u", inputEvent.event_code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create InputEvent for injection
|
||||||
|
InputEvent event = {.inputEvent = (input_broker_event)inputEvent.event_code,
|
||||||
|
.kbchar = (unsigned char)inputEvent.kb_char,
|
||||||
|
.touchX = inputEvent.touch_x,
|
||||||
|
.touchY = inputEvent.touch_y};
|
||||||
|
|
||||||
|
// Log the event being injected
|
||||||
|
LOG_INFO("Injecting input event from admin: source=%s, event=%u, char=%c(%u), touch=(%u,%u)", event.source, event.inputEvent,
|
||||||
|
(event.kbchar >= 32 && event.kbchar <= 126) ? event.kbchar : '?', event.kbchar, event.touchX, event.touchY);
|
||||||
|
|
||||||
|
// Wake the device if asleep
|
||||||
|
powerFSM.trigger(EVENT_INPUT);
|
||||||
|
|
||||||
|
// Inject the event through InputBroker
|
||||||
|
if (inputBroker) {
|
||||||
|
inputBroker->injectInputEvent(&event);
|
||||||
|
} else {
|
||||||
|
LOG_ERROR("InputBroker not available for event injection");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AdminModule::sendWarning(const char *message)
|
void AdminModule::sendWarning(const char *message)
|
||||||
{
|
{
|
||||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||||
|
@ -54,6 +54,7 @@ class AdminModule : public ProtobufModule<meshtastic_AdminMessage>, public Obser
|
|||||||
void handleSetChannel();
|
void handleSetChannel();
|
||||||
void handleSetHamMode(const meshtastic_HamParameters &req);
|
void handleSetHamMode(const meshtastic_HamParameters &req);
|
||||||
void handleStoreDeviceUIConfig(const meshtastic_DeviceUIConfig &uicfg);
|
void handleStoreDeviceUIConfig(const meshtastic_DeviceUIConfig &uicfg);
|
||||||
|
void handleSendInputEvent(const meshtastic_AdminMessage_InputEvent &inputEvent);
|
||||||
void reboot(int32_t seconds);
|
void reboot(int32_t seconds);
|
||||||
|
|
||||||
void setPassKey(meshtastic_AdminMessage *res);
|
void setPassKey(meshtastic_AdminMessage *res);
|
||||||
|
Loading…
Reference in New Issue
Block a user