Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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  
  Issue Finding Controllers (Solved)  (Read 1914 times)
0 Members and 1 Guest are viewing this topic.
Offline forfor573

Junior Newbie





« Posted 2009-04-20 07:10:32 »

Hi everyone.  First off, I'm excited to use JInput, it looks like a lot of work has gone into it and I'm pretty impressed with what I've used so far.  I'm attempting to integrate an Xbox360 controller into a project i'm working on and using the jinput-test.jar I can press buttons, move the joystick etc etc.  Interestingly enough, it's also showing the USB Mouse attached to my computer.

However, when I get a controller list using this standard method:
1  
2  
3  
4  
5  
6  
7  
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] controllers = ce.getControllers();

for( int i = 0; i < controllers.length; i++ )
{
    Print(controllers[i].getType().toString(), true);
}


it only finds my laptop keyboard and mouse, none of the USB devices that are plugged in.  I'm on Vista 32 and like I said, most everything appears to be working.  Is the source for jinput-test.jar available anywhere?  That would be a good start but I couldn't find it on the CVS or anywhere else.

Any help on what I'm doing wrong or a push in the right direction would be much appreciated!
Thanks!
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #1 - Posted 2009-04-20 08:05:23 »

Hi

You can find the source for JInput here. The stuff that ends up in the jinput-test.jar is coreAPI/src/java/net/java/games/input/test/.

You mention the 360 controller and then say nothing plugged in via USB is recognised, what else is plugged in but not recognised?

The 360 controller is a wierd one as microsoft decided that directx wasn't good enough for it, and introduced xinput (not to be confused with xinput, the input interface under X windows). JInput doesn't support either xinputs as yet. I believe there is also a directx driver for the 360 controller, but I don't think it supports 100% of the controllers functionality.

Cheers

Endolf

Offline forfor573

Junior Newbie





« Reply #2 - Posted 2009-04-20 08:48:22 »

I think I may have discovered a large part of the problem, although I'm not sure how to fix it.

First of all, the other USB device found is the attached USB mouse (when I run jinput-test.jar using the suggested method shown below)

1  
java -Djava.library.path=. -cp jinput.jar;jinput-test.jar net.java.games.input.test.ControllerReadTest



What's interesting, is that I'm doing my development inside netbeans for now, in which I called the ControllerReadTest function from within my own main.  When it launches, it too shows only my laptop mouse and keyboard.  Similiarly, when I launch the automatically generated JAR file from double clicking it in windows explorer, the ControllerReadTest window pops up, but this time there are no controllers found.  This must be related to netbeans?

I have the necessary .dlls and JAR files appended to the values in my main PATH variable.  Do you have any suggestions, particularly for development in netbeans?  There must be a link i'm missing.  I added the file to the classpath and imported it as a local library (which worked, when adding it to the classpath did not).

Anyway, thanks for taking this up!  I appreciate it.  Look forward to hearing back  Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline forfor573

Junior Newbie





« Reply #3 - Posted 2009-04-20 09:02:25 »

also, in case I wasn't 100% clear, when I run the ControllerReadTest(); in, say, C:\JInput, it works excellent.  The XBox controller is found and it reports the status of everything to me.

It is when I run it from inside, say netbeans that nothing plugged in via USB is found.

Any idea?  Thanks!


*** Update ***
Okay, so I gave something a shot (with my limited understanding of what's happening here).

I modified the runline to be:
1  
java -Djava.library.path=C:\JInput\ -cp C:\Users\...\NetBeansProjects\XBoxController\dist\XBoxController.jar MainJFrame


And it worked perfectly, XBox 360 controller and all.  This same project (exact same file) run inside netbeans does not give the same results.  So...

What this indicates to me is that I need to set the java.library.path for this project somehow?  I would guess that question is unrelated to actual JInput issues but if someone wouldn't mind helping me then I'm sure some peole would find it useful.  I'll be happy to throw a little guide to making JInput work easily with Netbeans if you would like.  That's especially useful for newbies like myself  Smiley
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #4 - Posted 2009-04-20 12:33:07 »

Hi

the native files (dlls on windows) are loaded by the JVM from java.library.path. This *must* be set to the folder containing the files at runtime. I havn't used netbeans for years, so I have no idea how to set it.

A quick google suggests you can pass properties to the ant command that launches the project in netbeans, the one your after is the java.library.path, this needs to be set to the folder containing the natives for your platform.

HTH

Endolf

Offline forfor573

Junior Newbie





« Reply #5 - Posted 2009-04-20 17:04:39 »

Okay, my problem was solved.  A rested pair of eyes helps tremendously.

There are two ways to get the natives (dll's) to work with netbeans.  There may be more, but these are definitly sufficient, at least for now.

1) Netbeans Specific:
Right-click your project -> Properties -> click on "Run" -> Under VM Option's type: -Djava.library.path=C:\JInput        // this was where my JInput files resided.

2) Generic:
Copy and paste all .dlls into your C:\Windows or C:\Windows\System32 folder


Anyway, I appreciate all your help Endolf.  I'm looking forward to using this thing now  Smiley
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #6 - Posted 2009-04-20 19:53:52 »

Please don't do number 2, it will cause all sorts of headaches if you try applets or other versions of JInput Smiley

Endolf

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.

SHC (24 views)
2014-11-25 12:00:59

SHC (23 views)
2014-11-25 11:53:45

Norakomi (22 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (68 views)
2014-11-07 19:57:14
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!