Undocumented AMOTION_EVENT_ACTION code when stylus button pressed (Samsung S Pen Stylus)

87 views Asked by At

The Android NDK Input Docs there are 15 AMOTION_EVENT_ACTION types, which are enumerated 0 to 14 as can be seen in the summary section when scrolling down. However, I observe the following behavior:

  1. Have the S Pen not touching the screen (both being out of range of hovering is okay)
  2. Press and hold the button on the S Pen
  3. While still holding the button, touch the touch screen
  4. When inspecting the action associated with the MotionEvent with AMotionEvent_getAction(...), I now get the code 213, which I can't find to be defined or documented anywhere.

I have masked out the upper eight bit as they contain the index of the pointer associated with the index, but this doesn't (and shouldn't) make any difference. As the stylus comes into or out of contact with the touchscreen I also get a 211/212, presumably a constant offset gets applied to those events (AMOTION_EVENT_ACTION_MOVE = 2 + 211, AMOTION_EVENT_ACTION_UP = 1 + 211, AMOTION_EVENT_ACTION_DOWN = 0 + 211, ...). Hovering still emits normal/expected codes. The button status itself gets detected correctly. Here is an event long of the stylus touching the touchscreen while the button is pressed and then going into hover:

D PRESSURE: 0.041758, TILT: 0.404251, ORIENTATION: -1.119569
D Event[Action=UNKNOWN_ACTION/211, ToolType=AMOTION_EVENT_TOOL_TYPE_STYLUS/2, Source=20482, ButtonStatus=00000020, PointerIdx=0]
I updatePointerIcon pointerType = 20001, calling pid = 26706
D setPointerIconType iconId = 20001, callingPid = 26706
D PRESSURE: 0.081319, TILT: 0.435829, ORIENTATION: -1.152598
D Event[Action=UNKNOWN_ACTION/213, ToolType=AMOTION_EVENT_TOOL_TYPE_STYLUS/2, Source=20482, ButtonStatus=00000020, PointerIdx=0]
D PRESSURE: 0.095482, TILT: 0.435829, ORIENTATION: -1.152598
...
D PRESSURE: 0.001465, TILT: 0.435829, ORIENTATION: -1.152598
D Event[Action=UNKNOWN_ACTION/212, ToolType=AMOTION_EVENT_TOOL_TYPE_STYLUS/2, Source=20482, ButtonStatus=00000020, PointerIdx=0]
D Event[Action=AMOTION_EVENT_ACTION_HOVER_ENTER/9, ToolType=AMOTION_EVENT_TOOL_TYPE_STYLUS/2, Source=20482, ButtonStatus=00000020, PointerIdx=0]
D DISTANCE: 6.000000, PRESSURE: 0.000000, TILT: 0.000000, ORIENTATION: 1.570796

The hardware I am using is a Samsung Tab S6 Lite with a S Pen (not the Bluetooth one). I've also tried to find some documentation by Samsung on this but with no luck.

Has anyone observed this behavior/knows whether it's formally defined somewhere? I'd really like to actually understand what's going on instead of just hardcoding some magic offsets. Thanks.

0

There are 0 answers