1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

keyballに雑にスクロール反転機能を搭載した

Last updated at Posted at 2023-12-21

動機

macとwindowsを使用しており、スクロールの方向を統一したかった。

前提

keyballのリポジトリをクローンし、自分でビルド可能な環境

やり方

変更を加えるファイル

  • qmk/keyboard/keyball/lib/keyball.h
  • qmk/keyboard/keyball/lib/keyball.c
  • qmk/keyboard/keyball/{所持しているkeyball}/keymap/{任意のkeymap}/config.h

以下ではファイル名を省略してます。

keyball.h

// 20行目あたりのconfigurationsの中に追記
#ifndef KEYBALL_SCROLL_INV
#    define KEYBALL_SCROLL_INV 0
#endif

keyball.c

// 184行目あたりのmotion_to_mouse_scrollの最後に追記

static void motion_to_mouse_scroll(keyball_motion_t *m, report_mouse_t *r, bool is_left) {
    // consume motion of trackball.
    uint8_t div = keyball_get_scroll_div() - 1;
    int16_t x   = m->x >> div;
    m->x -= x << div;
    int16_t y = m->y >> div;
    m->y -= y << div;

    // apply to mouse report.
#if KEYBALL_MODEL == 61 || KEYBALL_MODEL == 39 || KEYBALL_MODEL == 147 || KEYBALL_MODEL == 44
    r->h = clip2int8(y);
    r->v = -clip2int8(x);
    if (is_left) {
        r->h = -r->h;
        r->v = -r->v;
    }
#elif KEYBALL_MODEL == 46
    r->h = clip2int8(x);
    r->v = clip2int8(y);
#else
#    error("unknown Keyball model")
#endif

#if KEYBALL_SCROLLSNAP_ENABLE
    // scroll snap.
    uint32_t now = timer_read32();
    if (r->h != 0 || r->v != 0) {
        keyball.scroll_snap_last = now;
    } else if (TIMER_DIFF_32(now, keyball.scroll_snap_last) >= KEYBALL_SCROLLSNAP_RESET_TIMER) {
        keyball.scroll_snap_tension_h = 0;
    }
    if (abs(keyball.scroll_snap_tension_h) < KEYBALL_SCROLLSNAP_TENSION_THRESHOLD) {
        keyball.scroll_snap_tension_h += y;
        r->h = 0;
    }
#endif

// !ここを追記!
// ---------------------
#if KEYBALL_SCROLL_INV
    r->h = -r->h;
    r->v = -r->v;
#endif
// ---------------------
}

config.h

自分のキーマップのconfig.hに以下を記載

// どこでも良いので以下を記載
#define KEYBALL_SCROLL_INV 1

あとは通常通りビルドしてpromicroに書き込めば完了です。

あとがき

PR送ったほうがいいものなのかな、と思いつつgithubの使い方覚えられてないので後回し

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?