Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (606)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  how to get JInput to work under linux?  (Read 5584 times)
0 Members and 1 Guest are viewing this topic.
Offline TheBohemian

Junior Devvie




Java will rule them all!


« Posted 2004-01-13 05:20:00 »

I have problems to see any devices in the linux version. Can someone explain me which kernel options are required?

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #1 - Posted 2004-01-13 05:42:42 »

Hi
 First question, what kernel are you running, 2.6 series?

Cheers

Endolf

Offline TheBohemian

Junior Devvie




Java will rule them all!


« Reply #2 - Posted 2004-01-15 16:47:15 »

Of course 2.6. I am following JInput development since may last year and know from one your posts that it only runs on 2.5+. Smiley

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #3 - Posted 2004-01-15 17:19:19 »

Hi
 You need to make sure of the following options

CONFIG_INPUT=y
CONFIG_INPUT_MOUSEDEV=y

if you want joystick support add

CONFIG_INPUT_JOYDEV=y

CONFIG_INPUT_EVDEV=y

CONFIG_INPUT_MOUSE=y and
CONFIG_MOUSE_PS2 or
CONFIG_MOUSE_SERIAL for your legacy mouse, ignore if you have a USB one

you'll need to make sure you have the appropriate joystick drivers loaded, if you have a USB, non force feedback joystick then you will be fine, otherwise you will need drivers and maybe gameport drivers if you are using an old gameport on a soundcard type thing.

CONFIG_USB_HID=y and any drivers for USB devices you want to show up

I think thats it, let me know if something inparticular doesn't work

Cheers

Endolf

Offline Conzar

Junior Devvie




There is nothing common about common sense


« Reply #4 - Posted 2004-01-18 18:27:29 »


Also will this work with 2.4.x kernels?

Ubuntu
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2004-01-18 20:34:48 »

Look 3 messages back.
(The answer is no.)

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Conzar

Junior Devvie




There is nothing common about common sense


« Reply #6 - Posted 2004-01-18 23:07:18 »

Quote
Of course 2.6. I am following JInput development since may last year and know from one your posts that it only runs on 2.5+


Quote
Look 3 messages back.


This doesn't answere my question.  Just because 2.4 wasn't supported maybe a year ago, or from whenever that guy read the posts doesn't mean that it isn't supported now.  

So why isn't the 2.4 kernel supported?  Is there a big differnce in how devices are used in 2.5+ kernels?

Ubuntu
Offline cfmdobbie

Senior Devvie


Medals: 1


Who, me?


« Reply #7 - Posted 2004-01-18 23:16:51 »

Quote
So why isn't the 2.4 kernel supported?  Is there a big differnce in how devices are used in 2.5+ kernels?


Spot on.  I expect you can find the details if you search for them.

Edit: I'm in a generous mood: Grin

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jinput;action=display;num=1058288140

Basically, things couldn't work the way the team wanted them to with the way the 2.4 kernel handled things, but 2.5 added a new method of access which made everything possible.

Hellomynameis Charlie Dobbie.
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #8 - Posted 2004-01-19 15:21:30 »

Hi
 Yeah, joysticks and USB devices *should* work fine in 2.4, but I've not tested it. Under 2.6 *any* keyboard and/or mouse will show up as an event device in /dev/input, under 2.4 they don't. The event interface makes life very simple and means that jinput doesn't have to cope with every single mouse protocol, microsoft and logitec mice for example don't talk the same way with ps2 ports, so I would have had to written device drivers for each one, keyboards would have been simpler though. So thats why we have the requirement for 2.6, but like I said, if you are all USB, then you should get /dev/input/event* devices anyway, so it should work fine.

HTH

Endolf

Offline TheBohemian

Junior Devvie




Java will rule them all!


« Reply #9 - Posted 2004-01-22 17:00:10 »

Yahoo!!! This works!

I have tested this on Gentoo Linux with kernel 2.6.1.

But some notes on this:
1)
I had to add write permission on the event objects for 'others': Isn't read permission sufficent? Thats annoying because new hotplugged devices won't be recognized until I change the access rights.

