Archived

This topic is now archived and is closed to further replies.

Peter Svensson

[java] Using a gamepad in Java?

Recommended Posts

not likely, as far as I know. Java was designed to work on diffrent platforms, and a gamepad is not a very popular input device on platforms like linux or solaris. The same thing goes for the middle button of the mouse...

On the other hand, there may be an hidden library somewhere that enables java to comunicate with a gamepad, but it will probably work then on pc''s only (which is probably what you are looking for)

Share this post


Link to post
Share on other sites
The only way that I can think of would be via JNI and then the code would be platform specific and you would not be able to use it in applets due to security reasons.

- Kaijin

"If you find a job that you love you''ll never have to work again."

Share this post


Link to post
Share on other sites
You can use SDL (libsdl.org) to access a joystick through JNI. SDL runs on win&lin (soon MacOSX), all you need to do is write a little bit of C to load a .dll or .so (depending on the platform) wrap 3 or 4 functions, export them to java, and there you go. I''ve found that, on average, C applications are more portable than Java applications.

Share this post


Link to post
Share on other sites
Here''s a crazy suggestion (I have not tried it - yet).

If you want to be able to control your applet based game with a joystick on win32, write an activex component to manage the joystick, then ship the input over to the applet via java script. I do not know if there''s enough power in the java-script layer to do this at a high enough rate tho...

A glitch is that you have to sign the component, but if it is a commercial game, just purchase a cert. Otherwise, sign it as testroot. I think that will work with the default IE security (but will look a bit ugly and cheap .



/ dr-m

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have not found in the current sdk anything to access joysticks or gamepads, however what you will need to look for is an add on sdk, I know that wild tangent has one that will do any variety of gamepads or joysticks they have a tutorial on there section at http://www.wildtangent.com/developer/support/howtos.html
this seems like what you would need, I have a vested interest in using a gamepad in java, as I hope to use it in my senior project, good luck and let us know how it is progressing.

Share this post


Link to post
Share on other sites