• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps HELP WITH: Reading Game Controller into Basic GUI

Jo_Han_Solo

Newbie
Hi Guys,

I'm developing a very basic app in Android Studio.

I'm trying to read a game controller from my Samsung Galaxy Note 2 into a basic GUI for seeing which button/joystick is being pressed/used. I basically just want like text boxes showing "Left Stick 0-100" "Button A pressed" or something like this.

I've got almost every common game controller so if you know how to get a USB Xbox360 controller working but not a PS4 controller that's not a problem.
I've got:
- PS3 & PS4 Controllers
- Steelseries Wireless Android Controller
- Xbox360 & XboxOne Controllers

I've found a few tutorials but I'm struggling with creating the app to do this.

Any help at all would be greatly appreciated.

Cheers!

Johan
 
I solved this problem using Googles own "Handling Game Controllers" guide as seen here: https://developer.android.com/training/game-controllers/controller-input.html

It worked out quite well, there were quite a few things that to someone as fresh with Java as I am struggles with, but essentially I followed that guide very closely and in all places where it told me to

"// Handle gamepad and D-pad button presses to navigate the ship"

I simply turned these commands into TextView boxes in the layout and used myTextView.setText(String.ValueOf(*INTEGER_OR_FLOAT*));

Using this I managed to create a simple app that reads out each button, dpad, analog sticks and triggers to a simple layout. I ended up using the Steelseries Controller.

Also, the following code is how to make the triggers work, the first guide doesn't explain that:
float LeftT = getCenteredAxis(event, mInputDevice, MotionEvent.AXIS_BRAKE,historyPos); //Left Trigger
float RightT = getCenteredAxis(event, mInputDevice, MotionEvent.AXIS_GAS,historyPos); //Right Trigger

It makes sense if you follow the rest of the guide.
 
Back
Top Bottom