Hi everyone! I’m working on a music game: the player has to play a melody using a virtual keyboard.
Now I’m working on a demo designed for people with visual impairment… so we splitted the screen in regions: the number of regions is equal to the amount of “keys” the player has to play (it’s like a piano keyboard).
The problem is that the application is installed on iOS devices and Android devices that has some kind of accessibility service enabled during the execution.
For instance, when the user open the game using iOS with VoiceOver enabled we had a problem detecting single-tap events (the player has to double-tap the screen to play a key)… we fixed this problem using a few lines of code:
//allows direct touch interaction when user is using iOS VoiceOver.
UIAccessibilityTraits traits = UIAccessibilityTraitAllowsDirectInteraction;
eaglView.accessibilityTraits = traits;
Now I’m looking for some kind of setting flag similar to iOS UIAccessibilityTraitAllowsDirectInteraction but for Android accessibility framework. I’ve searched for hours but I couldn’t find anything like that. For now, I’ve added onHoverEvent to Cocos2dxGLSurfaceView.java in order to detect single-tap events when the accessibility service is active in the device… then I redirect this event to the onTouchEvent like this:
@Override
public boolean onHoverEvent(MotionEvent event) {
if(mAccessibilityManager == null)
return false;
if (mAccessibilityManager.isTouchExplorationEnabled() && event.getPointerCount() == 1) {
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_HOVER_ENTER: {
event.setAction(MotionEvent.ACTION_DOWN);
} break;
case MotionEvent.ACTION_HOVER_MOVE: {
event.setAction(MotionEvent.ACTION_MOVE);
} break;
case MotionEvent.ACTION_HOVER_EXIT: {
event.setAction(MotionEvent.ACTION_UP);
} break;
}
return onTouchEvent(event);
}
return true;
}
**But now I’ve two problems involved in this solution: **
1. There’s a sound fx involving the “touch exploration” feature when accessibility service is enabled on Android: every single tap emits a sound that I think belongs to Android OS.
2. The onTouchEvent is executed with some delay and this makes impossible to play the game.
I hope someone can share their experience with Android Accessibility Framework in order to solve those two problems!
Thanks in advance!