From bb3af86e1c2e8b2de74ecbc2e1b143ed78c04013 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Sat, 9 Nov 2024 17:55:34 +0900 Subject: [PATCH 01/17] add left_slinger --- .../takashicompany/left_slinger/keyboard.json | 187 ++++++++++++++++++ .../left_slinger/keymaps/default/keymap.c | 25 +++ .../takashicompany/left_slinger/readme.md | 27 +++ 3 files changed, 239 insertions(+) create mode 100644 keyboards/takashicompany/left_slinger/keyboard.json create mode 100644 keyboards/takashicompany/left_slinger/keymaps/default/keymap.c create mode 100644 keyboards/takashicompany/left_slinger/readme.md diff --git a/keyboards/takashicompany/left_slinger/keyboard.json b/keyboards/takashicompany/left_slinger/keyboard.json new file mode 100644 index 00000000000..137de5c0035 --- /dev/null +++ b/keyboards/takashicompany/left_slinger/keyboard.json @@ -0,0 +1,187 @@ +{ + "manufacturer": "takashicompany", + "keyboard_name": "Left Slinger", + "maintainer": "takashicompany", + "bootloader": "rp2040", + "diode_direction": "COL2ROW", + "features": { + "bootmagic": true, + "command": false, + "console": false, + "extrakey": true, + "mousekey": true, + "nkro": true + }, + "matrix_pins": { + "cols": [ + "GP5", + "GP6", + "GP7" + ], + "rows": [ + "GP8", + "GP9", + "GP10", + "GP11", + "GP12", + "GP13" + ] + }, + "processor": "RP2040", + "url": "", + "usb": { + "device_version": "1.0.0", + "pid": "0x0061", + "vid": "0x7463" + }, + "layouts": { + "LAYOUT": { + "layout": [ + { + "matrix": [ + 0, + 0 + ], + "x": 1, + "y": 0 + }, + { + "matrix": [ + 0, + 1 + ], + "x": 2, + "y": 0 + }, + { + "matrix": [ + 0, + 2 + ], + "x": 3, + "y": 0 + }, + { + "matrix": [ + 1, + 0 + ], + "x": 0, + "y": 1 + }, + { + "matrix": [ + 1, + 1 + ], + "x": 1, + "y": 1 + }, + { + "matrix": [ + 1, + 2 + ], + "x": 2, + "y": 1 + }, + { + "matrix": [ + 2, + 0 + ], + "x": 3, + "y": 1 + }, + { + "matrix": [ + 3, + 0 + ], + "x": 0, + "y": 2 + }, + { + "matrix": [ + 3, + 1 + ], + "x": 1, + "y": 2 + }, + { + "matrix": [ + 3, + 2 + ], + "x": 2, + "y": 2 + }, + { + "matrix": [ + 2, + 1 + ], + "x": 3, + "y": 2 + }, + { + "matrix": [ + 2, + 2 + ], + "x": 4.25, + "y": 2.25 + }, + { + "matrix": [ + 4, + 0 + ], + "x": 1, + "y": 3.25 + }, + { + "matrix": [ + 4, + 1 + ], + "x": 2, + "y": 3.25 + }, + { + "matrix": [ + 4, + 2 + ], + "x": 3, + "y": 3.25 + }, + { + "matrix": [ + 5, + 0 + ], + "x": 1, + "y": 4.25 + }, + { + "matrix": [ + 5, + 1 + ], + "x": 2, + "y": 4.25 + }, + { + "matrix": [ + 5, + 2 + ], + "x": 3, + "y": 4.25 + } + ] + } + } +} \ No newline at end of file diff --git a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c new file mode 100644 index 00000000000..5bf2989a196 --- /dev/null +++ b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c @@ -0,0 +1,25 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* + * ┌───┬───┬───┬───┐ + * │ 7 │ 8 │ 9 │ / │ + * ├───┼───┼───┼───┤ + * │ 4 │ 5 │ 6 │ * │ + * ├───┼───┼───┼───┤ + * │ 1 │ 2 │ 3 │ - │ + * ├───┼───┼───┼───┤ + * │ 0 │ . │Ent│ + │ + * └───┴───┴───┴───┘ + */ + [0] = LAYOUT( + KC_1, KC_2, KC_3, + KC_4, KC_5, KC_6, KC_7, + KC_8, KC_9, KC_0, KC_A, KC_B, + KC_C, KC_D, KC_E, + KC_F, KC_G, KC_H + ) +}; diff --git a/keyboards/takashicompany/left_slinger/readme.md b/keyboards/takashicompany/left_slinger/readme.md new file mode 100644 index 00000000000..798c3556f9d --- /dev/null +++ b/keyboards/takashicompany/left_slinger/readme.md @@ -0,0 +1,27 @@ +# takashicompany/left_slinger + +![takashicompany/left_slinger](imgur.com image replace me!) + +*A short description of the keyboard/project* + +* Keyboard Maintainer: [takashicompany](https://github.com/takashicompany) +* Hardware Supported: *The PCBs, controllers supported* +* Hardware Availability: *Links to where you can find this hardware* + +Make example for this keyboard (after setting up your build environment): + + make takashicompany/left_slinger:default + +Flashing example for this keyboard: + + make takashicompany/left_slinger:default:flash + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). + +## Bootloader + +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 `QK_BOOT` if it is available From 27e232c8774cd2884974273d677c0fc6441b4061 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Sun, 17 Nov 2024 01:51:27 +0900 Subject: [PATCH 02/17] rotary encoder --- keyboards/takashicompany/left_slinger/keyboard.json | 6 ++++++ .../takashicompany/left_slinger/keymaps/default/keymap.c | 6 ++++++ .../takashicompany/left_slinger/keymaps/default/rules.mk | 1 + 3 files changed, 13 insertions(+) create mode 100644 keyboards/takashicompany/left_slinger/keymaps/default/rules.mk diff --git a/keyboards/takashicompany/left_slinger/keyboard.json b/keyboards/takashicompany/left_slinger/keyboard.json index 137de5c0035..f0e0862ddc6 100644 --- a/keyboards/takashicompany/left_slinger/keyboard.json +++ b/keyboards/takashicompany/left_slinger/keyboard.json @@ -4,10 +4,16 @@ "maintainer": "takashicompany", "bootloader": "rp2040", "diode_direction": "COL2ROW", + "encoder": { + "rotary": [ + {"pin_a": "GP14", "pin_b": "GP15"} + ] + }, "features": { "bootmagic": true, "command": false, "console": false, + "encoder": true, "extrakey": true, "mousekey": true, "nkro": true diff --git a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c index 5bf2989a196..a392a0c74f3 100644 --- a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c +++ b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c @@ -23,3 +23,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_F, KC_G, KC_H ) }; + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [0] = { ENCODER_CCW_CW(KC_1, KC_2) } +}; +#endif diff --git a/keyboards/takashicompany/left_slinger/keymaps/default/rules.mk b/keyboards/takashicompany/left_slinger/keymaps/default/rules.mk new file mode 100644 index 00000000000..a40474b4d5c --- /dev/null +++ b/keyboards/takashicompany/left_slinger/keymaps/default/rules.mk @@ -0,0 +1 @@ +ENCODER_MAP_ENABLE = yes \ No newline at end of file From 14946e23e8b1f3061410f5e209366c4bedbccd53 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Sun, 17 Nov 2024 02:17:17 +0900 Subject: [PATCH 03/17] joy stick --- .../takashicompany/left_slinger/config.h | 5 ++ .../left_slinger/custom_joystick.c | 49 +++++++++++++++++++ .../left_slinger/custom_joystick.h | 6 +++ .../takashicompany/left_slinger/rules.mk | 4 ++ 4 files changed, 64 insertions(+) create mode 100644 keyboards/takashicompany/left_slinger/config.h create mode 100644 keyboards/takashicompany/left_slinger/custom_joystick.c create mode 100644 keyboards/takashicompany/left_slinger/custom_joystick.h create mode 100644 keyboards/takashicompany/left_slinger/rules.mk diff --git a/keyboards/takashicompany/left_slinger/config.h b/keyboards/takashicompany/left_slinger/config.h new file mode 100644 index 00000000000..e076cbf9e2e --- /dev/null +++ b/keyboards/takashicompany/left_slinger/config.h @@ -0,0 +1,5 @@ +#pragma once + +#define ANALOG_JOYSTICK_X_AXIS_PIN GP28 +#define ANALOG_JOYSTICK_Y_AXIS_PIN GP29 +#define ANALOG_JOYSTICK_READ_INTERVAL 1 \ No newline at end of file diff --git a/keyboards/takashicompany/left_slinger/custom_joystick.c b/keyboards/takashicompany/left_slinger/custom_joystick.c new file mode 100644 index 00000000000..9f6acd6826a --- /dev/null +++ b/keyboards/takashicompany/left_slinger/custom_joystick.c @@ -0,0 +1,49 @@ +#include QMK_KEYBOARD_H +#include "analog.h" +#include "gpio.h" +#include "wait.h" +#include "timer.h" +#include +#include "print.h" +#include "custom_joystick.h" + +int16_t xOrigin, yOrigin; +uint16_t lastCursor = 0; +int16_t joystick_ratio = 100; + +int16_t axisCoordinate_custom(pin_t pin, uint16_t origin) { + int8_t direction; // 符号 + int16_t distanceFromOrigin; // 原点からの距離。負数にはならない + + int16_t position = analogReadPin(pin); // 多分だけどデフォルトだと512が中心に来るようになっている + + if (origin == position) { // 原点と同じなら0とする + return 0; + } else if (origin > position) { // 原点よりマイナス方向の場合の処理 + distanceFromOrigin = origin - position; + direction = -1; + } else { // 原点よりプラス方向の処理 + distanceFromOrigin = position - origin; + direction = 1; + } + + return distanceFromOrigin * direction; +} + +void pointing_device_driver_init(void) { + xOrigin = analogReadPin(ANALOG_JOYSTICK_X_AXIS_PIN); + yOrigin = analogReadPin(ANALOG_JOYSTICK_Y_AXIS_PIN); +} +report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) { + + if (timer_elapsed(lastCursor) > ANALOG_JOYSTICK_READ_INTERVAL) { // 多分、指定のミリ秒経過したかを見て処理を走らせている + lastCursor = timer_read(); + mouse_report.x = axisCoordinate_custom(ANALOG_JOYSTICK_X_AXIS_PIN, xOrigin) / joystick_ratio; + mouse_report.y = axisCoordinate_custom(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin) / joystick_ratio; + } + + return mouse_report; +} + +uint16_t pointing_device_driver_get_cpi(void) { return 0; } +void pointing_device_driver_set_cpi(uint16_t cpi) {} \ No newline at end of file diff --git a/keyboards/takashicompany/left_slinger/custom_joystick.h b/keyboards/takashicompany/left_slinger/custom_joystick.h new file mode 100644 index 00000000000..0d7f6b94316 --- /dev/null +++ b/keyboards/takashicompany/left_slinger/custom_joystick.h @@ -0,0 +1,6 @@ +#pragma once + +#include +#include + +extern int16_t joystick_ratio; \ No newline at end of file diff --git a/keyboards/takashicompany/left_slinger/rules.mk b/keyboards/takashicompany/left_slinger/rules.mk new file mode 100644 index 00000000000..ea3cc965c5d --- /dev/null +++ b/keyboards/takashicompany/left_slinger/rules.mk @@ -0,0 +1,4 @@ +POINTING_DEVICE_ENABLE = yes +POINTING_DEVICE_DRIVER = custom +ANALOG_DRIVER_REQUIRED = yes +SRC += custom_joystick.c \ No newline at end of file From 3b9132d9d24e0bae90d0678b97b5e8a5a03cee70 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Sun, 17 Nov 2024 03:00:25 +0900 Subject: [PATCH 04/17] add custom key --- .../left_slinger/keymaps/default/keymap.c | 2 +- .../left_slinger/left_slinger.c | 399 ++++++++++++++++++ .../left_slinger/left_slinger.h | 17 + 3 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 keyboards/takashicompany/left_slinger/left_slinger.c create mode 100644 keyboards/takashicompany/left_slinger/left_slinger.h diff --git a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c index a392a0c74f3..70c2479f53b 100644 --- a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c +++ b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c @@ -17,7 +17,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { */ [0] = LAYOUT( KC_1, KC_2, KC_3, - KC_4, KC_5, KC_6, KC_7, + KC_4, KC_5, KC_6, KC_MY_BTN1, KC_8, KC_9, KC_0, KC_A, KC_B, KC_C, KC_D, KC_E, KC_F, KC_G, KC_H diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c new file mode 100644 index 00000000000..10e3243566b --- /dev/null +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -0,0 +1,399 @@ +// #include +#include "quantum.h" +#include "left_slinger.h" +#include "custom_joystick.h" + +///////////////////////////// +/// miniZoneの実装 ここから /// +//////////////////////////// + +#define MOUSE_SCROLL_V_REVERSE_BIT (1 << 0) // 0000 0001 +#define MOUSE_SCROLL_H_REVERSE_BIT (1 << 1) // 0000 0010 +#define IS_OLED_LOGO_BIT (1 << 2) // 0000 0100 + +enum click_state { + NONE = 0, + WAITING, // マウスレイヤーが有効になるのを待つ。 Wait for mouse layer to activate. + CLICKABLE, // マウスレイヤー有効になりクリック入力が取れる。 Mouse layer is enabled to take click input. + CLICKING, // クリック中。 Clicking. + SCROLLING // スクロール中。 Scrolling. +}; + +typedef union { + uint32_t raw; + + struct { + // int16_t to_clickable_time; // // この秒数(千分の一秒)、WAITING状態ならクリックレイヤーが有効になる。 For this number of seconds (milliseconds), if in WAITING state, the click layer is activated. + int16_t joystick_ratio; + int8_t to_clickable_movement; + uint8_t settings; + }; +} user_config_t; + +user_config_t user_config; + +enum click_state state; // 現在のクリック入力受付の状態 Current click input reception status +uint16_t click_timer; // タイマー。状態に応じて時間で判定する。 Timer. Time to determine the state of the system. + +// uint16_t to_clickable_time = 50; // この秒数(千分の一秒)、WAITING状態ならクリックレイヤーが有効になる。 For this number of seconds (milliseconds), if in WAITING state, the click layer is activated. +uint16_t to_reset_time = 1000; // この秒数(千分の一秒)、CLICKABLE状態ならクリックレイヤーが無効になる。 For this number of seconds (milliseconds), the click layer is disabled if in CLICKABLE state. + +const uint16_t click_layer = 8; // マウス入力が可能になった際に有効になるレイヤー。Layers enabled when mouse input is enabled + +int16_t scroll_v_mouse_interval_counter; // 垂直スクロールの入力をカウントする。 Counting Vertical Scroll Inputs +int16_t scroll_h_mouse_interval_counter; // 水平スクロールの入力をカウントする。 Counts horizontal scrolling inputs. + +int16_t scroll_v_threshold = 50; // この閾値を超える度に垂直スクロールが実行される。 Vertical scrolling is performed each time this threshold is exceeded. +int16_t scroll_h_threshold = 50; // この閾値を超える度に水平スクロールが実行される。 Each time this threshold is exceeded, horizontal scrolling is performed. + +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. + +const uint16_t ignore_disable_mouse_layer_keys[] = {KC_LGUI, KC_LCTL}; // この配列で指定されたキーはマウスレイヤー中に押下してもマウスレイヤーを解除しない + +int16_t mouse_movement; +uint32_t press_count; + +void eeconfig_init_kb(void) { + user_config.raw = 0; + user_config.joystick_ratio = 100; + user_config.to_clickable_movement = 50; + // 新しいビットフィールド設定 + + user_config.settings = 0; // 初期化 + user_config.settings |= MOUSE_SCROLL_V_REVERSE_BIT * false; // ここでfalseなので実際にはセットしない + user_config.settings |= MOUSE_SCROLL_H_REVERSE_BIT * false; // 同上 + user_config.settings |= IS_OLED_LOGO_BIT * false; // 同上 + + eeconfig_update_kb(user_config.raw); +} + +bool get_mouse_scroll_v_reverse(void) { + return user_config.settings & MOUSE_SCROLL_V_REVERSE_BIT; +} + +bool get_mouse_scroll_h_reverse(void) { + return user_config.settings & MOUSE_SCROLL_H_REVERSE_BIT; +} + +bool get_is_oled_logo(void) { + return user_config.settings & IS_OLED_LOGO_BIT; +} + +void set_mouse_scroll_v_reverse(bool value) { + if (value) { + user_config.settings |= MOUSE_SCROLL_V_REVERSE_BIT; + } else { + user_config.settings &= ~MOUSE_SCROLL_V_REVERSE_BIT; + } +} + +void set_mouse_scroll_h_reverse(bool value) { + if (value) { + user_config.settings |= MOUSE_SCROLL_H_REVERSE_BIT; + } else { + user_config.settings &= ~MOUSE_SCROLL_H_REVERSE_BIT; + } +} + +void set_is_oled_logo(bool value) { + if (value) { + user_config.settings |= IS_OLED_LOGO_BIT; + } else { + user_config.settings &= ~IS_OLED_LOGO_BIT; + } +} + +void keyboard_post_init_kb(void) { + user_config.raw = eeconfig_read_kb(); + // joystick_ratio = user_config.joystick_ratio; +} + +// クリック用のレイヤーを有効にする。 Enable layers for clicks +void enable_click_layer(void) { + layer_on(click_layer); + click_timer = timer_read(); + state = CLICKABLE; +} + +// クリック用のレイヤーを無効にする。 Disable layers for clicks. +void disable_click_layer(void) { + state = NONE; + layer_off(click_layer); + scroll_v_mouse_interval_counter = 0; + scroll_h_mouse_interval_counter = 0; +} + +// 自前の絶対数を返す関数。 Functions that return absolute numbers. +int8_t my_abs(int8_t num) { + if (num < 0) { + num = -num; + } + + return num; +} + +// 現在クリックが可能な状態か。 Is it currently clickable? +bool is_clickable_mode(void) { + return state == CLICKABLE || state == CLICKING || state == SCROLLING; +} + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + + if (record->event.pressed) { + press_count++; + } + + switch (keycode) { + case KC_MY_BTN1: + case KC_MY_BTN2: + case KC_MY_BTN3: + { + report_mouse_t currentReport = pointing_device_get_report(); + + // どこのビットを対象にするか。 Which bits are to be targeted? + uint8_t btn = 1 << (keycode - KC_MY_BTN1); + + if (record->event.pressed) { + // ビットORは演算子の左辺と右辺の同じ位置にあるビットを比較して、両方のビットのどちらかが「1」の場合に「1」にします。 + // Bit OR compares bits in the same position on the left and right sides of the operator and sets them to "1" if either of both bits is "1". + currentReport.buttons |= btn; + state = CLICKING; + after_click_lock_movement = 30; + } else { + // ビットANDは演算子の左辺と右辺の同じ位置にあるビットを比較して、両方のビットが共に「1」の場合だけ「1」にします。 + // Bit AND compares the bits in the same position on the left and right sides of the operator and sets them to "1" only if both bits are "1" together. + currentReport.buttons &= ~btn; + } + + enable_click_layer(); + + pointing_device_set_report(currentReport); + pointing_device_send(); + return false; + } + + case KC_MY_SCR: + if (record->event.pressed) { + state = SCROLLING; + } else { + enable_click_layer(); // スクロールキーを離した時に再度クリックレイヤーを有効にする。 Enable click layer again when the scroll key is released. + } + return false; + + case KC_TO_CLICKABLE_INC: + if (record->event.pressed) { + user_config.to_clickable_movement += 5; // user_config.to_clickable_time += 10; + eeconfig_update_kb(user_config.raw); + } + return false; + + case KC_TO_CLICKABLE_DEC: + if (record->event.pressed) { + + user_config.to_clickable_movement -= 5; // user_config.to_clickable_time -= 10; + + if (user_config.to_clickable_movement < 5) + { + user_config.to_clickable_movement = 5; + } + + // if (user_config.to_clickable_time < 10) { + // user_config.to_clickable_time = 10; + // } + + eeconfig_update_kb(user_config.raw); + } + return false; + + case KC_SCROLL_DIR_V: + if (record->event.pressed) { + set_mouse_scroll_v_reverse(!get_mouse_scroll_v_reverse()); // user_config.mouse_scroll_v_reverse = !user_config.mouse_scroll_v_reverse; + eeconfig_update_kb(user_config.raw); + } + return false; + + case KC_SCROLL_DIR_H: + if (record->event.pressed) { + set_mouse_scroll_h_reverse(!get_mouse_scroll_h_reverse()); // user_config.mouse_scroll_h_reverse = !user_config.mouse_scroll_h_reverse; + eeconfig_update_kb(user_config.raw); + } + return false; + + case KC_OLED: + if (record->event.pressed) { + set_is_oled_logo(!get_is_oled_logo()); + eeconfig_update_kb(user_config.raw); + } + break; + + case KC_JS_INC: + if (record->event.pressed) { + joystick_ratio = joystick_ratio + 10; + user_config.joystick_ratio = joystick_ratio; + eeconfig_update_kb(user_config.raw); + } + + break; + + case KC_JS_DEC: + if (record->event.pressed) { + joystick_ratio = joystick_ratio - 10; + user_config.joystick_ratio = joystick_ratio; + eeconfig_update_kb(user_config.raw); + } + + break; + + default: + if (record->event.pressed) { + + if (state == CLICKING || state == SCROLLING) + { + enable_click_layer(); + return false; + } + + for (int i = 0; i < sizeof(ignore_disable_mouse_layer_keys) / sizeof(ignore_disable_mouse_layer_keys[0]); i++) + { + if (keycode == ignore_disable_mouse_layer_keys[i]) + { + enable_click_layer(); + return true; + } + } + + disable_click_layer(); + } + } + + return process_record_user(keycode, record); +} + + +report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { + int8_t current_x = mouse_report.x; + int8_t current_y = mouse_report.y; + int8_t current_h = 0; + int8_t current_v = 0; + + if (current_x != 0 || current_y != 0) { + + switch (state) { + case CLICKABLE: + click_timer = timer_read(); + break; + + case CLICKING: + after_click_lock_movement -= my_abs(current_x) + my_abs(current_y); + + if (after_click_lock_movement > 0) { + current_x = 0; + current_y = 0; + } + + break; + + case SCROLLING: + { + int8_t rep_v = 0; + int8_t rep_h = 0; + + // 垂直スクロールの方の感度を高める。 Increase sensitivity toward vertical scrolling. + if (my_abs(current_y) * 2 > my_abs(current_x)) { + + scroll_v_mouse_interval_counter += current_y; + while (my_abs(scroll_v_mouse_interval_counter) > scroll_v_threshold) { + if (scroll_v_mouse_interval_counter < 0) { + scroll_v_mouse_interval_counter += scroll_v_threshold; + rep_v += scroll_v_threshold; + } else { + scroll_v_mouse_interval_counter -= scroll_v_threshold; + rep_v -= scroll_v_threshold; + } + + } + } else { + + scroll_h_mouse_interval_counter += current_x; + + while (my_abs(scroll_h_mouse_interval_counter) > scroll_h_threshold) { + if (scroll_h_mouse_interval_counter < 0) { + scroll_h_mouse_interval_counter += scroll_h_threshold; + rep_h += scroll_h_threshold; + } else { + scroll_h_mouse_interval_counter -= scroll_h_threshold; + rep_h -= scroll_h_threshold; + } + } + } + + current_h = rep_h / scroll_h_threshold * (get_mouse_scroll_h_reverse() ? -1 : 1); + current_v = -rep_v / scroll_v_threshold * (get_mouse_scroll_v_reverse() ? -1 : 1); + current_x = 0; + current_y = 0; + } + break; + + case WAITING: + /* + if (timer_elapsed(click_timer) > user_config.to_clickable_time) { + enable_click_layer(); + } + */ + + mouse_movement += my_abs(current_x) + my_abs(current_y); + + if (mouse_movement >= user_config.to_clickable_movement) + { + mouse_movement = 0; + enable_click_layer(); + } + break; + + default: + click_timer = timer_read(); + state = WAITING; + mouse_movement = 0; + } + } + else + { + switch (state) { + case CLICKING: + case SCROLLING: + + break; + + case CLICKABLE: + if (timer_elapsed(click_timer) > to_reset_time) { + disable_click_layer(); + } + break; + + case WAITING: + if (timer_elapsed(click_timer) > 50) { + mouse_movement = 0; + state = NONE; + } + break; + + default: + mouse_movement = 0; + state = NONE; + } + } + + mouse_report.x = current_x; + mouse_report.y = current_y; + mouse_report.h = current_h; + mouse_report.v = current_v; + + return mouse_report; +} + +///////////////////////////// +/// miniZoneの実装 ここまで /// +//////////////////////////// \ No newline at end of file diff --git a/keyboards/takashicompany/left_slinger/left_slinger.h b/keyboards/takashicompany/left_slinger/left_slinger.h new file mode 100644 index 00000000000..130d57ca228 --- /dev/null +++ b/keyboards/takashicompany/left_slinger/left_slinger.h @@ -0,0 +1,17 @@ +#pragma once + +#include "quantum.h" + +enum custom_keycodes_kb { + KC_MY_BTN1 = SAFE_RANGE, + KC_MY_BTN2, + KC_MY_BTN3, + KC_MY_SCR, + KC_TO_CLICKABLE_INC, + KC_TO_CLICKABLE_DEC, + KC_SCROLL_DIR_V, + KC_SCROLL_DIR_H, + KC_OLED, + KC_JS_INC, + KC_JS_DEC +}; \ No newline at end of file From a6a84314442a9c2ee2f148f5aace765bf6d906c3 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Mon, 18 Nov 2024 01:50:08 +0900 Subject: [PATCH 05/17] fix setting --- .../left_slinger/custom_joystick.c | 13 +- .../left_slinger/keymaps/default/keymap.c | 88 +++++++++--- .../left_slinger/left_slinger.c | 129 ++++++++++++------ .../left_slinger/left_slinger.h | 22 +-- 4 files changed, 180 insertions(+), 72 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/custom_joystick.c b/keyboards/takashicompany/left_slinger/custom_joystick.c index 9f6acd6826a..91de7245137 100644 --- a/keyboards/takashicompany/left_slinger/custom_joystick.c +++ b/keyboards/takashicompany/left_slinger/custom_joystick.c @@ -38,8 +38,17 @@ report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) { if (timer_elapsed(lastCursor) > ANALOG_JOYSTICK_READ_INTERVAL) { // 多分、指定のミリ秒経過したかを見て処理を走らせている lastCursor = timer_read(); - mouse_report.x = axisCoordinate_custom(ANALOG_JOYSTICK_X_AXIS_PIN, xOrigin) / joystick_ratio; - mouse_report.y = axisCoordinate_custom(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin) / joystick_ratio; + + int16_t jsr = joystick_ratio; + if (0 <= jsr && jsr < 10) { + jsr = 10; + } + else if (-10 < jsr && jsr < 0) { + jsr = -10; + } + + mouse_report.x = axisCoordinate_custom(ANALOG_JOYSTICK_X_AXIS_PIN, xOrigin) / jsr; + mouse_report.y = axisCoordinate_custom(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin) / jsr; } return mouse_report; diff --git a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c index 70c2479f53b..43f716d8adb 100644 --- a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c +++ b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c @@ -4,28 +4,80 @@ #include QMK_KEYBOARD_H const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - /* - * ┌───┬───┬───┬───┐ - * │ 7 │ 8 │ 9 │ / │ - * ├───┼───┼───┼───┤ - * │ 4 │ 5 │ 6 │ * │ - * ├───┼───┼───┼───┤ - * │ 1 │ 2 │ 3 │ - │ - * ├───┼───┼───┼───┤ - * │ 0 │ . │Ent│ + │ - * └───┴───┴───┴───┘ - */ [0] = LAYOUT( - KC_1, KC_2, KC_3, - KC_4, KC_5, KC_6, KC_MY_BTN1, - KC_8, KC_9, KC_0, KC_A, KC_B, - KC_C, KC_D, KC_E, - KC_F, KC_G, KC_H - ) + KC_Q , KC_W , KC_E , + KC_TAB , KC_A , KC_S , KC_D , + KC_LSFT, KC_Z , KC_X , KC_C , KC_V , + KC_LCTL, KC_UP , KC_LALT, + KC_LEFT, KC_DOWN, KC_RGHT + ), + + [1] = LAYOUT( + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO + ), + + [2] = LAYOUT( + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO + ), + + [3] = LAYOUT( + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO + ), + + [4] = LAYOUT( + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO + ), + + [5] = LAYOUT( + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO + ), + + [6] = LAYOUT( + KC_NO , KC_NO , KC_NO , + KC_NO , MY_BTN2, MY_SCRL, MY_BTN1, + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO + ), + + [7] = LAYOUT( + KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , MY_CLKD, MY_CLKI, + QK_BOOT, KC_NO , MY_SCDV, MY_SCDH, KC_NO , + KC_NO , MY_JSDD, MY_JSDI, + KC_NO , MY_STGE, KC_NO + ), }; #if defined(ENCODER_MAP_ENABLE) const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - [0] = { ENCODER_CCW_CW(KC_1, KC_2) } + [0] = { ENCODER_CCW_CW(MS_WHLD, MS_WHLU) }, + [1] = { ENCODER_CCW_CW(MS_WHLL, MS_WHLR) }, + [2] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }, + [3] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }, + [4] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }, + [5] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }, + [6] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) }, + [7] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) } }; #endif diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c index 10e3243566b..c13a9efbd52 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.c +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -9,7 +9,6 @@ #define MOUSE_SCROLL_V_REVERSE_BIT (1 << 0) // 0000 0001 #define MOUSE_SCROLL_H_REVERSE_BIT (1 << 1) // 0000 0010 -#define IS_OLED_LOGO_BIT (1 << 2) // 0000 0100 enum click_state { NONE = 0, @@ -38,7 +37,8 @@ uint16_t click_timer; // タイマー。状態に応じて時間で判定 // uint16_t to_clickable_time = 50; // この秒数(千分の一秒)、WAITING状態ならクリックレイヤーが有効になる。 For this number of seconds (milliseconds), if in WAITING state, the click layer is activated. uint16_t to_reset_time = 1000; // この秒数(千分の一秒)、CLICKABLE状態ならクリックレイヤーが無効になる。 For this number of seconds (milliseconds), the click layer is disabled if in CLICKABLE state. -const uint16_t click_layer = 8; // マウス入力が可能になった際に有効になるレイヤー。Layers enabled when mouse input is enabled +const uint16_t click_layer = 6; // マウス入力が可能になった際に有効になるレイヤー。Layers enabled when mouse input is enabled +const uint16_t setting_layer = 7; int16_t scroll_v_mouse_interval_counter; // 垂直スクロールの入力をカウントする。 Counting Vertical Scroll Inputs int16_t scroll_h_mouse_interval_counter; // 水平スクロールの入力をカウントする。 Counts horizontal scrolling inputs. @@ -54,7 +54,6 @@ int16_t mouse_move_count_ratio = 5; // ポインターの動きを再生す const uint16_t ignore_disable_mouse_layer_keys[] = {KC_LGUI, KC_LCTL}; // この配列で指定されたキーはマウスレイヤー中に押下してもマウスレイヤーを解除しない int16_t mouse_movement; -uint32_t press_count; void eeconfig_init_kb(void) { user_config.raw = 0; @@ -65,7 +64,6 @@ void eeconfig_init_kb(void) { user_config.settings = 0; // 初期化 user_config.settings |= MOUSE_SCROLL_V_REVERSE_BIT * false; // ここでfalseなので実際にはセットしない user_config.settings |= MOUSE_SCROLL_H_REVERSE_BIT * false; // 同上 - user_config.settings |= IS_OLED_LOGO_BIT * false; // 同上 eeconfig_update_kb(user_config.raw); } @@ -78,10 +76,6 @@ bool get_mouse_scroll_h_reverse(void) { return user_config.settings & MOUSE_SCROLL_H_REVERSE_BIT; } -bool get_is_oled_logo(void) { - return user_config.settings & IS_OLED_LOGO_BIT; -} - void set_mouse_scroll_v_reverse(bool value) { if (value) { user_config.settings |= MOUSE_SCROLL_V_REVERSE_BIT; @@ -98,17 +92,9 @@ void set_mouse_scroll_h_reverse(bool value) { } } -void set_is_oled_logo(bool value) { - if (value) { - user_config.settings |= IS_OLED_LOGO_BIT; - } else { - user_config.settings &= ~IS_OLED_LOGO_BIT; - } -} - void keyboard_post_init_kb(void) { user_config.raw = eeconfig_read_kb(); - // joystick_ratio = user_config.joystick_ratio; + joystick_ratio = user_config.joystick_ratio; } // クリック用のレイヤーを有効にする。 Enable layers for clicks @@ -126,6 +112,29 @@ void disable_click_layer(void) { scroll_h_mouse_interval_counter = 0; } +bool setting_flags[4] = { false, false, false, false }; + +void enable_setting_layer(void) { + for (int i = 0; i < 4; i++) + { + setting_flags[i] = false; + } + layer_on(setting_layer); + + SEND_STRING("Setting Layer Start."); +} + +void disable_setting_layer(void) { + + for (int i = 0; i < 4; i++) + { + setting_flags[i] = false; + } + + layer_off(setting_layer); + SEND_STRING("Setting Layer End."); +} + // 自前の絶対数を返す関数。 Functions that return absolute numbers. int8_t my_abs(int8_t num) { if (num < 0) { @@ -141,20 +150,51 @@ bool is_clickable_mode(void) { } bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - - if (record->event.pressed) { - press_count++; - } + if (record->event.key.row == 0 && record->event.key.col == 0) + { + setting_flags[0] = record->event.pressed; + } + + if (record->event.key.row == 0 && record->event.key.col == 2) + { + setting_flags[1] = record->event.pressed; + } + + if (record->event.key.row == 5 && record->event.key.col == 0) + { + setting_flags[2] = record->event.pressed; + } + + if (record->event.key.row == 5 && record->event.key.col == 2) + { + setting_flags[3] = record->event.pressed; + } + + for (int i = 0; i < 4; i++) + { + if (!setting_flags[i]) + { + break; + } + + if (i == 3) + { + enable_setting_layer(); + return true; + } + } + + switch (keycode) { - case KC_MY_BTN1: - case KC_MY_BTN2: - case KC_MY_BTN3: + case MY_BTN1: + case MY_BTN2: + case MY_BTN3: { report_mouse_t currentReport = pointing_device_get_report(); // どこのビットを対象にするか。 Which bits are to be targeted? - uint8_t btn = 1 << (keycode - KC_MY_BTN1); + uint8_t btn = 1 << (keycode - MY_BTN1); if (record->event.pressed) { // ビットORは演算子の左辺と右辺の同じ位置にあるビットを比較して、両方のビットのどちらかが「1」の場合に「1」にします。 @@ -175,7 +215,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return false; } - case KC_MY_SCR: + case MY_SCRL: if (record->event.pressed) { state = SCROLLING; } else { @@ -183,14 +223,14 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { } return false; - case KC_TO_CLICKABLE_INC: + case MY_CLKI: if (record->event.pressed) { user_config.to_clickable_movement += 5; // user_config.to_clickable_time += 10; eeconfig_update_kb(user_config.raw); } return false; - case KC_TO_CLICKABLE_DEC: + case MY_CLKD: if (record->event.pressed) { user_config.to_clickable_movement -= 5; // user_config.to_clickable_time -= 10; @@ -208,45 +248,52 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { } return false; - case KC_SCROLL_DIR_V: + case MY_SCDV: if (record->event.pressed) { set_mouse_scroll_v_reverse(!get_mouse_scroll_v_reverse()); // user_config.mouse_scroll_v_reverse = !user_config.mouse_scroll_v_reverse; eeconfig_update_kb(user_config.raw); } return false; - case KC_SCROLL_DIR_H: + case MY_SCDH: if (record->event.pressed) { set_mouse_scroll_h_reverse(!get_mouse_scroll_h_reverse()); // user_config.mouse_scroll_h_reverse = !user_config.mouse_scroll_h_reverse; eeconfig_update_kb(user_config.raw); } return false; - - case KC_OLED: - if (record->event.pressed) { - set_is_oled_logo(!get_is_oled_logo()); - eeconfig_update_kb(user_config.raw); - } - break; - case KC_JS_INC: + case MY_JSDI: if (record->event.pressed) { - joystick_ratio = joystick_ratio + 10; + joystick_ratio = joystick_ratio + 5; user_config.joystick_ratio = joystick_ratio; eeconfig_update_kb(user_config.raw); + + // char str[256]; + // sprintf(str, "%d", joystick_ratio); + // SEND_STRING(str); } break; - case KC_JS_DEC: + case MY_JSDD: if (record->event.pressed) { - joystick_ratio = joystick_ratio - 10; + joystick_ratio = joystick_ratio - 5; user_config.joystick_ratio = joystick_ratio; eeconfig_update_kb(user_config.raw); + + // char str[256]; + // sprintf(str, "%d", joystick_ratio); + // SEND_STRING(str); } break; + case MY_STGE: + if (record->event.pressed) { + disable_setting_layer(); + } + break; + default: if (record->event.pressed) { diff --git a/keyboards/takashicompany/left_slinger/left_slinger.h b/keyboards/takashicompany/left_slinger/left_slinger.h index 130d57ca228..e669845d439 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.h +++ b/keyboards/takashicompany/left_slinger/left_slinger.h @@ -3,15 +3,15 @@ #include "quantum.h" enum custom_keycodes_kb { - KC_MY_BTN1 = SAFE_RANGE, - KC_MY_BTN2, - KC_MY_BTN3, - KC_MY_SCR, - KC_TO_CLICKABLE_INC, - KC_TO_CLICKABLE_DEC, - KC_SCROLL_DIR_V, - KC_SCROLL_DIR_H, - KC_OLED, - KC_JS_INC, - KC_JS_DEC + MY_BTN1 = SAFE_RANGE, + MY_BTN2, + MY_BTN3, + MY_SCRL, // Scroll + MY_CLKI, // Click time increase + MY_CLKD, // Click time decrease + MY_SCDV, // Scroll vertical + MY_SCDH, // Scroll horizontal + MY_JSDI, // Joy stick movement divisor increase + MY_JSDD, // Joy stick movement divisor decrease + MY_STGE, // Setting End }; \ No newline at end of file From baa99f9ff14201b720c54fc8cb9f403c7509298c Mon Sep 17 00:00:00 2001 From: takashicompany Date: Tue, 19 Nov 2024 09:53:20 +0900 Subject: [PATCH 06/17] add stick key --- keyboards/takashicompany/left_slinger/left_slinger.c | 11 +++++++++++ keyboards/takashicompany/left_slinger/rules.mk | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c index c13a9efbd52..9d37f1670e9 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.c +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -3,6 +3,10 @@ #include "left_slinger.h" #include "custom_joystick.h" +#if CONSOLE_ENABLE +#include +#endif + ///////////////////////////// /// miniZoneの実装 ここから /// //////////////////////////// @@ -151,6 +155,10 @@ bool is_clickable_mode(void) { bool process_record_kb(uint16_t keycode, keyrecord_t *record) { +#ifdef CONSOLE_ENABLE + uprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); +#endif + if (record->event.key.row == 0 && record->event.key.col == 0) { setting_flags[0] = record->event.pressed; @@ -326,6 +334,9 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { int8_t current_h = 0; int8_t current_v = 0; +#ifdef CONSOLE_ENABLE + uprintf("pointing x: %d y:%d \n", current_x, current_y); +#endif if (current_x != 0 || current_y != 0) { switch (state) { diff --git a/keyboards/takashicompany/left_slinger/rules.mk b/keyboards/takashicompany/left_slinger/rules.mk index ea3cc965c5d..e1158d19669 100644 --- a/keyboards/takashicompany/left_slinger/rules.mk +++ b/keyboards/takashicompany/left_slinger/rules.mk @@ -1,4 +1,6 @@ POINTING_DEVICE_ENABLE = yes POINTING_DEVICE_DRIVER = custom ANALOG_DRIVER_REQUIRED = yes -SRC += custom_joystick.c \ No newline at end of file +SRC += custom_joystick.c + +CONSOLE_ENABLE = yes \ No newline at end of file From b4ac67cf5330eae312e8fe71a6e6d2c7013e1046 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Tue, 19 Nov 2024 14:22:56 +0900 Subject: [PATCH 07/17] =?UTF-8?q?=E3=81=84=E3=82=8D=E3=81=84=E3=82=8D?= =?UTF-8?q?=E9=80=94=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../left_slinger/custom_joystick.c | 10 +++- .../left_slinger/custom_joystick.h | 4 +- .../takashicompany/left_slinger/keyboard.json | 34 +++++++++++-- .../left_slinger/keymaps/default/keymap.c | 32 ++++++------ .../left_slinger/left_slinger.c | 51 ++++++++++++++++++- 5 files changed, 108 insertions(+), 23 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/custom_joystick.c b/keyboards/takashicompany/left_slinger/custom_joystick.c index 91de7245137..5c68bd9789e 100644 --- a/keyboards/takashicompany/left_slinger/custom_joystick.c +++ b/keyboards/takashicompany/left_slinger/custom_joystick.c @@ -10,6 +10,8 @@ int16_t xOrigin, yOrigin; uint16_t lastCursor = 0; int16_t joystick_ratio = 100; +int16_t joystick_raw_x = 0; +int16_t joystick_raw_y = 0; int16_t axisCoordinate_custom(pin_t pin, uint16_t origin) { int8_t direction; // 符号 @@ -34,6 +36,7 @@ void pointing_device_driver_init(void) { xOrigin = analogReadPin(ANALOG_JOYSTICK_X_AXIS_PIN); yOrigin = analogReadPin(ANALOG_JOYSTICK_Y_AXIS_PIN); } + report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) { if (timer_elapsed(lastCursor) > ANALOG_JOYSTICK_READ_INTERVAL) { // 多分、指定のミリ秒経過したかを見て処理を走らせている @@ -47,8 +50,11 @@ report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) { jsr = -10; } - mouse_report.x = axisCoordinate_custom(ANALOG_JOYSTICK_X_AXIS_PIN, xOrigin) / jsr; - mouse_report.y = axisCoordinate_custom(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin) / jsr; + joystick_raw_x = axisCoordinate_custom(ANALOG_JOYSTICK_X_AXIS_PIN, xOrigin); + joystick_raw_y = axisCoordinate_custom(ANALOG_JOYSTICK_Y_AXIS_PIN, yOrigin); + + mouse_report.x = joystick_raw_x / jsr; + mouse_report.y = joystick_raw_y / jsr; } return mouse_report; diff --git a/keyboards/takashicompany/left_slinger/custom_joystick.h b/keyboards/takashicompany/left_slinger/custom_joystick.h index 0d7f6b94316..b56425bc79a 100644 --- a/keyboards/takashicompany/left_slinger/custom_joystick.h +++ b/keyboards/takashicompany/left_slinger/custom_joystick.h @@ -3,4 +3,6 @@ #include #include -extern int16_t joystick_ratio; \ No newline at end of file +extern int16_t joystick_ratio; +extern int16_t joystick_raw_x; +extern int16_t joystick_raw_y; \ No newline at end of file diff --git a/keyboards/takashicompany/left_slinger/keyboard.json b/keyboards/takashicompany/left_slinger/keyboard.json index f0e0862ddc6..872662456aa 100644 --- a/keyboards/takashicompany/left_slinger/keyboard.json +++ b/keyboards/takashicompany/left_slinger/keyboard.json @@ -6,7 +6,10 @@ "diode_direction": "COL2ROW", "encoder": { "rotary": [ - {"pin_a": "GP14", "pin_b": "GP15"} + { + "pin_a": "GP14", + "pin_b": "GP15" + } ] }, "features": { @@ -30,7 +33,8 @@ "GP10", "GP11", "GP12", - "GP13" + "GP13", + "GP0" ] }, "processor": "RP2040", @@ -137,7 +141,7 @@ 2 ], "x": 4.25, - "y": 2.25 + "y": 2 }, { "matrix": [ @@ -163,6 +167,22 @@ "x": 3, "y": 3.25 }, + { + "matrix": [ + 6, + 0 + ], + "x": 4.25, + "y": 3.25 + }, + { + "matrix": [ + 6, + 1 + ], + "x": 5.25, + "y": 3.25 + }, { "matrix": [ 5, @@ -186,6 +206,14 @@ ], "x": 3, "y": 4.25 + }, + { + "matrix": [ + 6, + 2 + ], + "x": 4.25, + "y": 4.25 } ] } diff --git a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c index 43f716d8adb..40bac09ca9b 100644 --- a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c +++ b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c @@ -8,64 +8,64 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_Q , KC_W , KC_E , KC_TAB , KC_A , KC_S , KC_D , KC_LSFT, KC_Z , KC_X , KC_C , KC_V , - KC_LCTL, KC_UP , KC_LALT, - KC_LEFT, KC_DOWN, KC_RGHT + KC_LCTL, KC_UP , KC_LALT, KC_1 , KC_2 , + KC_LEFT, KC_DOWN, KC_RGHT, KC_3 ), [1] = LAYOUT( KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO ), [2] = LAYOUT( KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO ), [3] = LAYOUT( KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO ), [4] = LAYOUT( KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO ), [5] = LAYOUT( KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO ), [6] = LAYOUT( KC_NO , KC_NO , KC_NO , KC_NO , MY_BTN2, MY_SCRL, MY_BTN1, KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO , - KC_NO , KC_NO , KC_NO + KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , + KC_NO , KC_NO , KC_NO , KC_NO ), [7] = LAYOUT( KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , MY_CLKD, MY_CLKI, QK_BOOT, KC_NO , MY_SCDV, MY_SCDH, KC_NO , - KC_NO , MY_JSDD, MY_JSDI, - KC_NO , MY_STGE, KC_NO + KC_NO , MY_JSDD, MY_JSDI, KC_NO , KC_NO , + KC_NO , MY_STGE, KC_NO , KC_NO ), }; diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c index 9d37f1670e9..2126a015c9a 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.c +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -148,6 +148,14 @@ int8_t my_abs(int8_t num) { return num; } +int16_t my_abs_16(int16_t num) { + if (num < 0) { + num = -num; + } + + return num; +} + // 現在クリックが可能な状態か。 Is it currently clickable? bool is_clickable_mode(void) { return state == CLICKABLE || state == CLICKING || state == SCROLLING; @@ -335,8 +343,49 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { int8_t current_v = 0; #ifdef CONSOLE_ENABLE - uprintf("pointing x: %d y:%d \n", current_x, current_y); + // uprintf("pointing x: %d y:%d \n", current_x, current_y); #endif + + int16_t range = 100; + + if (true) { + uprintf("x: %d, y: %d, raw_x: %d, raw_y: %d \n", current_x, current_y, joystick_raw_x, joystick_raw_y); + if ((current_x != 0 || current_y != 0) && + (joystick_raw_x > range || joystick_raw_y > range) == false && + (my_abs_16(joystick_raw_x) + my_abs_16(joystick_raw_y) > 200)){ + + if (joystick_raw_y < joystick_raw_x * 3) { + // 上 + uprintf("up\n"); + } else if (joystick_raw_x < joystick_raw_y * 3) { + uprintf("left\n"); + } else { + uprintf("left-up\n"); + } + + // if (current_y < 0) { + // if (current_y < current_x * 2) { + // // 上 + // uprintf("up d: %d, x: %d, y: %d, raw_x: %d, raw_y: %d \n", joystick_ratio, current_x, current_y, joystick_raw_x, joystick_raw_y); + // } else { + // // 左上 + // uprintf("UL d: %d, x: %d, y: %d, raw_x: %d, raw_y: %d \n", joystick_ratio, current_x, current_y, joystick_raw_x, joystick_raw_y); + // } + // } else if (current_y == 0 && current_x < 0) { + // // 左 + // uprintf("left d: %d, x: %d, y: %d, raw_x: %d, raw_y: %d \n", joystick_ratio, current_x, current_y, joystick_raw_x, joystick_raw_y); + // } + + mouse_report.x = 0; + mouse_report.y = 0; + mouse_report.h = 0; + mouse_report.v = 0; + + + } + return mouse_report; + } + if (current_x != 0 || current_y != 0) { switch (state) { From 4c94a00512fa12777cd425cdce4893f351f4f109 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Tue, 19 Nov 2024 16:56:05 +0900 Subject: [PATCH 08/17] fix --- .../left_slinger/keymaps/default/keymap.c | 6 +- .../left_slinger/left_slinger.c | 133 ++++++++++-------- .../left_slinger/left_slinger.h | 2 + 3 files changed, 79 insertions(+), 62 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c index 40bac09ca9b..e34b9879063 100644 --- a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c +++ b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c @@ -6,7 +6,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT( KC_Q , KC_W , KC_E , - KC_TAB , KC_A , KC_S , KC_D , + MY_JSKE, KC_A , KC_S , KC_D , KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_LCTL, KC_UP , KC_LALT, KC_1 , KC_2 , KC_LEFT, KC_DOWN, KC_RGHT, KC_3 @@ -54,7 +54,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [6] = LAYOUT( KC_NO , KC_NO , KC_NO , - KC_NO , MY_BTN2, MY_SCRL, MY_BTN1, + KC_TRNS, MY_BTN2, MY_SCRL, MY_BTN1, KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO @@ -64,7 +64,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , MY_CLKD, MY_CLKI, QK_BOOT, KC_NO , MY_SCDV, MY_SCDH, KC_NO , - KC_NO , MY_JSDD, MY_JSDI, KC_NO , KC_NO , + MY_JSKD, MY_JSDD, MY_JSDI, KC_NO , KC_NO , KC_NO , MY_STGE, KC_NO , KC_NO ), }; diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c index 2126a015c9a..1cb2c984a5b 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.c +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -11,8 +11,9 @@ /// miniZoneの実装 ここから /// //////////////////////////// -#define MOUSE_SCROLL_V_REVERSE_BIT (1 << 0) // 0000 0001 -#define MOUSE_SCROLL_H_REVERSE_BIT (1 << 1) // 0000 0010 +#define MOUSE_SCROLL_V_REVERSE_BIT (1 << 0) // 0000 0001 +#define MOUSE_SCROLL_H_REVERSE_BIT (1 << 1) // 0000 0010 +#define JOYSTICK_KEY_DEFAULT_ENABLE (1 << 2) // 0000 0100 enum click_state { NONE = 0, @@ -59,6 +60,8 @@ const uint16_t ignore_disable_mouse_layer_keys[] = {KC_LGUI, KC_LCTL}; // こ int16_t mouse_movement; +bool joystick_key_flag = false; + void eeconfig_init_kb(void) { user_config.raw = 0; user_config.joystick_ratio = 100; @@ -68,6 +71,7 @@ void eeconfig_init_kb(void) { user_config.settings = 0; // 初期化 user_config.settings |= MOUSE_SCROLL_V_REVERSE_BIT * false; // ここでfalseなので実際にはセットしない user_config.settings |= MOUSE_SCROLL_H_REVERSE_BIT * false; // 同上 + user_config.settings |= JOYSTICK_KEY_DEFAULT_ENABLE * false; eeconfig_update_kb(user_config.raw); } @@ -96,6 +100,18 @@ void set_mouse_scroll_h_reverse(bool value) { } } +bool get_joystick_key_default_enable(void) { + return user_config.settings & JOYSTICK_KEY_DEFAULT_ENABLE; +} + +void set_joystick_key_default_enable(bool value) { + if (value) { + user_config.settings |= JOYSTICK_KEY_DEFAULT_ENABLE; + } else { + user_config.settings &= ~JOYSTICK_KEY_DEFAULT_ENABLE; + } +} + void keyboard_post_init_kb(void) { user_config.raw = eeconfig_read_kb(); joystick_ratio = user_config.joystick_ratio; @@ -125,7 +141,7 @@ void enable_setting_layer(void) { } layer_on(setting_layer); - SEND_STRING("Setting Layer Start."); + SEND_STRING(" Setting Layer Start."); } void disable_setting_layer(void) { @@ -136,7 +152,7 @@ void disable_setting_layer(void) { } layer_off(setting_layer); - SEND_STRING("Setting Layer End."); + SEND_STRING(" Setting Layer End."); } // 自前の絶対数を返す関数。 Functions that return absolute numbers. @@ -162,10 +178,6 @@ bool is_clickable_mode(void) { } bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - -#ifdef CONSOLE_ENABLE - uprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); -#endif if (record->event.key.row == 0 && record->event.key.col == 0) { @@ -241,7 +253,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { case MY_CLKI: if (record->event.pressed) { - user_config.to_clickable_movement += 5; // user_config.to_clickable_time += 10; + user_config.to_clickable_movement += 5; eeconfig_update_kb(user_config.raw); } return false; @@ -249,31 +261,26 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { case MY_CLKD: if (record->event.pressed) { - user_config.to_clickable_movement -= 5; // user_config.to_clickable_time -= 10; + user_config.to_clickable_movement -= 5; - if (user_config.to_clickable_movement < 5) - { + if (user_config.to_clickable_movement < 5) { user_config.to_clickable_movement = 5; } - // if (user_config.to_clickable_time < 10) { - // user_config.to_clickable_time = 10; - // } - eeconfig_update_kb(user_config.raw); } return false; case MY_SCDV: if (record->event.pressed) { - set_mouse_scroll_v_reverse(!get_mouse_scroll_v_reverse()); // user_config.mouse_scroll_v_reverse = !user_config.mouse_scroll_v_reverse; + set_mouse_scroll_v_reverse(!get_mouse_scroll_v_reverse()); eeconfig_update_kb(user_config.raw); } return false; case MY_SCDH: if (record->event.pressed) { - set_mouse_scroll_h_reverse(!get_mouse_scroll_h_reverse()); // user_config.mouse_scroll_h_reverse = !user_config.mouse_scroll_h_reverse; + set_mouse_scroll_h_reverse(!get_mouse_scroll_h_reverse()); eeconfig_update_kb(user_config.raw); } return false; @@ -283,10 +290,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { joystick_ratio = joystick_ratio + 5; user_config.joystick_ratio = joystick_ratio; eeconfig_update_kb(user_config.raw); - - // char str[256]; - // sprintf(str, "%d", joystick_ratio); - // SEND_STRING(str); } break; @@ -296,10 +299,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { joystick_ratio = joystick_ratio - 5; user_config.joystick_ratio = joystick_ratio; eeconfig_update_kb(user_config.raw); - - // char str[256]; - // sprintf(str, "%d", joystick_ratio); - // SEND_STRING(str); } break; @@ -309,6 +308,17 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { disable_setting_layer(); } break; + + case MY_JSKD: + if (record->event.pressed) { + set_joystick_key_default_enable(!get_joystick_key_default_enable()); + eeconfig_update_kb(user_config.raw); + } + break; + + case MY_JSKE: + joystick_key_flag = record->event.pressed; + break; default: if (record->event.pressed) { @@ -335,54 +345,59 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); } +int8_t joystick_key_column = -1; +uint16_t joystick_key_timer; + +void reset_joystick_key(void) { + if (joystick_key_column >= 0) { + action_exec(MAKE_KEYEVENT(6, joystick_key_column, false)); + } + + joystick_key_column = -1; +} + +void press_joystick_key(int8_t column) { + + if (joystick_key_column != -1 || timer_elapsed(joystick_key_timer) < 200) { + return; + } + joystick_key_column = column; + joystick_key_timer = timer_read(); + action_exec(MAKE_KEYEVENT(6, column, true)); +} report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { int8_t current_x = mouse_report.x; int8_t current_y = mouse_report.y; int8_t current_h = 0; int8_t current_v = 0; - -#ifdef CONSOLE_ENABLE - // uprintf("pointing x: %d y:%d \n", current_x, current_y); -#endif - int16_t range = 100; - - if (true) { + if (get_joystick_key_default_enable() != joystick_key_flag) { +#ifdef CONSOLE_ENABLE uprintf("x: %d, y: %d, raw_x: %d, raw_y: %d \n", current_x, current_y, joystick_raw_x, joystick_raw_y); +#endif if ((current_x != 0 || current_y != 0) && - (joystick_raw_x > range || joystick_raw_y > range) == false && + (joystick_raw_x > 100 || joystick_raw_y > 100) == false && (my_abs_16(joystick_raw_x) + my_abs_16(joystick_raw_y) > 200)){ - if (joystick_raw_y < joystick_raw_x * 3) { + if (joystick_raw_y < joystick_raw_x * 4) { // 上 - uprintf("up\n"); - } else if (joystick_raw_x < joystick_raw_y * 3) { - uprintf("left\n"); + press_joystick_key(1); + } else if (joystick_raw_x < joystick_raw_y * 5) { + press_joystick_key(2); } else { - uprintf("left-up\n"); + press_joystick_key(0); } - - // if (current_y < 0) { - // if (current_y < current_x * 2) { - // // 上 - // uprintf("up d: %d, x: %d, y: %d, raw_x: %d, raw_y: %d \n", joystick_ratio, current_x, current_y, joystick_raw_x, joystick_raw_y); - // } else { - // // 左上 - // uprintf("UL d: %d, x: %d, y: %d, raw_x: %d, raw_y: %d \n", joystick_ratio, current_x, current_y, joystick_raw_x, joystick_raw_y); - // } - // } else if (current_y == 0 && current_x < 0) { - // // 左 - // uprintf("left d: %d, x: %d, y: %d, raw_x: %d, raw_y: %d \n", joystick_ratio, current_x, current_y, joystick_raw_x, joystick_raw_y); - // } - - mouse_report.x = 0; - mouse_report.y = 0; - mouse_report.h = 0; - mouse_report.v = 0; - - } + else { + reset_joystick_key(); + } + + mouse_report.x = 0; + mouse_report.y = 0; + mouse_report.h = 0; + mouse_report.v = 0; + return mouse_report; } diff --git a/keyboards/takashicompany/left_slinger/left_slinger.h b/keyboards/takashicompany/left_slinger/left_slinger.h index e669845d439..a664cd26583 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.h +++ b/keyboards/takashicompany/left_slinger/left_slinger.h @@ -14,4 +14,6 @@ enum custom_keycodes_kb { MY_JSDI, // Joy stick movement divisor increase MY_JSDD, // Joy stick movement divisor decrease MY_STGE, // Setting End + MY_JSKD, // Joy stick key default + MY_JSKE, // Joy stick key enable }; \ No newline at end of file From 37881707b4091bff3326815cde99ade343b4a79c Mon Sep 17 00:00:00 2001 From: takashicompany Date: Tue, 19 Nov 2024 17:49:14 +0900 Subject: [PATCH 09/17] fix keymap --- .../takashicompany/left_slinger/keymaps/default/keymap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c index e34b9879063..ce52b2d380c 100644 --- a/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c +++ b/keyboards/takashicompany/left_slinger/keymaps/default/keymap.c @@ -8,8 +8,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_Q , KC_W , KC_E , MY_JSKE, KC_A , KC_S , KC_D , KC_LSFT, KC_Z , KC_X , KC_C , KC_V , - KC_LCTL, KC_UP , KC_LALT, KC_1 , KC_2 , - KC_LEFT, KC_DOWN, KC_RGHT, KC_3 + KC_LCTL, KC_UP , KC_LALT, KC_ESC , KC_ENT , + KC_LEFT, KC_DOWN, KC_RGHT, KC_BSPC ), [1] = LAYOUT( From 270afe875df505e9077d71d90c065d7d3b048932 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Tue, 19 Nov 2024 17:57:34 +0900 Subject: [PATCH 10/17] readme --- keyboards/takashicompany/left_slinger/readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/readme.md b/keyboards/takashicompany/left_slinger/readme.md index 798c3556f9d..5419cb7c4e0 100644 --- a/keyboards/takashicompany/left_slinger/readme.md +++ b/keyboards/takashicompany/left_slinger/readme.md @@ -1,12 +1,12 @@ # takashicompany/left_slinger -![takashicompany/left_slinger](imgur.com image replace me!) +![takashicompany/left_slinger](https://i.imgur.com/7U0BMuT.jpeg) -*A short description of the keyboard/project* +Left Slinger is a left hand only macro pad & gaming device with joystick and rotary encoder. * Keyboard Maintainer: [takashicompany](https://github.com/takashicompany) -* Hardware Supported: *The PCBs, controllers supported* -* Hardware Availability: *Links to where you can find this hardware* +* Hardware Supported: PCB, RP2040-Zero +* Hardware Availability: https://github.com/takashicompany/left_slinger Make example for this keyboard (after setting up your build environment): From ca78bd7b9f459c60b6d9b8904dd846f17408c64c Mon Sep 17 00:00:00 2001 From: takashicompany Date: Tue, 19 Nov 2024 17:58:02 +0900 Subject: [PATCH 11/17] del console --- keyboards/takashicompany/left_slinger/rules.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/rules.mk b/keyboards/takashicompany/left_slinger/rules.mk index e1158d19669..535ec48bd85 100644 --- a/keyboards/takashicompany/left_slinger/rules.mk +++ b/keyboards/takashicompany/left_slinger/rules.mk @@ -2,5 +2,3 @@ POINTING_DEVICE_ENABLE = yes POINTING_DEVICE_DRIVER = custom ANALOG_DRIVER_REQUIRED = yes SRC += custom_joystick.c - -CONSOLE_ENABLE = yes \ No newline at end of file From 5b9d208ee10e4416a60e2f16a0a1b4be614b58d0 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Tue, 19 Nov 2024 18:00:05 +0900 Subject: [PATCH 12/17] format json --- .../takashicompany/left_slinger/keyboard.json | 210 ++---------------- 1 file changed, 24 insertions(+), 186 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/keyboard.json b/keyboards/takashicompany/left_slinger/keyboard.json index 872662456aa..370623eb59c 100644 --- a/keyboards/takashicompany/left_slinger/keyboard.json +++ b/keyboards/takashicompany/left_slinger/keyboard.json @@ -6,10 +6,7 @@ "diode_direction": "COL2ROW", "encoder": { "rotary": [ - { - "pin_a": "GP14", - "pin_b": "GP15" - } + {"pin_a": "GP14", "pin_b": "GP15"} ] }, "features": { @@ -22,20 +19,8 @@ "nkro": true }, "matrix_pins": { - "cols": [ - "GP5", - "GP6", - "GP7" - ], - "rows": [ - "GP8", - "GP9", - "GP10", - "GP11", - "GP12", - "GP13", - "GP0" - ] + "cols": ["GP5", "GP6", "GP7"], + "rows": ["GP8", "GP9", "GP10", "GP11", "GP12", "GP13", "GP0"] }, "processor": "RP2040", "url": "", @@ -47,174 +32,27 @@ "layouts": { "LAYOUT": { "layout": [ - { - "matrix": [ - 0, - 0 - ], - "x": 1, - "y": 0 - }, - { - "matrix": [ - 0, - 1 - ], - "x": 2, - "y": 0 - }, - { - "matrix": [ - 0, - 2 - ], - "x": 3, - "y": 0 - }, - { - "matrix": [ - 1, - 0 - ], - "x": 0, - "y": 1 - }, - { - "matrix": [ - 1, - 1 - ], - "x": 1, - "y": 1 - }, - { - "matrix": [ - 1, - 2 - ], - "x": 2, - "y": 1 - }, - { - "matrix": [ - 2, - 0 - ], - "x": 3, - "y": 1 - }, - { - "matrix": [ - 3, - 0 - ], - "x": 0, - "y": 2 - }, - { - "matrix": [ - 3, - 1 - ], - "x": 1, - "y": 2 - }, - { - "matrix": [ - 3, - 2 - ], - "x": 2, - "y": 2 - }, - { - "matrix": [ - 2, - 1 - ], - "x": 3, - "y": 2 - }, - { - "matrix": [ - 2, - 2 - ], - "x": 4.25, - "y": 2 - }, - { - "matrix": [ - 4, - 0 - ], - "x": 1, - "y": 3.25 - }, - { - "matrix": [ - 4, - 1 - ], - "x": 2, - "y": 3.25 - }, - { - "matrix": [ - 4, - 2 - ], - "x": 3, - "y": 3.25 - }, - { - "matrix": [ - 6, - 0 - ], - "x": 4.25, - "y": 3.25 - }, - { - "matrix": [ - 6, - 1 - ], - "x": 5.25, - "y": 3.25 - }, - { - "matrix": [ - 5, - 0 - ], - "x": 1, - "y": 4.25 - }, - { - "matrix": [ - 5, - 1 - ], - "x": 2, - "y": 4.25 - }, - { - "matrix": [ - 5, - 2 - ], - "x": 3, - "y": 4.25 - }, - { - "matrix": [ - 6, - 2 - ], - "x": 4.25, - "y": 4.25 - } + {"matrix": [0, 0], "x": 1, "y": 0}, + {"matrix": [0, 1], "x": 2, "y": 0}, + {"matrix": [0, 2], "x": 3, "y": 0}, + {"matrix": [1, 0], "x": 0, "y": 1}, + {"matrix": [1, 1], "x": 1, "y": 1}, + {"matrix": [1, 2], "x": 2, "y": 1}, + {"matrix": [2, 0], "x": 3, "y": 1}, + {"matrix": [3, 0], "x": 0, "y": 2}, + {"matrix": [3, 1], "x": 1, "y": 2}, + {"matrix": [3, 2], "x": 2, "y": 2}, + {"matrix": [2, 1], "x": 3, "y": 2}, + {"matrix": [2, 2], "x": 4.25, "y": 2}, + {"matrix": [4, 0], "x": 1, "y": 3.25}, + {"matrix": [4, 1], "x": 2, "y": 3.25}, + {"matrix": [4, 2], "x": 3, "y": 3.25}, + {"matrix": [6, 0], "x": 4.25, "y": 3.25}, + {"matrix": [6, 1], "x": 5.25, "y": 3.25}, + {"matrix": [5, 0], "x": 1, "y": 4.25}, + {"matrix": [5, 1], "x": 2, "y": 4.25}, + {"matrix": [5, 2], "x": 3, "y": 4.25}, + {"matrix": [6, 2], "x": 4.25, "y": 4.25} ] } } From b27f81c9b9bf6d1d59a6e80654eb930ac594b4e1 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Tue, 19 Nov 2024 18:06:30 +0900 Subject: [PATCH 13/17] add license header --- keyboards/takashicompany/left_slinger/config.h | 3 +++ keyboards/takashicompany/left_slinger/custom_joystick.c | 3 +++ keyboards/takashicompany/left_slinger/custom_joystick.h | 3 +++ keyboards/takashicompany/left_slinger/left_slinger.h | 3 +++ 4 files changed, 12 insertions(+) diff --git a/keyboards/takashicompany/left_slinger/config.h b/keyboards/takashicompany/left_slinger/config.h index e076cbf9e2e..c7ee2b29940 100644 --- a/keyboards/takashicompany/left_slinger/config.h +++ b/keyboards/takashicompany/left_slinger/config.h @@ -1,3 +1,6 @@ +// Copyright 2024 takashicompany (@takashicompany) +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #define ANALOG_JOYSTICK_X_AXIS_PIN GP28 diff --git a/keyboards/takashicompany/left_slinger/custom_joystick.c b/keyboards/takashicompany/left_slinger/custom_joystick.c index 5c68bd9789e..609d053dcb9 100644 --- a/keyboards/takashicompany/left_slinger/custom_joystick.c +++ b/keyboards/takashicompany/left_slinger/custom_joystick.c @@ -1,3 +1,6 @@ +// Copyright 2024 takashicompany (@takashicompany) +// SPDX-License-Identifier: GPL-2.0-or-later + #include QMK_KEYBOARD_H #include "analog.h" #include "gpio.h" diff --git a/keyboards/takashicompany/left_slinger/custom_joystick.h b/keyboards/takashicompany/left_slinger/custom_joystick.h index b56425bc79a..dddb6553c90 100644 --- a/keyboards/takashicompany/left_slinger/custom_joystick.h +++ b/keyboards/takashicompany/left_slinger/custom_joystick.h @@ -1,3 +1,6 @@ +// Copyright 2024 takashicompany (@takashicompany) +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #include diff --git a/keyboards/takashicompany/left_slinger/left_slinger.h b/keyboards/takashicompany/left_slinger/left_slinger.h index a664cd26583..318506e832e 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.h +++ b/keyboards/takashicompany/left_slinger/left_slinger.h @@ -1,3 +1,6 @@ +// Copyright 2024 takashicompany (@takashicompany) +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #include "quantum.h" From d85671882171d5c5f417739099115ceb243c6f08 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Wed, 20 Nov 2024 02:16:00 +0900 Subject: [PATCH 14/17] fix interval --- .../takashicompany/left_slinger/left_slinger.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c index 1cb2c984a5b..904b039f715 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.c +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -358,9 +358,16 @@ void reset_joystick_key(void) { void press_joystick_key(int8_t column) { - if (joystick_key_column != -1 || timer_elapsed(joystick_key_timer) < 200) { + // if (joystick_key_column != -1 || timer_elapsed(joystick_key_timer) < 200) { + // return; + // } + + if (joystick_key_column == column || timer_elapsed(joystick_key_timer) < 200) { return; } + + reset_joystick_key(); + joystick_key_column = column; joystick_key_timer = timer_read(); action_exec(MAKE_KEYEVENT(6, column, true)); @@ -378,7 +385,7 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { #endif if ((current_x != 0 || current_y != 0) && (joystick_raw_x > 100 || joystick_raw_y > 100) == false && - (my_abs_16(joystick_raw_x) + my_abs_16(joystick_raw_y) > 200)){ + (my_abs_16(joystick_raw_x) + my_abs_16(joystick_raw_y) > 350)){ if (joystick_raw_y < joystick_raw_x * 4) { // 上 @@ -390,7 +397,9 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { } } else { - reset_joystick_key(); + if (timer_elapsed(joystick_key_timer) > 50) { + reset_joystick_key(); + } } mouse_report.x = 0; @@ -400,6 +409,9 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { return mouse_report; } + else { + reset_joystick_key(); + } if (current_x != 0 || current_y != 0) { From b16bf7e0f5526b9b0e9548fc5b3bfeb5ca7a178a Mon Sep 17 00:00:00 2001 From: takashicompany Date: Wed, 20 Nov 2024 02:25:58 +0900 Subject: [PATCH 15/17] adjust --- keyboards/takashicompany/left_slinger/left_slinger.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c index 904b039f715..be57a8332bd 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.c +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -358,11 +358,9 @@ void reset_joystick_key(void) { void press_joystick_key(int8_t column) { - // if (joystick_key_column != -1 || timer_elapsed(joystick_key_timer) < 200) { - // return; - // } + joystick_key_timer = timer_read(); - if (joystick_key_column == column || timer_elapsed(joystick_key_timer) < 200) { + if (joystick_key_column == column /* || timer_elapsed(joystick_key_timer) < 200*/) { return; } @@ -397,7 +395,7 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { } } else { - if (timer_elapsed(joystick_key_timer) > 50) { + if (timer_elapsed(joystick_key_timer) > 100) { reset_joystick_key(); } } From c298330faf666e33f90c8b82f11fdb320b78bfbf Mon Sep 17 00:00:00 2001 From: takashicompany Date: Wed, 20 Nov 2024 02:28:40 +0900 Subject: [PATCH 16/17] fix range --- keyboards/takashicompany/left_slinger/left_slinger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c index be57a8332bd..c97ba9c535c 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.c +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -383,7 +383,7 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { #endif if ((current_x != 0 || current_y != 0) && (joystick_raw_x > 100 || joystick_raw_y > 100) == false && - (my_abs_16(joystick_raw_x) + my_abs_16(joystick_raw_y) > 350)){ + (my_abs_16(joystick_raw_x) + my_abs_16(joystick_raw_y) > 200)){ if (joystick_raw_y < joystick_raw_x * 4) { // 上 From 10887b796c470a62d57b72c95d94f5784605b3a6 Mon Sep 17 00:00:00 2001 From: takashicompany Date: Wed, 20 Nov 2024 02:29:52 +0900 Subject: [PATCH 17/17] Revert "fix range" This reverts commit c298330faf666e33f90c8b82f11fdb320b78bfbf. --- keyboards/takashicompany/left_slinger/left_slinger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/takashicompany/left_slinger/left_slinger.c b/keyboards/takashicompany/left_slinger/left_slinger.c index c97ba9c535c..be57a8332bd 100644 --- a/keyboards/takashicompany/left_slinger/left_slinger.c +++ b/keyboards/takashicompany/left_slinger/left_slinger.c @@ -383,7 +383,7 @@ report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { #endif if ((current_x != 0 || current_y != 0) && (joystick_raw_x > 100 || joystick_raw_y > 100) == false && - (my_abs_16(joystick_raw_x) + my_abs_16(joystick_raw_y) > 200)){ + (my_abs_16(joystick_raw_x) + my_abs_16(joystick_raw_y) > 350)){ if (joystick_raw_y < joystick_raw_x * 4) { // 上