diff --git a/Matrix/firmware/ju_matrix.uf2 b/Matrix/firmware/ju_matrix.uf2 new file mode 100644 index 0000000..55abcf3 Binary files /dev/null and b/Matrix/firmware/ju_matrix.uf2 differ diff --git a/firmware/src/commands.c b/firmware/src/commands.c index 952757b..2c65bc8 100644 --- a/firmware/src/commands.c +++ b/firmware/src/commands.c @@ -49,6 +49,7 @@ static void disp_hid() { printf("[HID]\n"); printf(" Rotate: %d degree\n", (ju_cfg->hid.rotate % 4) * 90); + printf(" Report Rotate: %s\n", ju_cfg->hid.report_rotate ? "on" : "off"); } #define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0])) @@ -129,6 +130,25 @@ static void handle_rotate(int argc, char *argv[]) config_changed(); } +static void handle_report_rotate(int argc, char *argv[]) +{ + const char *usage = "Usage: report_rotate \n"; + if (argc != 1) { + printf(usage); + return; + } + + const char *choicses[] = {"on", "off"}; + int axis = cli_match_prefix(choicses, ARRAYSIZE(choicses), argv[0]); + if (axis < 0) { + printf(usage); + return; + } + + ju_cfg->hid.report_rotate = (axis == 0); + config_changed(); +} + static void handle_stat(int argc, char *argv[]) { printf("[STAT]\n"); @@ -148,6 +168,7 @@ void commands_init() cli_register("display", handle_display, "Display all config."); cli_register("level", handle_level, "Set LED brightness level."); cli_register("rotate", handle_rotate, "Set button rotate angle."); + cli_register("report_rotate", handle_report_rotate, "Set rotate report on axis."); cli_register("stat", handle_stat, "Display statistics."); cli_register("save", handle_save, "Save config to flash."); cli_register("factory", config_factory_reset, "Reset everything to default."); diff --git a/firmware/src/config.c b/firmware/src/config.c index 6b373c4..5e2febb 100644 --- a/firmware/src/config.c +++ b/firmware/src/config.c @@ -25,6 +25,7 @@ static ju_cfg_t default_cfg = { }, .hid = { .rotate = 0, + .report_rotate = true, }, }; diff --git a/firmware/src/config.h b/firmware/src/config.h index 5355e35..981ee4c 100644 --- a/firmware/src/config.h +++ b/firmware/src/config.h @@ -25,6 +25,7 @@ typedef struct __attribute__((packed)) { } sense; struct { uint8_t rotate; + bool report_rotate; } hid; uint8_t reserved[8]; } ju_cfg_t; diff --git a/firmware/src/hid.c b/firmware/src/hid.c index caf7712..cbcfd40 100644 --- a/firmware/src/hid.c +++ b/firmware/src/hid.c @@ -46,14 +46,20 @@ static void report_usb_hid() hid_report.buttons = do_rotate(button_read() & 0xffff); hid_report.aux = button_read() >> 16; - const struct { - uint8_t x; - uint8_t y; - } dirs[] = { {0, 127}, {127, 0}, {255, 127}, {127, 255}}; + if (ju_cfg->hid.report_rotate) { + const struct { + uint8_t x; + uint8_t y; + } dirs[] = { {0, 127}, {127, 0}, {255, 127}, {127, 255}}; - uint8_t rotate = ju_cfg->hid.rotate % 4; - hid_report.axis[0] = dirs[rotate].x; - hid_report.axis[1] = dirs[rotate].y; + uint8_t rotate = ju_cfg->hid.rotate % 4; + hid_report.axis[0] = dirs[rotate].x; + hid_report.axis[1] = dirs[rotate].y; + } + else { + hid_report.axis[0] = 127; + hid_report.axis[1] = 127; + } uint64_t now = time_us_64(); if ((memcmp(&hid_reported, &hid_report, sizeof(hid_report)) != 0) ||