jMonkeyEngine / jmonkeyengine

A complete 3-D game development suite written in Java.
http://jmonkeyengine.org
BSD 3-Clause "New" or "Revised" License
3.84k stars 1.13k forks source link

App crashes with setUseJoysticks=true on lwjgl2 and windows 11 #1925

Open capdevon opened 1 year ago

capdevon commented 1 year ago

The app crashes with setUseJoysticks=true on lwjgl2 and Windows 11, both with the joystick connected and disconnected.

Details:

public class Main extends SimpleApplication {

    /**
     * Start the jMonkeyEngine application
     * @param args
     */
    public static void main(String[] args) {

        Main app = new Main();

        AppSettings settings = new AppSettings(true);
        settings.setUseJoysticks(true); //I have not connected the joystick.
        settings.setResolution(1280, 720);

        app.setSettings(settings);
        app.setShowSettings(true);
        app.setPauseOnLostFocus(false);
        app.start();
    }
...
}
gen 25, 2023 5:08:32 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.6.0-beta1
 * Branch: HEAD
 * Git Hash: ee91fb8
 * Build Date: 2023-01-24
gen 25, 2023 5:08:32 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main
 * Graphics Adapter: igdumdim64
 * Driver Version: null
 * Scaling Factor: 1
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jme3.util.ReflectionAllocator (file:/C:/Users/xxxx/.gradle/caches/modules-2/files-2.1/org.jmonkeyengine/jme3-core/3.6.0-beta1/f3f826a70693ae115c1e84a0ddd8ca971f61a4bb/jme3-core-3.6.0-beta1.jar) to method sun.nio.ch.DirectBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.jme3.util.ReflectionAllocator
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
gen 25, 2023 5:08:32 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: Intel
 * Renderer: Intel(R) Iris(R) Xe Graphics
 * OpenGL Version: 3.2.0 - Build 31.0.101.3358
 * GLSL Version: 1.50 - Build 31.0.101.3358
 * Profile: Core
gen 25, 2023 5:08:32 PM com.jme3.renderer.opengl.GLRenderer setMainFrameBufferSrgb
WARNING: Driver claims that default framebuffer is not sRGB capable. Enabling anyway.

crash

pavly-gerges commented 1 year ago

I have no idea if this has to do with issue #1674.

Ali-RS commented 1 year ago

Sounds like a JInput bug to me. Earlier OP said it works on windows 10 in a PM. I also tested it on a windows 10 device with java 8 installed and it did not crash for me as well. I do not have a windows 11 device to test and investigate this.

This was also in the log that he provided to me in the PM, not sure if it is related.

gen 25, 2023 5:08:32 PM net.java.games.input.ControllerEnvironment log
INFO: Failed to initialize device TUF GAMING M3 because of: java.io.IOException: Failed to acquire device (8007001e)

I also found these:

https://github.com/jinput/jinput/issues/8

https://github.com/jinput/jinput/issues/14

JInput has not been updated since 2019, looks like it is not maintained anymore.

pavly-gerges commented 1 year ago

@Ali-RS Have you tried on jdk-11 ?

. I do not have a windows 11 device to test and investigate this

I have a windows 11 64-bit image, I may test this.

Ali-RS commented 1 year ago

@Ali-RS Have you tried on jdk-11 ?

No, the windows 10 device I tested on is not mine, I am not allowed to install a new JDK on it.

I have windows 10 with java 11 on a virtual box but I could not run JME app there. Seems it can not detect the monitor and throws an illegal monitor state exception or something.

stephengold commented 1 year ago

I failed to reproduce this issue on my WIndows 11 laptop. No joystick was connected. Here is the output:

Jan 26, 2023 10:11:15 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.7.0-SNAPSHOT
 * Branch: master
 * Git Hash: ead32f1
 * Build Date: 2023-01-26
Jan 26, 2023 10:11:16 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main
 * Graphics Adapter: C:\WINDOWS\System32\DriverStore\FileRepository\nvhm.inf_amd64_4a2f8a62d5686839\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nvhm.inf_amd64_4a2f8a62d5686839\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nvhm.inf_amd64_4a2f8a62d5686839\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nvhm.inf_amd64_4a2f8a62d5686839\nvldumdx.dll
 * Driver Version: null
 * Scaling Factor: 1
