Native Controller Support Implementation - #508
Closed
varung2 wants to merge 3 commits into
Closed
Conversation
added 3 commits
December 26, 2025 11:08
…tion in the Gamepad settings called 'Native Controller Mode'
|
Hi, I am on Android, how to connect my controller. |
|
Does it work? And why is it cancelled? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Native Controller Support Implementation
🎮 Overview
This PR adds full native gamepad/controller support to ZalithLauncher, allowing Minecraft to receive direct controller input via the GLFW joystick API. Previously, controllers only worked through keyboard emulation. Now users can choose between keyboard emulation mode (legacy, default) or native gamepad mode (new, experimental) for a true controller experience in Minecraft 1.12+. My specific reason for adding this is because I wanted to use the native controller input built into my android handheld when playing minecraft (and with Controlify mod). Full disclosure: AI coding tools were partly used to help develop this feature and for this description below.
Test instructions are at the bottom, I've been testing with my integrated physical controller but this input flow should work with any bluetooth controller. For perf concerns, I think the impact should be minimal as it uses the same thread as before that processes inputs, so latency should be the same as before.
Please feel free to edit and modify this PR request. Also, if more documentation is desired, I'd be glad to add it. Thanks!
✨ Key Features
1. Native Gamepad Input
2. Non-Breaking Implementation
3. Dual Input Architecture
🏗️ Architecture
System Flow Diagram
graph TB subgraph "Hardware Layer" A[Physical Controller<br/>Xbox/PS/Generic] end subgraph "Android Input Layer" B[Android InputDevice API] C[KeyEvent / MotionEvent] end subgraph "ZalithLauncher Kotlin Layer" D[GamepadEvents.kt<br/>Event Capture] E[GamepadRemapper.kt<br/>Button/Axis Mapping] F[GamepadViewModel.kt<br/>State Management] G{Control Mode?} H[Keyboard Emulation<br/>Path] I[Native Gamepad<br/>Path] end subgraph "Java Bridge Layer" J[CallbackBridge.java<br/>sendGamepadButton/Axis] K[sendKeyPress<br/>Legacy Path] end subgraph "Native C/JNI Layer" L[input_bridge_v3.c<br/>Event Queue] M[pojavPumpEvents<br/>Event Processing] end subgraph "LWJGL/GLFW Layer" N[GLFW.java<br/>State Storage] O[GLFWGamepadState<br/>15 buttons + 6 axes] P[glfwGetGamepadState<br/>Polling API] end subgraph "Minecraft" Q[Minecraft Game Loop] R[Controller Input Handler] end A --> B B --> C C --> D D --> E E --> F F --> G G -->|Emulation Mode| H G -->|Native Mode| I H --> K K --> L I --> J J --> L L --> M M -->|Update State| N N --> O O --> P M -->|Legacy Callbacks| Q P -->|Modern Polling| Q Q --> R style G fill:#ff9800 style I fill:#4caf50 style H fill:#2196f3 style O fill:#9c27b0 style P fill:#9c27b0Data Flow by Mode
Native Mode Flow
🎯 User Experience
Access Path
Default Behavior
When Native Mode is Enabled
Controller Connection Flow
🔒 Backward Compatibility
Backwards Compatible
Safe Defaults
🚀 How to Test This PR
Prerequisites
Test Procedure
Expected Results
📖 References
GLFW Documentation
Android Documentation
LWJGL Documentation