Skip to content

Commit ee2f3f1

Browse files
f4mrfauxclaude
andcommitted
docs: Update S Pen implementation documentation with side button fixes
Document recent improvements to S Pen side button drag implementation: * Add comprehensive side button support section explaining PRIMARY/SECONDARY button detection for broader stylus device compatibility * Update commit history with recent fixes and improvements * Document August 2025 fixes addressing hover-drag and contact gate issues * Update code location references to reflect current line numbers * Clarify hover-drag vs click semantics separation Technical documentation updates: - Side button detection now supports both button types - Hover-drag operates independently of contact click settings - Updated line number references for maintainer guidance - Added troubleshooting context for future development 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 38deb35 commit ee2f3f1

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/S-Pen-Implementation.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ if (!is_stylus && !is_finger) {
132132

133133
**Note:** ToolType classification is more reliable than source-only filtering because xlabs' research showed stylus events sometimes come through `TOUCHSCREEN` source.
134134

135+
### Side Button Support (Updated August 2025)
136+
Comprehensive button detection supports both common stylus button types:
137+
```c
138+
buttons = p_AMotionEvent_getButtonState ? AMotionEvent_getButtonState(event) : 0;
139+
side_primary = (buttons & AMOTION_EVENT_BUTTON_STYLUS_PRIMARY) != 0;
140+
side_secondary = (buttons & AMOTION_EVENT_BUTTON_STYLUS_SECONDARY) != 0;
141+
bool side_pressed = side_primary || side_secondary;
142+
```
143+
144+
This ensures compatibility with stylus devices that report barrel button as either PRIMARY or SECONDARY.
145+
135146
## Contact Detection Logic
136147

137148
### Hardware-Based Detection
@@ -213,7 +224,8 @@ These values can be adjusted per device if needed.
213224
- **Core Logic:** `input/drivers/android_input.c`
214225
- Lines ~105-143: Hover guard implementation
215226
- Lines ~698-722: Quick-tap defense function
216-
- Lines ~853-983: Stylus event processing
227+
- Lines ~914-1002: Stylus hover and side button processing (updated August 2025)
228+
- Lines ~1007-1080: Stylus contact event processing
217229
- Lines ~2040-2055, ~2128-2143: Input state queries
218230

219231
- **Menu Integration:** `menu/menu_driver.c`
@@ -285,8 +297,19 @@ The implementation was developed across multiple commits:
285297
- `7daf2ae`: Base S Pen implementation with toolType classification
286298
- `050a396`: Comprehensive hover→tap prevention with proximity tracking
287299
- `4c47eac`: Defense-in-depth enhancement to quick-tap function
300+
- `5e64f61`: Fix side button hover click detection
301+
- `488b368`: Fix S Pen side button drag with comprehensive button support
288302
- Build integration fixes: Function declaration ordering and enum integration
289303

304+
### Recent Fixes (August 2025)
305+
306+
**Side Button Drag Implementation (`488b368`)**:
307+
- **Issue**: Side button drag was broken due to `require_contact` gate preventing hover-drag when contact setting was enabled
308+
- **Issue**: Only `STYLUS_PRIMARY` button was supported, missing `STYLUS_SECONDARY` button devices
309+
- **Solution**: Removed contact requirement gate from hover path since hover-drag ≠ click semantics
310+
- **Solution**: Added support for both PRIMARY and SECONDARY stylus buttons for broader device compatibility
311+
- **Result**: Side button hover-drag now works regardless of contact setting and supports more stylus devices
312+
290313
## Build Status
291314

292315
**Implementation Complete** - All components integrated and building successfully

0 commit comments

Comments
 (0)