Jan 26, 2023 10:11:16 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: NVIDIA GeForce RTX 2070/PCIe/SSE2
 * OpenGL Version: 3.2.0 NVIDIA 512.78
 * GLSL Version: 1.50 NVIDIA via Cg compiler
 * Profile: Core
Jan 26, 2023 10:11:16 AM net.java.games.input.DefaultControllerEnvironment getControllers
WARNING: Found unknown Windows version: Windows 11
Jan 26, 2023 10:11:16 AM net.java.games.input.DefaultControllerEnvironment getControllers
WARNING: Attempting to use default windows plug-in.
Jan 26, 2023 10:11:16 AM net.java.games.input.ControllerEnvironment log
INFO: Failed to initialize device HIDI2C Device because of: java.io.IOException: Failed to acquire device (8007001e)
Jan 26, 2023 10:11:17 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Jan 26, 2023 10:11:17 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Jan 26, 2023 10:11:17 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Jan 26, 2023 10:11:17 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4

No crash, but it appears Jinput 2.0.9 is confused by Windows 11, which was officially released in October 2021, 3+ years after Jinput 2.0.9.

stephengold commented 1 year ago

@capdevon : could you provide a crash log, please?

stephengold commented 1 year ago

My previous test was with JDK 17. I tried again with the Zulu 11.0.18+10 JDK and still no crash.

capdevon commented 1 year ago

Tried again with both joystick connected and disconnected. The application starts but freezes (Not Responding).

This is all the log when the mouse and joystick are connected:

gen 27, 2023 10:16:51 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.6.0-beta1
 * Branch: HEAD
 * Git Hash: ee91fb8
 * Build Date: 2023-01-24
gen 27, 2023 10:16:52 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main
 * Graphics Adapter: igdumdim64
 * Driver Version: null
 * Scaling Factor: 1
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jme3.util.ReflectionAllocator (file:/C:/Users/xxxx/.gradle/caches/modules-2/files-2.1/org.jmonkeyengine/jme3-core/3.6.0-beta1/f3f826a70693ae115c1e84a0ddd8ca971f61a4bb/jme3-core-3.6.0-beta1.jar) to method sun.nio.ch.DirectBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.jme3.util.ReflectionAllocator
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
gen 27, 2023 10:16:52 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: Intel
 * Renderer: Intel(R) Iris(R) Xe Graphics
 * OpenGL Version: 3.2.0 - Build 31.0.101.3358
 * GLSL Version: 1.50 - Build 31.0.101.3358
 * Profile: Core
gen 27, 2023 10:16:52 AM com.jme3.renderer.opengl.GLRenderer setMainFrameBufferSrgb
WARNING: Driver claims that default framebuffer is not sRGB capable. Enabling anyway.
gen 27, 2023 10:16:52 AM net.java.games.input.ControllerEnvironment log
INFO: Failed to initialize device TUF GAMING M3 because of: java.io.IOException: Failed to acquire device (8007001e)

This is all the log when mouse and joystick are disconnected:

gen 27, 2023 10:16:51 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.6.0-beta1
 * Branch: HEAD
 * Git Hash: ee91fb8
 * Build Date: 2023-01-24
gen 27, 2023 10:16:52 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main
 * Graphics Adapter: igdumdim64
 * Driver Version: null
 * Scaling Factor: 1
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jme3.util.ReflectionAllocator (file:/C:/Users/xxxx/.gradle/caches/modules-2/files-2.1/org.jmonkeyengine/jme3-core/3.6.0-beta1/f3f826a70693ae115c1e84a0ddd8ca971f61a4bb/jme3-core-3.6.0-beta1.jar) to method sun.nio.ch.DirectBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.jme3.util.ReflectionAllocator
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
gen 27, 2023 10:16:52 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: Intel
 * Renderer: Intel(R) Iris(R) Xe Graphics
 * OpenGL Version: 3.2.0 - Build 31.0.101.3358
 * GLSL Version: 1.50 - Build 31.0.101.3358
 * Profile: Core
gen 27, 2023 10:16:52 AM com.jme3.renderer.opengl.GLRenderer setMainFrameBufferSrgb
WARNING: Driver claims that default framebuffer is not sRGB capable. Enabling anyway.

