From 75b18773bd9368ad53d7072d73a6280e053123a3 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Sun, 4 Dec 2016 14:51:27 +0700 Subject: [PATCH 1/6] fix RGB LED order --- keyboards/handwired/promethium/promethium.h | 124 ++++++++++---------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/keyboards/handwired/promethium/promethium.h b/keyboards/handwired/promethium/promethium.h index 8f2a8c3be2..662eeab990 100644 --- a/keyboards/handwired/promethium/promethium.h +++ b/keyboards/handwired/promethium/promethium.h @@ -23,77 +23,77 @@ } enum led_sequence { - LED_IND_EMOJI, - LED_IND_NUM, - LED_IND_FUNC, - - LED_IND_BATTERY, - LED_IND_USB, LED_IND_BLUETOOTH, + LED_IND_USB, + LED_IND_BATTERY, - LED_TAB, - LED_ESC, - LED_LSFT, - LED_LCTL, + LED_IND_FUNC, + LED_IND_NUM, + LED_IND_EMOJI, - LED_LGUI, - LED_Z, - LED_A, - LED_Q, - - LED_W, - LED_S, - LED_X, - LED_LALT, - - LED_PUNC, - LED_C, - LED_D, - LED_E, - - LED_R, - LED_F, - LED_V, - LED_NUM, - - LED_LSPC, - LED_B, - LED_G, - LED_T, - - LED_TRACKPOINT1, - LED_TRACKPOINT2, - LED_TRACKPOINT3, - - LED_RSPC, - LED_N, - LED_HH, - LED_Y, - - LED_U, - LED_J, - LED_M, - LED_FUNC, - - LED_EMOJI, - LED_COMM, - LED_K, - LED_I, - - LED_O, - LED_L, - LED_DOT, - LED_RALT, + LED_BKSP, + LED_ENT, + LED_RSFT, + LED_RCTL, LED_RGUI, LED_SLSH, LED_SCLN, LED_P, - LED_BKSP, - LED_ENT, - LED_RSFT, - LED_RCTL + LED_O, + LED_L, + LED_DOT, + LED_RALT, + + LED_EMOJI, + LED_COMM, + LED_K, + LED_I, + + LED_U, + LED_J, + LED_M, + LED_FUNC, + + LED_RSPC, + LED_N, + LED_HH, + LED_Y, + + LED_TRACKPOINT3, + LED_TRACKPOINT2, + LED_TRACKPOINT1, + + LED_LSPC, + LED_B, + LED_G, + LED_T, + + LED_R, + LED_F, + LED_V, + LED_NUM, + + LED_PUNC, + LED_C, + LED_D, + LED_E, + + LED_W, + LED_S, + LED_X, + LED_LALT, + + LED_LGUI, + LED_Z, + LED_A, + LED_Q, + + LED_TAB, + LED_ESC, + LED_LSFT, + LED_LCTL, }; #endif From a8e5f6180585f46684d713976ad05d4d81b11ab1 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Sun, 4 Dec 2016 23:55:06 +0700 Subject: [PATCH 2/6] fix emoji LED indicators. --- .../promethium/keymaps/priyadi/keymap.c | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c index b2da2f97b7..3d34e98229 100644 --- a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c +++ b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c @@ -282,25 +282,25 @@ void led_layer_func(void) { rgbsps_set(LED_K, 15, 0, 15); rgbsps_set(LED_L, 15, 0, 15); - rgbsps_set(LED_U, 15, 0, 10); - rgbsps_set(LED_O, 15, 0, 10); - rgbsps_set(LED_COMM, 15, 0, 10); - rgbsps_set(LED_DOT, 15, 0, 10); - rgbsps_set(LED_SCLN, 15, 0, 10); - rgbsps_set(LED_P, 15, 0, 10); + rgbsps_set(LED_U, 15, 0, 0); + rgbsps_set(LED_O, 15, 0, 0); + rgbsps_set(LED_COMM, 15, 0, 0); + rgbsps_set(LED_DOT, 15, 0, 0); + rgbsps_set(LED_SCLN, 15, 0, 0); + rgbsps_set(LED_P, 15, 0, 0); - rgbsps_set(LED_Q, 10, 0, 15); - rgbsps_set(LED_W, 10, 0, 15); - rgbsps_set(LED_E, 10, 0, 15); - rgbsps_set(LED_R, 10, 0, 15); - rgbsps_set(LED_A, 10, 0, 15); - rgbsps_set(LED_S, 10, 0, 15); - rgbsps_set(LED_D, 10, 0, 15); - rgbsps_set(LED_F, 10, 0, 15); - rgbsps_set(LED_Z, 10, 0, 15); - rgbsps_set(LED_X, 10, 0, 15); - rgbsps_set(LED_C, 10, 0, 15); - rgbsps_set(LED_V, 10, 0, 15); + rgbsps_set(LED_Q, 0, 15, 0); + rgbsps_set(LED_W, 0, 15, 0); + rgbsps_set(LED_E, 0, 15, 0); + rgbsps_set(LED_R, 0, 15, 0); + rgbsps_set(LED_A, 0, 15, 0); + rgbsps_set(LED_S, 0, 15, 0); + rgbsps_set(LED_D, 0, 15, 0); + rgbsps_set(LED_F, 0, 15, 0); + rgbsps_set(LED_Z, 0, 15, 0); + rgbsps_set(LED_X, 0, 15, 0); + rgbsps_set(LED_C, 0, 15, 0); + rgbsps_set(LED_V, 0, 15, 0); rgbsps_send(); } @@ -361,7 +361,15 @@ void led_layer_num(void) { } void led_layer_emoji(void) { - rgbsps_setall(15, 15, 0); + for(uint8_t i = 0; i < COUNT(LED_ALNUM); i++) { + rgbsps_set(pgm_read_byte(&LED_ALNUM[i]), 15, 15, 0); + } + for(uint8_t i = 0; i < COUNT(LED_MODS); i++) { + rgbsps_set(pgm_read_byte(&LED_MODS[i]), 15, 15, 0); + } + for(uint8_t i = 0; i < COUNT(LED_FN); i++) { + rgbsps_set(pgm_read_byte(&LED_FN[i]), 15, 15, 0); + } rgbsps_set(LED_IND_FUNC, 0, 0, 0); rgbsps_set(LED_IND_NUM, 0, 0, 0); From 6ef3060b4292392be1455c26d260e819f7d12ef0 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Mon, 5 Dec 2016 01:07:12 +0700 Subject: [PATCH 3/6] Implemented weak ps2_mouse_init_user() There are a lot of PS/2 commands, some are vendor/device specific, so we provide a weak ps2_mouse_init_user() to be implemented in each keyboard that need it. --- tmk_core/protocol/ps2_mouse.c | 54 +++++------------------------------ tmk_core/protocol/ps2_mouse.h | 49 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 47 deletions(-) diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index af971dd497..e3c6974440 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c @@ -28,53 +28,7 @@ along with this program. If not, see . /* ============================= MACROS ============================ */ -#define PS2_MOUSE_SEND(command, message) \ -do { \ - uint8_t rcv = ps2_host_send(command); \ - if (debug_mouse) { \ - print((message)); \ - xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \ - } \ -} while(0) - -#define PS2_MOUSE_SEND_SAFE(command, message) \ -do { \ - if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ - ps2_mouse_disable_data_reporting(); \ - } \ - PS2_MOUSE_SEND(command, message); \ - if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ - ps2_mouse_enable_data_reporting(); \ - } \ -} while(0) - -#define PS2_MOUSE_SET_SAFE(command, value, message) \ -do { \ - if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ - ps2_mouse_disable_data_reporting(); \ - } \ - PS2_MOUSE_SEND(command, message); \ - PS2_MOUSE_SEND(value, "Sending value"); \ - if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ - ps2_mouse_enable_data_reporting(); \ - } \ -} while(0) - -#define PS2_MOUSE_RECEIVE(message) \ -do { \ - uint8_t rcv = ps2_host_recv_response(); \ - if (debug_mouse) { \ - print((message)); \ - xprintf(" result: %X, error: %X \n", rcv, ps2_error); \ - } \ -} while(0) - -static enum ps2_mouse_mode_e { - PS2_MOUSE_STREAM_MODE, - PS2_MOUSE_REMOTE_MODE, -} ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; - -static report_mouse_t mouse_report = {}; +static report_mouse_t mouse_report = {};./ static inline void ps2_mouse_print_report(report_mouse_t *mouse_report); static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report); @@ -108,6 +62,12 @@ void ps2_mouse_init(void) { #ifdef PS2_MOUSE_USE_2_1_SCALING ps2_mouse_set_scaling_2_1(); #endif + + ps2_mouse_init_user(); +} + +__attribute__((weak)) +void ps2_mouse_init_user(void) { } void ps2_mouse_task(void) { diff --git a/tmk_core/protocol/ps2_mouse.h b/tmk_core/protocol/ps2_mouse.h index e11c705fc6..3c93a46342 100644 --- a/tmk_core/protocol/ps2_mouse.h +++ b/tmk_core/protocol/ps2_mouse.h @@ -19,6 +19,53 @@ along with this program. If not, see . #define PS2_MOUSE_H #include +#include "debug.h" + +#define PS2_MOUSE_SEND(command, message) \ +do { \ + uint8_t rcv = ps2_host_send(command); \ + if (debug_mouse) { \ + print((message)); \ + xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \ + } \ +} while(0) + +#define PS2_MOUSE_SEND_SAFE(command, message) \ +do { \ + if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ + ps2_mouse_disable_data_reporting(); \ + } \ + PS2_MOUSE_SEND(command, message); \ + if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ + ps2_mouse_enable_data_reporting(); \ + } \ +} while(0) + +#define PS2_MOUSE_SET_SAFE(command, value, message) \ +do { \ + if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ + ps2_mouse_disable_data_reporting(); \ + } \ + PS2_MOUSE_SEND(command, message); \ + PS2_MOUSE_SEND(value, "Sending value"); \ + if (PS2_MOUSE_STREAM_MODE == ps2_mouse_mode) { \ + ps2_mouse_enable_data_reporting(); \ + } \ +} while(0) + +#define PS2_MOUSE_RECEIVE(message) \ +do { \ + uint8_t rcv = ps2_host_recv_response(); \ + if (debug_mouse) { \ + print((message)); \ + xprintf(" result: %X, error: %X \n", rcv, ps2_error); \ + } \ +} while(0) + +static enum ps2_mouse_mode_e { + PS2_MOUSE_STREAM_MODE, + PS2_MOUSE_REMOTE_MODE, +} ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; /* * Data format: @@ -107,6 +154,8 @@ typedef enum ps2_mouse_sample_rate_e { void ps2_mouse_init(void); +void ps2_mouse_init_user(void); + void ps2_mouse_task(void); void ps2_mouse_disable_data_reporting(void); From 73073f270b55d939559e8cfd4a7d36e3510ba2f6 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Mon, 5 Dec 2016 01:15:04 +0700 Subject: [PATCH 4/6] Trackpoint initialization --- .../promethium/keymaps/priyadi/flash.sh | 1 + .../promethium/keymaps/priyadi/keymap.c | 110 +++++++++++++++++- 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/keyboards/handwired/promethium/keymaps/priyadi/flash.sh b/keyboards/handwired/promethium/keymaps/priyadi/flash.sh index fb81a54ee0..14a3b43789 100755 --- a/keyboards/handwired/promethium/keymaps/priyadi/flash.sh +++ b/keyboards/handwired/promethium/keymaps/priyadi/flash.sh @@ -1,3 +1,4 @@ #!/bin/sh +sleep 10 avrdude -p m32u4 -P /dev/ttyACM0 -c avr109 -U flash:w:../../../../../.build/handwired_promethium_priyadi.hex diff --git a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c index 3d34e98229..bf797a7491 100644 --- a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c +++ b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c @@ -11,6 +11,8 @@ #include "process_unicode.h" #include "quantum.h" #include "rgbsps.h" +#include "ps2_mouse.h" +#include "ps2.h" #define COUNT(x) (sizeof (x) / sizeof (*(x))) // #define RGBLED_NUM 5 @@ -730,4 +732,110 @@ void shutdown_user() stop_all_notes(); } -#endif \ No newline at end of file +#endif + + +void ps2_mouse_init_user() { + // set TrackPoint sensitivity + PS2_MOUSE_SEND(0xE2, "set trackpoint sensitivity: 0xE2"); + PS2_MOUSE_SEND(0x81, "set trackpoint sensitivity: 0x81"); + PS2_MOUSE_SEND(0x4A, "set trackpoint sensitivity: 0x4A"); + PS2_MOUSE_SEND(0x60, "set trackpoint sensitivity: 0x60"); + + // set TrackPoint speed + // (transfer function upper plateau speed) + PS2_MOUSE_SEND(0xE2, "set trackpoint speed: 0xE2"); + PS2_MOUSE_SEND(0x81, "set trackpoint speed: 0x81"); + PS2_MOUSE_SEND(0x60, "set trackpoint speed: 0x60"); + PS2_MOUSE_SEND(0x90, "set trackpoint speed: 0x90"); + + // set TrackPoint Negative Inertia factor + PS2_MOUSE_SEND(0xE2, "set negative inertia factor: 0xE2"); + PS2_MOUSE_SEND(0x81, "set negative inertia factor: 0x81"); + PS2_MOUSE_SEND(0x4D, "set negative inertia factor: 0x4D"); + PS2_MOUSE_SEND(0x03, "set negative inertia factor: 0x03"); + + // disable up threshold (click) + PS2_MOUSE_SEND(0xE2, "set disable up threshold: 0xE2"); + PS2_MOUSE_SEND(0x47, "set disable up threshold: 0x47"); + PS2_MOUSE_SEND(0x2C, "set disable up threshold: 0x2C"); + PS2_MOUSE_SEND(0x01, "set disable up threshold: 0x01"); + + // enable TrackPoint Press to Select (PtS) + // print("ps2_mouse_init: send 0xE2: "); + // rcv = ps2_host_send(0xE2); + // phex(rcv); phex(ps2_error); print("\n"); + // print("ps2_mouse_init: send 0x47: "); + // rcv = ps2_host_send(0x47); + // phex(rcv); phex(ps2_error); print("\n"); + // print("ps2_mouse_init: send 0x2C: "); + // rcv = ps2_host_send(0x2C); + // phex(rcv); phex(ps2_error); print("\n"); + // print("ps2_mouse_init: send 0x00: "); + // rcv = ps2_host_send(0x00); + // phex(rcv); phex(ps2_error); print("\n"); + + // set TrackPoint Press to Select threshold + // print("ps2_mouse_init: send 0xE2: "); + // rcv = ps2_host_send(0xE2); + // phex(rcv); phex(ps2_error); print("\n"); + // print("ps2_mouse_init: send 0x81: "); + // rcv = ps2_host_send(0x81); + // phex(rcv); phex(ps2_error); print("\n"); + // print("ps2_mouse_init: send 0x5C: "); + // rcv = ps2_host_send(0x5C); + // phex(rcv); phex(ps2_error); print("\n"); + // // default PtS threshold is 0x08 + // print("ps2_mouse_init: send 0x04: "); + // rcv = ps2_host_send(0x04); + // phex(rcv); phex(ps2_error); print("\n"); + + // set TrackPoint Press to Select time constant (zTc) + // print("ps2_mouse_init: send 0xE2: "); + // rcv = ps2_host_send(0xE2); + // phex(rcv); phex(ps2_error); print("\n"); + // print("ps2_mouse_init: send 0x81: "); + // rcv = ps2_host_send(0x81); + // phex(rcv); phex(ps2_error); print("\n"); + // print("ps2_mouse_init: send 0x5E: "); + // rcv = ps2_host_send(0x5E); + // phex(rcv); phex(ps2_error); print("\n"); + // // default zTc is 0x26 + // print("ps2_mouse_init: send 0x45: "); + // rcv = ps2_host_send(0x45); + // phex(rcv); phex(ps2_error); print("\n"); + + /* + // set TrackPoint Press to Select Jenks Curvature (jkcur) + print("ps2_mouse_init: send 0xE2: "); + rcv = ps2_host_send(0xE2); + phex(rcv); phex(ps2_error); print("\n"); + print("ps2_mouse_init: send 0x81: "); + rcv = ps2_host_send(0x81); + phex(rcv); phex(ps2_error); print("\n"); + print("ps2_mouse_init: send 0x5D: "); + rcv = ps2_host_send(0x5D); + phex(rcv); phex(ps2_error); print("\n"); + // default jkcur is 0x87 + print("ps2_mouse_init: send 0x87: "); + rcv = ps2_host_send(0x87); + phex(rcv); phex(ps2_error); print("\n"); + */ + + /* + // set TrackPoint Minimum Drag (mindrag) + print("ps2_mouse_init: send 0xE2: "); + rcv = ps2_host_send(0xE2); + phex(rcv); phex(ps2_error); print("\n"); + print("ps2_mouse_init: send 0x81: "); + rcv = ps2_host_send(0x81); + phex(rcv); phex(ps2_error); print("\n"); + print("ps2_mouse_init: send 0x59: "); + rcv = ps2_host_send(0x59); + phex(rcv); phex(ps2_error); print("\n"); + // default PtS mindrag is 0x14 + print("ps2_mouse_init: send 0x14: "); + rcv = ps2_host_send(0x14); + phex(rcv); phex(ps2_error); print("\n"); + */ +} \ No newline at end of file From 236c0408596e525c949abc5a3b3ef8b853c28504 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Mon, 5 Dec 2016 01:22:40 +0700 Subject: [PATCH 5/6] syntax error fix --- tmk_core/protocol/ps2_mouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index e3c6974440..d9ccbecb43 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c @@ -28,7 +28,7 @@ along with this program. If not, see . /* ============================= MACROS ============================ */ -static report_mouse_t mouse_report = {};./ +static report_mouse_t mouse_report = {}; static inline void ps2_mouse_print_report(report_mouse_t *mouse_report); static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report); From c7d11fd001cac4f0baeecdda79b7743e3695c77f Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Mon, 5 Dec 2016 02:15:38 +0700 Subject: [PATCH 6/6] Remove unnecessary build options --- keyboards/handwired/promethium/keymaps/priyadi/Makefile | 7 ++++--- keyboards/handwired/promethium/rules.mk | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/keyboards/handwired/promethium/keymaps/priyadi/Makefile b/keyboards/handwired/promethium/keymaps/priyadi/Makefile index 2f6f27a732..46fdfa0118 100644 --- a/keyboards/handwired/promethium/keymaps/priyadi/Makefile +++ b/keyboards/handwired/promethium/keymaps/priyadi/Makefile @@ -4,16 +4,17 @@ # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration +COMMAND_ENABLE = no # Commands for debug and configuration NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality MIDI_ENABLE = no # MIDI controls AUDIO_ENABLE = no # Audio output on port C6 UNICODE_ENABLE = no # Unicode +UNICODEMAP_ENABLE = yes BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. PS2_MOUSE_ENABLE = yes diff --git a/keyboards/handwired/promethium/rules.mk b/keyboards/handwired/promethium/rules.mk index 0842780cce..891f523c22 100644 --- a/keyboards/handwired/promethium/rules.mk +++ b/keyboards/handwired/promethium/rules.mk @@ -61,7 +61,7 @@ BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality MIDI_ENABLE ?= no # MIDI controls AUDIO_ENABLE ?= no # Audio output on port C6 UNICODE_ENABLE ?= no # Unicode -UNICODEMAP_ENABLE = yes +UNICODEMAP_ENABLE ?= yes BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. PS2_MOUSE_ENABLE ?= yes