Skip to content

Threshold of movement before activating a mouse layer aka AUTO_MOUSE_THRESHOLD - #886

Merged
Yowkees merged 4 commits into
Yowkees:mainfrom
okuRaku:upstream
Oct 27, 2026
Merged

Yowkees merged 4 commits into
Yowkees:mainfrom
okuRaku:upstream

Conversation

@okuRaku

@okuRaku okuRaku commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Renewed version of #563 with latest from Yowkees/keyball:main

This change re-implements the "auto mouse threshold" parameter/feature from the QMK firmware. This feature defines an amount of pointing device (trackball in the case of keyball) movement needed in order to activate a mouse layer. This can be helpful in preventing accidental mouse layer activation while typing. The default threshold is 10 units - tune to preference with KEYBALL_AUTO_MOUSE_THRESHOLD.

Built locally on my keyball61 and works as expected.

Reference:

https://docs.qmk.fm/features/pointing_device#config-h-options

https://github.com/qmk/qmk_firmware/blob/1e340cd59c1012d5f4d48b483b5c14e3e99b2bc3/quantum/pointing_device/pointing_device_auto_mouse.h#L46

@Yowkees

Yowkees commented Oct 26, 2026

Copy link
Copy Markdown
Owner

CIワークフローの承認待ちのまま時間が経過し、実行がタイムアウトしたため、再トリガーのため一旦クローズして再オープンします。

@Yowkees Yowkees closed this Oct 26, 2026
@Yowkees Yowkees reopened this Oct 26, 2026
@Yowkees

Yowkees commented Oct 26, 2026

Copy link
Copy Markdown
Owner

実装、ありがとうございます。QMK本体のauto_mouse_activationフックを正しく使う形で、設計方針として良いと思います。1点、動作について質問させてください。

total_motionのリセットがpointing_device_driver_get_report()内のis_keyboard_master() && should_report()ブロックの先頭に置かれていますが、このブロックはmotion_to_mouse()(=トラックボールの移動量を実際のマウスレポートに変換し、this_motion/that_motionをクリアする処理)の直前でもあります。

pointing_device_task()の呼び出し順を見ると、pointing_device_driver_get_report()が返したrepは、同じサイクル内でそのままpointing_device_task_auto_mouse() → auto_mouse_activation(rep)に渡されます。つまり:

  1. total_motionを0にリセット
  2. motion_to_mouse()でrepに今回分の移動量を反映
  3. (同じサイクルで)auto_mouse_activation(rep)が呼ばれ、total_motion += rep.x/y

という順序になるため、total_motionは実質「直近1サイクル分の移動量」にしかならず、複数サイクルにまたがって累積されないように見えます。KEYBALL_REPORTMOUSE_INTERVALが未設定(デフォルト)の場合、should_report()は毎サイクルtrueを返すため、この影響を受けやすいのではと思います。

実機でのテストでは意図通りに動いているとのことですが、念のため「ゆっくりカーソルを動かした場合にも閾値に到達して発動するか」を確認いただけますか? もし複数サイクルにまたがる累積が必要な設計意図であれば、リセットの位置を見直す必要があるかもしれません。

@okuRaku

okuRaku commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

ご指摘ありがとうございます!おっしゃる通りだと思います。私は主にタイピング中に起きる小さな衝撃でマウスレイヤーが発動しないようにする目的でこの変更を使っており、閾値も小さく設定していたため、問題に気づいていませんでした。total_motion のリセット処理を auto_mouse_activation() 内に移動するよう、コードを修正しました。

ビルドしてキーボードに書き込み、小さな衝撃ではマウスレイヤーが発動しないことは引き続き確認できました。ただし、より大きな閾値でのテストはしていません。

ご確認いただきありがとうございました。

@Yowkees

Yowkees commented Oct 27, 2026

Copy link
Copy Markdown
Owner

修正ありがとうございます、ロジックは良くなりました。ただ、CIが落ちています。

lib/keyball/keyball.cは全機種・全キーマップ共通のファイルですが、one47はどのキーマップでもPOINTING_DEVICE_AUTO_MOUSE_ENABLEを定義していません(keyball61のdefault/viaキーマップでは定義されています)。このマクロが無効だとget_auto_mouse_timeout()の宣言自体が見えなくなるため、one47:testのビルドがimplicit declaration of function 'get_auto_mouse_timeout'で失敗しています。

新しく追加したauto_mouse_activation()全体を#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE 〜 #endifで囲んでいただけますか?(この機能自体がPOINTING_DEVICE_AUTO_MOUSE_ENABLE前提の機能なので、無効な場合はこの関数自体が存在しなくても問題ありません)

修正いただければ再度CIを確認します。

@okuRaku

okuRaku commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

ご指摘ありがとうございます。auto_mouse_activation() を #ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE で囲むよう修正しました。

@Yowkees Yowkees left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2回のレビューラウンドにお付き合いいただきありがとうございました。total_motionのリセットタイミング、one47でのビルド失敗(POINTING_DEVICE_AUTO_MOUSE_ENABLE未定義時)、両方とも適切に修正していただきました。CIも全機種・全キーマップで成功しています。マージします!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants