Galaxy Tab S9 FE+: Can't get any spen specific events

Hello, i’m currently working on a drawing app, but there are parts of the pen events i can’t get.

Questions:
I can get all pointer related events fine, but I can’t get the button press event. How do i get those ?
Also, on some scroll views, i want to disable the air preview auto scroll feature, how can that be done ?

  • Tried the race car app, which is the demo app from samsung to showcase the spen features, but none of the gestures nor the button to pause works.
  • Tried all the onXX events: onTouch, onKeyDown, dispatchTouches, onHover, onGenericMotionEvent, none of them triggers when overriden in my scrollView subclass when i press the side button, and returning false doesn’t prevent the auto scroll feature.
  • Tried SPen Remote SDK, but it says that this tablet doesn’t support it.

I’m really confused on how to interact with those features.

Hello,
You can observe button action with the following code snippet:

    SpenUnit button = mSpenUnitManager.getUnit(SpenUnit.TYPE_BUTTON);
    mSpenUnitManager.registerSpenEventListener(mButtonEventListener, button);
    ...
    //EventListener for Button Unit
    private SpenEventListener mButtonEventListener = new SpenEventListener() {
        @Override
        public void onEventChanged(SpenEvent ev) {
            ButtonEvent buttonEvent = new ButtonEvent(ev)
            
            switch (buttonEvent.getAction()) {
                case ButtonEvent.ACTION_DOWN:
                    Log.d(TAG, "Spen Button Pressed");
                    break;
                case ButtonEvent.ACTION_UP:
                    Log.d(TAG, "Spen Button Released");
                    break;
            }
        }
    };

Please check out the link below:

Thank you,
Ummey

1 Like

Hello,
Thanks for the answer, unfortunately, as mentioned, I can’t use the SDK as the SPen is not a pro one.
In the process of getting the UnitManager, it fails to connect saying the device doesn’t support it.

The only way to use the button is through the android events, where the event.buttonState will have the state of the spen button.
If you need to actually perform something on the click with a normal non pro spen, you’ll have to build a system that checks the state in the onHover and onTouch methods and figures when a press/release occurs.