Slick Forums

Discuss the Slick 2D Library
It is currently Fri Dec 13, 2019 3:28 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: BUG: Controller Input
PostPosted: Sun Mar 20, 2011 6:55 pm 
Offline

Joined: Sun May 16, 2010 8:25 am
Posts: 59
Code:
   public void update(GameContainer container, int delta) throws SlickException
   {
      System.out.println(Controllers.getController(0).getName());
      System.out.println(Controllers.getController(0).getXAxisValue());
      System.out.println(Controllers.getController(0).getYAxisValue());
      
       Controller[] cons = ControllerEnvironment.getDefaultEnvironment().getControllers();
       for (Controller c : cons)
       {
          if (c.getName().contains("USB"))
          {
             for (net.java.games.input.Component ca : c.getComponents())
             {
                if (ca.getName().contains("X Axis") || ca.getName().contains("Y Axis"))
                {
                   System.out.println(ca.getPollData());
                }
             }
          }
       }
   }


getXAxisValue() and getYAxisValue() return -1 at the start of the game. When i click the corresponding direction once, they return 0.

If i use Jinput directly, it returns the correct value.

Tested with 3 different joysticks

The example above outputs the following at the start of the program:

Code:
USB Joystick     
-1.0
-1.0
-1.5258789E-5
-1.5258789E-5


If i press the direction, as said, it outputs:

Code:
USB Joystick     
0
0
-1.5258789E-5
-1.5258789E-5


Not sure whether it's a LWJGL problem or Slick messing up some LWJGL input initialization.[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 20, 2011 7:17 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Sry i don't get it jet.
Why not using the Input class from the container?

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 20, 2011 7:23 pm 
Offline

Joined: Sun May 16, 2010 8:25 am
Posts: 59
R.D. wrote:
Sry i don't get it jet.
Why not using the Input class from the container?


Because it results in the same error. If you implement InputProvider

Code:
   @Override
   public void controlPressed(Command command)
   {
      System.out.println("Pressed:" +command);
   }


Gets called without a button being pressed.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 20, 2011 7:42 pm 
Offline

Joined: Sun May 16, 2010 8:25 am
Posts: 59
arg crap double post

Or if you try input.isControlPressed it also displays the wrong results unless a button on the joystick has been pressed.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 21, 2011 6:32 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Why InputProvider?

You can easily use container.getInput(). Which is the recommended way for controller input :D
Also there you just check if isControllerLeft(). If this is not working than you might have a broken controller.

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 21, 2011 11:09 am 
Offline

Joined: Sun May 16, 2010 8:25 am
Posts: 59
R.D. wrote:
Why InputProvider?

You can easily use container.getInput(). Which is the recommended way for controller input :D
Also there you just check if isControllerLeft(). If this is not working than you might have a broken controller.


That's what i was trying to say in my first post. No matter what slick utility you use or even what kind of lwjgl class you use, you get the wrong results.

I start the programm, isControllerLeft() gives me -1.0. I press LEFT on my Controller, it says that Left just got released and gives me 0.0 and works properly afterwards.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 10, 2011 4:14 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Controllers is part of LWJGL not Slick?

Kev


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group