diff options
author | lokher <lokher@gmail.com> | 2022-09-13 11:13:00 +0800 |
---|---|---|
committer | lokher <lokher@gmail.com> | 2022-09-13 11:13:00 +0800 |
commit | fe13cedf8c09fa34d5cec4e4c624738095176625 (patch) | |
tree | 818436626d49c7f22f325632b2053edba10d4358 /keyboards/takashicompany/minizone | |
parent | fa207545a9759c50b9f230eb608d86a9085801d4 (diff) | |
parent | f46379f308783994b8178f95adc686f4b4c3ebd8 (diff) |
merge upstream master
Diffstat (limited to 'keyboards/takashicompany/minizone')
4 files changed, 132 insertions, 72 deletions
diff --git a/keyboards/takashicompany/minizone/config.h b/keyboards/takashicompany/minizone/config.h index 73a85e2d9f..0c8def659f 100644 --- a/keyboards/takashicompany/minizone/config.h +++ b/keyboards/takashicompany/minizone/config.h @@ -5,13 +5,6 @@ #include "config_common.h" -/* USB Device descriptor parameter */ -#define VENDOR_ID 0x7463 // tc = takashicompany -#define PRODUCT_ID 0x0021 -#define DEVICE_VER 0x0001 -#define MANUFACTURER takashicompany -#define PRODUCT miniZone - /* key matrix size */ #define MATRIX_ROWS 6 #define MATRIX_COLS 7 @@ -28,7 +21,6 @@ */ #define MATRIX_ROW_PINS { D4, C6, D7, E6, B4, B5 } #define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3, B2} -#define UNUSED_PINS /* COL2ROW, ROW2COL */ #define DIODE_DIRECTION COL2ROW diff --git a/keyboards/takashicompany/minizone/info.json b/keyboards/takashicompany/minizone/info.json index 4c4969d1fc..51fb57276c 100644 --- a/keyboards/takashicompany/minizone/info.json +++ b/keyboards/takashicompany/minizone/info.json @@ -1,7 +1,13 @@ { "keyboard_name": "miniZone", + "manufacturer": "takashicompany", "url": "https://github.com/takashicompany/minizone", "maintainer": "takashicompany", + "usb": { + "vid": "0x7463", + "pid": "0x0021", + "device_version": "0.0.1" + }, "layouts": { "LAYOUT": { "layout": [ diff --git a/keyboards/takashicompany/minizone/keymaps/pimoroni_trackball/keymap.c b/keyboards/takashicompany/minizone/keymaps/pimoroni_trackball/keymap.c index 0d070b4596..f1652d344a 100644 --- a/keyboards/takashicompany/minizone/keymaps/pimoroni_trackball/keymap.c +++ b/keyboards/takashicompany/minizone/keymaps/pimoroni_trackball/keymap.c @@ -3,12 +3,24 @@ #include QMK_KEYBOARD_H +typedef union { + uint32_t raw; + struct { + int8_t trackball_movement_ratio; + int8_t mode; + }; +} user_config_t; + +user_config_t user_config; enum custom_keycodes { KC_MY_BTN1 = SAFE_RANGE, KC_MY_BTN2, KC_MY_BTN3, KC_MY_SCR, + KC_TB_RAT_INC, + KC_TB_RAT_DEC, + KC_TB_MODE, }; @@ -37,7 +49,6 @@ int16_t scroll_h_threshold = 30; // この閾値を超える度に水平ス int16_t after_click_lock_movement = 0; // クリック入力後の移動量を測定する変数。 Variable that measures the amount of movement after a click input. int16_t mouse_record_threshold = 30; // ポインターの動きを一時的に記録するフレーム数。 Number of frames in which the pointer movement is temporarily recorded. -int16_t mouse_move_count_ratio = 5; // ポインターの動きを再生する際の移動フレームの係数。 The coefficient of the moving frame when replaying the pointer movement. int16_t mouse_record_x; int16_t mouse_record_y; @@ -113,8 +124,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), LAYOUT( - RGB_TOG, RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, KC_NO, KC_NO, KC_NO, DF(0), DF(3), - RGB_M_P, RGB_M_B, RGB_M_R, RGB_M_SW, RGB_M_SN, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, + RGB_TOG, RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, KC_TB_RAT_INC, KC_TB_RAT_DEC, KC_TB_MODE, DF(0), DF(3), + RGB_M_P, RGB_M_B, RGB_M_R, RGB_M_SW, RGB_M_SN, EEP_RST, KC_NO, KC_NO, KC_NO, KC_NO, RGB_M_K, RGB_M_X, RGB_M_G, KC_NO, KC_NO, QK_BOOT, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), @@ -127,6 +138,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; +void eeconfig_init_user(void) { + user_config.raw = 0; + user_config.trackball_movement_ratio = 10; + user_config.mode = 0; + eeconfig_update_user(user_config.raw); +} + +void keyboard_post_init_user(void) { + user_config.raw = eeconfig_read_user(); +} + // クリック用のレイヤーを有効にする。 Enable layers for clicks void enable_click_layer(void) { layer_on(click_layer); @@ -152,7 +174,7 @@ int16_t my_abs(int16_t num) { } // 自前の符号を返す関数。 Function to return the sign. -int16_t mmouse_move_y_sign(int16_t num) { +int16_t my_sign(int16_t num) { if (num < 0) { return -1; } @@ -201,7 +223,39 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } else { enable_click_layer(); // スクロールキーを離した時に再度クリックレイヤーを有効にする。 Enable click layer again when the scroll key is released. } - return false; + return false; + + case KC_TB_RAT_INC: + if (record->event.pressed) { + user_config.trackball_movement_ratio += 1; + eeconfig_update_user(user_config.raw); + } + + return false; + + case KC_TB_RAT_DEC: + if (record->event.pressed) { + if (user_config.trackball_movement_ratio > 1) user_config.trackball_movement_ratio -= 1; + eeconfig_update_user(user_config.raw); + } + + return false; + + case KC_TB_MODE: + if (record->event.pressed) { + + if (user_config.mode == 0) + { + user_config.mode = 1; + } + else + { + user_config.mode = 0; + } + + eeconfig_update_user(user_config.raw); + } + return false; default: if (record->event.pressed) { @@ -216,83 +270,91 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { - if (!is_record_mouse) { - if (mouse_report.x != 0 || mouse_report.y != 0) { - is_record_mouse = true; - mouse_record_x = 0; - mouse_record_y = 0; - mouse_record_count = 0; + if (user_config.mode == 0) + { + if (!is_record_mouse) { + if (mouse_report.x != 0 || mouse_report.y != 0) { + is_record_mouse = true; + mouse_record_x = 0; + mouse_record_y = 0; + mouse_record_count = 0; + } } - } - if (is_record_mouse) { - mouse_record_x += mouse_report.x; - mouse_record_y += mouse_report.y; - mouse_record_count++; + if (is_record_mouse) { + mouse_record_x += mouse_report.x; // * user_config.trackball_movement_ratio; + mouse_record_y += mouse_report.y; // * user_config.trackball_movement_ratio; + mouse_record_count++; - if (mouse_record_count >= mouse_record_threshold) { - mouse_interval_counter = 0; - int16_t absX = my_abs(mouse_record_x); - int16_t absY = my_abs(mouse_record_y); - is_mouse_move_x_min = absX < absY; + if (mouse_record_count >= mouse_record_threshold) { + mouse_interval_counter = 0; + int16_t absX = my_abs(mouse_record_x); + int16_t absY = my_abs(mouse_record_y); + is_mouse_move_x_min = absX < absY; - mouse_move_remain_count = absY + absX; - mouse_move_remain_count *= mouse_move_count_ratio; + mouse_move_remain_count = is_mouse_move_x_min ? absY : absX; + mouse_move_remain_count *= user_config.trackball_movement_ratio; - mouse_move_x_sign = mmouse_move_y_sign(mouse_record_x); - mouse_move_y_sign = mmouse_move_y_sign(mouse_record_y); + mouse_move_x_sign = my_sign(mouse_record_x); + mouse_move_y_sign = my_sign(mouse_record_y); - if (is_mouse_move_x_min) { - if (mouse_record_x == 0) { - mouse_interval_delta = 0; - } else { - mouse_interval_delta = (double)absX / (double)absY; - } - } else { - if (mouse_record_y == 0) { - mouse_interval_delta = 0; + if (is_mouse_move_x_min) { + if (mouse_record_x == 0) { + mouse_interval_delta = 0; + } else { + mouse_interval_delta = (double)absX / (double)absY; + } } else { - mouse_interval_delta = (double)absY / (double)absX; + if (mouse_record_y == 0) { + mouse_interval_delta = 0; + } else { + mouse_interval_delta = (double)absY / (double)absX; + } } - } - is_record_mouse = false; - mouse_record_count = 0; + is_record_mouse = false; + mouse_record_count = 0; + } } - } - - if (mouse_move_remain_count > 0) { - mouse_interval_counter += mouse_interval_delta; - bool can_move_min = mouse_interval_counter >= 1; + if (mouse_move_remain_count > 0) { + mouse_interval_counter += mouse_interval_delta; - if (can_move_min) { - mouse_interval_counter -= 1; - } - - if (is_mouse_move_x_min) { - - mouse_report.y = mouse_move_y_sign; + bool can_move_min = mouse_interval_counter >= 0.99; if (can_move_min) { - mouse_report.x = mouse_move_x_sign; + mouse_interval_counter -= 0.99; } - } else { - - mouse_report.x = mouse_move_x_sign; - if (can_move_min) { + if (is_mouse_move_x_min) { + mouse_report.y = mouse_move_y_sign; - } - } - mouse_report.x *= 1 + mouse_move_remain_count / 10; - mouse_report.y *= 1 + mouse_move_remain_count / 10; + if (can_move_min) { + mouse_report.x = mouse_move_x_sign; + } + } else { + + mouse_report.x = mouse_move_x_sign; + + if (can_move_min) { + mouse_report.y = mouse_move_y_sign; + } + } - mouse_move_remain_count--; - } else { - mouse_report.x = 0; - mouse_report.y = 0; + mouse_report.x *= 1 + mouse_move_remain_count / 10; + mouse_report.y *= 1 + mouse_move_remain_count / 10; + + mouse_move_remain_count--; + } else { + mouse_report.x = 0; + mouse_report.y = 0; + } + } + else + { + mouse_report.x *= user_config.trackball_movement_ratio; + mouse_report.y *= user_config.trackball_movement_ratio; } int16_t current_x = mouse_report.x; diff --git a/keyboards/takashicompany/minizone/readme.md b/keyboards/takashicompany/minizone/readme.md index 79f2fef7ad..04b6896d28 100644 --- a/keyboards/takashicompany/minizone/readme.md +++ b/keyboards/takashicompany/minizone/readme.md @@ -50,4 +50,4 @@ Enter the bootloader in 3 ways: * **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard * **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead -* **Keycode in layout**: Press the key mapped to `RESET` if it is available +* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available |