Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Using a gamepad in Java?

Started by Peter Svensson Nov 9, 2001 at 3:04 PM 4 replies 3k views
Original Post
Peter Svensson
Peter Svensson
Hello.... Is it possible to use a Gamepad in Java, and if so, how to do it? //Peter - Cheers!
rouli
rouli
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)
Kaijin
Kaijin
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."
Jim_Ross
Jim_Ross
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.
dr-m
dr-m
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
/ dr-m

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.