Skip to content

feat: Add hardware keyboard support, mouse mode selection, and input handling improvements - #56

Merged
TSTC123 merged 17 commits into
mainfrom
dev_1111_Keyboard_Mouse_And_UI_Support
Nov 11, 2026
Merged

TSTC123 merged 17 commits into
mainfrom
dev_1111_Keyboard_Mouse_And_UI_Support

Conversation

@TSTC123

@TSTC123 TSTC123 commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces hardware keyboard support, absolute/relative mouse mode selection, and improvements to the input handling architecture. It also includes bug fixes and UI refinements for portrait and landscape layouts.

Key Features

Hardware Keyboard Support

  • Added hardware keyboard support with HID key mappings
  • Implemented key press/release separation for proper held key repeat
  • Filtered modifier keys from the key slot
  • Hardened CH9329 serial communication paths

Mouse Mode Selection

  • Added absolute/relative mouse mode infrastructure
  • Wired mouse mode selection in the UI
  • Fixed relative-mode clicks carrying unwanted cursor movement
  • Mouse button state persists across move frames for drag operations

Input Handling Refactor

  • Extracted touch handling into dedicated TouchInputHandler class
  • Activity now owns the PiP controller instead of using a static field
  • Cleaner separation of concerns for input processing

Bug Fixes

  • PiP: Viewport indicator stays visible during mouse use
  • PiP: Kept the PiP indicator in step with the viewport in landscape mode
  • Keyboard: Fixed modifier keys leaking into key slots
  • Input: Stopped relative-mode clicks from carrying cursor movement
  • HID/Serial: Dropped unverified CH9329 config frame and hardened hot paths

UI Improvements

  • Reworked portrait layout for better usability
  • Deduped portrait settings layout via include
  • Cleaner landscape layout with proper PiP indicator alignment

Code Cleanup

  • Removed unused floating label accessor
  • Trimmed excessive keyboard HID logging
  • Dropped stack traces from per-event logs
  • Separated key press from release logic

Commits (17 total)

  • 3 new features (keyboard, mouse mode, mouse mode UI)
  • 3 refactoring (touch handler, PiP controller, settings layout)
  • 7 bug fixes (mouse, PiP, keyboard, input, HID)
  • 4 cleanup (logging, dead code)

Testing Checklist

  • Hardware keyboard key press/release
  • Mouse mode switching (absolute/relative)
  • Drag operations in both mouse modes
  • PiP indicator visibility during mouse/keyboard use
  • Portrait and landscape layout behavior
  • CH9329 serial communication stability

TSTC123 added 17 commits November 10, 2026 11:51
- MainActivity: Add dispatchKeyEvent() to handle Bluetooth/USB keyboard input
- MainActivity: Add detectInputDevices() for debugging connected input devices
- MainActivity: Request focus in onCreate/onStart for hardware key events
- CH9329MSKBMap: Fix scan code for | and \ (64 -> 31)
- CH9329MSKBMap: Fix DEL key mapping to Backspace (4C -> 2A)
- CH9329MSKBMap: Add numpad key mappings (ENTER, 1-9, DECIMAL)
- MouseMode enum, MouseModeManager state holder and MouseModePreferences persistence

- CoordinateConverter for touch-to-content coordinate mapping

- ZoomPanManager encapsulates portrait/landscape zoom and pan state

- BlackBorderOverlayView keeps a transparent pointer over letterboxed areas so the system cursor never shows
- move single/multi-touch gesture logic out of CustomTouchListener

- two-finger classifier now uses cumulative deltas with a 1.8x dominance ratio, 5px/8px thresholds, a 30-degree axis lock and a 100ms press gap before the right click

- double tap uses a drag-candidate state: the first click is flushed on the second DOWN and the second click fires on UP, making double click reachable again

- remove the long-press drag entry that hijacked slow cursor movement

- BtMouseInputHandler owns BT mouse decoding without debug file writes
…aths

- remove the SET_PARA_CFG path; connecting no longer writes chip configuration

- gate per-frame absolute-move logging behind CH9329Function.DEBUG_SEND_LOG

- skip hex formatting and per-packet logs while the debug switch is off

- move baud-rate reconnect off the UI thread and release the FE0C interface before reopening

- add back/forward button constants
- mouse control mode selector in the settings panel (absolute/relative)

- portrait layout rework for the removed drawer plus new settings rows

- Bluetooth mouse status hints and matching strings

