ANDROID S-Pen stylus support#18201
Conversation
|
one thing im noticing on additional testing: |
|
Thank you for taking the effort. Preliminary comments:
|
|
Thank you for helping me polish my PRs so they meet standards, and doing
so, so politely. I will re-submit with your suggested changes thank you for
the valuable feedback. Thanks.
…On Tue, Aug 26, 2025, 2:09 PM zoltanvb ***@***.***> wrote:
*zoltanvb* left a comment (libretro/RetroArch#18201)
<#18201 (comment)>
Thank you for taking the effort. Preliminary comments:
- config.def.h, readme.md, androidmanifest.xml, version.all changes
should be removed from the PR
- android.mk change should probably also not be put to master
—
Reply to this email directly, view it on GitHub
<#18201 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIDANIC5OROW6UYEHVZCJAD3PSPHPAVCNFSM6AAAAACEXWTIZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMRVGIYDMMRWGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
dfa52bd to
e2dbb2e
Compare
|
It also needs a rebase, since as-is it will remove my latest recently merged changes regarding menu toggle. |
|
Cleanup done — I’ve removed all changes to config.def.h, README.md, version.all, AndroidManifest.xml, and Android.mk. |
AAAARG! ty, will do. |
ee58e9b to
fbe7e12
Compare
|
@sonninnos @zoltanvb Rebased onto latest master and preserved the recently merged menu-toggle changes. |
|
I checked it on my device (no S-Pen, so just for regression) and seems to behave OK. But then again, I built the change that was causing problem earlier, and it was also working on this device, so this is not a particularly good test. |
for what its worth I have HW tested it on a dell NASHER360 that has been loaded with trixie>waydroid |
Let me know I guess when the person who had the previous issue has tested the latest PR build here and reports no more issues |
I can confirm on native hardware that issue has been resolved or at least "works on my machine". I can post logs as receipt. I had thatissue when I first implemented using xtabs method without knowing it. |
|
I was able to validate one scenario on my device. When connecting a controller, the old build (1.16.0) exhibited the problem, neither the controller worked nor the touchscreen. I am glad to say that this does not happen with this change, touchscreen and controller continues to work as before, so I have no more objections. |
There was a problem hiding this comment.
Combining this condition with the previous one, the remaining part of the code could stay as it is, reducing the diff.
There was a problem hiding this comment.
Please do not put this behind ifdef. This log writing is related to a recent change by me and would like to see it in logs in case someone reports a problem.
There was a problem hiding this comment.
will do, thanks for your patience, and feedback as we get this ball down the field
|
did HW testing with new implimentation. snes9x is much better, but stylus support is a less polished experience on the menu. |
|
Let me know if you want me to merge this now or if you want to hold off further. |
|
Please hold off I found a bug right before leaving on vacation and I'm just
getting back into cell range :) thank you!
…On Mon, Sep 1, 2025, 10:22 AM LibretroAdmin ***@***.***> wrote:
*LibretroAdmin* left a comment (libretro/RetroArch#18201)
<#18201 (comment)>
Let me know if you want me to merge this now or if you want to hold off
further.
—
Reply to this email directly, view it on GitHub
<#18201 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIDANIFHXAUWKUDTPMJLAZL3QRJARAVCNFSM6AAAAACEXWTIZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTENBSGU3DANZXGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
Alright, thanks |
|
oof. |
2b10ee4 to
330e445
Compare
|
Hi, there seem to be some build failures now with the latest commit |
|
There are some other issues with this: the Pokemon-branded files in here do not belong in RetroArch or in this PR. |
330e445 to
71739c5
Compare
I totally agree I have two different features Im working on, and accidentally mixed my unified feature testing branch. this is a huge learning experience for me working with version control, and github branching. I sincerely apologize I got lost on what branch I was working in and got sloppy. apologies again. |
1a6ce09 to
342de91
Compare
…ustness - Add missing <math.h> include for fabsf() function - Add fallback classification when toolType is unknown/unavailable - Improves stylus detection reliability on stacks with limited toolType support 🤖 Generated with Claude Code
android/input+menu: Comprehensive S Pen hover→tap prevention with proximity tracking and gesture isolation Add robust multi-layer protection against Samsung firmware synthesized phantom touchscreen events following S Pen hover transitions: Android Input Layer (android_input.c): - Add stylus proximity tracking with 120ms temporal window using nanosecond timestamps - Gate android_check_quick_tap() calls to finger-only input when stylus proximity detected - Clear proximity flags on real stylus contact to prevent interference - Fix timestamp unit consistency (ns storage, ms comparison) and C89 compliance - Guard production logging behind DEBUG_ANDROID_INPUT Menu Layer (menu_driver.c): - Restrict gesture detection (TAP/SHORT_PRESS/LONG_PRESS/SWIPE) to TOUCHSCREEN pointer type only - Force mouse/stylus input to use explicit button presses rather than motion timing gestures - Prevent hover motion from being promoted to tap gestures in menu navigation This eliminates phantom clicks across the entire input→menu stack while preserving normal finger touch and stylus contact behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
android/input: Add defense-in-depth hover guard to android_check_quick_tap function Enhance quick-tap protection with direct hover guard check inside android_check_quick_tap(): - Abort quick-tap promotion when g_hover_guard_active is true - Clear any pending quick_tap_time to prevent delayed phantom clicks - Provides final safety layer against Samsung firmware synthesized touch events This works in concert with existing proximity tracking and menu gesture isolation to create comprehensive protection against S Pen hover→tap conversion throughout the input processing pipeline. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
docs: Add comprehensive S Pen implementation documentation Create detailed developer documentation explaining the multi-layer protection approach for Samsung S Pen hover→tap phantom click prevention: - Problem analysis and root cause explanation referencing xlabs' previous research - Four-layer defense-in-depth architecture documentation - Input channel separation design with mouse_activated flag logic - ToolType vs source classification strategy and fallback mechanisms - Contact detection using hardware pressure/distance sensors - Time unit consistency patterns across Android NDK APIs - Settings framework integration details - Performance considerations and guard window tuning - Future maintainer guidance with key code locations - Complete test requirements and debug support This provides essential context for future developers working on stylus input handling and helps preserve the architectural knowledge of this complex system. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
android/input: Route S Pen to RETRO_DEVICE_POINTER for menu interaction Fixes phantom hover clicks while enabling proper menu activation: Core Changes: - Route stylus contact events to pointer array (not mouse state) - Use proper motion_ptr indexing for multi-touch support - Implement pointer compaction on UP events - Maintain early returns to prevent contamination of finger touch logic Contact Detection: - Accept pressure >= 0.0f (was > 0.01f) for broader device support - Relax distance check to <= 1.0f for better contact detection - Respect input_stylus_require_contact_for_click setting Debug Support: - Add comprehensive logging for POINTER DOWN/UP events - Log pointer state queries for menu system debugging - Enable DEBUG_ANDROID_INPUT flag for detailed analysis Version: 1.21.69 for easy identification during testing This resolves GitHub issue #15490 and improves upon rejected PR #15597 by providing proper pointer lifecycle management and multi-touch support. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Address side button detection for hover-click functionality: * Fix side button state detection during hover events * Ensure side button logic is properly integrated with hover guard system * Maintain compatibility with existing stylus contact detection * Preserve phantom click prevention during side button operations This commit resolves initial side button detection issues and prepares the foundation for comprehensive drag operation support. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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 <noreply@anthropic.com>
Set default log levels to 0 (DEBUG) for comprehensive debugging: * DEFAULT_FRONTEND_LOG_LEVEL = 0 (most verbose debug output) * DEFAULT_LIBRETRO_LOG_LEVEL = 0 (most verbose core debug output) * Logging to file and timestamps remain enabled by default This ensures debug builds automatically capture detailed logs without manual configuration, improving development workflow and debugging capabilities for S Pen implementation and other features. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Complete settings framework integration for S Pen stylus support: * Add three new boolean configuration options: - input_stylus_enable: Master enable/disable for all stylus features - input_stylus_require_contact_for_click: Two-mode interaction control - input_stylus_hover_moves_pointer: Cursor movement during hover * Full menu system integration: - Menu entries with proper categorization in Input settings - Internationalization support with descriptive labels - Context-sensitive help text and sublabels - Proper settings validation and display logic * Configuration persistence across sessions * Backward compatibility with existing configurations Enables user control over S Pen behavior: contact-based vs hover+button interaction modes, with granular control over cursor movement and feature enablement. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ction modes Complete Samsung S Pen implementation addressing phantom hover clicks and enabling proper menu interaction with two distinct modes: **Core Features:** * Phantom hover click prevention using multi-layer protection * Two-mode interaction system: - Contact Mode: Require physical tip contact for clicks/drags - Hover Mode: Side button + hover for air clicking and dragging * Comprehensive button support (PRIMARY + SECONDARY) * Proper RETRO_DEVICE_POINTER routing for menu compatibility **Technical Implementation:** * Multi-layer hover guard system (100ms window, 12px spatial tolerance) * Stateful side button tracking for proper drag operations * ToolType classification with fallback support * Proximity tracking with nanosecond precision * Settings-controlled behavior with backward compatibility **Device Compatibility:** * Samsung Galaxy Note series (all generations) * Galaxy Tab S series with S Pen * Galaxy Z Fold series with S Pen support * Broader stylus device support via dual button detection **Testing Verified:** * Hover navigation without phantom clicks ✓ * Contact-based interaction ✓ * Side button hover clicking ✓ * Side button hover dragging ✓ * Menu interaction and drag operations ✓ Resolves long-standing S Pen usability issues while maintaining full backward compatibility and user choice between interaction modes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Implement S-Pen stylus support for Android - Add stylus tool type detection and hover handling - Support for barrel button and pointer interaction modes - Clean implementation without cheat autoload contamination 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Index 0: Current cursor position (always available during hover/contact) - Index 1: Tip contact coordinates (only active during tip press) - Index 2: Barrel button coordinates (only active during barrel press) - Preserves legacy finger touch multi-touch behavior using motion_ptr - Gives cores semantic meaning rather than arbitrary Android indices - Removes vestigial button mapping complexity 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Clean up menu settings for removed input_stylus_hover_moves_pointer - Remove sublabel references in menu_cbs_sublabel.c - Fixes build error after simplifying S-Pen to semantic pointer indices - Ensures clean compilation of semantic S-Pen implementation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
59659a4 to
4f104c4
Compare
|
This feature is cursed :) |
indeed. I had to ostep away from it for a while it was really bumming me out lol. I am proud to say that I fixed it, and I have a fork of the SNES9X core that is actually more accurate than N's implementation of the SNES mouse for the switch 2 :) re-opening |
|
Reworked and resubmitted as a focused, S-Pen-only PR (rebased onto current |
Description
Focused, S-Pen-only re-submission of Android Samsung S-Pen stylus support, rebased onto current
master.This addresses the review that closed the earlier version of this PR. The branch has been split down to the S-Pen feature alone — the unrelated files (
cheat_managerand other "omnibus" changes, the Pokémon-branded files,config.def.h) and the non-portablestrcasestrusage are gone. It builds, and the history is two clean commits on top of currentmaster.What it does
RETRO_DEVICE_POINTERpath — no ad-hoc mouse/touch emulation.toolType-based stylus/finger classification with input-source fallback.AMOTION_EVENT_BUTTON_STYLUS_PRIMARYand…_SECONDARYbarrel buttons (devices vary).Settings (Android only; menu + i18n wired)
input_stylus_enable— master switch (default ON)input_stylus_require_contact_for_click— tip contact required for a click (default ON)input_stylus_hover_moves_pointer— hover moves pointer without asserting PRESSED (default OFF)input_stylus_pressure_sensitivity— click pressure threshold, 1–100 (default 70)How prior review was addressed
cheat_manager/unrelated files.strcasestr(or other non-portable libc calls) introduced.aarch64debug build. Also fixed a config-persistence bug whereinput_stylus_pressure_sensitivity(a uint) was mistakenly registered among the bool settings, so it now saves/loads correctly.Files changed
input/drivers/android_input.c,configuration.c,configuration.h,menu/menu_setting.c,menu/menu_displaylist.c,menu/cbs/menu_cbs_sublabel.c,menu/menu_driver.c,msg_hash.h,intl/msg_hash_lbl.h,intl/msg_hash_us.h,runloop.c,docs/S-Pen-Implementation.md.Related issues
Credits