2)
My Thrustmaster gamepad (recognized as "Mega World") is in fact a digital pad but JInput tells me it is analog and the values for x and y are 0,004 in released state (However when pressed everything is alright..)

3)
The 12 buttons of the gamepad were named by some unknown scheme. In Windows it just says 'Button i' but in Linux names like 'Button A' or 'Left Thumb Button' were given. These names are not correct with my particular gamepad.

Although there are some minor flaws I am very happy with that library especially because it recognizes additional mice as separate devices (Which is impossible on Win, I think).
I suppose this is true for additional (USB-) keyboards too?

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #10 - Posted 2004-01-22 17:15:14 »

Quote
Yahoo!!! This works!

Great! Smiley

Quote
I have tested this on Gentoo Linux with kernel 2.6.1.

i'm using gentoo too, but that box has 2.6.0 on it still, not that thats important Smiley

Quote

1)
I had to add write permission on the event objects for 'others': Isn't read permission sufficent? Thats annoying because new hotplugged devices won't be recognized until I change the access rights.

no, read isn't enough, to send requests to the device you have to write to it, also forcefeedback will need write permissions, but even non ff stuff needs it. sorry.

Quote

2)
My Thrustmaster gamepad (recognized as "Mega World") is in fact a digital pad but JInput tells me it is analog and the values for x and y are 0,004 in released state (However when pressed everything is alright..)

Digital means 0 or 1, your axis report -1 to +1, so it's classed as  analog, it's picked up by the kernel driver, so there is nothing we can do, also, any axis that has a positive and a negative is analog.

Quote

3)
The 12 buttons of the gamepad were named by some unknown scheme. In Windows it just says 'Button i' but in Linux names like 'Button A' or 'Left Thumb Button' were given. These names are not correct with my particular gamepad.

Tha naming is done by linux, in the input modules in the kernel, as far as I can see *no* linux devices can name their own buttons, or axes, they get to choose one from the list and thats it.

Quote

Although there are some minor flaws I am very happy with that library especially because it recognizes additional mice as separate devices (Which is impossible on Win, I think).
I suppose this is true for additional (USB-) keyboards too?


Coo, hadn't though of that, this is the first machine I've had more than one k/b connected too, and I don't have jinput on it yet (still building it with linux). But I think it should do. Interesting is when you enable things like event support for the pc speaker and it shows up in the jinput test apps Smiley, no axes or buttons, just amusing, guess I'm just sad enough to laff at that Smiley

Cheers

Endolf

Offline TheBohemian

Junior Devvie




Java will rule them all!


« Reply #11 - Posted 2004-01-22 19:51:52 »

Hello Endolf:
The stuff is working but now I tried to actually use JInput(Linux) in a game and the following problems came up:

1)
My gamepad is not identified as such. Instead JInput recognizes it as an unknown device. This is rather bad because this way I cannot programmatically decide what kind of polldata I can expect.

2) Then I went over to the axes:
Using Controller.getAxis(Axis.Identifier.BUTTON) is useless because it currently returns null and otherwise would give me no possibility to choose from one of the 12 buttons the gamepad has.

Then I took the direct approach with Controller.getAxes() which gave me all the wanted Axes-implementation but again it is hard to decide whether one of them is a button. For a real axis (eg: X) this is true:
1  
axisx.getIdentifier().equals(Axis.Identifier.X)


but for a button:
1  
button.getIdentifier().equals(Axis.Identifier.BUTTON)

is false. And that would be the last way to find out of what type that thing is.

Please help. Cry
I am really interested in JInput. So if you want me to test things out and such just call me.

BTW: I am using a current version of JInput - downloaded some hours ago.

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #12 - Posted 2004-01-22 21:23:41 »

Hi
 Do you get all the axes and buttons and responses you expect if you try the java webstart version here ?

Cheers

Endolf

Offline TheBohemian

Junior Devvie




Java will rule them all!


« Reply #13 - Posted 2004-01-22 23:19:26 »

Webstart version version works but I have no problem with the responses with the local JInput here.

My own jinputtester can enumerate all devices and show their polldata, too. But the tester is somewhat dumb: it isnt neccessary to know whether some axis is a button or not. Problems arise when I actually do something meaningful with the data and what to interpret it.

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #14 - Posted 2004-01-23 12:07:46 »

