use std::{ any::{ Any, TypeId, }, collections::HashMap, hash::Hash, marker::PhantomData, }; use bevy::{ prelude::*, reflect::GetTypeRegistration, }; use bevy_common_assets::toml::TomlAssetPlugin; use leafwing_input_manager::{ Actionlike, plugin::InputManagerPlugin, prelude::*, }; use serde::{ Deserialize, Serialize, de::DeserializeOwned, }; const INPUT_ASSET_EXTENSIONS: [&'static str; 1] = ["input.toml"]; #[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq, Eq, Reflect)] #[reflect(Clone, Debug, Serialize, Deserialize, Default, PartialEq)] pub struct MultiInput { pub keyboard: Option>, pub mouse: Option>, pub gamepad: Option>, } impl From for InputKind { fn from(value: MultiInput) -> Self { Self::Button(value) } } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Reflect)] #[reflect(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(untagged)] pub enum InputKind { Button(MultiInput), Axis(Vec>), DualAxis(Vec>), } #[derive(Default, Deref, DerefMut, Debug, Asset, Reflect, Clone, Serialize, Deserialize, PartialEq, Eq)] #[reflect(Debug, Clone, PartialEq)] pub struct InputAsset where Name: Sized + Hash + Eq + Reflect + TypePath + Actionlike { #[serde(flatten)] events: HashMap, } fn copy_keys(input_map: &mut InputMap, name: &Name, buttons: &Vec