Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new keyboard "Left Slinger" #24618

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions keyboards/takashicompany/left_slinger/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2024 takashicompany (@takashicompany)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#define ANALOG_JOYSTICK_X_AXIS_PIN GP28
#define ANALOG_JOYSTICK_Y_AXIS_PIN GP29
#define ANALOG_JOYSTICK_READ_INTERVAL 1
67 changes: 67 additions & 0 deletions keyboards/takashicompany/left_slinger/custom_joystick.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2024 takashicompany (@takashicompany)
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H
#include "analog.h"
#include "gpio.h"
#include "wait.h"
#include "timer.h"
#include <stdlib.h>
#include "print.h"
#include "custom_joystick.h"

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; // 符号
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();

int16_t jsr = joystick_ratio;
if (0 <= jsr && jsr < 10) {
jsr = 10;
}
else if (-10 < jsr && jsr < 0) {
jsr = -10;
}

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;
}

uint16_t pointing_device_driver_get_cpi(void) { return 0; }
void pointing_device_driver_set_cpi(uint16_t cpi) {}
11 changes: 11 additions & 0 deletions keyboards/takashicompany/left_slinger/custom_joystick.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2024 takashicompany (@takashicompany)
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <stdint.h>
#include <stdbool.h>

extern int16_t joystick_ratio;
extern int16_t joystick_raw_x;
extern int16_t joystick_raw_y;
59 changes: 59 additions & 0 deletions keyboards/takashicompany/left_slinger/keyboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"manufacturer": "takashicompany",
"keyboard_name": "Left Slinger",
"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
},
"matrix_pins": {
"cols": ["GP5", "GP6", "GP7"],
"rows": ["GP8", "GP9", "GP10", "GP11", "GP12", "GP13", "GP0"]
},
"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},
{"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}
]
}
}
}
83 changes: 83 additions & 0 deletions keyboards/takashicompany/left_slinger/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
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_ESC , KC_ENT ,
KC_LEFT, KC_DOWN, KC_RGHT, KC_BSPC
),

[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
),

[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
),

[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
),

[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
),

[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
),

[6] = LAYOUT(
KC_NO , KC_NO , KC_NO ,
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
),

[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 ,
MY_JSKD, MY_JSDD, MY_JSDI, KC_NO , KC_NO ,
KC_NO , MY_STGE, KC_NO , KC_NO
),
};

#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
[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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENCODER_MAP_ENABLE = yes
Loading