From 39eda1e38bca488eea35e282f703f1c247d5f3e1 Mon Sep 17 00:00:00 2001 From: Denis Date: Sun, 12 Nov 2023 19:11:59 +0100 Subject: [PATCH] Fiter test --- input_dev.c | 27 +++++++++++++++++++++++++++ output_dev.c | 10 +++------- platform.c | 7 ++++++- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/input_dev.c b/input_dev.c index 4ac6e1d..32bae29 100644 --- a/input_dev.c +++ b/input_dev.c @@ -37,6 +37,33 @@ int input_filter_asus_kb(struct input_event* events, size_t* size, uint32_t* cou return INPUT_FILTER_RESULT_DO_NOT_EMIT; } else if ((*count >= 2) && (events[0].type == EV_MSC) && (events[0].code == MSC_SCAN) && (events[0].value == -13565784)) { return INPUT_FILTER_RESULT_DO_NOT_EMIT; + } else if ((*count == 2) && (events[0].type == EV_MSC) && (events[0].code == MSC_SCAN) && (events[0].value == 458860)) { + if ((events[1].type == EV_KEY) && (events[1].code == KEY_F17)) { + if (events[1].value < 2) { + *count = 1; + events[0].type = EV_KEY; + events[0].code = BTN_GEAR_DOWN; + events[0].value = events[1].value; + } + } + } else if ((*count == 2) && (events[0].type == EV_MSC) && (events[0].code == MSC_SCAN) && (events[0].value == 458861)) { + if ((events[1].type == EV_KEY) && (events[1].code == KEY_F18)) { + if (events[1].value < 2) { + *count = 1; + events[0].type = EV_KEY; + events[0].code = BTN_GEAR_UP; + events[0].value = events[1].value; + } + } + } else if ((*count == 2) && (events[0].type == EV_MSC) && (events[0].code == MSC_SCAN) && (events[0].value == -13565786)) { + if ((events[1].type == EV_KEY) && (events[1].code == KEY_F16)) { + if (events[1].value < 2) { + *count = 1; + events[0].type = EV_KEY; + events[0].code = BTN_MODE; + events[0].value = events[1].value; + } + } } return INPUT_FILTER_RESULT_OK; diff --git a/output_dev.c b/output_dev.c index 7e4fe70..e6f130e 100644 --- a/output_dev.c +++ b/output_dev.c @@ -410,15 +410,11 @@ void *output_dev_thread_func(void *ptr) { .time = now, }; - if ((ev.type == EV_KEY) && (ev.code == KEY_F16)) { - ev.code = BTN_MODE; - } else if ((ev.type == EV_KEY) && (ev.code == KEY_PROG1)) { // To be wired to F16 + /* + if ((ev.type == EV_KEY) && (ev.code == KEY_PROG1)) { // To be wired to F16 ev.code = KEY_F12; - } else if ((ev.type == EV_KEY) && (ev.code == KEY_F18)) { // To be wired to F16 - ev.code = BTN_GEAR_UP; - } else if ((ev.type == EV_KEY) && (ev.code == KEY_F17)) { // To be wired to F16 - ev.code = BTN_GEAR_DOWN; } + */ #if defined(INCLUDE_OUTPUT_DEBUG) printf( diff --git a/platform.c b/platform.c index 49708da..43966c9 100644 --- a/platform.c +++ b/platform.c @@ -41,7 +41,12 @@ int cycle_mode() { fprintf(stderr, "Asus MCU not registered: aborting.\n"); } - char new_mode_str[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + char new_mode_str[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00 + }; + unsigned long new_mode = (global_platform->mode + 1) % global_platform->modes_count; sprintf(new_mode_str, "%lu\n", new_mode);