feat(input): implement unified input manager and register Vibrator classes in JNI

This commit is contained in:
katR 2026-09-30 07:46:08 +05:30
parent 52ac39072f
commit ddf37578fb
4 changed files with 42 additions and 0 deletions

View file

@ -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(),
}
}
}

View file

@ -2,3 +2,4 @@
pub mod gamepad;
pub mod haptics;
pub mod ime;
pub mod manager;

View file

@ -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());

View file

@ -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);
}