GamePad Component and OTG Support- Proposal

172 views
Skip to first unread message

Rachael Thompson

unread,
Aug 11, 2016, 12:36:32 PM8/11/16
to App Inventor Open Source Development

I’ve been working on creating a component that will let you use an OTG gamepad with your AI App. After using the method enableGamepad to enable the Gamepad, you can get the state of any of the buttons or joysticks as, respectively, a boolean value or a float axis value from -1 to 1.


To achieve this, in addition to the GamePad component, I added two methods to the Form class - dontGrabKeyEventsForComponent and dontGrabMotionEventsForComponent. These methods are called within the GamePad component to enable or disable key grabbing. 

I also added implementations of the onKeyUp and onGenericMotionEvent methods, and edited onKeyDown, so that the relevant events are dispatched to the key grabbing component instead of propagated back to the main EvenDispatcher. 


I’m using the code for a personal robotics project - but is this something that would be considered for a pull request? The changes to the Form class aren’t just useful for gamepads - they would add support for any OTG input device (keyboard, joystick, etc.) that someone wants to use in their component.


I’ve exported to Google App Engine. I know the next step is deploying a public build server for testing, but as I understand, that requires another machine - which I’m not sure how to acquire or set up (I’m a high school senior w/out much experience there), so I’d appreciate any guidance. For now, here are copies of the files I edited, and the .aia and .apk files for my test app, which just lists the values of the different buttons and joysticks:


https://github.com/RachaelT/GamePadAppInventor


And here’s my branch:


https://github.com/RachaelT/appinventor-sources


Known Limitations:

I tested my component and app with a Logitech gamepad, so it would be nice to see if it works with an Xbox or other supported gamepad.

The component only supports one gamepad at this time. 

My unit test currently only covers the Gamepad component - not the changes to the Form class, as I struggled to create a Form test that didn’t require me to recreate all the relevant code through Easymock.

I’m not sure I have all the annotations done properly.


Thanks for the help, and any feedback is appreciated!


Matt Devriese

unread,
Aug 21, 2018, 4:41:28 PM8/21/18
to App Inventor Open Source Development
Hi Rachael!

Were you ever able to get your component established? My son and I have been building a combat robot, and we would like to use this method for control... possibly. ;-)

Rachael Thompson

unread,
Aug 29, 2018, 11:20:53 AM8/29/18
to App Inventor Open Source Development
Hello!

Sorry for the late response - while it was never integrated officially as part of app inventor, my source is at https://github.com/rsthomp/appinventor-sources and all my documentation is here: https://github.com/rsthomp/Stagebot
I just updated my fork to the most recent version of the source without any issues. Hopefully, the method still works, but let me know if you have any problems. 
Reply all
Reply to author
Forward
0 new messages