Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (122)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Libgdx Xbox360 controller mapping  (Read 5609 times)
0 Members and 1 Guest are viewing this topic.
Offline Cero
« Posted 2013-04-07 22:36:21 »

So Libgdx has now official controller support and should work with all controllers.
Of course there is special support for Ouya and its controller by having a mapping already there.
https://github.com/libgdx/libgdx/tree/master/extensions/gdx-controllers/gdx-controllers/src/com/badlogic/gdx/controllers/mappings

But there are no other mappings currently. Most interesting would be the Xbox360 pad mappings... does anyone have that ?
also: there are some models, at least the wireless and cable models - they dont happen to have different mappings ? would be silly, but you know... microsoft...

Offline ReBirth
« Reply #1 - Posted 2013-04-08 01:41:55 »

Xbox controller is still my champ. But doesn't Ouya's controller similiar to this?

Offline Cero
« Reply #2 - Posted 2013-04-08 17:06:17 »

sure controllers are similar, but the mapping is always kinda different

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Danny02
« Reply #3 - Posted 2013-04-08 17:14:47 »

I have one lieing around, but not much time atm to constribute.
could you post some little code which reads out all the things you need to know?
Offline Cero
« Reply #4 - Posted 2013-04-08 17:24:36 »

well just the button mappings - not sure about stick calibrations, dead zones and whatnot

also I'll get my pad this week and will probably tackle it then myself. I just thought someone has that mapping already =P

Offline ReBirth
« Reply #5 - Posted 2013-04-09 03:37:47 »

Well, worst case is you have to map by yourself Grin

Offline Cero
« Reply #6 - Posted 2013-04-10 16:21:52 »

Here we go

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
public class Xbox360Pad
{
   /*
    * It seems there are different versions of gamepads with different ID Strings.
    * Therefore its IMO a better bet to check for:
    * if (controller.getName().toLowerCase().contains("xbox") &&
                  controller.getName().contains("360"))
    *
    * Controller (Gamepad for Xbox 360)
      Controller (XBOX 360 For Windows)
      Controller (Xbox 360 Wireless Receiver for Windows)
      Controller (Xbox wireless receiver for windows)
      XBOX 360 For Windows (Controller)
      Xbox 360 Wireless Receiver
      Xbox Receiver for Windows (Wireless Controller)
      Xbox wireless receiver for windows (Controller)
    */

   //public static final String ID = "XBOX 360 For Windows (Controller)";
   public static final int BUTTON_X = 2;
   public static final int BUTTON_Y = 3;
   public static final int BUTTON_A = 0;
   public static final int BUTTON_B = 1;
   public static final int BUTTON_BACK = 6;
   public static final int BUTTON_START = 7;
   public static final PovDirection BUTTON_DPAD_UP = PovDirection.north;
   public static final PovDirection BUTTON_DPAD_DOWN = PovDirection.south;
   public static final PovDirection BUTTON_DPAD_RIGHT = PovDirection.east;
   public static final PovDirection BUTTON_DPAD_LEFT = PovDirection.west;
   public static final int BUTTON_LB = 4;
   public static final int BUTTON_L3 = 8;
   public static final int BUTTON_RB = 5;
   public static final int BUTTON_R3 = 9;
   public static final int AXIS_LEFT_X = 1; //-1 is left | +1 is right
   public static final int AXIS_LEFT_Y = 0; //-1 is up | +1 is down
   public static final int AXIS_LEFT_TRIGGER = 4; //value 0 to 1f
   public static final int AXIS_RIGHT_X = 3; //-1 is left | +1 is right
   public static final int AXIS_RIGHT_Y = 2; //-1 is up | +1 is down
   public static final int AXIS_RIGHT_TRIGGER = 4; //value 0 to -1f
}

Offline Khazrak

Senior Newbie





« Reply #7 - Posted 2013-05-30 16:23:50 »

Hi

Have you tried to use the Xbox 360 controller pull-based? ex: controller.getButton(buttonCode);

I get everything to work except Start and Back-button. It works in event-based code, but not in pull-based.

I submitted an Issue about it: https://code.google.com/p/libgdx/issues/detail?id=1436 but they Invalid it because they thought I didn't use the right buttoncode (6 and 7 for back and start).

Any one seen this problem?

/Khazrak
Offline Cero
« Reply #8 - Posted 2013-05-30 17:00:43 »

I think you mean POLL based

Yeah I've been using ControllerAdapter exclusively actually, so event based...

edit:
No I cannot confirm that. I tested your code:
1  
2  
3  
4  
5  
6  
for (int i = 0; i < 14; i++) {
            System.out.println("Poll "+i+ " " +pad.getButton(i));    
       }
       
       System.out.println("ButtonTest Start: "+pad.getButton(7));
       System.out.println("ButtonTest Back: "+pad.getButton(6));


And yeah:
Quote
Poll 0 false
Poll 1 false
Poll 2 false
Poll 3 false
Poll 4 false
Poll 5 false
Poll 6 false
Poll 7 true
Poll 8 false
Poll 9 false
Poll 10 false
Poll 11 false
Poll 12 false
Poll 13 false
ButtonTest Start: true
ButtonTest Back: false

It works for me.

Offline Khazrak

Senior Newbie





« Reply #9 - Posted 2013-05-30 17:40:51 »

Intresting, from the code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
@Override
         public boolean buttonDown (Controller controller, int buttonCode)
         {
            System.out.println("code: "+buttonCode);
            if(buttonCode == 7)
            {
               System.out.println("Start button Pressed!");      
            }
            return true;
         }
         
         @Override
         public boolean buttonUp (Controller controller, int buttonCode)
         {
            System.out.println("code: "+buttonCode);
            if(buttonCode == 7)
            {
              System.out.println("Start button released!");
            }
            return true;
         }


and

1  
2  
3  
4  
5  
6  
for (int i = 0; i < 14; i++) {
         System.out.println("Pull "+i+ " " +controller.getButton(i));  
      }
     
      System.out.println("ButtonTest Start: "+controller.getButton(7));
      System.out.println("ButtonTest Back: "+controller.getButton(6));


I get:

Quote
code: 7
Start button Pressed!
Pull 0 false
Pull 1 false
Pull 2 false
Pull 3 false
Pull 4 false
Pull 5 false
Pull 6 false
Pull 7 false
Pull 8 false
Pull 9 false
Pull 10 false
Pull 11 false
Pull 12 false
Pull 13 false
ButtonTest Start: false
ButtonTest Back: false

I'm trying it with a wired Xbox 360-controll under ubuntu 12.04 64-bit. I will try it on my Windows-pc at work tomorrow to see if it is a linux-specific problem.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #10 - Posted 2013-05-30 18:20:42 »

The most likely scenario is that the controller variable you are using for polling is not the same / not the right one.
Be 100% sure.

Offline Khazrak

Senior Newbie





« Reply #11 - Posted 2013-05-31 08:29:27 »

I get the same problem on my win 7 64 bit laptop?
Weird...

Which version of libgdx are you using?
I'm using 0.9.8 stable version.

Offline Cero
« Reply #12 - Posted 2013-05-31 11:17:57 »

I always use nightlies.
But like I said: Make sure you have the right instance when polling. Or post your whole code or sonething.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (31 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (40 views)
2014-10-26 19:37:11

Luminem (21 views)
2014-10-26 10:17:50

Luminem (26 views)
2014-10-26 10:14:04

theagentd (32 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (57 views)
2014-10-16 15:22:06

Norakomi (46 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!