We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Gamepads - Joysticks - etc
Pages: 1 2 
Gamepads - Joysticks - etc (Read 5777 times)
Gamepads - Joysticks - etc
May 8th, 2005, 3:19pm
 
Is it possible to use gamepads and joysticks in Processing?

If not, are there any plans of supporting joysticks or other USB devices?

I guess one could use the HID Device on OS X, but I don't know what would be the equivalent on the PC.

How is that situation, and what are the plans?

Re: Gamepads - Joysticks - etc
Reply #1 - May 8th, 2005, 4:40pm
 
You can use JInput. If there is a lot of interest in this, I may create a library (JInput by itself isn't terribly user friendly). Let me know.

Re: Gamepads - Joysticks - etc
Reply #2 - May 8th, 2005, 5:19pm
 
Ok, JInput looks good. I for one, wouldn't know how to make a library for Processing, so if you can do it, it would be great!

I think it makes sense to do that now. Processing is growing so much and people are starting to use it for all kinds of purposes, increasingly for games. A gamecontrol support for gaming interfaces would be awesome.
Re: Gamepads - Joysticks - etc
Reply #3 - May 9th, 2005, 4:32am
 
Kristian,

I think making a library from JInput is a great idea.

Casey
Re: Gamepads - Joysticks - etc
Reply #4 - May 9th, 2005, 4:52am
 
OK. I've got the summer semester starting tomorrow, but as soon as I get a few moments I'll code something up.
Re: Gamepads - Joysticks - etc
Reply #5 - May 10th, 2005, 8:34am
 
Alrighty, I've started on this little project and I wanted to give those of you who might be waiting on it some info:

1) This library will find ALL controllers (including mice and keyboards) so I am working on a method for registering the controllers that will work similar to the Video library's Capture class. i.e. list the controllers then pass a String identifier to the constructor to make a Controller object for that specific controller.

2) Like the JOGL library, this one will not be distributable. This is because there is a hardware-specific plugin that JInput uses to communicate with the OS to find registered controllers. On the plus side, there are plug-ins for Windows, Linux, and MacOSX... they just don't coexist nicely. I may be able to find a way around this eventually, but I will probably not spend time dealing with this at the outset.

3) Installation may be a little strange. The JInput plug-ins have to be placed in the application's root directory (processing-XXXX/) to work. I've been trying to find a way around this so that I can package the plug-ins in the .jar, but the they're being downright cantankerous.

4) Like JOGL, JInput likes to be verbose, especially at startup. Casey and Ben... did you ever find a way to catch the unsolicited output, or are we stuck with it? (here's a sample of what to expect)
Code:
Scanning jar: dxinput.jar
Examining file : META-INF/
Examining file : META-INF/MANIFEST.MF
Examining file : net/
Examining file : net/java/
Examining file : net/java/games/
Examining file : net/java/games/input/
Examining file : net/java/games/input/DirectInputAxis.class
Examining file : net/java/games/input/DirectInputDevice.class
Examining file : net/java/games/input/DirectInputEnvironmentPlugin.class
Found candidate class: net/java/games/input/DirectInputEnvironmentPlugin.class
Adding class to plugins:net.java.games.input.DirectInputEnvironmentPlugin
Examining file : net/java/games/input/DirectInputKeyboard.class
Examining file : net/java/games/input/DirectInputMouse$BallAxis.class
Examining file : net/java/games/input/DirectInputMouse$BallImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonImpl.class
Examining file : net/java/games/input/DirectInputMouse$ButtonsImpl.class
Examining file : net/java/games/input/DirectInputMouse.class
Examining file : net/java/games/input/DirectInputRumbler.class
Creating AIRFLO polling = false
Mouse Mouse
Keyboard (Keyboard)
AIRFLO AIRFLO


I only asked for the following to be output:

Code:
Mouse Mouse
Keyboard (Keyboard)
AIRFLO AIRFLO


Alright, I'll post more when I've made a bit more progress.

--- EDIT: Afterthought ----------

By the way, I'll take suggestions for the name of the library. Right now "Oz" is the best I've come up with. Can you do better? Right now the only exposed class name is "InputController". Sorry, "Controller" conflicts with the JInput class of the same name.
Re: Gamepads - Joysticks - etc
Reply #6 - May 10th, 2005, 2:04pm
 
Hi Kristian. Thanks a lot for doing this. I am looking forwad to try the library out. Some questions/comments:

What do you mean by that it won't be "distributable"? Does that mean that it won't work in an applet? Surely you could distribute it as a program, no?

About the name: Oz is cool, but it is not very descriptive. "GameControl" would be a descriptive name for the lib, but that's perhaps too boring? : ) Or limiting? Is there more the library would do than gamecontrol?

Re: Gamepads - Joysticks - etc
Reply #7 - May 10th, 2005, 2:17pm
 
Njetti,

1) Yes, I mean that it won't work in an applet. You would definitely be able to use it in an installation though.

