use std::{any::{Any, TypeId}, collections::HashMap, hash::Hash, marker::PhantomData}; use bevy::prelude::*; use bevy_common_assets::toml::TomlAssetPlugin; use leafwing_input_manager::{Actionlike, prelude::{Axislike, Buttonlike, DualAxislike, InputMap}}; use serde::{Deserialize, Serialize, de::DeserializeOwned}; const INPUT_ASSET_EXTENSIONS: [&'static str; 1] = ["input.toml"]; #[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq, Eq)] 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)] #[serde(untagged)] pub enum InputKind { Button(MultiInput), Axis(Vec>), DualAxis(Vec>), } #[derive(Default, Deref, DerefMut, Debug, Asset, Reflect, Clone, Serialize, Deserialize, PartialEq, Eq)] 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