Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 9:16 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sun May 13, 2012 3:54 pm 
Offline

Joined: Fri Dec 16, 2011 5:15 pm
Posts: 6
Hi, I'm having a slight problem using the joypad interface, the controls always seem to move left at the start of the game until something is pressed. I debugged into the input code and it looks like all axes in the controller are starting off set to -1. Do I need to do some kind of initialisation?

Input input = gc.getInput();
int controller = 0;
if (input.isControllerLeft(controller)) setPressed(buttonCodes.LEFT);
if (input.isControllerRight(controller)) setPressed(buttonCodes.RIGHT);
if (input.isControllerUp(controller)) setPressed(buttonCodes.UP);
if (input.isControllerDown(controller)) setPressed(buttonCodes.DOWN);
if (input.isButton1Pressed(controller)) setPressed(buttonCodes.JUMP);
if (input.isButton2Pressed(controller)) setPressed(buttonCodes.FIRE);

thanks,

Nick


Top
 Profile  
 
PostPosted: Sun May 13, 2012 6:52 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
I just did some testing.

Console output:

Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
Sun May 13 19:45:04 BST 2012 INFO:Found 4 controllers
Sun May 13 19:45:04 BST 2012 INFO:0 : HID-compliant consumer control device
Sun May 13 19:45:04 BST 2012 INFO:1: Controller (XBOX 360 For Windows)
Sun May 13 19:45:04 BST 2012 INFO:2: PLAYSTATION(R)3 Controller
Sun May 13 19:45:04 BST 2012 INFO:3 : SteelSeries HID Device

360 Pad:

Input input = gc.getInput();
System.out.println(Controllers.getController(1).getYAxisValue());

Console output = -1.0 (as you said)

PS3 Pad:

Input input = gc.getInput();
System.out.println(Controllers.getController(2).getYAxisValue());

Console output = 0.0

Strange results indeed...anyone have any ideas? i'm also interested to know about this.


Top
 Profile  
 
PostPosted: Sun May 13, 2012 8:09 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1469
This seems to be a bug/limitation with LWJGL.
http://lwjgl.org/forum/index.php?topic=3610.0
http://lwjgl.org/forum/index.php?topic=2969.0;wap2
viewtopic.php?t=3132

Seems like better practice would be not to rely on initial axis values until controller events have begun. You'll need to look into LWJGL for that.

Unfortunately I haven't worked much with controller inputs. I'll have access to a PS3 controller in a couple days so maybe I can start looking into refactoring Slick to use the event system.


Top
 Profile  
 
PostPosted: Wed May 16, 2012 9:40 am 
Offline

Joined: Fri Dec 16, 2011 5:15 pm
Posts: 6
Everything seems to work OK after any button has been pressed, so it should be fine in-game.

Incidentally, how are you folks using a PS3 controller on your computer? I'd rather use that if it's easy to set up :)

nick


Top
 Profile  
 
PostPosted: Wed May 16, 2012 12:03 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
well, theres 2 ways (that i know of). One is MotioninJoy http://www.howtogeek.com/howto/45610/how-to-use-your-ps-3-controllers-as-a-joystick-for-your-windows-pc/ and the other is a simple SIXAXIS driver http://dl.qj.net/playstation-3/tools-and-utilities/sixaxis-driver-for-pc.html.

I use the second one. Apparently, it might be a little weird getting it working on windows 7. I use it on windows 7 though. What i do is, connect the pad to the usb port, run the ps3sixaxis_en.exe, press the Home button, run the exe again, and it should work.

If you're planning on releasing a game, allowing gamepad support, i would advise sticking to actual pc gamepads though, like a logitech pad or the 360 pad even though theres that axis bug/issue, which does actually affect the game, because, if your character can move, it will be moving.

I was thinking of how to get around it, and thought maybe needing to "press start" to load the main game menu (like for example, in street fighter game and so on). That might be enough to set the axis back to 0, right?


Top
 Profile  
 
PostPosted: Wed May 16, 2012 1:56 pm 
Offline

Joined: Fri Dec 16, 2011 5:15 pm
Posts: 6
Awesome, I'll try the SIXAXIS driver, I much prefer the PS3 controller to the Xbox one. I agree what you say, it's probably better to support the Xbox controller by default and yes, I think the axis thing won't be a problem in game as the axes seem to sort themselves out after any button has been pressed.

cheers!

nick


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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