Reputation: 41
I'm trying to make a custom keyboard for my smart watch (specifically Samsung galaxy watch 4 classic), and want to be able to use the rotary input as an optional way to select a letter. However, my motion event is not triggered, and whenever I use the rotor while my keyboard is open, I get this message in the log:
D/ViewRootImpl@6f11041[InputMethod]: Do not drop RSB event due to visible IME window: MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=36162981, downTime=0, deviceId=6, source=0x400000, displayId=-1 }
Is there a way to allow rotary events while using the keyboard?
Here is the method I'm currently using to get rotary inputs:
myView.setOnGenericMotionListener { v, ev ->
if (ev.action == MotionEvent.ACTION_SCROLL &&
ev.isFromSource(InputDeviceCompat.SOURCE_ROTARY_ENCODER)
) {
val delta = -ev.getAxisValue(MotionEventCompat.AXIS_SCROLL) *
ViewConfigurationCompat.getScaledVerticalScrollFactor(
ViewConfiguration.get(applicationContext), applicationContext
)
// This commits text to the ic, im currently trying to have it
// enter delta into the text field as a sort of test
type(delta.roundToInt())
true
} else {
false
}
}
}
Upvotes: 1
Views: 170