LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: wayne on August 06, 2006, 23:14:09

Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 06, 2006, 23:14:09
Hi peeps,

I have just found lwjgl after looking a few other similar projects, I like it  and think I will stay here :)

This is my first post, sorry it's a bug report/call for help!

I couldn't find anything on the forums, but I was hoping if anyone has seen this and knows a suitable fix already?


command:

java -cp  .;res;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.jar;jar\lwjgl_fmod3.jar;jar\
lwjgl_devil.jar;jar\jinput.jar; -Djava.library.path=native\win32 org.lwjgl.test.input.TestControllersjava -version

(The webstart controller  demo fails to start too)

Result:

8 Controllers Found
Microsoft eHome In
Microsoft eHome In
Microsoft eHome In
Microsoft eHome In
Logitech U
Logitech U
Rockfire PS
Rockfire PS


[I do have 2x RockfirePS, the others 2 types look like dups when appearing more than once)


lwjgl info

lwjgl-1.0beta2

Java info:


Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)



Windows Info:

xp-sp2 (media center edition)


JVM crashfile:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c93426d, pid=4944, tid=2616
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode, sharing)
# Problematic frame:
# C  [ntdll.dll+0x3426d]
#

---------------  T H R E A D  ---------------

Current thread (0x02d3b8c8):  JavaThread "Thread-6" [_thread_in_native, id=2616]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x00000000, EBX=0x000004ff, ECX=0x009c2fd8, EDX=0x0000f704
ESP=0x0f5df500, EBP=0x0f5df720, ESI=0x009c0550, EDI=0x009c07d8
EIP=0x7c93426d, EFLAGS=0x00010246

Top of Stack: (sp=0x0f5df500)
0x0f5df500:   00000000 00000280 02d3b8c8 0f5df530
0x0f5df510:   6d7a59d3 00030470 6d6e8905 02d3b8c8
0x0f5df520:   00000003 6d6e8910 2b462e80 23015968
0x0f5df530:   2306a3d0 2306a3d0 0f5df558 00ad0155
0x0f5df540:   00000000 00000000 02d3b8c8 02dc8d10
0x0f5df550:   02c90000 00ad0125 02d42410 0f5df58c
0x0f5df560:   00000000 0f5df5d4 6d73243e 00030178
0x0f5df570:   00000000 0f5df72c 02d3b8c8 6d732999

Instructions: (pc=0x7c93426d)
0x7c93425d:   11 89 95 64 ff ff ff 8b 40 0c 89 85 5c ff ff ff
0x7c93426d:   8b 00 3b 42 04 0f 85 13 01 00 00 3b c1 0f 85 0b


Stack: [0x0f5a0000,0x0f5e0000),  sp=0x0f5df500,  free space=253k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [ntdll.dll+0x3426d]
C  [jinput-dx8.dll+0x24b6]
J  net.java.games.input.IDirectInputDevice.getDeviceData(Lnet/java/games/input/DataQueue;)Z
J  net.java.games.input.IDirectInputDevice.pollAll()V
J  net.java.games.input.DIAbstractController.pollDevice()V
J  net.java.games.input.AbstractController.poll()Z
J  org.lwjgl.input.JInputController.poll()V
J  org.lwjgl.test.input.TestControllers.pollAndUpdate()V
v  ~RuntimeStub::alignment_frame_return Runtime1 stub
j  org.lwjgl.test.input.TestControllers$2.run()V+14
v  ~StubRoutines::call_stub
V  [jvm.dll+0x8295c]
V  [jvm.dll+0xd752e]
V  [jvm.dll+0x8282d]
V  [jvm.dll+0x8258a]
V  [jvm.dll+0x9d476]
V  [jvm.dll+0x1042ae]
V  [jvm.dll+0x10427c]
C  [MSVCRT.dll+0x2a3b0]
C  [kernel32.dll+0xb50b]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J  net.java.games.input.IDirectInputDevice.nGetDeviceData(JILnet/java/games/input/DataQueue;[Ljava/lang/Object;II)I
J  net.java.games.input.IDirectInputDevice.getDeviceData(Lnet/java/games/input/DataQueue;)Z
J  net.java.games.input.IDirectInputDevice.pollAll()V
J  net.java.games.input.DIAbstractController.pollDevice()V
J  net.java.games.input.AbstractController.poll()Z
J  org.lwjgl.input.JInputController.poll()V
J  org.lwjgl.test.input.TestControllers.pollAndUpdate()V
v  ~RuntimeStub::alignment_frame_return Runtime1 stub
j  org.lwjgl.test.input.TestControllers$2.run()V+14
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
 0x000361d0 JavaThread "DestroyJavaVM" [_thread_blocked, id=6104]
 0x02d4fa70 JavaThread "Thread-10" [_thread_blocked, id=3616]
 0x02d45760 JavaThread "Thread-9" [_thread_blocked, id=5360]
 0x02d42c50 JavaThread "Thread-8" [_thread_blocked, id=6084]
 0x02d41120 JavaThread "Thread-7" [_thread_blocked, id=1384]
=>0x02d3b8c8 JavaThread "Thread-6" [_thread_in_native, id=2616]
 0x02d37ed8 JavaThread "Thread-5" [_thread_blocked, id=3680]
 0x02d35808 JavaThread "TimerQueue" daemon [_thread_blocked, id=2764]
 0x02d33810 JavaThread "Thread-4" [_thread_blocked, id=2960]
 0x02d30870 JavaThread "Thread-3" [_thread_blocked, id=6116]
 0x02d20a20 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=2932]
 0x02cfd8d8 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=2912]
 0x02ccc008 JavaThread "AWT-Windows" daemon [_thread_in_native, id=2948]
 0x02cc6a00 JavaThread "AWT-Shutdown" [_thread_blocked, id=3864]
 0x00a6ec08 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4644]
 0x00a6d870 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1020]
 0x00a6cb00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=596]
 0x00a475d8 JavaThread "Finalizer" daemon [_thread_blocked, id=2936]
 0x0003f8c0 JavaThread "Reference Handler" daemon [_thread_blocked, id=1232]

