Skip to content

Add low-level hook for SDL3 input events#2867

Open
Ivan1pl wants to merge 2 commits into
jMonkeyEngine:masterfrom
Ivan1pl:issue/2864/SDL3-low-level-input-event
Open

Add low-level hook for SDL3 input events#2867
Ivan1pl wants to merge 2 commits into
jMonkeyEngine:masterfrom
Ivan1pl:issue/2864/SDL3-low-level-input-event

Conversation

@Ivan1pl

@Ivan1pl Ivan1pl commented Jun 10, 2026

Copy link
Copy Markdown

Resolves #2864

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the SdlEventListener interface to allow custom listeners to receive raw SDL events, and updates SdlJoystickInput, SdlKeyInput, and SdlMouseInput to implement it. LwjglWindow is updated to manage these listeners and dispatch events. The feedback suggests wrapping the custom listener event dispatch loop in a try-catch block to prevent any unhandled exceptions from interrupting the dispatching of events to subsequent listeners and internal input handlers.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java
@Ivan1pl Ivan1pl force-pushed the issue/2864/SDL3-low-level-input-event branch from deee7e0 to dcc7875 Compare July 10, 2026 19:20
@yaRnMcDonuts yaRnMcDonuts added this to the v3.10.0 milestone Jul 13, 2026
windowSizeListeners.remove(listener);
}

public void registerSdlEventListener(SdlEventListener listener) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if registerSdlEventListener(...) could be renamed to addSdlEventListener(...) for consistency with removeSdlEventListener(...).

Using complementary method pairs (add/remove, get/set, etc.) is a well-established Java API convention and tends to make APIs more intuitive. Since the method simply adds the listener to an internal collection, addSdlEventListener() also seems to better reflect what it actually does.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I went for consistency with existing API for WindowSizeListener: registerWindowSizeListener and removeWindowSizeListener. With that in mind, should I rename this to addSdlEventListener, or keep it as it is?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, and I owe you an apology for assuming your suggestion was inconsistent with the existing API. Your reply made it clear that you were actually following the current WindowSizeListener naming (registerWindowSizeListener / removeWindowSizeListener).

At this point, I see two possible approaches:

  1. Adopt the add/remove convention for new APIs. In that case, this PR could introduce addSdlEventListener() / removeSdlEventListener(), and a follow-up PR could deprecate registerWindowSizeListener() in favor of addWindowSizeListener(), while keeping backward compatibility for the time being.

  2. Keep consistency with the existing API. That would mean naming the new methods registerSdlEventListener() / removeSdlEventListener(), matching the current WindowSizeListener API even though the register/remove pairing is less consistent with common Java naming conventions.

That said, this is only my opinion. The final decision on API direction should rest with the engine maintainers.
@riccardobl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add low-level hook for SDL3 input event

3 participants