Hi
 Do you have a website you could post your code to for us to look at, or the relivant bits of it?

Cheers

Endolf

P.S. I probably won't get to look at it till next week now

Offline Conzar

Junior Devvie




There is nothing common about common sense


« Reply #15 - Posted 2004-02-07 04:50:26 »


Hey.  I am using gentoo 2.6.1 kernel and I am getting the following error for the keyboardtest.java.


Exception in thread "main" java.lang.NullPointerException
       at KeyboardTest.keyboardupdate(KeyboardTest.java:26)
       at KeyboardTest.<init>(KeyboardTest.java:19)
       at KeyboardTest.main(KeyboardTest.java:39)

Do you guys think this is a classpath/environment path problem?


Thanks

Ubuntu
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #16 - Posted 2004-02-09 16:33:24 »

Hi
 It looks like a null pointer exception ;P, but without any of your code I can't tell.

Cheers

Endolf

Offline Conzar

Junior Devvie




There is nothing common about common sense


« Reply #17 - Posted 2004-02-09 17:09:02 »

Ah, I got this either on the formums here or from the jinput demos stuff.  

Anyways, here it is:


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
import net.java.games.input.*;
public class KeyboardTest {
  Keyboard kb = null;
  public KeyboardTest() {
   //ControllerEnvironment ce = LinuxEnvironmentPlugin.getDefaultEnvironment();
    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
    Controller[] cont = ce.getControllers();
    System.out.println("cont: " + cont.length);
     for (int i = 0; i < cont.length; i++) {
       if (cont[i].getType() == cont[i].getType().KEYBOARD) {
         kb = (Keyboard) cont[i];
      }
    }
    for(int i = 0; i < 100000; i++) {
      keyboardupdate();
    }
    System.out.println("done...");
  }
  public void keyboardupdate() {
    kb.poll();
    Axis[] ax = kb.getAxes();
    for (int x = 0; x < ax.length; x++) {
      float num = ax[x].getPollData();
      if (num != ax[x].getDeadZone()) {
        if (ax[x].getName().equalsIgnoreCase("key 110")) {
          System.out.println("up arrow");
        }
      }
    }
  }
   public static void main(String []args){
      KeyboardTest kbt = new KeyboardTest();
   }
}


Ubuntu
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #18 - Posted 2004-02-10 04:57:05 »

Hi
 Thats not the code you are running, the stack trace starts at 39, but the code you posted doesn't have 39 lines, the other lines don't point to anything that makes sense either, either you posted the wrong code, or you have a classpath issue that is causeing you to run a different KeyboardTest class.

HTH

Endolf

Offline Conzar

Junior Devvie




There is nothing common about common sense


« Reply #19 - Posted 2004-02-10 11:58:54 »

Nope, the error I get is from running KeyboardTest.  Note, in the above code, I removed spaces and other comment stuff so thats why there isn't a line 39.  I did this so it wouldn't take up so much space in the forum.

So the null pointer is caused by this line
1  
  kb.poll(); 


Here is how I'm setting up my class path and stuff.

java -cp .:/opt/java/java-gaming/jinput.jar:/opt/java/java-gaming/linux.jar:/opt/java/java-gaming/jutils.jar -Djava.library.path=/opt/java/java-gaming KeyboardTest

Ubuntu
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #20 - Posted 2004-02-10 20:20:57 »

Hi
 I was right, thats not the code you are running, the code you are running has the comments in Smiley, ok, if kb.poll() is causing the null pointer then I guess kb is null. That means it's not found a controller of type KEYBOARD (looking at your constructor). How many controllers are listed when you dump cont.length?

It looks like it is due to the plugins code. the linux.jar should be in a directorycalled controllers that is located from where you are running. Either that, or you can specifiy the class to use for the environment with the property jinput.plugins and use the classname of the plugin, in this case net.java.games.input.LinuxEnvironmentPlugin. But by default the controllers directory is scanned for any plugins so you should use that ideally.

HTH

Endolf

Offline Conzar

Junior Devvie




There is nothing common about common sense


« Reply #21 - Posted 2004-02-10 22:46:10 »

