Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  ControllerListeners ineffective ?  (Read 5974 times)
0 Members and 1 Guest are viewing this topic.
Offline parabellum

Junior Newbie




can divide by zero!


« Posted 2007-01-17 10:19:37 »

Hi,

I'm trying to use JInput2 (jinput_combined_dist_20060514) in an emulator project on Windows XP, but I'm currently experiencing some problems related to ControllerListeners : For some unknown reason, it seems that the ControllerListener I registered never get notified about added/removed controllers.

Moreover, the array returned by the getControllers() method is never updated (when I unplug a controller, it's still returned in this array, although the controller cannot be polled anymore - even if I plug it back )

For instance, when I run the following test case with, say, 2 controllers connected, then unplug one (or plug a new one), I get "Available controllers count : 2" print once, and nothing else...

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  
import net.java.games.input.*;

public class TestListener
{
    static public void main( String[] args )
    {
        ControllerEnvironment env = ControllerEnvironment.getDefaultEnvironment();

        env.addControllerListener( new ControllerListener() {
            public void controllerRemoved( ControllerEvent e ) { System.out.println("REMOVED"); }
            public void controllerAdded  ( ControllerEvent e ) { System.out.println("ADDED"  ); }
        });

        int count = -1;

        for(;;) {
            int update = env.getControllers().length;
            if (count != update) {
                count = update;
                System.out.println( "Available controllers count : " + count );
            }
            try { Thread.sleep(200); } catch( InterruptedException e ) { /*empty*/ }
        }
    }
}


Did I do something wrong?

Thanks!
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #1 - Posted 2007-01-17 12:18:16 »

You didn't do anything wrong, they just arn't implemented at the last check.

HTH

Endolf

Offline parabellum

Junior Newbie




can divide by zero!


« Reply #2 - Posted 2007-01-17 13:34:33 »

Oh all right, no wonder then... Smiley
Thanks for the info, Endolf!

By the way, I was wondering if Jinput2 was still an active project, or if it has been discontinued?
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 2007-01-17 17:42:27 »

It's active in as much as if there is things people want/need, that make sence, it generally happens. Late last year I wrote a new plug in that was requested for example. I check the forums here several times each day, and any issues raised in the issue tracker on jinput.dev.java.net I get emailed and look at.

Elias seems to be using jinput activly at the moment, and seems to be spotting the odd thing here and there, and fixese them and checks them in, december was his last checkin.

There are a number of other folks using it too, it's in lwjgl and jME too.

As far as I am aware, at this moment in time, there are no major features being worked on, but that is a reflection of the requests we've had, rather than a reflection of interest from the devs.

Endolf

Offline parabellum

Junior Newbie




can divide by zero!


« Reply #4 - Posted 2007-01-17 18:19:20 »

Good, glad to hear it's still being updated, as it's clearly the java API of choice to access controllers !

If I happen to find some strange behaviour I'll post them here in the future, it might be of use, then... Smiley

Well, actually, I already got an exception yesterday while playing with the library yesterday ; and from the top of my head it looks like the same problem as desribed in this thread : NullPointerException thrown from Poll() method (I'd have to check the exception stack to be sure).

Is this issue resolved in the last checkin yet?
If not, maybe I could be of use and provide you with any extra info / tests that could help regarding the problem ?

Cheers,
Franck.
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #5 - Posted 2007-01-18 07:49:49 »

I commited a fix way back in may last year for that, but never heard anything back from the person who reported it, so I don't know if it worked. Can you post your symptoms and stack trace in a new thread here and I'll take a look.

Can you also let me know if the jinput tests work, or do they fail too?

Thanks

Endolf

Offline parabellum

Junior Newbie




can divide by zero!


« Reply #6 - Posted 2007-01-18 08:42:41 »

Ok, I'll check this evening and post the result.

Franck.
Offline parabellum

Junior Newbie




can divide by zero!


« Reply #7 - Posted 2007-01-18 21:10:35 »

All right, things are clear now...

After several tests, I finally noticed that the fix you were talking about was not included into the build I used (the latest available : jinput_combined_dist_20060514), since I got exactly the same exception as described in the other thread (when using the jinput test class) :
1  
2  
3  
4  
5  
6  
7  
java.lang.NullPointerException
   at net.java.games.input.DIControllers.getNextDeviceEvent(DIControllers.java:62)
   at net.java.games.input.DIAbstractController.getNextDeviceEvent(DIAbstractController.java:62)
   at net.java.games.input.AbstractController.poll(AbstractController.java:219)
   at net.java.games.input.test.ControllerWindow.poll(ControllerReadTest.java:230)
   at net.java.games.input.test.ControllerReadTest$1.run(ControllerReadTest.java:269)
   at java.lang.Thread.run(Unknown Source)


So I checkout the latest version from CVS and compiled it, and the NPE is not here anymore !
Thus I can confirm that your fix works properly.  Smiley

I was just not using the latest sources... My bad, sorry.

Thanks for your time,
Franck.
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #8 - Posted 2007-01-19 07:51:11 »

Looks like I need to do a new build and upload it Smiley

The latest one was October 29th last year. That build should have worked.

Other things have gone in since then, so I ought to do one soon, maybe over the weekend.

Endolf


Offline parabellum

Junior Newbie




can divide by zero!


« Reply #9 - Posted 2007-01-22 11:43:48 »

Indeed, it does.
I don't know how I missed this one, sorry for the mess!   Embarrassed
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 2007-01-22 12:03:25 »

No worries

Answering questions like this at least prove that the API is being used Smiley

Answering questions like this is also alot easier than the technical ones Smiley

Endolf

Offline delauti

Innocent Bystander





« Reply #11 - Posted 2009-07-25 22:35:05 »

Has there been any progress on implementing this feature? I saw a post (can't remember where) made this year (2009) asking which OS's to give preference to. I'd love to see this implemented in Windows. The ability to handle as events removed or added controllers would be wonderful. Or at least re-implement ControllerEnvironment.getControllers() such that it returns an updated array of controllers. At present it appears to, on first execution, get the list of attached devices and then on all future calls return the same list regardless of any hardware changes (removing/adding controllers). I'll happily code the listener and add it to the codebase once getControllers returns accurate information.

Thank you for this great library, many people are using it!
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #12 - Posted 2009-07-26 17:43:21 »

There was some work done (not by me), but they have been unable to release it as open source. So there is nothing we can use other than the experience I gained talking to them whilst helping get it working.

Endolf

Pages: [1]
  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.

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

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

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

BurntPizza (70 views)
2014-12-08 04:46:31

JscottyBieshaar (32 views)
2014-12-05 12:39:02

SHC (44 views)
2014-12-03 16:27:13

CopyableCougar4 (40 views)
2014-11-29 21:32:03

toopeicgaming1999 (108 views)
2014-11-26 15:22:04

toopeicgaming1999 (94 views)
2014-11-26 15:20:36

toopeicgaming1999 (29 views)
2014-11-26 15:20:08
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

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!