Game Pad Controller Misery

I recently bought a Game Pad “8bitdo sn30 pro+”

I wrote a prototype to see how I could get it working my my games.

I’m not sure but I think it behaves like a 360 controller, also I’m not sure if the Axisis are different if you’re using it on a different OS, All the games I write are Android-based so I changed the project type accordingly

The Game Pad left stick works and 2 of the 4 buttons are working fine “out of the box” although Fire3 for joystick button 2 does not do anything in the input manager.

Anyways so I thought I would go into the input manager “I’m using the old version not the package manager version” and create additional content.

I’m using some source “visual” from the following link http://wiki.unity3d.com/index.php?title=Xbox360Controller

As this controller has names on the trigger buttons I thought I would match that:
“Left Trigger 2”

Name = L2
Gravity = 1000
Dead = 0.2
Sensitivity = 1000
Snap = Checked
Invert = Checked
Type = Joystick Axis
Axis = 3rd Axis (Joystick and Scrollwheel)
Joy Num = Get Motion From all Joysticks

Here is the code I call:

  float mL2 = Input.GetAxisRaw("L2");
//Debug.Log("Left Trigger Pressed: " + mL2);
   if (mL2 > 0)
     {
     Debug.Log("Left Trigger Pressed: " + mL2);
     }
Input.ResetInputAxes();

Although the code does run it has problems but I’m not sure if it is the input setup or something else.

A - It fires on all triggers
B - The ResetInputAxes does not work, once a button is pressed the code keeps getting called.

So far I’m at a loss with this one.

I recommend using the new input system since it is now out of preview for 2019.4. It is far superior for controller support.

@Chris-Trueman
@Rene-Damm

Yes I think your correct here although I did find that my 8BitDo SN30 Pro+ does not register normal input for most of the data it produces, e.g left stick or right stick.

I’m having a little problem with the follow and I do have this in my project I want to convert over to using GamePad/Touch Input

I’ve been building a prototype lets say I have a canvas that has a bunch of buttons on it, and I want to have that controlled by touch “the old system I would use the click event for the button”, and by GamePad “use eventsystem.current.setselectedgameobject etc”.

Now on a child of the canvas, a have a dialog it has a canvas group on it so I can hide the dialog until I need it to display it, by pressing one of the buttons on the canvas manager.

What’s the best options here, as I cannot find a tutorial I can watch for this subject as most only deal with player controller.

I thought of this:

A - In the main canvas define the new Input Manager class, hooking this up to use the gamepad and cycle though the buttons for pressing, I did something in the old system before Chris mentioned the new input manager.

B - Now once I press a button using the gamepad “somehow”, I deactivate the input manager on the canvas by calling “disabled”, and create a new one for the dialog that has just popped up, the dialog has it’s own class so it should not bother the other.

It’s sound a lot of work just to get GamePads etc working, now I bet that my own touch joystick I have built will not work now I have enabled the new input system. as it deletes the inputmodule from the event system.

I hope you didn’t mind by adding you into here Rene, as you understand the new input system better than most as your one of the designers of it.

uGUI is already setup for controller/keyboard navigation regardless of the input system used. I find it a bit cumbersome to setup, but I was able to get a working system before adding the new input system to the project. After I added the new input system I needed to change nothing. There isn’t much for tutorials on navigation with uGUI, so it’s not exactly easy if you don’t know what to do.

You don’t need to disable it. Each menu or dialog box only needs to have focus set on the control you want to start with. Using EventSystem.current.setselectedgameobject will do this for you as you have with the old system. With a menu system I have built, I have a field available in the inspector to drop the control I want to focus when the menu is opened. Once its focused then I can navigate that menu with the controller or keyboard. You also need to setup the navigation correctly or it will start doing things you don’t want, like selecting a button that is not part of the currently focus menu or dialog.

Each control handles its own navigation. I found the only way to get it to work the way you want is to setup explicit navigation setting up each control to say what control up, left, right, down moves to.

No it isn’t easy to get gamepads working, it took me about a week at a few hours a day to get navigation working the way I wanted it to.

This entirely depends on how you have your touch joystick working. I don’t have a touch/mobile project to test the new input system with but it wasn’t hard to add it in with any of my other projects.

@Chris-Trueman

Hi Chris I would like to start by thanking you for taking the time to answer my questions, it’s not every day, you find somebody taking the time to do that.

I’m making the changes on a weekend as work and writing a new game gets in the way on weekdays.

after I added the new Input system to my project and said NO to the dialog, I went and changed the project settings “Active Input Handling” in the player to Both, and tested I though the touch joystick might not work but it does.

It’s funny as the event system says about changing the Input Module to the new input system module, but does not error out if you don’t, although if you do change it the on-screen touch stops.

I did go to your site, to see what you have made, and I tried to see the game on the play store but the links did not work
:frowning:

Cheers again.

Not a problem, though I have been known to be wrong.

That’s strange, touch shouldn’t stop working. After adding the EventSystem that uses the new input system, are you using the default controls that it assigns?

Game is defunct, Google changed a few things and it was pulled for violating their policy. It is a minor thing of mentioning another game in the description(flappy bird.) I went to fix it and needed to upload a new APK, which was required to be 64bit and the minimum android version was upped as well, which I needed to update the version of Unity that I was using to do so. This caused too many problems for me to bother fixing. The game was a test project to go through the whole process of putting up a game so I decided to not waste time fixing it to get it back up.

@Chris-Trueman

Hi Chris thanks again for your help, I’ve got most of it working through the controller, tomorrow night is the big test on one of my android devices.

I did find that if I put the new input system on a class that was app-wide “not destroyed” the input system went really funny unless I disabled it and enabled it again on a new scene.

I’m using the old system to detect if a controller is plugged in

mManagers.Project.Settings.DeviceType = DeviceTypes.TOUCHPAD;
   String[] mNames = Input.GetJoystickNames();
    if (mNames != null && mNames.Length > 0)
      {
       mManagers.Project.Settings.DeviceType = DeviceTypes.GAMEPAD;
       Debug.Log("A Gamepad Has Been found"); 
      }

I’m not sure what the equivalent is in the new system.

It’s a pity about the game, I’m trying to write new games all the time or at least ideas that get too much feature creep. I wish I was not doing this on my own, 20+ years I’ve looked for a fellow developer to work with but I just cannot find anybody hence I have to do it on my own.

so where you from Chris? my users for the game “Gauntlet on Google Shameless plug :)” have been asking since I released the first version in late 2016 to use the controller as the touch system I created works but it can be a bit hit and miss sometimes.

Yes I remember mentioning some games in my other release on the store and it got pulled until I changed it, I also had a link to the other game on the store, and they said I could not do that but others do :(.

You can check this out. https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/manual/Migration.html
There is an equivalent method in that list that shows how to get an event when a controller is connected/disconnected and also how to check the devices connected and what they are. Its a good page for reference.

Sounds like me, 14+ years though. I don’t have the ideas, my best friend is very creative and comes up with new game ideas and gives me lots of feature creep all the time. He’s not good at programming, but logic is second nature to him. He is slowly learning c# making small games that he tends to out idea his ability. He is also an awesome artist/musician(link in my sig, shameless plug :smile:.) My biggest problem is I have a full time job that has nothing to do with programming or computers and it wipes me out being a physical job(I work with heavy windows for 8 hours a day.)

I’m from Canada. Where are you from?

Google is an odd cat. They keep changing policies, making it harder to keep up for small developers. But this is the way, let the small developers pave the way and then tailor to the big ones that only hurt the little guy.