0 controllers are listed.

so the directory called 'controllers' should be in the same directory as the code that is to be executed?  I've tried that and it didn't work.

Ubuntu
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #22 - Posted 2004-02-11 05:12:46 »

Was the linux.jar in there?

Offline Conzar

Junior Devvie




There is nothing common about common sense


« Reply #23 - Posted 2004-02-11 12:17:44 »

yep.  maybe I'm not spelling the directory correctly???

Ubuntu
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #24 - Posted 2004-02-11 16:01:48 »

Hi
 Take a look at the layout of the ready to run binaries, and mirror it, that should get you running.

Cheers

Endolf

Offline TheBohemian

Junior Devvie




Java will rule them all!


« Reply #25 - Posted 2004-02-11 17:06:18 »

Why is that strange plugin mechanism needed btw? And aren't there enough of such mechanisms (Eclipse?!?)?

I once read that it would be possible to selectively load multiple plugins. But I am wondering how many plugins one need per machine? I think every OS offers only one API for comprehensive input management. Well one could write a jinput plugin using Win32 API oder DirectInput but what would be the benefit?

I am very happy with the way JDBC drivers are loaded or every other classpath-compatible library. But Jinput seems to be doomed to suffer not only from features but also from a really odd plugin mechanism.

@Endolf:
I am going to provide you with problematic sample code (see end of 1st page) just when my exams are over .... (2 weeks or so)

cya

TheBohemian

---------------------------------------
my favorite OS: http://jnode.sf.net
Java 1.5 -> 1.4 converter: http://retroweaver.sf.net
Offline Jeff

JGO Coder




Got any cats?


« Reply #26 - Posted 2004-02-11 21:03:02 »

I'll take Design for 200, Bob Smiley

The plug-in mechanism exists fro a few reasons:

(1) To make the fundemental library platform neutral.  The only cdoe that is paltform specific is well-isolated in the plug-ins.  This is a stability feature.

(2) To allow for arbitrary additional controllers.  (eg See the post by the guy who wants to support his flock-of-birds position detection system.)

Fundementally I believe its a strong, good mechanism and was written for the job at hand.  I don't know eclipses plug-in structure, but I suppose someone could as easily ask why Eclipse came up with one when NetBeans had had one for years.  If you did you  would likely get a similar answer.

As the JUtils plug-in system has already proved useful to another project (not a core project) here I think its proving out that its combination of simplicity and features hits a sweet spot for some apps at least.



Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Jeff

JGO Coder




Got any cats?


« Reply #27 - Posted 2004-02-11 21:05:24 »

FWIW btw I am NOT happy on a personal level with the JDBC solution.

Having to put a string reference to the driver  into the context of the app to me is just wrong.  Drivers are a matter of environment, not application.  And havign to do a manaul class load that you throw away just so it can run its static initializers and register itself IMO is very very ugly.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Conzar

Junior Devvie




There is nothing common about common sense


« Reply #28 - Posted 2004-03-17 17:11:33 »

Hello again.

I'm frustrated with getting this to work.  I don't understand the directory structure needed to get the JVM to find the plugin and I don't understand the jinput.plugins environment variable.

Could someone clear this up.  Maybe write a small howto or some documentation on how this works?  If there is such documentation, please point me there.

Thanks

Ubuntu
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #29 - Posted 2004-03-18 04:55:54 »

Hi
 Jeff is working on such a document, but I suspect he is rather busy with GDC right now. If you get the nightly builds it has the directory structure in it.

Cheers

Endolf

Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Elsealabs (20 views)
2014-12-28 10:39:27

CopyableCougar4 (21 views)
2014-12-28 02:10:29

BurntPizza (25 views)
2014-12-27 22:38:51

Mr.CodeIt (15 views)
2014-12-27 04:03:04

TheDudeFromCI (20 views)
2014-12-27 02:14:49

Mr.CodeIt (26 views)
2014-12-23 03:34:11

rwatson462 (60 views)
2014-12-15 09:26:44

Mr.CodeIt (48 views)
2014-12-14 19:50:38

BurntPizza (98 views)
2014-12-09 22:41:13

BurntPizza (117 views)
2014-12-08 04:46:31
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!