- skip the viewport-center move while a BT mouse is in use
- single tap and two-finger right click now send zero deltas; the old (x, y, 0, 0) form turned the view coordinate into a delta and the host cursor jumped up to 127px on every click in relative mode

- BT mouse relative path: the first sample after (re)connect only learns the baseline, so the initial movement no longer jumps; btMouseRelInitialized was declared and reset but never read
- moveMouseToViewportCenter and releaseBtMouseButtons now log a single line instead of building an Exception on every call

- gate the sendHexRelData trace behind DEBUG_SEND_LOG since it runs on every relative move frame
- getFloatingLabel() had no callers and the field was only assigned in the constructor

- drop the always-gone floating_label TextView from the landscape layout; the portrait layout never had this id, so findViewById() returned null there anyway
- add DEBUG_KEY_LOG (off) and gate the live traces behind it

- drop the eleven constant component dumps that ran before every key frame

- sendKeyBoardPress, sendKeyBoardRelease and EmptyKeyboard logged 6-10 Log.e lines per keystroke; success paths are now silent and only real failures stay at error level
Hardware key down used to send press + auto-release while key up sent nothing, so the target only ever saw a complete tap and never entered the held state that USB HID auto-repeat depends on. Down now sends press only, up sends release, and onStop releases any key still held when focus is lost.

Also drops the per-key verbose logging from the queued press/release path now that the hardware keyboard routes through it.
The press+release path logged seven lines per key on the error channel, including two messages that announced a successful send. Progress and parameter dumps are gone, success paths are silent, and the remaining trace output sits behind DEBUG_KEY_LOG. Failure paths keep their Log.e, and three device-not-connected checks that were logged at debug level now report as errors.
Sending a modifier on its own put E0/E1/E2 into the key field, which is the HID usage code for LeftControl/LeftShift/LeftAlt. Once presses stopped auto-releasing, that bogus key stayed held and the target discarded the next real key, so Ctrl+C and friends stopped working. Modifiers now emit no frame at all; their state travels in the modifier byte of the following key.

getFunctionKey also builds the modifier byte bit by bit instead of returning after the first match, which restores Ctrl+Shift combinations and adds the Win key bit that was never handled.
- moveMouseToViewportCenter ignored the drawer scroll, so releasing the indicator put the cursor in the middle of the target desktop instead of the middle of the visible part. It now adds the scroll offset and sends the point through the same path a tap uses.

- The indicator size was read from the portrait zoom scale, which stays at 1.0 in landscape, and from a PiP that has no measured size on the frame it appears, so it collapsed to the 20px floor. The size is now the PiP size divided by the real zoom (the drawer scale), re-applied on every pinch and once more after the first layout pass.

- enlargeView no longer returns early when the binding view is missing, which used to skip the indicator setup entirely.

Also folds in the E8 cleanup of ZoomLayoutDeal and DrawerLayoutDeal: hot-path logging and dead work removed, stale imports dropped, null guards added, the drawable-null mouse-mode gate corrected, DrawerLayoutDeal no longer pretends to be a Fragment, and one hardcoded string moved to resources.
…atic field

ZoomLayoutDeal kept the activity, its window and the whole view tree alive through a static field. The members are instance members now and the activity holds the only instance, so the controller dies with the activity.

Also rebuild the controller in reloadLayoutForOrientation: the local variable shadowed the field, so after rotation it still pointed at the discarded view tree.
Both entry points are live (touch pad settings button and the bottom settings tab), so the cards live in module_portrait_settings_inner.xml and this file keeps only the ScrollView and the settings_module_root container.

This removes 40+ duplicated ids such as settings_theme_section and restores the mouse mode and bluetooth mouse section that this copy had missed.
- Rename updateBtMouseCursorState to applyBtMousePointerCapture
- Fix isBtMouseConnected() misused as connection state
- Remove scroll/move speed sliders from settings
- Remove Bluetooth mouse toast and bt_mouse_* strings
- Fix doSendHexAbsData hardcoding SecNullData breaking drag
- Remove sendMouseClick 30ms auto-release, enable keycap lock
- Fix BT mouse relative mode sending zero delta
- Widen double-tap window to 400ms/32px
- Add gestureButtons/lockedButtons dual-mask mechanism
@TSTC123
TSTC123 merged commit c3769ee into main Nov 11, 2026
2 of 6 checks passed
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.

1 participant