Other Threads:
 0x00a390d0 VMThread [id=3456]
 0x00a897c8 WatcherThread [id=2012]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation   total 576K, used 201K [0x22a90000, 0x22b30000, 0x22f70000)
 eden space 512K,  38% used [0x22a90000, 0x22ac10f0, 0x22b10000)
 from space 64K,   7% used [0x22b20000, 0x22b213b0, 0x22b30000)
 to   space 64K,   0% used [0x22b10000, 0x22b10000, 0x22b20000)
tenured generation   total 2500K, used 1524K [0x22f70000, 0x231e1000, 0x26a90000)
  the space 2500K,  60% used [0x22f70000, 0x230ed1d0, 0x230ed200, 0x231e1000)
compacting perm gen  total 8192K, used 362K [0x26a90000, 0x27290000, 0x2aa90000)
  the space 8192K,   4% used [0x26a90000, 0x26aea930, 0x26aeaa00, 0x27290000)
   ro space 8192K,  66% used [0x2aa90000, 0x2afeae88, 0x2afeb000, 0x2b290000)
   rw space 12288K,  46% used [0x2b290000, 0x2b828490, 0x2b828600, 0x2be90000)

Dynamic libraries:
0x00400000 - 0x0040c000    C:\wk\apps\jdk1.5.0_05\bin\java.exe
0x7c900000 - 0x7c9b0000    C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f4000    C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000    C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000    C:\WINDOWS\system32\RPCRT4.dll
0x77c10000 - 0x77c68000    C:\WINDOWS\system32\MSVCRT.dll
0x6d6b0000 - 0x6d83c000    C:\wk\apps\jdk1.5.0_05\jre\bin\client\jvm.dll
0x77d40000 - 0x77dd0000    C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f57000    C:\WINDOWS\system32\GDI32.dll
0x76b40000 - 0x76b6d000    C:\WINDOWS\system32\WINMM.dll
0x6d2f0000 - 0x6d2f8000    C:\wk\apps\jdk1.5.0_05\jre\bin\hpi.dll
0x76bf0000 - 0x76bfb000    C:\WINDOWS\system32\PSAPI.DLL
0x6d680000 - 0x6d68c000    C:\wk\apps\jdk1.5.0_05\jre\bin\verify.dll
0x6d370000 - 0x6d38d000    C:\wk\apps\jdk1.5.0_05\jre\bin\java.dll
0x6d6a0000 - 0x6d6af000    C:\wk\apps\jdk1.5.0_05\jre\bin\zip.dll
0x6d070000 - 0x6d1d7000    C:\wk\apps\jdk1.5.0_05\jre\bin\awt.dll
0x73000000 - 0x73026000    C:\WINDOWS\system32\WINSPOOL.DRV
0x76390000 - 0x763ad000    C:\WINDOWS\system32\IMM32.dll
0x774e0000 - 0x7761d000    C:\WINDOWS\system32\ole32.dll
0x10000000 - 0x10011000    C:\wk\proj\WildStallions\lib\lwjgl-1.0beta2\native\win32\jinput-dx8.dll
0x6ce10000 - 0x6ce48000    C:\WINDOWS\system32\DINPUT8.dll
0x688f0000 - 0x688f9000    C:\WINDOWS\system32\HID.DLL
0x77920000 - 0x77a13000    C:\WINDOWS\system32\SETUPAPI.DLL
0x76c30000 - 0x76c5e000    C:\WINDOWS\system32\WINTRUST.dll
0x77a80000 - 0x77b14000    C:\WINDOWS\system32\CRYPT32.dll
0x77b20000 - 0x77b32000    C:\WINDOWS\system32\MSASN1.dll
0x76c90000 - 0x76cb8000    C:\WINDOWS\system32\IMAGEHLP.dll
0x02fe0000 - 0x02ff2000    C:\WINDOWS\system32\RFVibra2.dll
0x72280000 - 0x722aa000    C:\WINDOWS\system32\DINPUT.dll
0x73760000 - 0x737a9000    C:\WINDOWS\system32\ddraw.dll
0x73bc0000 - 0x73bc6000    C:\WINDOWS\system32\DCIMAN32.dll
0x73940000 - 0x73a10000    C:\WINDOWS\system32\D3DIM700.DLL
0x7c9c0000 - 0x7d1d5000    C:\WINDOWS\system32\shell32.dll
0x77f60000 - 0x77fd6000    C:\WINDOWS\system32\SHLWAPI.dll
0x773d0000 - 0x774d2000    C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
0x5d090000 - 0x5d127000    C:\WINDOWS\system32\comctl32.dll
0x6d2b0000 - 0x6d2ed000    C:\wk\apps\jdk1.5.0_05\jre\bin\fontmanager.dll
0x6d530000 - 0x6d543000    C:\wk\apps\jdk1.5.0_05\jre\bin\net.dll
0x71ab0000 - 0x71ac7000    C:\WINDOWS\system32\WS2_32.dll
0x71aa0000 - 0x71aa8000    C:\WINDOWS\system32\WS2HELP.dll
0x6d550000 - 0x6d559000    C:\wk\apps\jdk1.5.0_05\jre\bin\nio.dll
0x03460000 - 0x03467000    C:\wk\apps\musikCube\MMShellHook.dll
0x7c340000 - 0x7c396000    C:\wk\apps\musikCube\MSVCR71.dll