2) Regarding the name... it was late at night (isn't that a good enough excuse? Smiley) and all I could think about as I was typing up the first few lines was the little man behind the curtain manipulating all the switches and levers... this library will allow you to capture events from all the buttons, switches, levers, etc. that you have plugged into your machine, hence the name. I wanted to avoid a library name like "GameController" because the library will allow you to get ALL controller-based input events, not just GamePad ones.
Re: Gamepads - Joysticks - etc
Reply #8 - May 10th, 2005, 8:47pm
 
when you put it like that 'oz' sounds perfect.
Re: Gamepads - Joysticks - etc
Reply #9 - Jun 4th, 2005, 12:32pm
 
Hi Kristian

Just wondering how work is going with the Oz library? I am looking forward to try it as I think it would be the last important addition to Processings libs.

Good luck with the last bit of work,

njetti
Re: Gamepads - Joysticks - etc
Reply #10 - Jun 7th, 2005, 9:50pm
 
Hey there,

Work is going well with Oz, but I had to put it on hold these last few weeks while I tended to my official responsibilities. I'll try to post something around Thursday, Friday, or this weekend at the latest.
Re: Gamepads - Joysticks - etc
Reply #11 - Sep 3rd, 2005, 3:50pm
 
Dear Kristian!

How's it going now? I know there are quite few of us waiting for the library and this is very exciting. Do you have an alpha version that you could upload somewhere? Are there any problems with the code or is it just summer and sunshine that distracts? : )

Hope all is well
njetti
Re: Gamepads - Joysticks - etc
Reply #12 - Sep 23rd, 2005, 2:20am
 
I'm using Processing for a small project testing reaction speeds using a joystick and was able to co-opt the JavaJoystick driver (http://sourceforge.net/projects/javajoystick/) to do what I needed.

Basically, I copied the /com folder from the distribution into Processing's main directory and copied /lib/jjstick.dll into /Windows/System32.  To use it within Processing:

Code:

import com.centralnexus.input.*;
...

void setup() {
...

framerate(20);

Joystick joy;

try {
joy = Joystick.createInstance();
}
catch (IOException e) {
print ("Joystick error\n");
}
...

}

void draw() {
joy.poll();
print (joy.getX() + " " + joy.getY() + "\n");

if ((joy.getButtons() & 0x01) != 0 && lastheld1 == 0) {
lastheld1 = 1;
pauseToggle();
}
else if ((joy.getButtons() & 0x01) != 0) {
lastheld1 = 1;
}
...

}

...


You can pull out each of the buttons like that (0x02 for button 2, 0x04 for button 3, 0x08 for 4, etc. -- I use button 1 here to pause the program) and joy.getX() and joy.getY() to get the direction (each ranges from -1 to 1).

I should add that I have no affiliation with the JavaJoystick project, though if you have any simple questions on using it, I might be able to help with that.
Re: Gamepads - Joysticks - etc
Reply #13 - Sep 25th, 2005, 6:04am
 
Hi, rcarneva. I've been looking to find a gamepad interface for p5 this last week or two but hadn't come across this driver. So thanks for the link + handy example.

Cheers,
Samuel
Re: Gamepads - Joysticks - etc
Reply #14 - Sep 28th, 2005, 12:19am
 

Pity that the javajoystick project is not cross-platform.
I'd need to get something working for OS X. I've tried jinput which Kristian was going to make a library of for Processing but it has some problems. Any suggestions?

Pages: 1 2