Skip to content
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

External Input Hardware Click #29

Open
hajile95 opened this issue Jan 16, 2019 · 7 comments
Open

External Input Hardware Click #29

hajile95 opened this issue Jan 16, 2019 · 7 comments

Comments

@hajile95
Copy link

Would it be possible to create a click based on an Xbox gamepad button press? I have tried implementing an onKeyDown listener in some of the classes, but have not been successful in capturing gamepad inputs.

This could be a helpful feature if using the Xbox adaptive controller as an input method. Being able to just look and click could be valuable to someone who has some ability to press a large button.

@cmauri
Copy link
Owner

cmauri commented Jan 30, 2019

Yes it is technically possible and makes sense. AFAIK you might need to capture onKeyDown events on a full screen overlay with accessibility permissions (TYPE_ACCESSIBILITY_OVERLAY) and then route to the core and use to clicking

@hajile95
Copy link
Author

hajile95 commented Jan 30, 2019

Any tips on where I could put things to make this work? I've been digging through the code trying to learn how it all works, but I'm a fairly inexperienced developer. Would I need to create a new overlay, or is there one that already exists that I could capture an onKeyDown event?

Based on initial investigation with my limited knowledge, it looks like that could fit in the OverlayView class, but I'm not quite sure how all that works.

Also would it be possible to utilize BroadcastReceivers? Not exactly sure how those work, but stumbled across them trying to learn how to capture inputs in a service.

@cmauri
Copy link
Owner

cmauri commented Feb 11, 2019

Perhaps an easier option is to intercept the callback
AccessibilityService.onKeyEvent

You will also need to provide some additional permissions to your accessibility service. See the following link for further details.
https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html#onKeyEvent(android.view.KeyEvent)

Hope it helps.

@hajile95
Copy link
Author

I have been trying to override the AccessibilityService.onKeyEvent method, but have been unsuccessful in capturing anything. Maybe I haven't added the right permissions, but I am having trouble finding what needs to be added.

@hajile95
Copy link
Author

So I tried adding this flag as well as a few others to the manifest under the TheAccessibilityService class, and overrode the onKeyEvent method within the class, but it doesn't seem to ever be called when I click a button. Could something else be consuming the event before it can get to the service?

@cmauri
Copy link
Owner

cmauri commented Mar 6, 2019

Try disabling any other accessibility service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants