1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use lotus_script_sys::FfiObject;
pub use lotus_shared::action::*;
use lotus_shared::input::ActionState;

/// Get the current state of an action. If the action is not registered, it will return `ActionState::None`.
pub fn state(action: &str) -> ActionState {
    let action = FfiObject::new(&action);
    let state = unsafe { lotus_script_sys::action::state(action.packed()) };

    FfiObject::from_packed(state).deserialize()
}

#[doc(hidden)]
pub fn register_many(actions: &[RegisterAction]) {
    for action in actions {
        let action = FfiObject::new(&action);
        unsafe {
            lotus_script_sys::action::register(action.packed());
        }
    }
}