DX8 Controller assertion?

I’m giving JInput’s support for controllers a whirl, however I get a funny assertion poping up.

Triggering the assert from:


            ControllerEnvironment env = ControllerEnvironment.getDefaultEnvironment();
            Controller[] controllers = env.getControllers();
            System.out.println("Found "+controllers.length+" controllers.");

java.lang.AssertionError
      at net.java.games.input.DirectInputEnvironmentPlugin.addDevice(DirectInputEnvironmentPlugin.java:165)
      at net.java.games.input.DirectInputEnvironmentPlugin.enumDevices(Native Method)
      at net.java.games.input.DirectInputEnvironmentPlugin.enumControllers(DirectInputEnvironmentPlugin.java:133)
      at net.java.games.input.DirectInputEnvironmentPlugin.<init>(DirectInputEnvironmentPlugin.java:113)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
      at java.lang.Class.newInstance0(Class.java:296)
      at java.lang.Class.newInstance(Class.java:249)
      at net.java.games.input.DefaultControllerEnvironment.scanControllersAt(DefaultControllerEnvironment.java:188)
      at net.java.games.input.DefaultControllerEnvironment.scanControllers(DefaultControllerEnvironment.java:169)
      at net.java.games.input.DefaultControllerEnvironment.access$000(DefaultControllerEnvironment.java:57)
      at net.java.games.input.DefaultControllerEnvironment$1.run(DefaultControllerEnvironment.java:108)
      at java.security.AccessController.doPrivileged(Native Method)
      at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:106)
      at com.vecript.core.entity.DefaultRootEntity.<init>(DefaultRootEntity.java:36)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
      at java.lang.Class.newInstance0(Class.java:296)
      at java.lang.Class.newInstance(Class.java:249)
      at com.vecript.core.entity.EntityFactory.createEntity(EntityFactory.java:78)
      at com.vecript.core.entity.EntityFactory.createEntity(EntityFactory.java:64)
      at com.vecript.core.Scene.<init>(Scene.java:33)
      at com.vecript.core.Vecript.initialise(Vecript.java:183)
      at com.vecript.core.Vecript.main(Vecript.java:289)

The offending code:


    private void addDevice(ArrayList list, long lpDevice,
        int type, String productName, String instanceName, boolean polled) {
        Controller c;
        int category = GET_DIDEVICE_TYPE(type);
        int subtype = GET_DIDEVICE_SUBTYPE(type);
        //System.out.println("Category = "+category);
        if (category == DI8DEVTYPE_MOUSE) {
            c = DirectInputMouse.createMouse(lpDevice, subtype, productName,
                instanceName);
        } else if (category == DI8DEVTYPE_KEYBOARD) {
            c = DirectInputKeyboard.createKeyboard(lpDevice, subtype,
                productName, instanceName);
        } else {
            assert category == DI8DEVTYPE_JOYSTICK; // Asserts here!
            c = DirectInputDevice.createDevice(lpDevice, subtype, productName,
                instanceName,polled);
        }
        if (c != null) {
            list.add(c);
        }
    }

A quick check in the debugger shows that the final else statement checks the catergory is a joystick. Well, close enough its a gamecube joypad hooked up via usb. But the actual catergory is DI8DEVTYPE_1STPERSON :o Is this possibly because its a 6-axis controller?

Running without asserts I obviously don’t get the assertion, but I also don’t get any values back :frowning: All the Controller axies return 0.0 (although it gets a full 18 axies, I assumes this is 6 analog axies + 12 buttons).

Anyone any ideas?

Hi
I have an idea, raise it as a bug on the jinput.dev.java.net issues list :), that way, someone might take a look :). I have some ideas, but havn’t got anything to test with, i’ll add it to my todo list once the issue has been raised prod, unless Jeff has a free second :slight_smile:

Endolf

Cheers, Its raised as issue 2: https://games.dev.java.net/issues/show_bug.cgi?id=2

Checking out other stuff, its seems like it doesn’t find any rumblers for the pad either :frowning: Should return one rumbler I think. Is this a known issue?

Assuming I can get the time to get my system building JInput itself, is there anything specific I could try to see whats going on?

I’ve raised this over here where it belongs (jinput.dev.java.net).

If you buy me a gamecube so I can test the controller, i’ll fix it for you :stuck_out_tongue:

Hi
I’ve just had a quick look at the code and have a reasonable guess at what might be happening, if you can get jinput building we can work something out (off the list, else it will get noisy in here) where I mail you code, and you mail me results, it won’t be quick, but we can probably fix it this way. I don’t have access to a gamecube controller (or any gamepad) and I think that a ‘normal’ PC gamepad won’t show the same error (although some might have troubles). If it comes to it I can mail you the controller plugin bits, but i’m on very restricted bandwidth for personal code (9600bps) as my phone line hasn’t been activated yet.

