If I attach a controller, say a gamecube or ps2 controller, to my computer through some sort of attachment how can I read input from it for my (jogl) game?
See JInput
Although I’m not sure how a gamecube or ps2 controller will function. My gamepad (Logitech Wingman) works happily through JInput.
Kev
Don’t forget JXInput. Whatever shows up as a DirectInput-device will be usable.
And - with JXInput you can code with virtual or auxiluary devices so that your game works when the control is NOT available.
Look at FlyingGuns as an example, where you can use joystick, mouse or keyboard … even simulatniously … same code…
So to plug my own project, and for completeness.
All of the above is also true for JInput. You do virtual control devices by writing plug-ins.
JInput is currently ported to Win32, OSX and Linux. On Win32 it supports DirectInput devices as well as the Win32 plug-in also calls DirectInput. The linux and OSX developers can tell you the details of those plug-ins.
JInput is part of the 3 current “core” APIs that the sun Game Technology Group is supporting. (JOGL, JOAL, JInput). Having said that, there are cetainly other API sets out there that work fine if they meet your needs better (LWJGL, JXInput, JavaJoystick, etc)
thanks 8)
What I meant is that JXInput supports high-level structures that allow e.g. to have an ‘Axis’ (like a joysticks x-, y- or z-axis) only by using 'Button’s (e.g. from a joystick again or a keyboard. Like this one:
JXKeyboardInputDevice kd = JXInputManager.createKeyboardDevice( comp );
Button left = kd.createButton( KeyEvent.VK_LEFT );
Button right = kd.createButton( KeyEvent.VK_RIGHT );
JXVirtualInputDevice vd = JXInputManager.createVirtualDevice();
VirtualAxis vaileron = vd.createAxis( Axis.ID_X );
vaileron.setButtons( right, left );
vaileron.setTimeFor0To1( 1000 );
vaileron.setTimeFor1To0( 500 );
vaileron.setName( "Aileron" );
Or something that allows for ‘overlaying’ axes and ‘or’-ing buttons:
Axis aileron = new LatestChangedValueAxis( vaileron, mouseaileron );
Button trigger = new OrButton( joysticktrigger, mousetrigger );
FlyingGuns shows user extensions (that I may mave to JXInput). E.g. a ‘MouseDevice’
that creates x/y axes from mouse movements.
JInput unders Linux will expose any joysticks and / or event devices. That means almost anything with a USB interface. My scanner shows up there with 3 buttons, which in theory, I could use in a game for input :). LWJGL, and by extention JME use/can use JInput under the covers.
Endolf
I had a problem with JXInput crashing on certain machines. It turned out it was some USB keyboard device enumerating 665 buttons!!
This caused a buffer overflow in my code (shame on me :-[ )