VM Arguments:
jvm_args: -Djava.library.path=native\win32
java_command: org.lwjgl.test.input.TestControllers

Environment Variables:
PATH=C:\wk\apps\jdk1.5.0_05\bin;c:\wk\apps\devkitPro\msys\bin;C:\wk\apps\php-4.4.0-Win32;C:\wk\apps\perl5.8.6\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Python22;C:\Program Files\PC-Doctor for Windows\;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Common Files\GTK\2.0\bin;"c:\Program Files\Resource Kit\";c:\wk\proj\bin;C:\wk\apps\mysql-4.1\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\VoiceAge\Common;C:\wk\apps\bin;C:\Program Files\ATI Technologies\ATI.ACE\
USERNAME=wayne
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 4 Stepping 1, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 2 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht

Memory: 4k page, physical 1047852k(289616k free), swap 2517548k(1608020k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_05-b05) for windows-x86, built on Aug 26 2005 15:36:02 by "java_re" with MS VC++ 6.0


------------------------------------------------------------




DXDiag info:





------------------
System Information
------------------
Time of this report: 8/7/2006, 00:00:34
      Machine name: THEDEEPBLUE
  Operating System: Windows XP Professional (5.1, Build 2600) Service Pack 2 (2600.xpsp_sp2_gdr.050301-1519)
          Language: English (Regional Setting: English)
System Manufacturer: HP Pavilion 061
      System Model: PY147AA-ABU m7081.uk
              BIOS: BIOS Date: 04/29/05 17:55:16 Ver: 08.00.10
         Processor: Intel(R) Pentium(R) 4 CPU 3.20GHz (2 CPUs)
            Memory: 1024MB RAM
         Page File: 868MB used, 1589MB available
       Windows Dir: C:\WINDOWS
   DirectX Version: DirectX 9.0c (4.09.0000.0904)
DX Setup Parameters: Not found
    DxDiag Version: 5.03.2600.2180 32bit Unicode

------------
DxDiag Notes
------------
 DirectX Files Tab: No problems found.
     Display Tab 1: No problems found.
       Sound Tab 1: No problems found.
       Sound Tab 2: The file btaudio.sys is not digitally signed, which means that it has not been tested by Microsoft's Windows Hardware Quality Labs

(WHQL).  You may be able to get a WHQL logo'd driver from the hardware manufacturer.
         Music Tab: DirectMusic test results: All tests were successful.
         Input Tab: No problems found.
       Network Tab: No problems found.

--------------------
DirectX Debug Levels
--------------------
Direct3D:    0/4 (n/a)
DirectDraw:  0/4 (retail)
DirectInput: 0/5 (n/a)
DirectMusic: 0/5 (n/a)
DirectPlay:  0/9 (retail)
DirectSound: 0/5 (retail)
DirectShow:  0/6 (retail)


-------------------
DirectInput Devices
-------------------
     Device Name: Mouse
        Attached: 1
   Controller ID: n/a
Vendor/Product ID: n/a
       FF Driver: n/a

     Device Name: Keyboard
        Attached: 1
   Controller ID: n/a
Vendor/Product ID: n/a
       FF Driver: n/a

     Device Name: Microsoft eHome Infrared Transceiver
        Attached: 1
   Controller ID: 0x0
Vendor/Product ID: 0x045E, 0x006D
       FF Driver: n/a

     Device Name: Microsoft eHome Infrared Transceiver
        Attached: 1
   Controller ID: 0x0
Vendor/Product ID: 0x045E, 0x006D
       FF Driver: n/a

     Device Name: Microsoft eHome Infrared Transceiver
        Attached: 1
   Controller ID: 0x0
Vendor/Product ID: 0x045E, 0x006D
       FF Driver: n/a

     Device Name: Microsoft eHome Infrared Transceiver
        Attached: 1
   Controller ID: 0x0
Vendor/Product ID: 0x045E, 0x006D
       FF Driver: n/a

     Device Name: Logitech USB Keyboard
        Attached: 1
   Controller ID: 0x0
Vendor/Product ID: 0x046D, 0xC308
       FF Driver: n/a

     Device Name: Logitech USB Keyboard
        Attached: 1
   Controller ID: 0x0
Vendor/Product ID: 0x046D, 0xC308
       FF Driver: n/a

     Device Name: Rockfire PSX\USB Bridge
        Attached: 1
   Controller ID: 0x0
Vendor/Product ID: 0x0583, 0x2050
       FF Driver: RFVibra2.dll
  FF Driver Date:
FF Driver Version: 4.00.0000.0001
  FF Driver Size: 0 bytes

     Device Name: Rockfire PSX\USB Bridge
        Attached: 1
   Controller ID: 0x1
Vendor/Product ID: 0x0583, 0x2050
       FF Driver: RFVibra2.dll
  FF Driver Date:
FF Driver Version: 4.00.0000.0001
  FF Driver Size: 0 bytes

Poll w/ Interrupt: No
        Registry: OK

-----------
USB Devices
-----------
+ USB Root Hub
| Vendor/Product ID: 0x8086, 0x2658
| Matching Device ID: usb\root_hub
| Service: usbhub
| Driver: usbhub.sys, 8/10/2004 13:00:00, 57600 bytes
| Driver: usbd.sys, 8/10/2004 13:00:00, 4736 bytes

----------------
Gameport Devices
----------------

------------
PS/2 Devices
------------
+ Microsoft eHome Remote Control Keyboard keys
| Vendor/Product ID: 0x03EE, 0x2501
| Matching Device ID: hid\vid_03ee&pid_2501&col05
| Service: kbdhid
| Driver: kbdhid.sys, 8/3/2004 22:58:36, 14848 bytes
| Driver: kbdclass.sys, 8/10/2004 13:00:00, 24576 bytes
|
+ HID Keyboard Device
| Vendor/Product ID: 0x046D, 0xC308
| Matching Device ID: hid_device_system_keyboard
| Service: kbdhid
| Driver: kbdhid.sys, 8/3/2004 22:58:36, 14848 bytes
| Driver: kbdclass.sys, 8/10/2004 13:00:00, 24576 bytes
|
+ Terminal Server Keyboard Driver
| Matching Device ID: root\rdp_kbd
| Upper Filters: kbdclass
| Service: TermDD
| Driver: termdd.sys, 8/4/2004 08:01:08, 40840 bytes
| Driver: kbdclass.sys, 8/10/2004 13:00:00, 24576 bytes
|
+ Microsoft USB IntelliMouse Explorer
| Vendor/Product ID: 0x045E, 0x001E
| Matching Device ID: hid\vid_045e&pid_001e
| Service: mouhid
| Driver: mouclass.sys, 8/10/2004 19:00:00, 23040 bytes
| Driver: mouhid.sys, 8/17/2001 13:48:00, 12160 bytes
|
+ HID-compliant mouse
| Vendor/Product ID: 0x046D, 0xC308
| Matching Device ID: hid_device_system_mouse
| Service: mouhid
| Driver: mouclass.sys, 8/10/2004 19:00:00, 23040 bytes
| Driver: mouhid.sys, 8/17/2001 13:48:00, 12160 bytes
|
+ Terminal Server Mouse Driver
| Matching Device ID: root\rdp_mou
| Upper Filters: mouclass
| Service: TermDD
| Driver: termdd.sys, 8/4/2004 08:01:08, 40840 bytes
| Driver: mouclass.sys, 8/10/2004 19:00:00, 23040 bytes
Title: org.lwjgl.test.input.TestControllers crash
Post by: Matzon on August 07, 2006, 05:58:29
nasty
We need to get a jinput guy to look at this. LWJGL had its own controller code, but we instead changed to use jinput, and then wrap the code in a LWJGL wrapper that simplifies access.
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 07, 2006, 07:47:20
if it helps, I forgot to mention a couple of things:

1. JXInput 0.3 from hardcode works on my machine and during enumeration only reports the 2 connected devices (2x RockPort PSXbridge)

2. The controller testhaness (standalone and via webstart) display a panel for each enumerated controller just before crashing.

all the best
Wayne
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 09, 2006, 09:05:57
Not sure what is causing this. Could you post a minimal test program that exhibits this behaviour? Also, try out this special build of jinput-dx8.dll with debug output. I'll need the last few dozen lines of output before the crash.

http://download.oddlabs.com/elias/jinput-dx8.dll

- elias
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 09, 2006, 18:26:48
I will cut down the org.lwjgl.test.input.TestControllers test case and use the original DLL as it works okay with the debug build, panels show input and on the console output:
7 Controllers Found
Microsoft eHome In
Microsoft eHome In
Microsoft eHome In
Microsoft eHome In
Logitech U
Logitech U
Rockfire PS
Event Fired:
       org.lwjgl.input.JInputController@169ca65:3:false
       true:false
GetDeviceData 1
GetDeviceData 2
GetDeviceData 3
GetDeviceData 4
GetDeviceData 9
GetDeviceData 10
GetDeviceData 1
GetDeviceData 2
GetDeviceData 3
GetDeviceData 4
GetDeviceData 9
GetDeviceData 10
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 09, 2006, 19:17:31
I can tell you now that if I change the loop in the testharness main to only 'look' at my last device, it works 'better', e.g. it gets past the initial crash and I can see lots of "Event Fired..." for my PS2 controller.

However, if I press a button on my Windows Media remote this occurs:

Exception in thread "Thread-3" 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 org.lwjgl.input.JInputController.poll(JInputController.java:160)
   at org.lwjgl.input.Controllers.poll(Controllers.java:108)
   at wk.org.lwjgl.test.input.TestControllers.pollAndUpdate(TestControllers.java:112)
   at wk.org.lwjgl.test.input.TestControllers$2.run(TestControllers.java:104)
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 09, 2006, 19:23:07
buy the looks of it,  pollAndUpdate still polls controllers im not interested in,
a bug in net.java.games.input ???
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 09, 2006, 22:04:53
changing the threat sleep to:

Thread.sleep(500);

makes the test more reliable, however the Media Controller stiull causes the previous (non-fatal) exception.
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 09, 2006, 22:55:25
Minimal testcase follows.

Doesn't crash with DEbug DLL

crashes with non debug native DLL:




package wk.org.lwjgl.test.input;

import org.lwjgl.input.Controller;
import org.lwjgl.input.Controllers;


public class TestControllers {
   public TestControllers(int index) {
      
      Thread t = new Thread() {
         public void run() {
            while (true) {
               try { Thread.sleep(100); } catch (Exception e) {};
               pollAndUpdate();
            }
         }
      };
      t.start();
   }
   
   public void pollAndUpdate() {
      Controllers.poll();
   }
   
   public static void main(String[] argv) {
      try {
         Controllers.create();
      } catch (Exception e) {
         e.printStackTrace();
         System.exit(0);
      }
      int count = Controllers.getControllerCount();
      for (int i=0;i<count;i++) {
         new TestControllers(i);
      }
   }
}

with stack trace:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c93426d, pid=5644, tid=2304
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode)
# Problematic frame:
# C  [ntdll.dll+0x3426d]
#

---------------  T H R E A D  ---------------

Current thread (0x0ade2f78):  JavaThread "Thread-4" [_thread_in_native, id=2304]

siginfo: ExceptionCode=0xc0000005, reading address 0x11cfc9f3

Registers:
EAX=0x11cfc9f3, EBX=0x000004af, ECX=0x0af92d08, EDX=0xa36d02f0
ESP=0x0b3af6c8, EBP=0x0b3af8e8, ESI=0x0af90500, EDI=0x0af90788
EIP=0x7c93426d, EFLAGS=0x00010246

Top of Stack: (sp=0x0b3af6c8)
0x0b3af6c8:   0ade2f78 00000280 06c567d0 0b3af9ec
0x0b3af6d8:   06c86050 00000000 02b17f38 0b3af6e4
0x0b3af6e8:   06c63df8 0b3af70c 06c64920 00000000
0x0b3af6f8:   06c63e20 0b3af708 0b3af720 00a90155
0x0b3af708:   00000000 02b17f38 00000003 00000000
0x0b3af718:   0ade2f78 00a90125 0add7ed0 0b3af754
0x0b3af728:   00000000 0b3af79c 6d73243e 0add7ed0
0x0b3af738:   00000000 00360178 0ade2f78 6d732999

Instructions: (pc=0x7c93426d)
0x7c93425d:   11 89 95 64 ff ff ff 8b 40 0c 89 85 5c ff ff ff
0x7c93426d:   8b 00 3b 42 04 0f 85 13 01 00 00 3b c1 0f 85 0b


Stack: [0x0b370000,0x0b3b0000),  sp=0x0b3af6c8,  free space=253k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [ntdll.dll+0x3426d]
C  [jinput-dx8.dll+0x24b6]
j  net.java.games.input.IDirectInputDevice.getDeviceData(Lnet/java/games/input/DataQueue;)Z+18
j  net.java.games.input.IDirectInputDevice.pollAll()V+28
j  net.java.games.input.DIAbstractController.pollDevice()V+4
J  net.java.games.input.AbstractController.poll()Z
J  org.lwjgl.input.JInputController.poll()V
v  ~RuntimeStub::alignment_frame_return Runtime1 stub
j  org.lwjgl.input.Controllers.poll()V+16
j  wk.org.lwjgl.test.input.TestControllers.pollAndUpdate()V+0
j  wk.org.lwjgl.test.input.TestControllers$1.run()V+14
v  ~StubRoutines::call_stub
V  [jvm.dll+0x8295c]
V  [jvm.dll+0xd752e]
V  [jvm.dll+0x8282d]
V  [jvm.dll+0x8258a]
V  [jvm.dll+0x9d476]
V  [jvm.dll+0x1042ae]
V  [jvm.dll+0x10427c]
C  [MSVCRT.dll+0x2a3b0]
C  [kernel32.dll+0xb50b]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  net.java.games.input.IDirectInputDevice.nGetDeviceData(JILnet/java/games/input/DataQueue;[Ljava/lang/Object;II)I+0
j  net.java.games.input.IDirectInputDevice.getDeviceData(Lnet/java/games/input/DataQueue;)Z+18
j  net.java.games.input.IDirectInputDevice.pollAll()V+28
j  net.java.games.input.DIAbstractController.pollDevice()V+4
J  net.java.games.input.AbstractController.poll()Z
J  org.lwjgl.input.JInputController.poll()V
v  ~RuntimeStub::alignment_frame_return Runtime1 stub
j  org.lwjgl.input.Controllers.poll()V+16
j  wk.org.lwjgl.test.input.TestControllers.pollAndUpdate()V+0
j  wk.org.lwjgl.test.input.TestControllers$1.run()V+14
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
 0x00366a48 JavaThread "DestroyJavaVM" [_thread_blocked, id=4184]
 0x0add9398 JavaThread "Thread-7" [_thread_blocked, id=5368]
 0x0add88c8 JavaThread "Thread-6" [_thread_blocked, id=4512]
 0x0ade48f0 JavaThread "Thread-5" [_thread_blocked, id=376]
=>0x0ade2f78 JavaThread "Thread-4" [_thread_in_native, id=2304]
 0x0add4f50 JavaThread "Thread-3" [_thread_blocked, id=3628]
 0x0ade09d0 JavaThread "Thread-2" [_thread_blocked, id=932]
 0x0add5608 JavaThread "Thread-1" [_thread_blocked, id=5144]
 0x00a5c390 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3864]
 0x00a5ab78 JavaThread "CompilerThread0" daemon [_thread_blocked, id=4116]
 0x00a59bb8 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=6004]
 0x00a58768 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=2396]
 0x00a573b8 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=1224]
 0x00a55ac0 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=2932]
 0x00a47950 JavaThread "Finalizer" daemon [_thread_blocked, id=1936]
 0x00a464c0 JavaThread "Reference Handler" daemon [_thread_blocked, id=3368]

