Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (602)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (650)
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  
  Using a gamepad with jinput  (Read 12370 times)
0 Members and 1 Guest are viewing this topic.
Offline Kanne

Junior Newbie

« Posted 2009-12-12 20:17:31 »


I'm trying to use my X-Box gamepad for input. I found this should be possible with the library jinput.
I can detect my gamepad with this library, but thats about it.the hole lot of example code I found won't work. I guess the problem is that the tutorials I found are to old. Jinput has changed over time.

So, how do I get startet best with this? Where do I find stuff that helps (for the current version)?

Thx Wink
Offline Nate

« JGO Bitwise Duke »

Medals: 165
Projects: 4
Exp: 14 years

Esoteric Software

« Reply #1 - Posted 2009-12-12 22:45:40 »

Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

« Reply #2 - Posted 2009-12-13 12:19:07 »

All the information in the getting started with jinput thread should work.



Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kanne

Junior Newbie

« Reply #3 - Posted 2009-12-15 07:51:21 »

Thx....this really helped.

There is one problem left (and I searched for a long time): I can find and use the rumblertest...but how do I acces the rumbler myself? Is there a topic somewhere I was too blind to find?
Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

« Reply #4 - Posted 2009-12-15 09:41:41 »


The javadoc should be enough, you can find it here, although thats just my local copy, so don't rely on it being up to date.

From each controller you can get the list of rumblers it has, and then deal with them.



Offline Kanne

Junior Newbie

« Reply #5 - Posted 2009-12-16 00:59:03 »

OK, now I get the input ...what I press on the controller. I can nicely use the rumblers. (though it shows I have 5 rumblers, but afaik my controller has only 2...whatever)

My (hopefully) last problem:

I repeatedly print which controllers my Programm can see.
It looks something like this:

while (true) {
    Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
    for (Controller cont : controllers) {

    //here are some lines for polling and printing out data


The problem is when I unplug my gamepad it still appears in the list but can't be polled anymore(of course...its not there). When I replug it, it still can't be polled. As well its not found as a new one. The only thing I can do about this so far is restarting my programm.
Is there anything I can do about this? Am I doing something wrong? I don't want to have to restart my programm to find new gamepads, or a repluged one.
Offline endolf

JGO Coder

Medals: 7
Exp: 15 years

Current project release date: sometime in 3003

« Reply #6 - Posted 2009-12-16 06:49:56 »

The answer to that question is in the forum as well. At the moment, JInput does not rescan the controllers. It's focus is as a games API, most gamers have their hardware plugged in when they start a game. That said, it is on the todo list, but no-one has volunteered and I don't get as much time on my own code as I would like. That said, I have 3 days off work between Christmas and new year, so you all might get a late Christmas present from me Wink


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

Jesse (16 views)
2015-07-29 04:35:27

Riven (37 views)
2015-07-27 16:38:00

Riven (18 views)
2015-07-27 15:35:20

Riven (21 views)
2015-07-27 12:26:13

Riven (12 views)
2015-07-27 12:23:39

BurntPizza (30 views)
2015-07-25 00:14:37

BurntPizza (42 views)
2015-07-24 22:06:39

BurntPizza (24 views)
2015-07-24 06:06:53

NoxInc (31 views)
2015-07-22 22:16:53

NoxInc (18 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!