Edit: Sometimes the game starts correctly, like 1 time out of 20.

This is the log when it works (mouse and joystick disconnected):

gen 27, 2023 10:28:33 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.6.0-beta1
 * Branch: HEAD
 * Git Hash: ee91fb8
 * Build Date: 2023-01-24
gen 27, 2023 10:28:34 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main
 * Graphics Adapter: igdumdim64
 * Driver Version: null
 * Scaling Factor: 1
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jme3.util.ReflectionAllocator (file:/C:/Users/xxxxx/.gradle/caches/modules-2/files-2.1/org.jmonkeyengine/jme3-core/3.6.0-beta1/f3f826a70693ae115c1e84a0ddd8ca971f61a4bb/jme3-core-3.6.0-beta1.jar) to method sun.nio.ch.DirectBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.jme3.util.ReflectionAllocator
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
gen 27, 2023 10:28:34 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: Intel
 * Renderer: Intel(R) Iris(R) Xe Graphics
 * OpenGL Version: 3.2.0 - Build 31.0.101.3358
 * GLSL Version: 1.50 - Build 31.0.101.3358
 * Profile: Core
gen 27, 2023 10:28:34 AM com.jme3.renderer.opengl.GLRenderer setMainFrameBufferSrgb
WARNING: Driver claims that default framebuffer is not sRGB capable. Enabling anyway.
gen 27, 2023 10:28:34 AM net.java.games.input.ControllerEnvironment log
INFO: Failed to initialize device HIDI2C Device because of: java.io.IOException: Failed to acquire device (8007001e)
gen 27, 2023 10:28:34 AM net.java.games.input.ControllerEnvironment log
INFO: Failed to initialize device HIDI2C Device because of: java.io.IOException: Failed to acquire device (8007001e)
gen 27, 2023 10:28:35 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
gen 27, 2023 10:28:35 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
gen 27, 2023 10:28:35 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
gen 27, 2023 10:28:35 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
Libbulletjme version 17.5.4 initializing
capdevon commented 1 year ago

With lwjgl3 the problem never occurs.

Ali-RS commented 1 year ago

Please run with --stacktrace and --debug and see if you can get any useful info about the crash.

And just a blind guess, if you have an antivirus program try to disable it and see if it makes any difference.

Also, if you were running the app from Gradle, try to build an executable (e.g. using "distZip" task) and run it without using Gradle and see if it makes any difference.

stephengold commented 1 year ago

Even though the "crash" doesn't generate any stack trace, it may be possible to obtain a snapshot of what the frozen application is doing, using jstack.

capdevon commented 1 year ago
Full thread dump Java HotSpot(TM) 64-Bit Server VM (11.0.6+8-LTS mixed mode):

Threads class SMR info:
_java_thread_list=0x000002bd8b84fb60, length=15, elements={
0x000002bdfc556000, 0x000002bdfc558000, 0x000002bdfce6e800, 0x000002bdfce16800,
0x000002bdfce18800, 0x000002bdfce25000, 0x000002bdfce7d000, 0x000002bdfd011000,
0x000002bdfd013000, 0x000002bdfd806000, 0x000002bdfd887800, 0x000002bdfdffd000,
0x000002bdfd150000, 0x000002bdd8686000, 0x000002bd8b865800
}

"Reference Handler" #2 daemon prio=10 os_prio=2 cpu=0.00ms elapsed=148.88s tid=0x000002bdfc556000 nid=0x17c4 waiting on condition  [0x000000ecfe2fe000]
   java.lang.Thread.State: RUNNABLE
        at java.lang.ref.Reference.waitForReferencePendingList(java.base@11.0.6/Native Method)
        at java.lang.ref.Reference.processPendingReferences(java.base@11.0.6/Reference.java:241)
        at java.lang.ref.Reference$ReferenceHandler.run(java.base@11.0.6/Reference.java:213)

"Finalizer" #3 daemon prio=8 os_prio=1 cpu=15.63ms elapsed=148.88s tid=0x000002bdfc558000 nid=0x1dbc in Object.wait()  [0x000000ecfe3fe000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(java.base@11.0.6/Native Method)
        - waiting on <0x000000070557f3d0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(java.base@11.0.6/ReferenceQueue.java:155)
        - waiting to re-lock in wait() <0x000000070557f3d0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(java.base@11.0.6/ReferenceQueue.java:176)
        at java.lang.ref.Finalizer$FinalizerThread.run(java.base@11.0.6/Finalizer.java:170)