Other Threads:
 0x00a43af0 VMThread [id=5692]
 0x00a77068 WatcherThread [id=4792]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation   total 576K, used 224K [0x02a90000, 0x02b30000, 0x02f70000)
 eden space 512K,  31% used [0x02a90000, 0x02ab80d0, 0x02b10000)
 from space 64K,  99% used [0x02b10000, 0x02b1fff8, 0x02b20000)
 to   space 64K,   0% used [0x02b20000, 0x02b20000, 0x02b30000)
tenured generation   total 1408K, used 273K [0x02f70000, 0x030d0000, 0x06a90000)
  the space 1408K,  19% used [0x02f70000, 0x02fb4410, 0x02fb4600, 0x030d0000)
compacting perm gen  total 8192K, used 2013K [0x06a90000, 0x07290000, 0x0aa90000)
  the space 8192K,  24% used [0x06a90000, 0x06c875c0, 0x06c87600, 0x07290000)
No shared spaces configured.

Dynamic libraries:
0x00400000 - 0x0040c000    C:\wk\apps\jdk1.5.0_05\bin\javaw.exe
0x7c900000 - 0x7c9b0000    C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f4000    C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000    C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000    C:\WINDOWS\system32\RPCRT4.dll
0x77d40000 - 0x77dd0000    C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f57000    C:\WINDOWS\system32\GDI32.dll
0x77c10000 - 0x77c68000    C:\WINDOWS\system32\MSVCRT.dll
0x6d6b0000 - 0x6d83c000    C:\wk\apps\jdk1.5.0_05\jre\bin\client\jvm.dll
0x76b40000 - 0x76b6d000    C:\WINDOWS\system32\WINMM.dll
0x6d2f0000 - 0x6d2f8000    C:\wk\apps\jdk1.5.0_05\jre\bin\hpi.dll
0x76bf0000 - 0x76bfb000    C:\WINDOWS\system32\PSAPI.DLL
0x6d3f0000 - 0x6d425000    C:\wk\apps\jdk1.5.0_05\jre\bin\jdwp.dll
0x6d680000 - 0x6d68c000    C:\wk\apps\jdk1.5.0_05\jre\bin\verify.dll
0x6d370000 - 0x6d38d000    C:\wk\apps\jdk1.5.0_05\jre\bin\java.dll
0x6d6a0000 - 0x6d6af000    C:\wk\apps\jdk1.5.0_05\jre\bin\zip.dll
0x6d290000 - 0x6d297000    C:\wk\apps\jdk1.5.0_05\jre\bin\dt_socket.dll
0x71ab0000 - 0x71ac7000    C:\WINDOWS\system32\WS2_32.dll
0x71aa0000 - 0x71aa8000    C:\WINDOWS\system32\WS2HELP.dll
0x71a50000 - 0x71a8f000    C:\WINDOWS\System32\mswsock.dll
0x76f20000 - 0x76f47000    C:\WINDOWS\system32\DNSAPI.dll
0x76fb0000 - 0x76fb8000    C:\WINDOWS\System32\winrnr.dll
0x76f60000 - 0x76f8c000    C:\WINDOWS\system32\WLDAP32.dll
0x751d0000 - 0x751ee000    C:\WINDOWS\system32\wshbth.dll
0x77920000 - 0x77a13000    C:\WINDOWS\system32\SETUPAPI.dll
0x76fc0000 - 0x76fc6000    C:\WINDOWS\system32\rasadhlp.dll
0x662b0000 - 0x66308000    C:\WINDOWS\system32\hnetcfg.dll
0x71a90000 - 0x71a98000    C:\WINDOWS\System32\wshtcpip.dll
0x10000000 - 0x10011000    C:\wk\proj\eclipse_workspace\lwjgl_tests\lib\lwjgl-1.0beta2\native\win32\jinput-dx8.dll
0x6ce10000 - 0x6ce48000    C:\WINDOWS\system32\DINPUT8.dll
0x688f0000 - 0x688f9000    C:\WINDOWS\system32\HID.DLL
0x76c30000 - 0x76c5e000    C:\WINDOWS\system32\WINTRUST.dll
0x77a80000 - 0x77b14000    C:\WINDOWS\system32\CRYPT32.dll
0x77b20000 - 0x77b32000    C:\WINDOWS\system32\MSASN1.dll
0x76c90000 - 0x76cb8000    C:\WINDOWS\system32\IMAGEHLP.dll
0x0b0f0000 - 0x0b102000    C:\WINDOWS\system32\RFVibra2.dll
0x72280000 - 0x722aa000    C:\WINDOWS\system32\DINPUT.dll

VM Arguments:
jvm_args: -Djava.library.path=C:\wk\proj\eclipse_workspace\lwjgl_tests\lib\lwjgl-1.0beta2\native\win32 -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,suspend=y,address=localhost:36700
java_command: wk.org.lwjgl.test.input.TestControllers

Environment Variables:
PATH=C:\wk\apps\jdk1.5.0_05\bin;c:\wk\apps\devkitPro\msys\bin;C:\wk\apps\php-4.4.0-Win32;C:\wk\apps\perl5.8.6\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Python22;C:\Program Files\PC-Doctor for Windows\;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Common Files\GTK\2.0\bin;"c:\Program Files\Resource Kit\";c:\wk\proj\bin;C:\wk\apps\mysql-4.1\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\VoiceAge\Common;C:\wk\apps\bin;C:\Program Files\ATI Technologies\ATI.ACE\
USERNAME=wayne
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 4 Stepping 1, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 2 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht

