-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve key-swipe interface #983
base: main
Are you sure you want to change the base?
Conversation
Thanks for working on this! |
My current Bottleneck is the lack of member logic in KeyboardActionListenerImpl—there is one Maybe there should be a separate listener for key swipes. Maybe not. |
I have a branch where the layout (numpad) swipe has that step minimum and doesn't trigger until pointer release. Its logic depends on knowing that initial swipe direction. An enum of the lateral directions determined onSwipeStart strikes me as a good approach. Diagonals seem untenable atm, but I could definitely see a fifth "omnidirectional" option being used by certain actions. |
I'm not sure about having multiple listeners. Originally the
So maybe we should first gather what we need/want, and then choose how to do it:
Anything I missed? Looks like what we need boils down essentially the same for all, except the unexpected keyboard style swipe. So what do we need? (currently not considering there might be multiple pointer trackers)
And last... how to deal with multiple pointertrackers? |
Using the pointer ID sounds like a solid approach. |
I tried to sketch some idea how it could be done with class KeySwipeState(var keyCode: Int = 0, var inSwipe: Boolean = false, /* other stuff we may need */)
val keySwipeStates = Array(10) { KeySwipeState() } // maybe not fixed size array, but whatever for now
fun keySwipeAllowed(keyCode: Int): Boolean { // use a pointerTrackerId? does it make sense?
// basically a more generic isSwiper
}
// this is only called if keySwipeAllowed for keyCode is true
// returns whether startX and startY should be updated
fun onKeySwipe(keyCode: Int, stepsX: Int, stepsY: Int, pointerTrackerId: Int): Boolean {
val keySwipeState = keySwipeStates[pointerTrackerId]
// we want the action for that key code
// it depends on code, steps, and settings
val sv = Settings.getInstance().current
if (keyCode == Constants.CODE_SPACE) {
val result = if (stepsX < stepsY)
onVerticalSpaceSwipe(stepsY)
else
onHorizontalSpaceSwipe(stepsX)
if (!keySwipeState.inSwipe && result) {
keySwipeState.inSwipe = true
keySwipeState.keyCode = keyCode
}
return result
}
else if ...
return false
}
fun onEndSwipe(pointerTrackerId: Int) { // do we need any other information if we store keyCode in swipe action?
val keySwipeState = keySwipeStates[pointerTrackerId]
if (!keySwipeState.inSwipe) return
// determine up action (e.g. for delete) and do it
} It should work with multiple pointer trackers, but otherwise it looks like determining the action from key code and steps could get messy when adding more actions. |
My memory is also a bit shaky. I still care about this project, but uni will probably be keeping me rather busy in the coming weeks. You might be able to expect more contributions from me around the US Autumn holiday :) KeySwipeAllowed has me interested in the ability to give swipe actions to any key via JSON or something, seems pretty advanced for my code skills.. I'm also curious if the layout slide ability could be converted to a keyswipe, and if key boundaries can be used in these swipe actions more generally. For example, "only begin the action once your touch is n density pixels outside the key bounds." Imo that's probably the most sensible approach for the spacebar layout toggles and other potential gestures. |
Sure, I don't to steal your time!
Such flexibility or even customizability would be great, but currently I'm afraid even my idea is a bit much. (also I'm afraid of performance impact, as stuff might get called every single frame during gestures) |
This is my WIP for improving the key-swipe interface.
Closes #962.