DX Plugin Bug

Ok, the bug could be in jinputtester.jar… but it looks deeper than that… probably caused by a bad device driver, but I think we should try to fail more gracefully with it.

With a Logitech iTouch keyboard I get some strange devices showing up, I’m using the jinputtester.jar posted in another thread. The keyboard is listed as three devices:
Keyboard (keyboard)
Internet Keys USB Internet Keys USB
Internet Keys USB Internet Keys USB

Yes those last two are named the same (and are listed with the name repeated)

If I select the first ‘Internet Keys USB…’ device, the jinputtester program starts spitting out this as it tries to poll:

java.lang.ArrayIndexOutOfBoundsException: 72
at net.java.games.input.DirectInputAxis.getPollData(DirectInputAxis.java:148)
at robs.jinput.AxisTableModel.getValueAt(AxisTableModel.java:60)
at javax.swing.JTable.getValueAt(Unknown Source)
at javax.swing.JTable.prepareRenderer(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paintCell(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paintCells(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI.paint(Unknown Source)
at javax.swing.plaf.ComponentUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source)
at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Obviously the tester app is asking for an axis that is out of bounds… but why? It appears to be working fine for the other two devices and the mouse, I assume it queries the number of axis from JInput, so I suspect that this device is reporting bad data to JInput, but if the client code is written correctly, I think the exception shouldn’t happen… even if it is the devices fault, there is little that the client can do… maybe JInput can do something to avoid the problem?, like some sort of internal checks that would avoid listing a device that it detects a problem with? Maybe some sort of blacklist of known problem devices?

Note that ControllerReadTest has the same problem.
Here is the error that it spews…
java.lang.ArrayIndexOutOfBoundsException: 63
at net.java.games.input.DirectInputAxis.getPollData(DirectInputAxis.java:148)
at net.java.games.input.test.AxisPanel.poll(ControllerReadTest.java:63)
at net.java.games.input.test.ControllerWindow.poll(ControllerReadTest.java:224)
at net.java.games.input.test.ControllerReadTest$1.run(ControllerReadTest.java:251)
at java.lang.Thread.run(Unknown Source)

I have checked my code it is relying upon information given by JInput. An array of axes is requested from a controller and handled over to a TableModel that constructs one column for each axis.

This seems to be a strange error you encountered because as far as I know keyboard data is transferred via a 256 byte array in DirectInput (you didn’t mention win32 but I think it is). It may be a problem on the java side thinking to have anything else than a keyboard-like controller and acquiring to less space for ‘buttons’. Well, this may be caused due to incorrect driver interaction with DirectInput …

Yes, it was Win32… I think the keyboard was a bit odd when I tried it on OS X as well… but at the time the JInput support for keyboards on OS X 10.2 was a tad odd. I will try again on OS X and maybe linux. I strongly suspect bogus info is coming from the device itself. I bet it doesn’t follow the USB HID spec properly.

Look what i’ve found here (DirectInputKeyboard.java):


private byte[] keyData = new byte[256];

I think this means that your keyboard isn’t recognized as a keyboard. When it would have been recognized correctly an AIIOB-Exception on index 72 cannot happen with this class …

I have found some comments in the dxplugin that states that the constants used in the java code are taken from dinput header files and that this may be a little bit unstable. Maybe someone has used outdated header files or miss-typed/copy-pasted something.

I will soon add some BeanShell support to my inputtester application. That way you will be able to inspect your input devices even more …

[quote]I think this means that your keyboard isn’t recognized as a keyboard. When it would have been recognized correctly an AIIOB-Exception on index 72 cannot happen with this class …
[/quote]
Ah, but it is…it is recognized as a keyboard AND two other devices. One of those other devices lists a few buttons, sleep, wake up, etc… some that I can’t even find on the keyboard! But the other device causes the index error.

Note that this keyboard has multimedia keys (play,stop,volume up/down, etc.) a scroll wheel, and many programmable keys (Go, Finance, My Sites, Community, Favourites, E-Mail, Shopping, Search, My Home, iTouch)
Logitech Internet Navigator Keyboard P/N: 867150-0100 for anyone that might care.

Strange piece of hardware you’ve get :smiley:
I am interested of what type JInput recognizes the controller ‘Internet Keys USB’. BeanShell is comming …