JInput introduction

I found the problem in my deployment. In fact it was not related to the deployment, the problem was the fact that I used the DirectInputEnvironmentPlugin class directly in the code. Don’t ask me why I did that. I think I didn’t relalized that it was specific to DX.

This bug fixed, I have now another one that occurs on Linux. I can initialize the plugin but no controller is found with the call ControllerEnvironment.getDefaultEnvironment().getControllers();

Any idea why it behaves like that?

For your information the OS is SUSE (version 8 I think) with KDE 3.1 running on a Pentium 3.

Thanks in advance.

[quote] I can initialize the plugin but no controller is found with the call ControllerEnvironment.getDefaultEnvironment().getControllers();

Any idea why it behaves like that?
[/quote]
Its a kernel 2.4 based system that why only USB-devices will show up and you even need to allow read & write access to the event devices.

Try this:
run ‘cat /dev/input/event’ as a user and play around on your controllers (mice, kbs, sticks etc). if garbage is displayed on your console everything is fine. if you run into problems with access rights change them. if it tells you that there are no devices (= device file exists but no physical device) complain on this board and ask someone (eg. endolf & me) to support the joystick & keyboard API on Linux which is the pre-2.6 way of accessing input hardware :slight_smile:

you may do cat on mouse and js to verify that it works without problems there.

In theory jinput on a 2.4 kernel will pick up the joysticks and any USB devices, it’s the keyboard and mouse (non usb) that are the only problem. That was one reason for proposing the AWT plugin for mice and keyboards (which is still on my todo list). The major problem is that there will be no axis names for a joystick, a standard joystick plugged into a game port (if it’s USB all will work fine anyway, i think) you can get no axis names. Thats why currently the first linux plugin tries to find an event device descriptor for each joystick. It uses the old joystick interface as I found the data comming from the event interface was a little more than dodgy, like my digital joystick reported axis values from -256 to 256 if I recal, yet the centre position was not 0 and the axis ranges were not even. That was after running the jscal program, and the joystick interface reported the whole range and a centre position of 0, and although it moved a fraction even when stationary, it was all within the null zone.

Endolf

Thanks for support TheBohemian and endolf. What I understand is that there is no easy way to use JInput on Linux for the keyboard if it is not a USB device?

I am thinking of implementing a fallback IO mode based on the AWT event model in case JInput is not working for the requested device. Is there a better way of doing this without AWT events?

If you arn’t using a 2.6 kernel that is correct, although like I said, I’m planning on an AWT plugin, that will hopefully solve your problems. I’m in the middle of moving house right now, so I’m stuck with a windows only laptop, which means I should be able to get some of the non linux jinput things done, and you never know, I might even get some of my own game done :slight_smile: (was that pig just fly past the window)

Endolf

At first: Could some mod move the discussion started by TheAnalogKid in a separate thread?

And now:
Here is the link to my first JInput tutorial:
https://freefodder.dev.java.net/tutorial/jinputTutorialOne.html

Have fun!

[quote]At first: Could some mod move the discussion started by TheAnalogKid in a separate thread?
[/quote]
Only by copying and pasting, and getting it all under the moderators name as if they’d said it :(. YaBB is too crappy to let mods simply “move” a chunk of a thread :(. Although maybe ChrisM can do this…

So you decided you didn’t want it on JGF then? If so, would help to know why (so hopefully we can improve it with version 3, coming soon)

[quote] So you decided you didn’t want it on JGF then? If so, would help to know why (so hopefully we can improve it with version 3, coming soon)
[/quote]
I just started coding and typing two days ago and did not think about how to publish it. I remembered that there are these JOAL tutorials and borrowed a bit of their look & feel.
Finally the tutorial is CCed: You can do nearly everything with the document even without asking me :slight_smile:

Just wanted to mention that I have updated the first post again and added links to JInputTester.

That first post should be part of the Wiki - is it?

I can build the oddlabs version fine, but when I test it with my own code (which worked earlier with this version of jinput: http://www.newdawnsoftware.com/resources/jinput/?C=M;O=D)
it is not finding a force feedback steering wheel I have connected. I have the latest version of the sources with the raw plugin commented out. I tried various combinations with dxinput.jar and the other dlls in the same folder or a “controller” folder. I tried various values for -Djinput.plugins.
It recognizes the directx plugin, but only lists the mouse and keyboard. It says “Failed to create rumblers: Failed to create effect (Ox80070057)”.

I was just wondering where are the right places to put all the jar files and dll files, if that is the problem. Thanks for any help.

hmm I can’t seem to follow the intro. I’m trying to get JInput set up but even with this intro I just don’t know what I’m doing (in terms of directories etc.) like how do i find the folder mentioned below to do this?

[quote]1) the easiest but most (system) polluting way:
create a folder named ‘controller’ inside your ${jre.home}/lib/ext folder and copy the two files in.
[/quote]
Also, I downloaded the Jinput thing and I’m not sure what files are supposed to go where,

I downloaded the file jinput_windows_2005-06-15.zip which has directories:

(folder) Jinput

jinput.jar
jutils.jar

(sub-folder)controller
dxinput.dll
dxinput.jar

are these all the files necessary to start using the API?
what exactly do I need to do next to get it running? I am on windows XP by the way.

Any help would be greatly appreciated!

Jim

Hi

Look in the jinput2 thread, and find the builds Elias posted there. They are of the newer jinput builds and should work.

Endolf

Thanks, but which link do i use? The first link is loads of directories and stuff and the second link is a zip, i downloaded the zip and put all the files in a folder and tried to run the ControllerReadTest from that folder but it wouldn’t work…

So nobody can help me out any further?

Hi

Go to jinput.dev.java.net, On the left hand menu select ‘Documents & Files’, click on the ‘Combined’ folder and get the latest combined binaries file. This contains all the Java and all the native binaries.

Extract the zip somewhere.

The jar file needs adding to your classpath and you need to set -Djava.library.path to point to the folder with the .so, dll’s and jnilib in.

This layout will work on any of the supported platforms.

There are no tests included in the distribution currently, but I can upload the test jar if you want, and that would need adding you your classpath too.

HTH

Endolf

Firstly, thanks a lot for the help, I really appreciate it! But if ye could just bear with me, I have downloaded the files and extracted them to a folder C:\Java.

I went to environmental variables and in “user variables” I appended C:\Java\jinput.jar to the CLASSPATH. Is that correct?
Do I have to add anything in the system variables beneath?
Also, to set the -Dpath library.path thing, where do i do that and also could you give an example of using this command?

I know I’m asking alot but there is nowhere else I can go, I would really appreciate if you could help me further.

Thank you.

bump

Erm, it would work, but it’s not the recommended way.

I sugest you do some research on the java command line. Type ‘java’ on the dos prompt to get a list of the switches you can use. Take particular not of the -D and -cp switches.

Are you trying to use jinput in an existing app? or just run the tests?

Endolf

well first I would like to figure out how to use it if i got it up and running by doing some test apps. Then i would be using it in a game app