Memory: 4k page, physical 1047852k(101708k free), swap 2517548k(1572576k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_05-b05) for windows-x86, built on Aug 26 2005 15:36:02 by "java_re" with MS VC++ 6.0
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 09, 2006, 23:34:35
Smaller test case, crashes after a non-constant number of polls:

package wk.org.lwjgl.test.input;
import org.lwjgl.input.Controllers;
public class TestControllers {
   public static void main(String[] argv) {
      try {
         Controllers.create();
         int count = Controllers.getControllerCount();
         for (int i=0;i<count;i++) {
            Thread t = new Thread() {
               public void run() {
                  while (true) {
                     try { Thread.sleep(100); } catch (Exception e) {};
                     System.out.println("Polling on tid:" +this.getId());
                     Controllers.poll();
                  }
               }
            };
            t.start();
         }
      } catch (Exception e) {
         e.printStackTrace();
         System.exit(0);
      }
      
   }
}
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 10, 2006, 08:07:20
Ok, I'll include the updated dll and a an updated jinput.jar which should fix the NullPointerException. Please test beta3 when it's out (should be very soon now).

- elias
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 10, 2006, 14:06:44
Okay, will do.
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 19, 2006, 08:58:38
good news, and bad news.  

good news: the default LWJGL test controller case works iwhtout crashing:
1. at start up
&
2. when I press a button om my remote.

bad news:

there are exceptions throw at the start of testing that eventually seem to subside/'go away', but the gui isn't updated with events anymore, although the console is outputting 'fired events'.


C:\wk\proj\WildStallions\lib\lwjgl-1.0beta3>java -cp .;res;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.jar;jar\lwjgl_fmod3.jar;jar
lwjgl_devil.jar;jar\jinput.jar; -Djava.library.path=native\win32 org.lwjgl.test.input.TestControllers
7 Controllers Found
Microsoft eHome In
Microsoft eHome In
Microsoft eHome In
Microsoft eHome In
Logitech U
Logitech U
Rockfire PS
Event Fired:
       org.lwjgl.input.JInputController@1b9ce4b:0:false
Event Fired:
       true:false
Event Fired:
Exception in thread "Thread-8"  org.lwjgl.input.JInputController@1b9ce4b:2:falsejava.lang.NullPointerException

       at org.lwjgl.input.Controllers.getEventSource(Controllers.java:170)
       at org.lwjgl.test.input.TestControllers.pollAndUpdate(TestControllers.java:126)
       at org.lwjgl.test.input.TestControllers$2.run(TestControllers.java:104)
Event Fired: Exception in thread "Thread-4"
java.lang.NullPointerException
       at org.lwjgl.input.Controllers.isEventXAxis(Controllers.java:206)
       at org.lwjgl.test.input.TestControllers.pollAndUpdate(TestControllers.java:127)
       at org.lwjgl.test.input.TestControllers$2.run(TestControllers.java:104)
Exception in thread "Thread-9" java.lang.NullPointerException
       at org.lwjgl.input.Controllers.getEventSource(Controllers.java:170)
       at org.lwjgl.test.input.TestControllers.pollAndUpdate(TestControllers.java:126)
       at org.lwjgl.test.input.TestControllers$2.run(TestControllers.java:104)
Event Fired:
       org.lwjgl.input.JInputController@1b9ce4b:2:false
       false:true
Event Fired:
       org.lwjgl.input.JInputController@1b9ce4b:3:false
Event Fired:
       false:true
       org.lwjgl.input.JInputController@1b9ce4b:2:false
Exception in thread "Thread-7" Event Fired: java.lang.NullPointerException

       at org.lwjgl.input.Controllers.isEventXAxis(Controllers.java:206)       org.lwjgl.input.JInputController@1b9ce4b:2:false

       at org.lwjgl.test.input.TestControllers.pollAndUpdate(TestControllers.java:127) false:true

       at org.lwjgl.test.input.TestControllers$2.run(TestControllers.java:104)Event Fired:

       org.lwjgl.input.JInputController@1b9ce4b:3:false
       true:false
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 21, 2006, 08:12:35
You seem to have multiple threads involved. Jinput itself supports multithreading but I'm not sure the LWJGL Controllers class does.

- elias
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 21, 2006, 08:49:42
It's the testcase shipped with LWJGL (org.lwjgl.test.input.TestControllers)
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 21, 2006, 10:06:02
And so it is :) Alright, I'll have to get a hold of Kevglass and see if he can figure this out.

- elias
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 21, 2006, 16:30:19
I'll take a look right away.

Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 21, 2006, 17:17:06
Fixed it, can't commit to SVN for some reason.

I've also got a minor change to prune out controllers with zero buttons OR zero axis since they're not likely to be game controllers in either case - that should get rid of monitors being picked up and my new laptop keyboard reporting as 4 seperate game controllers.

I'd like to commit this aswell unless theres a good example of why it shouldn't be so.

Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 21, 2006, 17:30:05
Good news, thanks very much, but by excluding controllers with 0 axis you are ignoring:

Infrared remotes
'Media' Keyboards.
Retro button only controllers.
Some crazy homebrew device, okay the original Amiga 'joystick' was a meditation device with an axis or two.

