AVD and mouse wheel inputs

30 views
Skip to first unread message

Hophop

unread,
Dec 27, 2022, 7:47:34 PM12/27/22
to android-ndk
Hey,
I am using android emulator v. 31.3.11.0 (build_id 9058569) and I'm trying to handle the mouse wheel using NDK but I can't read the values.
Below is the code I am using to process inputs:



int32_t action = AMotionEvent_getAction(event);
LOGV("ACTION: %X", action);     // on mouse wheel returns 0 or 1 or 2

// always FALSE
if ((AMOTION_EVENT_ACTION_MASK & action) & AMOTION_EVENT_ACTION_SCROLL) {
     LOGV("ITS A SCROLL!");
}

if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
     s32 source = AInputEvent_getSource(event);
     if (source & AINPUT_SOURCE_MOUSE) // TRUE on mouse wheel
     {
         LOGV("ITS A MOUSE!");
     }

    // always 0!
    f32 v = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_VSCROLL, 0);
    f32 h = AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_HSCROLL, 0);
}


Pointer index is always 0.
How can i read mouse wheel values?

Hophop

unread,
Dec 28, 2022, 7:30:57 PM12/28/22
to android-ndk
I tested this implementation on my phone and it works fine there - values from "AMotionEvent_getAxisValue(event, AMOTION_EVENT_AXIS_VSCROLL, 0);" are different from zero when using the mouse scroll.
Is this a bug in the emulator?

It is interesting that when you connect the mouse to the phone, the mouse cursor appears on the screen.
Reply all
Reply to author
Forward
0 new messages