mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-26 16:26:06 -04:00
Touch emulation from usb cdc (#1706)
This commit is contained in:
parent
fbe7954f2e
commit
58bf60695d
9 changed files with 52 additions and 4 deletions
|
@ -51,6 +51,11 @@
|
|||
#define SHELL_WA_SIZE THD_WA_SIZE(1024 * 3)
|
||||
#define palOutputPad(port, pad) (LPC_GPIO->DIR[(port)] |= 1 << (pad))
|
||||
|
||||
static EventDispatcher* _eventDispatcherInstance = NULL;
|
||||
static EventDispatcher* getEventDispatcherInstance() {
|
||||
return _eventDispatcherInstance;
|
||||
}
|
||||
|
||||
// queue handler from ch
|
||||
static msg_t qwait(GenericQueue* qp, systime_t time) {
|
||||
if (TIME_IMMEDIATE == time)
|
||||
|
@ -338,6 +343,28 @@ static void cmd_button(BaseSequentialStream* chp, int argc, char* argv[]) {
|
|||
chprintf(chp, "ok\r\n");
|
||||
}
|
||||
|
||||
static void cmd_touch(BaseSequentialStream* chp, int argc, char* argv[]) {
|
||||
if (argc != 2) {
|
||||
chprintf(chp, "usage: touch x y\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int x = (int)strtol(argv[0], NULL, 10);
|
||||
int y = (int)strtol(argv[1], NULL, 10);
|
||||
if (x < 0 || x > ui::screen_width || y < 0 || y > ui::screen_height) {
|
||||
chprintf(chp, "usage: touch x y\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
auto evtd = getEventDispatcherInstance();
|
||||
if (evtd == NULL) {
|
||||
chprintf(chp, "error\r\n");
|
||||
}
|
||||
evtd->emulateTouch({{x, y}, ui::TouchEvent::Type::Start});
|
||||
evtd->emulateTouch({{x, y}, ui::TouchEvent::Type::End});
|
||||
chprintf(chp, "ok\r\n");
|
||||
}
|
||||
|
||||
static void cmd_sd_list_dir(BaseSequentialStream* chp, int argc, char* argv[]) {
|
||||
if (argc != 1) {
|
||||
chprintf(chp, "usage: ls /\r\n");
|
||||
|
@ -838,6 +865,7 @@ static const ShellCommand commands[] = {
|
|||
{"write_memory", cmd_write_memory},
|
||||
{"read_memory", cmd_read_memory},
|
||||
{"button", cmd_button},
|
||||
{"touch", cmd_touch},
|
||||
{"ls", cmd_sd_list_dir},
|
||||
{"rm", cmd_sd_delete},
|
||||
{"open", cmd_sd_open},
|
||||
|
@ -854,6 +882,7 @@ static const ShellConfig shell_cfg1 = {
|
|||
(BaseSequentialStream*)&SUSBD1,
|
||||
commands};
|
||||
|
||||
void create_shell() {
|
||||
void create_shell(EventDispatcher* evtd) {
|
||||
_eventDispatcherInstance = evtd;
|
||||
shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue