use bevy::input::InputPlugin;
use bevy::prelude::*;
use leafwing_input_manager::plugin::{AccumulatorPlugin, CentralInputStorePlugin};
use leafwing_input_manager::prelude::*;
use leafwing_input_manager::user_input::testing_utils::FetchUserInput;
#[derive(Debug, Resource)]
pub struct MouseJoy(pub Vec2);

pub fn update_mouse_joy(mut commands: Commands, windows: Query<&Window>) {
    let window = windows.single();
    let mut joy = MouseJoy(Vec2::default());
    if let Some(pos) = window.cursor_position() {
        joy.0.x = ((pos.x / window.width()) - 0.5) * 2.0;
        joy.0.y = ((pos.y / window.height()) - 0.5) * 2.0;
    }
    commands.insert_resource(joy);
}