Endolf

Well i’m downloading the whoppingly large DX9 SDK at the moment, i’ll give you a message when I get things building ok :slight_smile:

Cheers guys. if there’s anything I can do to help now that I’m back, ping me!

Jeff

[quote]Cheers, Its raised as issue 2: https://games.dev.java.net/issues/show_bug.cgi?id=2
[/quote]
That is a busy issues list, isn’t it? I raised issue 1 back in August and it’s obviously still being got around to… ::slight_smile: ;D

[quote]Cheers guys. if there’s anything I can do to help now that I’m back, ping me!
[/quote]
PING

hows about a game cube controller :stuck_out_tongue:

while yer at it, maybe some force feedback kit, I can see that i’m gonna end up in rumbler/ff code, in both linux and windows :), and just as I was getting back into 3d with xith3d :slight_smile:

and whilst the wish list is going. A house away from this dump called london with a nice view, somewhere up in scotland maybe, with a nice big broadband connection, and a salary to write jinput code for as long as I want :), that way I can do my own code in the evenings :). Ahh, the stuff dreams are made of

/me slaps Orangey Tang for interupting his coding plans :slight_smile:

Endolf

I’ve now got things set up at home with Mac OS X 10.2.8 (soon 10.3 yay!) (powerbook G4), WinXP, and RedHat Linux 9.

I have an iShock II game controller with rumblers that works on Mac and Windows. I haven’t a clue how to try it on Linux. I also have a Wingman Extreme joystick with tophat switch that I can try on XP and Linux. Along with PS/2 mouse/keyboard and USB mouse/keyboard.

I don’t have much time to contribute to development, but I will certainly run tests and collect debug output for anyone. Hopefully I can get up to speed with at least the WinXP and MacOS native code and start contributing more there.
I would like to get the rumbler support working.

Hey End,

If a 3rd party game cube controllers would do, I’ll see what i can do. (Sorry, I can’t afford to buy you a whole game cube just for the controller.)

On the rest, well, if I had funding for a JInput programmer, you’ld certainly be tops on the list. We can keep an ear out for folks who might be looking for a Java and Games savvy engineer but I can’t promise much beyond that I’m afraid :frowning:

JK

Unfortunatly its not that simple… To actually plug the thing into a usb port you need an adapter, and the only one avalible I could find I had to import from japan via lik-sang.com.

And before anyone starts pointing fingers at my freaky choice of hardware, LWJGL managed to support it without a hitch :stuck_out_tongue:

[quote]Unfortunatly its not that simple…
[/quote]
Is it ever??? :slight_smile:

Having got some more debug (thanks muchly), dx is failing when it calls the native poll with a DI_NOTATTACHED. This puts the readtest application on alert and it marks the device as disabled. The reason for this isn’t yet established. Further research to get things playing ball is needed.

Endolf

[quote]Hey End,

If a 3rd party game cube controllers would do, I’ll see what i can do.
[/quote]
Thanks for the offer, but as orangy tang pointed out, it’s far to simple a solution :), and I have am wondering right now if there is more to this than jinput getting things wrong, also, sending things from the US is painfully slow and/or expensive, my girlfriends parents who live in deleware sent her some mail by non airmail, it took almost 2 months to arrive (erg). The alternative was rather expensive for the item being sent.

Endolf

Boo
In a vague effort to try and work out wtf is going on, I’m off to try and get a wingman rumblepad cordless USB thingy, which OrangyTang has said is playing silly buggers too. Hopefully next week when i get back from home I can either reproduce it, or give it up as a configuration error and pretend the world is a wonderful place :P. On the plus side for you lot (and the down side for me) either way I will have a controller with rumblers in it, so can start playing with windows and linux rumbler support.

Endolf

Edit: Gamepad purchased, PC world for 40 quid, damn I hope it’s broken OrangyTang, or you get the bill :P, depending on how long I get stuck in traffic, I might start testing tonight, if not, I should be able to try it tomorrow evening after work.

Morning
I played with the controller last night, I get the same problem as Orangy Tang, yet it works fine in fs2004. I did a quick bit of research and found that if I comment out lines 457, 458 and 459 in the input.cpp, where it sets the poll attribute to true, then poll remains at false and it all works fine. I will look into this more tonight, but it looks like we are getting closer now. Orangy Tang, can you try it on your box and let me know if it also fixes the gamecube controller?

Cheers

Endolf

Fixed :slight_smile:

commited to cvs

Endolf