"Signal Dispatcher" #4 daemon prio=9 os_prio=2 cpu=0.00ms elapsed=148.86s tid=0x000002bdfce6e800 nid=0x4708 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Attach Listener" #5 daemon prio=5 os_prio=2 cpu=265.63ms elapsed=148.86s tid=0x000002bdfce16800 nid=0x3e30 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #6 daemon prio=9 os_prio=2 cpu=703.13ms elapsed=148.86s tid=0x000002bdfce18800 nid=0x4b10 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   No compile task

"C1 CompilerThread0" #9 daemon prio=9 os_prio=2 cpu=515.63ms elapsed=148.86s tid=0x000002bdfce25000 nid=0x3784 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   No compile task

"Sweeper thread" #10 daemon prio=9 os_prio=2 cpu=31.25ms elapsed=148.86s tid=0x000002bdfce7d000 nid=0x40e0 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Service Thread" #11 daemon prio=9 os_prio=0 cpu=0.00ms elapsed=148.77s tid=0x000002bdfd011000 nid=0x37b4 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Common-Cleaner" #12 daemon prio=8 os_prio=1 cpu=31.25ms elapsed=148.77s tid=0x000002bdfd013000 nid=0x28a0 in Object.wait()  [0x000000ecfebff000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(java.base@11.0.6/Native Method)
        - waiting on <0x00000007056b1a10> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(java.base@11.0.6/ReferenceQueue.java:155)
        - waiting to re-lock in wait() <0x00000007056b1a10> (a java.lang.ref.ReferenceQueue$Lock)
        at jdk.internal.ref.CleanerImpl.run(java.base@11.0.6/CleanerImpl.java:148)
        at java.lang.Thread.run(java.base@11.0.6/Thread.java:834)
        at jdk.internal.misc.InnocuousThread.run(java.base@11.0.6/InnocuousThread.java:134)

"Java2D Disposer" #14 daemon prio=10 os_prio=2 cpu=0.00ms elapsed=148.55s tid=0x000002bdfd806000 nid=0x2d34 in Object.wait()  [0x000000ecfecff000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(java.base@11.0.6/Native Method)
        - waiting on <0x0000000705249678> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(java.base@11.0.6/ReferenceQueue.java:155)
        - waiting to re-lock in wait() <0x0000000705249678> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(java.base@11.0.6/ReferenceQueue.java:176)
        at sun.java2d.Disposer.run(java.desktop@11.0.6/Disposer.java:144)
        at java.lang.Thread.run(java.base@11.0.6/Thread.java:834)

"AWT-Windows" #16 daemon prio=6 os_prio=0 cpu=406.25ms elapsed=148.55s tid=0x000002bdfd887800 nid=0x1938 runnable  [0x000000ecfeeff000]
   java.lang.Thread.State: RUNNABLE
        at sun.awt.windows.WToolkit.eventLoop(java.desktop@11.0.6/Native Method)
        at sun.awt.windows.WToolkit.run(java.desktop@11.0.6/WToolkit.java:305)
        at java.lang.Thread.run(java.base@11.0.6/Thread.java:834)

"TimerQueue" #21 daemon prio=5 os_prio=0 cpu=0.00ms elapsed=148.22s tid=0x000002bdfdffd000 nid=0x6c0 waiting on condition  [0x000000ecff2ff000]
   java.lang.Thread.State: WAITING (parking)
        at jdk.internal.misc.Unsafe.park(java.base@11.0.6/Native Method)
        - parking to wait for  <0x000000070521e6e0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(java.base@11.0.6/LockSupport.java:194)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@11.0.6/AbstractQueuedSynchronizer.java:2081)
        at java.util.concurrent.DelayQueue.take(java.base@11.0.6/DelayQueue.java:217)
        at javax.swing.TimerQueue.run(java.desktop@11.0.6/TimerQueue.java:171)
        at java.lang.Thread.run(java.base@11.0.6/Thread.java:834)

