diff --git a/Production/Firmware/nos_pico.uf2 b/Production/Firmware/nos_pico.uf2 index 07ab333..0e85b52 100644 Binary files a/Production/Firmware/nos_pico.uf2 and b/Production/Firmware/nos_pico.uf2 differ diff --git a/firmware/src/board_defs.h b/firmware/src/board_defs.h index 74bdb43..2611434 100644 --- a/firmware/src/board_defs.h +++ b/firmware/src/board_defs.h @@ -22,7 +22,7 @@ #define ADC_KEY_CHN { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, \ 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16 } -#define BUTTON_DEF { 13, 12, 11, 10 } +#define BUTTON_DEF { 13, 12, 10, 11 } #else #endif diff --git a/firmware/src/main.c b/firmware/src/main.c index c936837..14e599d 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -31,6 +31,7 @@ #include "light.h" #include "hammer.h" +#include "button.h" #define WHITE 0xffffff @@ -88,10 +89,10 @@ static void hid_update() } } - if (nos_cfg->hid.analog) { - for (int i = 0; i < hammer_keynum(); i++) { - hid_report.analog[i] = hammer_analog(i); - } + hid_report.buttons |= button_read() << 28; + + for (int i = 0; i < hammer_keynum(); i++) { + hid_report.analog[i] = nos_cfg->hid.analog ? hammer_analog(i) : 127; } if (!tud_hid_ready()) { @@ -143,7 +144,7 @@ static void core0_loop() savedata_loop(); hammer_update(); proc_midi(); - + button_update(); hid_update(); cli_fps_count(0); @@ -189,6 +190,7 @@ void init() light_init(); hammer_init(); + button_init(); cli_init("nos_pico>", "\n << Nos Pico Controller >>\n" " https://github.com/whowechina\n\n"); diff --git a/firmware/src/usb_descriptors.h b/firmware/src/usb_descriptors.h index 0b86f60..dd97211 100644 --- a/firmware/src/usb_descriptors.h +++ b/firmware/src/usb_descriptors.h @@ -23,12 +23,10 @@ enum { HID_COLLECTION(HID_COLLECTION_APPLICATION), \ HID_REPORT_ID(REPORT_ID_JOYSTICK) \ HID_USAGE_PAGE(HID_USAGE_PAGE_BUTTON), \ - HID_USAGE_MIN(1), HID_USAGE_MAX(28), \ + HID_USAGE_MIN(1), HID_USAGE_MAX(32), \ HID_LOGICAL_MIN(0), HID_LOGICAL_MAX(1), \ - HID_REPORT_COUNT(28), HID_REPORT_SIZE(1), \ + HID_REPORT_COUNT(32), HID_REPORT_SIZE(1), \ HID_INPUT(HID_DATA | HID_VARIABLE | HID_ABSOLUTE), \ - HID_REPORT_COUNT(4), HID_REPORT_SIZE(1), \ - HID_INPUT(HID_CONSTANT), \ HID_USAGE_PAGE(HID_USAGE_PAGE_DESKTOP), \ HID_LOGICAL_MIN(0x00), HID_LOGICAL_MAX_N(0x00ff, 2), \ HID_USAGE(HID_USAGE_DESKTOP_X), HID_USAGE(HID_USAGE_DESKTOP_Y), \