more buttons+multitouch

This commit is contained in:
frederik
2026-01-06 14:08:06 +01:00
committed by Alexander
parent 2b96660d32
commit 0d7fa30b8a
5 changed files with 84 additions and 0 deletions
+7
View File
@@ -37,6 +37,13 @@ inline void write_uint32_le(uint8_t *dst, uint32_t value)
dst[3] = (value >> 24) & 0xFF;
}
inline void write_float_le(uint8_t* dst, float value)
{
uint32_t bits;
std::memcpy(&bits, &value, sizeof(bits));
write_uint32_le(dst, bits);
}
inline void execute(const char *path)
{
if (!path || *path == '\0')
+9
View File
@@ -24,6 +24,7 @@
#define CMD_BLUETOOTH_INFO 13
#define CMD_WIFI_INFO 14
#define CMD_DEVICE_LIST 18
#define CMD_MULTI_TOUCH 23
#define CMD_JSON_CONTROL 25
#define CMD_MANUFACTURER 20
#define CMD_UNKNOWN_38 38
@@ -35,12 +36,19 @@
#define CMD_VERSION 204
#define CMD_ENCRYPTION 240
#define BTN_SIRI 5
#define BTN_MICROPHONE 7
#define BTN_LEFT 100
#define BTN_RIGHT 101
#define BTN_SELECT_DOWN 104
#define BTN_SELECT_UP 105
#define BTN_BACK 106
#define BTN_DOWN 114
#define BTN_HOME 200
#define BTN_PLAY 201
#define BTN_PAUSE 202
#define BTN_NEXT_TRACK 204
#define BTN_PREVIOUS_TRACK 205
#define AUDIO_BUFFER_SIZE 2560
@@ -65,6 +73,7 @@ const ProtocolCmdEntry protocolCmdList[] = {
{CMD_BLUETOOTH_INFO, "Bluetooth Info"},
{CMD_WIFI_INFO, "WiFi Info"},
{CMD_DEVICE_LIST, "Device List"},
{CMD_MULTI_TOUCH, "Multi Touch"},
{CMD_JSON_CONTROL, "Control JSON"},
{CMD_MANUFACTURER, "Manufacturer"},
{CMD_MEDIA_INFO, "Media info"},
+31
View File
@@ -61,6 +61,17 @@ void processKey(Protocol &protocol, SDL_Keysym key, RunParams &params)
case SDLK_r:
params.dirty = true;
return;
case SDLK_h:
protocol.sendKey(BTN_HOME);
return;
case SDLK_s:
protocol.sendKey(BTN_SIRI);
return;
case SDLK_m:
protocol.sendKey(BTN_MICROPHONE);
return;
case SDLK_LEFT:
protocol.sendKey(BTN_LEFT);
@@ -70,6 +81,26 @@ void processKey(Protocol &protocol, SDL_Keysym key, RunParams &params)
protocol.sendKey(BTN_RIGHT);
return;
case SDLK_DOWN:
protocol.sendKey(BTN_DOWN);
return;
case SDLK_SPACE:
protocol.sendKey(BTN_PLAY);
return;
case SDLK_p:
protocol.sendKey(BTN_PAUSE);
return;
case SDLK_MINUS:
protocol.sendKey(BTN_PREVIOUS_TRACK);
return;
case SDLK_EQUALS:
protocol.sendKey(BTN_NEXT_TRACK);
return;
case SDLK_RETURN:
protocol.sendKey(BTN_SELECT_DOWN);
protocol.sendKey(BTN_SELECT_UP);
+22
View File
@@ -153,6 +153,28 @@ void Protocol::sendClick(float x, float y, bool down)
send(CMD_TOUCH, false, buf, 16);
}
void Protocol::sendMultiTouch(const std::vector<Protocol::Touch>& touches)
{
if (touches.empty()) return;
const size_t touchSize = 16;
const size_t totalSize = touches.size() * touchSize;
std::vector<uint8_t> buf(totalSize);
uint8_t* p = buf.data();
for (const auto& t : touches) {
write_float_le(p + 0, t.x);
write_float_le(p + 4, t.y);
write_uint32_le(p + 8, static_cast<uint32_t>(t.action));
write_uint32_le(p + 12, t.id);
p += touchSize;
}
send(CMD_MULTI_TOUCH, false, buf.data(), totalSize);
}
void Protocol::sendMove(float dx, float dy)
{
uint8_t buf[16];
+15
View File
@@ -18,6 +18,20 @@ public:
Protocol(const Protocol &) = delete;
Protocol &operator=(const Protocol &) = delete;
enum Action {
UP = 16,
DOWN = 14,
MOVE = 15
};
struct Touch {
float x;
float y;
Action action;
uint32_t id;
};
void start(uint32_t evtStatus, uint32_t evtPhone);
void stop();
@@ -26,6 +40,7 @@ public:
void sendFile(const char *filename, const char *value);
void sendFile(const char *filename, int value);
void sendClick(float x, float y, bool down);
void sendMultiTouch(const std::vector<Touch>& touches);
void sendMove(float dx, float dy);
void sendAudio(uint8_t *data, uint32_t length) override;