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

feat: my-cutsom #705

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
tmp/
.idea
22 changes: 22 additions & 0 deletions qmk_firmware/keyboards/keyball/keyball39/keyball39.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------
参考文献:
- リポジトリ:
https://github.com/kamiichi99/keyball/tree/main/qmk_firmware/keyboards/keyball/keyball39/keymaps/kamidai
- keyballの販売ページ
https://shirogane-lab.com/collections/all
コード表:
- 公式ファームウェアのキーコード:
KBC_RST(0x5DA5): Keyball 設定のリセット
KBC_SAVE(0x5DA6): 現在の Keyball 設定を EEPROM に保存します
CPI_I100(0x5DA7): CPI を 100 増加させます(最大:12000)
CPI_D100(0x5DA8): CPI を 100 減少させます(最小:100)
CPI_I1K(0x5DA9): CPI を 1000 増加させます(最大:12000)
CPI_D1K(0x5DAA): CPI を 1000 減少させます(最小:100)
SCRL_TO(0x5DAB): タップごとにスクロールモードの ON/OFF を切り替えます
SCRL_MO(0x5DAC): キーを押している間、スクロールモードになります
SCRL_DVI(0x5DAD): スクロール除数を1つ上げます(max D7 = 1/128)← 最もスクロール遅い
SCRL_DVD(0x5DAE): スクロール除数を1つ下げます(min D0 = 1/1)← 最もスクロール速い
- オリジナルのキーコード:
KC_BACK_TO_LAYER0_BTN1(0x5DAF): レイヤー0に遷移できるBTN1
KC_DOUBLE_CLICK_BTN1(0x5DB0): 1タップでダブルクリックできるBTN1
KC_TRIPLE_CLICK_BTN1(0x5DB1): 1タップでトリプルクリックできるBTN1
*/

#include QMK_KEYBOARD_H
Expand Down
47 changes: 47 additions & 0 deletions qmk_firmware/keyboards/keyball/keyball39/keymaps/viamy/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
This is the c configuration file for the keymap

Copyright 2022 @Yowkees
Copyright 2022 MURAOKA Taro (aka KoRoN, @kaoriya)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

//#ifdef RGBLIGHT_ENABLE
//# define RGBLIGHT_EFFECT_BREATHING
//# define RGBLIGHT_EFFECT_RAINBOW_MOOD
//# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
//# define RGBLIGHT_EFFECT_SNAKE
//# define RGBLIGHT_EFFECT_KNIGHT
//# define RGBLIGHT_EFFECT_CHRISTMAS
//# define RGBLIGHT_EFFECT_STATIC_GRADIENT
//# define RGBLIGHT_EFFECT_RGB_TEST
//# define RGBLIGHT_EFFECT_ALTERNATING
//# define RGBLIGHT_EFFECT_TWINKLE
//#endif

//#define COMBO_COUNT 9

//#define KEYBALL_SCROLLSNAP_ENABLE 0 // scrollsnapをオフにする

#define TAP_CODE_DELAY 5
#define DYNAMIC_KEYMAP_LAYER_COUNT 7

#define KEYBALL_CPI_DEFAULT 700 // 光学センサーPMW3360DM の解像度 (CPI) の規定値
#define KEYBALL_SCROLL_DIV_DEFAULT 4 // スクロール速度の規定値

//#define POINTING_DEVICE_AUTO_MOUSE_ENABLE
//#define AUTO_MOUSE_DEFAULT_LAYER 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/* Copyright 2023 kamidai (@d_kamiichi)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

////////////////////////////////////
///
/// 自動マウスレイヤーの実装 ここから
/// 参考にさせていただいたページ
/// https://zenn.dev/takashicompany/articles/69b87160cda4b9
///
////////////////////////////////////

enum ball_state {
NONE = 0,
WAITING, // マウスレイヤーが有効になるのを待つ。 Wait for mouse layer to activate.
CLICKABLE, // マウスレイヤー有効になりクリック入力が取れる。 Mouse layer is enabled to take click input.
CLICKING, // クリック中。 Clicking.
CLICKED, // クリック直後。 Clicked.
SWIPE, // スワイプモードが有効になりスワイプ入力が取れる。 Swipe mode is enabled to take swipe input.
SWIPING // スワイプ中。 swiping.
};

enum ball_state state; // 現在のクリック入力受付の状態 Current click input reception status
uint16_t click_timer; // タイマー。状態に応じて時間で判定する。 Timer. Time to determine the state of the system.

uint16_t clicked_stay_time = 200; // CLICKEDの滞在時間(千分の一秒)。その後、クリックレイヤーが無効になる。 For this number of seconds (milliseconds), the click layer is disabled if in CLICKED state.
uint16_t clickable_stay_time = 1600; // CLICKABLEの滞在時間(千分の一秒)。その後、クリックレイヤーが無効になる。 For this number of seconds (milliseconds), the click layer is disabled if in CLICKABLE state.

const int16_t to_clickable_movement = 0; // クリックレイヤーが有効になるしきい値
const uint16_t click_layer = 6; // マウス入力が可能になった際に有効になるレイヤー。Layers enabled when mouse input is enabled

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.

// Modifierが絡むときの挙動が理想とは違ったので、一旦コメントアウト
// const uint16_t ignore_disable_mouse_layer_keys[] = {KC_LANG1, KC_LANG2}; // この配列で指定されたキーはマウスレイヤー中に押下してもマウスレイヤーを解除しない

int16_t mouse_movement;

