From ddf37578fb91dcc0053f5964405663132aa791a7 Mon Sep 17 00:00:00 2001 From: oiupoyt Date: Wed, 30 Sep 2026 07:46:08 +0530 Subject: [PATCH] feat(input): implement unified input manager and register Vibrator classes in JNI --- crates/molotov-core/src/input/manager.rs | 23 +++++++++++++++++++ crates/molotov-core/src/input/mod.rs | 1 + crates/molotov-core/src/jni/framework.rs | 2 ++ .../molotov-core/tests/input_manager_test.rs | 16 +++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 crates/molotov-core/src/input/manager.rs create mode 100644 crates/molotov-core/tests/input_manager_test.rs diff --git a/crates/molotov-core/src/input/manager.rs b/crates/molotov-core/src/input/manager.rs new file mode 100644 index 0000000..4abf5b9 --- /dev/null +++ b/crates/molotov-core/src/input/manager.rs @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +use super::haptics::RumbleManager; +use super::ime::ImeManager; + +pub struct InputManager { + pub ime: ImeManager, + pub haptics: RumbleManager, +} + +impl Default for InputManager { + fn default() -> Self { + Self::new() + } +} + +impl InputManager { + pub fn new() -> Self { + Self { + ime: ImeManager::new(), + haptics: RumbleManager::new(), + } + } +} diff --git a/crates/molotov-core/src/input/mod.rs b/crates/molotov-core/src/input/mod.rs index 7349334..97bbb33 100644 --- a/crates/molotov-core/src/input/mod.rs +++ b/crates/molotov-core/src/input/mod.rs @@ -2,3 +2,4 @@ pub mod gamepad; pub mod haptics; pub mod ime; +pub mod manager; diff --git a/crates/molotov-core/src/jni/framework.rs b/crates/molotov-core/src/jni/framework.rs index 02947b8..e69dc83 100644 --- a/crates/molotov-core/src/jni/framework.rs +++ b/crates/molotov-core/src/jni/framework.rs @@ -30,6 +30,8 @@ impl AndroidEnvironment { known.insert("android/os/Build".to_string()); known.insert("android/os/Build$VERSION".to_string()); known.insert("android/view/SurfaceView".to_string()); + known.insert("android/os/Vibrator".to_string()); + known.insert("android/os/VibrationEffect".to_string()); known.insert("com/roblox/client/RobloxApplication".to_string()); known.insert("com/roblox/client/ActivityNativeMain".to_string()); diff --git a/crates/molotov-core/tests/input_manager_test.rs b/crates/molotov-core/tests/input_manager_test.rs new file mode 100644 index 0000000..31cbdf5 --- /dev/null +++ b/crates/molotov-core/tests/input_manager_test.rs @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +use molotov_core::input::manager::InputManager; + +#[test] +fn test_input_manager_coordination() { + let mut input = InputManager::new(); + assert!(!input.ime.is_active()); + + // Game requests text entry + input.ime.start_text_input(Default::default()); + assert!(input.ime.is_active()); + + // Game dispatches haptics + input.haptics.rumble(0, 0.8, 0.8, 100); + assert_eq!(input.haptics.get_state(0).unwrap().duration_ms, 100); +}