"jME3 Main" #22 prio=5 os_prio=0 cpu=531.25ms elapsed=133.37s tid=0x000002bdfd150000 nid=0x1b38 runnable  [0x000000ecff6fc000]
   java.lang.Thread.State: RUNNABLE
        at net.java.games.input.IDirectInputDevice.nAcquire(Native Method)
        at net.java.games.input.IDirectInputDevice.acquire(IDirectInputDevice.java:359)
        at net.java.games.input.IDirectInputDevice.setBufferSize(IDirectInputDevice.java:508)
        - locked <0x0000000707284168> (a net.java.games.input.IDirectInputDevice)
        at net.java.games.input.IDirectInputDevice.<init>(IDirectInputDevice.java:259)
        at net.java.games.input.IDirectInput.addDevice(IDirectInput.java:82)
        at net.java.games.input.IDirectInput.nEnumDevices(Native Method)
        at net.java.games.input.IDirectInput.enumDevices(IDirectInput.java:73)
        at net.java.games.input.IDirectInput.<init>(IDirectInput.java:59)
        at net.java.games.input.DirectInputEnvironmentPlugin.enumControllers(DirectInputEnvironmentPlugin.java:204)
        at net.java.games.input.DirectInputEnvironmentPlugin.<init>(DirectInputEnvironmentPlugin.java:115)
        at net.java.games.input.DirectAndRawInputEnvironmentPlugin.<init>(DirectAndRawInputEnvironmentPlugin.java:45)
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(java.base@11.0.6/Native Method)
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(java.base@11.0.6/NativeConstructorAccessorImpl.java:62)
        at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(java.base@11.0.6/DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(java.base@11.0.6/Constructor.java:490)
        at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:134)
        at com.jme3.input.lwjgl.JInputJoyInput.loadJoysticks(JInputJoyInput.java:87)
        at com.jme3.input.InputManager.<init>(InputManager.java:147)
        at com.jme3.app.LegacyApplication.initInput(LegacyApplication.java:352)
        at com.jme3.app.LegacyApplication.initialize(LegacyApplication.java:649)
        at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:198)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:139)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)
        at java.lang.Thread.run(java.base@11.0.6/Thread.java:834)

"DestroyJavaVM" #23 prio=5 os_prio=0 cpu=468.75ms elapsed=133.37s tid=0x000002bdd8686000 nid=0xb70 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"RMI TCP Accept-0" #26 daemon prio=5 os_prio=0 cpu=0.00ms elapsed=33.15s tid=0x000002bd8b865800 nid=0x4aa8 runnable  [0x000000ecfd9ff000]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainSocketImpl.accept0(java.base@11.0.6/Native Method)
        at java.net.PlainSocketImpl.socketAccept(java.base@11.0.6/PlainSocketImpl.java:159)
        at java.net.AbstractPlainSocketImpl.accept(java.base@11.0.6/AbstractPlainSocketImpl.java:458)
        at java.net.ServerSocket.implAccept(java.base@11.0.6/ServerSocket.java:551)
        at java.net.ServerSocket.accept(java.base@11.0.6/ServerSocket.java:519)
        at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(jdk.management.agent@11.0.6/LocalRMIServerSocketFactory.java:52)
        at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(java.rmi@11.0.6/TCPTransport.java:394)
        at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(java.rmi@11.0.6/TCPTransport.java:366)
        at java.lang.Thread.run(java.base@11.0.6/Thread.java:834)

"VM Thread" os_prio=2 cpu=31.25ms elapsed=148.89s tid=0x000002bdfc551000 nid=0x1348 runnable

"GC Thread#0" os_prio=2 cpu=0.00ms elapsed=148.90s tid=0x000002bdd869a800 nid=0x8b8 runnable

"GC Thread#1" os_prio=2 cpu=31.25ms elapsed=133.48s tid=0x000002bdfe591800 nid=0x2fc4 runnable

"GC Thread#2" os_prio=2 cpu=15.63ms elapsed=133.48s tid=0x000002bdfe599000 nid=0x4088 runnable

"GC Thread#3" os_prio=2 cpu=15.63ms elapsed=133.48s tid=0x000002bdfe599800 nid=0xe9c runnable

"GC Thread#4" os_prio=2 cpu=15.63ms elapsed=133.48s tid=0x000002bdfe5e2000 nid=0x3ff4 runnable