I'm just thinking that LWJGL might be used in situations, such as mediacenter or perhap a set-top box, where an axis might not be present, but buttons are.
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 21, 2006, 17:43:43
Thanks for the feedback, I was a little worried about this. Bit of a rock and hard place though I suppose. If we don't ignore odd controllers in a "select your controller list" you potentially get a bunch of devices that arn't devices (and actually fail if you poll them). If we ignore them we might miss some controller variants.

I can change the check to buttons=0 only but that means we'll still get things like my 31 button only random device showing up.

The best solution would be if JInput was able to report the devices type as what they are rather than STICK which is what all my test devices here come back as (even the ones with no axis :))

FWIW, the only one that would worry me in the list would be "Media Keyboards" - not really sure what they are though? Would they not be reported as Keyboards - anyone got one to check :)

Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 21, 2006, 17:58:37
Thinking about it, since the check can be implemented by the developer really easily (it's what I do for tilt for instance) - I suppose the sanity checks are more hassle then they're worth.

Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: wayne on August 21, 2006, 17:59:05
JXInput from http://www.hardcode.de/jxinput/ identifies only game controllers.  
Perhaps this is a bug in jInput? or is it a limitation of JXInput?

My keyboard is a 'media' and 'internet' fandangled keyboard.

The Jpanel of the LWJGL TestControllers test case reports my keyboard twice, and I have buttons named things like:

Scan Previous TRack
Scan Next Track
Volume Incement
VolumeDecrement
Mute
System Sleep
System Power

My Windows Media remote returns lots of anonymous numerically named buttons, as well as those power related named ones too.

Also, oddly IMHO, they all seem to have a "POV X" and a "POV Y".
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 22, 2006, 09:25:40
Kevglass: I've tweaked jinput to use Controller.Type.UNKNOWN for the catch-all device type, and only STICK for the ones we know are stick-like.

- elias
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 22, 2006, 14:08:29
Ok, does stick-like handle do gamepads aswell (never really got that :)).

I'll update the controllers stuff to pick up STICK only then? If a controller that is considered a "Game Controller" doesn't get picked up it'll have to be revisited in JInput (god knows how you detect a gamepad as a gamepad if the driver reports unspecified)

Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 23, 2006, 04:46:33
The new version of jinput jar and dlls (in subversion) fail to detect any controllers for me on win32 with a:

Failed to enumerate devices: Failed to acquire device (8007001e)

Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 23, 2006, 07:25:20
Gamepads will get the Controller.Type.GAMEPAD type. It's not that devices reported themselves as unknown type, it was me simply making the default case in DirectInputEnvironmentPlugin.createControllerFromDevice a STICK type. Now only the obvious stick device types will be STICKs and the weirdos will be UNKNOWNs.

- elias
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 23, 2006, 08:09:38
I can't reproduce the acquire problem. Could you please test with the latest jinput with the "ant readtest" or "ant eventtest" test and tell me which device is failing and where? (Now the entire enumeration won't fail because one device fails). Also, if you could test with line 256 in IDirectInputDevice.java set to


setDataFormat(DIDF_ABSAXIS);


instead of


setDataFormat(axis_mode);


I'll be grateful.

- elias
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 25, 2006, 02:40:24
Running ControllerReadTest I get this fail:

Failed to initialize device SMSC HID CIR - Consumer IR because of: java.io.IOException: Failed to acquire device (8007001e)

So my Infra Red is being picked up? How cool is that :)

Anyway, in JInput I can see all the other devices (mouse, keyboard, controller and 3 others) show up fine. Just in the version with LWJGL I get zero controllers back from


ControllerEnvironment env = ControllerEnvironment.getDefaultEnvironment();

net.java.games.input.Controller[] found = env.getControllers();


I made that code change on 256 in IDirectInputDevice, tried the test again. This time I got this output:


Component count = 10
Component count = 127
Component count = 31
Component count = 0
Component count = 1
Component count = 0
Component count = 17
Failed to poll device: Failed to get device state (8007001e)
SMSC HID CIR - Consumer IR disabled
Failed to poll device: Failed to poll device (8007001e)
Failed to poll device: Failed to poll device (8007001e)
Failed to poll device: Failed to poll device (8007001e)
Failed to poll device: Failed to poll device (8007001e)
Failed to poll device: Failed to poll device (8007001e)
.... and so on


Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 25, 2006, 05:48:48
I've put the latest jinput.jar in lwjgl, which should simply ignore the failing device.

 - elias
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 25, 2006, 14:24:12
Ok, I'll update to LWJGL Controllers only returns GAMEPAD and STICK devices - but I think it might be worth adding a property that allows you to get any device detected and do the filtering yourself - that should account for people who want to write games using IR Remotes and such.

Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: kevglass on August 30, 2006, 18:00:44
The new JInput works well for me. I've revert the code to allow the end developer to do whatever filtering they require. I feel this gives the controllers API more flexibility for odd controllers and since the filtering of controllers is now trivial since JInput reports the appropriate type for each controller there doesn't seem much point restricting us.

The controllers will still not return devices of types KEYBOARD and MOUSE though since these might interfere with the standard LWJGL Mouse and Keyboard classes.

Kev
Title: org.lwjgl.test.input.TestControllers crash
Post by: elias on August 30, 2006, 18:05:50
Mouse and Keyboard devices shouldn't interfere with LWJGL operation. Could you elaborate that further? For example, I've recently made LWJGL use DirectInput8 where available, making Jinput and LWJGL input work seamlessly together. With LWJGL using DirectInput3, only one of LWJGL or Jinput would work, typically the last one to be initialized.

- elias