// クリック用のレイヤーを有効にする。 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);
}

//
report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
int16_t current_x = mouse_report.x;
int16_t current_y = mouse_report.y;

if (current_x != 0 || current_y != 0) {
switch (state) {
case CLICKABLE:
click_timer = timer_read();
break;

case CLICKING:
break;

case WAITING:
mouse_movement += my_abs(current_x) + my_abs(current_y);

if (mouse_movement >= to_clickable_movement) {
mouse_movement = 0;
enable_click_layer();
}
break;

case SWIPE:
click_timer = timer_read();

if (my_abs(current_x) >= SWIPE_THRESHOLD || my_abs(current_y) >= SWIPE_THRESHOLD) {
// rgblight_sethsv(HSV_PINK);
process_swipe_gesture(current_x, current_y);
is_swiped = true;

if (is_repeat == false) {
state = SWIPING;
}
}
break;

case SWIPING:
break;

default:
click_timer = timer_read();
state = WAITING;
mouse_movement = 0;
}
} else {
switch (state) {
case CLICKING:
break;

case CLICKED:
if (timer_elapsed(click_timer) > clicked_stay_time) {
disable_click_layer();
}
break;
case CLICKABLE:
if (timer_elapsed(click_timer) > clickable_stay_time) {
disable_click_layer();
}
break;

case WAITING:
if (timer_elapsed(click_timer) > 50) {
mouse_movement = 0;
state = NONE;
}
break;

case SWIPE:
// rgblight_sethsv(HSV_SPRINGGREEN);
break;

case SWIPING:
if (timer_elapsed(click_timer) > 300) {
state = SWIPE;
}
break;

default:
mouse_movement = 0;
state = NONE;
}
}
mouse_report.x = current_x;
mouse_report.y = current_y;

return mouse_report;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* Copyright 2023 kamidai (@d_kamiichi)
*
* 参考ページ
* 公式:https://docs.qmk.fm/#/ja/feature_combo?id=%e3%82%b3%e3%83%b3%e3%83%9c
*
* 注意: 以下の設定が必要です
* rules.mk: COMBO_ENABLE = yes
* config.h: #define COMBO_COUNT 2(=実際に設定するコンボ数)
*/

enum combos {
COMBO_F14,
COMBO_F15
};

// const uint16_t PROGMEM f14_combo[] = {KC_DOWN, KC_I, COMBO_END};
// const uint16_t PROGMEM f15_combo[] = {G(KC_C), KC_UP, COMBO_END};
// const uint16_t PROGMEM combo_layer_1[] = {KC_F, KC_D, COMBO_END};
// const uint16_t PROGMEM combo_layer_2[] = {KC_J, KC_K, COMBO_END};
// const uint16_t PROGMEM combo_layer_3[] = {KC_D, KC_S, COMBO_END};
// const uint16_t PROGMEM combo_layer_3[] = {KC_S, KC_A, COMBO_END};

const uint16_t PROGMEM combo_BRC[] = {KC_LBRC, KC_RBRC, COMBO_END};
const uint16_t PROGMEM combo_select_BRC[] = {KC_LBRC, S(KC_EQUAL), COMBO_END};

const uint16_t PROGMEM combo_S9_S0[] = {S(KC_9), S(KC_0), COMBO_END};
const uint16_t PROGMEM combo_select_S9_S0[] = {S(KC_9), KC_MINUS, COMBO_END};

const uint16_t PROGMEM combo_S_BRC[] = {S(KC_LBRC), S(KC_RBRC), COMBO_END};
const uint16_t PROGMEM combo_select_S_BRC[] = {S(KC_LBRC), KC_RBRC, COMBO_END};

const uint16_t PROGMEM combo_sumitsuki_BRC[] = {SFT_T(KC_GRAVE), KC_LBRC, COMBO_END};
const uint16_t PROGMEM combo_select_sumitsuki_BRC[] = {SFT_T(KC_GRAVE), S(KC_0), COMBO_END};

const uint16_t PROGMEM combo_MINUS_SPACE[] = {KC_RBRC, S(KC_EQUAL), COMBO_END};

combo_t key_combos[] = {
// [COMBO_F14] = COMBO(f14_combo, KC_F14),
// [COMBO_F15] = COMBO(f15_combo, KC_F15)
// COMBO(combo_layer_1, MO(3)),
// COMBO(combo_layer_2, MO(3)),
// COMBO(combo_layer_3, MO(2)),

COMBO(combo_BRC, COMBO_BRC),
COMBO(combo_select_BRC, COMBO_select_BRC),

COMBO(combo_S9_S0, COMBO_S9_S0),
COMBO(combo_select_S9_S0, COMBO_select_S9_S0),

COMBO(combo_S_BRC, COMBO_S_BRC),
COMBO(combo_select_S_BRC, COMBO_select_S_BRC),

COMBO(combo_sumitsuki_BRC, COMBO_sumitsuki_BRC),
COMBO(combo_select_sumitsuki_BRC, COMBO_select_sumitsuki_BRC),

COMBO(combo_MINUS_SPACE, COMBO_MINUS_SPACE),

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 自前の絶対数を返す関数。 Functions that return absolute numbers.
int16_t my_abs(int16_t num) {
if (num < 0) {
num = -num;
}
return num;
}

// 自前の符号を返す関数。 Function to return the sign.
int16_t mmouse_move_y_sign(int16_t num) {
if (num < 0) {
return -1;
}
return 1;
}
Loading