Skip to content

feat: support hardware keyboard input, including numpad keys#305

Open
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/hardware-keyboard-input
Open

feat: support hardware keyboard input, including numpad keys#305
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/hardware-keyboard-input

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 3, 2026

Copy link
Copy Markdown

Type of change(s)

  • Bug fix
  • Feature / enhancement

What changed and why

The Calculator had no hardware-keyboard handling at allMainActivity only wired the on-screen button click listeners, and the formula/result views are non-editable AutofitTextViews (no IME path). So every key event from a physical/numpad keyboard (the case reported in #134, e.g. an 8BitDo/Clicks numpad) was silently dropped, whether top-row KEYCODE_0..9 or KEYCODE_NUMPAD_*.

Fix: add an onKeyDown override that maps both the top-row and numpad key codes — digits, + − × ÷, =, Enter, decimal, backspace, clear — to the exact same calc.* calls the on-screen buttons already use (numpadClicked, handleOperation, handleEquals, handleClear, handleReset). Any unrecognized key falls through to super.onKeyDown, so no existing behavior changes.

Tests performed

Built fossDebug, installed on an Android 15 (API 35) emulator, drove input via adb shell input keyevent:

  • Numpad digits 7 8, NUMPAD_ADD, 2, NUMPAD_ENTER → evaluates correctly.
  • ESC resets the display to 0; then NUMPAD_5, NUMPAD_MULTIPLY, NUMPAD_3, NUMPAD_ENTER5×3 = 15.
  • Top-row digits (KEYCODE_7/8/9) enter digits; KEYCODE_DEL deletes the last character (backspace).
  • Unmapped keys (Back, volume) behave normally.

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator.
  • I updated the "Unreleased" section in CHANGELOG.md.
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • I understand every change in this pull request.

Coded with Opus 4.8 ultracode.

@MiMoHo MiMoHo requested a review from naveensingh as a code owner July 3, 2026 18:59
The calculator had no hardware-key handling, so digits/operators from a physical or numpad keyboard were silently dropped. Add an onKeyDown handler that routes both the top-row and numpad key codes (digits, + - * /, =, Enter, decimal, backspace, clear) to the same actions as the on-screen buttons. Unhandled keys fall through to super.
@MiMoHo MiMoHo force-pushed the fix/hardware-keyboard-input branch from 56a964f to a406d57 Compare July 3, 2026 19:16
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.

Calculator does not register numbers entered on hw keyboard (Clicks case for Razr)

1 participant