"GC Thread#5" os_prio=2 cpu=0.00ms elapsed=133.48s tid=0x000002bdfe59a800 nid=0x42b8 runnable

"GC Thread#6" os_prio=2 cpu=0.00ms elapsed=132.78s tid=0x000002bdfe332800 nid=0x4020 runnable

"GC Thread#7" os_prio=2 cpu=0.00ms elapsed=132.78s tid=0x000002bd8b69f000 nid=0x1b2c runnable

"G1 Main Marker" os_prio=2 cpu=0.00ms elapsed=148.90s tid=0x000002bdd86d3000 nid=0x4168 runnable

"G1 Conc#0" os_prio=2 cpu=0.00ms elapsed=148.90s tid=0x000002bdd86f9000 nid=0x1ed8 runnable

"G1 Refine#0" os_prio=2 cpu=0.00ms elapsed=148.90s tid=0x000002bdfc43f000 nid=0x4384 runnable

"G1 Young RemSet Sampling" os_prio=2 cpu=0.00ms elapsed=148.90s tid=0x000002bdfc440000 nid=0x29b4 runnable
"VM Periodic Task Thread" os_prio=2 cpu=15.63ms elapsed=148.77s tid=0x000002bdfcffd800 nid=0x3d08 waiting on condition

JNI global refs: 108, weak refs: 18
Ali-RS commented 1 year ago

It's similar to https://github.com/jinput/jinput/issues/8#issue-141675861

Try adding this at the very beginning of the main method:

System.setProperty("net.java.games.input.useDefaultPlugin", "false");

See: https://stackoverflow.com/a/68828083/15218487

capdevon commented 1 year ago

I added that property and it works fine now. Thanks so much for the help guys! Let me know if you want to create a PR or if I have to close the issue.

    /**
     * Start the jMonkeyEngine application
     * @param args
     */
    public static void main(String[] args) {

        Main app = new Main();

        System.setProperty("net.java.games.input.useDefaultPlugin", "false");
        AppSettings settings = new AppSettings(true);
        settings.setUseJoysticks(true); //With Joystick disconnected
        settings.setResolution(1280, 720);

        app.setSettings(settings);
        app.setShowSettings(true);
        app.setPauseOnLostFocus(false);
        app.start();
    }
Ali-RS commented 1 year ago

Glad it solved the issue.

Does it detect joystick correctly when plugged in?

pavly-gerges commented 1 year ago

I think this disables the whole library plugin from working, this is the documentation provided: https://github.com/jinput/jinput/blob/447ec94f22f9023e551a7c25ea2bd8470d5646db/coreAPI/src/main/java/net/java/games/input/package.html#L9

And this is the source where the useDefaultPlugin property is being utilized, a lot of spaghetti code everywhere: https://github.com/jinput/jinput/blob/447ec94f22f9023e551a7c25ea2bd8470d5646db/coreAPI/src/main/java/net/java/games/input/DefaultControllerEnvironment.java#L101-L154

I don't know how jinput works under the hood and in which parts does jme rely on it, but seems jinput provides system plugins under plugins folder and a PluginLoader, so you have to assign which plugin should be loaded on runtime, and in this case Wyatt @capdevon has disabled the default plugin, i am not sure what is the "default plugin", this needs some investigations.....

EDIT: Alright, i have found the usage, joystick support for lwjgl-2 desktop: https://github.com/jMonkeyEngine/jmonkeyengine/blob/7a5d085ff5274b651401d1460a7bf72abd006ac4/jme3-lwjgl/src/main/java/com/jme3/input/lwjgl/JInputJoyInput.java#L125-L126

capdevon commented 1 year ago

Unfortunately there is a problem, setting the useDefaultPlugin=false property the joystick doesn't work.

    /**
     * Start the jMonkeyEngine application
     * @param args
     */
    public static void main(String[] args) {

        Main app = new Main();

        System.setProperty("net.java.games.input.useDefaultPlugin", "false");
        AppSettings settings = new AppSettings(true);
        settings.setUseJoysticks(true); //With Joystick connected
        settings.setResolution(1280, 720);

        app.setSettings(settings);
        app.setShowSettings(true);
        app.setPauseOnLostFocus(false);
        app.start();
    }