From c2d89772336c52cce0b629f6ffc506eb1f221867 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Thu, 21 Nov 2024 12:33:58 -0500 Subject: Thu Nov 21 12:33:58 PM EST 2024 --- src/input/resources.rs | 96 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'src/input/resources.rs') diff --git a/src/input/resources.rs b/src/input/resources.rs index a733984..0324593 100644 --- a/src/input/resources.rs +++ b/src/input/resources.rs @@ -2,54 +2,54 @@ use bevy::{prelude::*, utils::HashSet}; use crossterm::event::{Event, KeyCode}; use std::sync::{Arc, Mutex}; -/// Resource containing currently pressed and released keys -#[derive(Resource, Default)] -pub struct TerminalInput { - pressed_keys: HashSet, - just_pressed_keys: HashSet, - just_released_keys: HashSet, -} - -impl TerminalInput { - /// Gets whether the given key is pressed - pub fn is_pressed(&self, code: KeyCode) -> bool { - self.pressed_keys.contains(&code) - } - - /// Gets whether the given key was just pressed - pub fn just_pressed(&self, code: KeyCode) -> bool { - self.just_pressed_keys.contains(&code) - } - - /// Gets whether the given key was just released - pub fn just_released(&self, code: KeyCode) -> bool { - self.just_released_keys.contains(&code) - } - - /// Sets given key to pressed - pub(super) fn press(&mut self, code: KeyCode) { - if !self.pressed_keys.contains(&code) { - self.pressed_keys.insert(code); - self.just_pressed_keys.insert(code); - } - } - - /// Sets given key to released and removes pressed state - pub(super) fn release(&mut self, code: KeyCode) { - self.pressed_keys.remove(&code); - self.just_released_keys.insert(code); - } - - /// Clears all just released keys - pub(super) fn clear_just_released(&mut self) { - self.just_released_keys.clear(); - } - - /// Clears all just pressed keys - pub(super) fn clear_just_pressed(&mut self) { - self.just_pressed_keys.clear(); - } -} +// /// Resource containing currently pressed and released keys +// #[derive(Resource, Default)] +// pub struct TerminalInput { +// pressed_keys: HashSet, +// just_pressed_keys: HashSet, +// just_released_keys: HashSet, +// } +// +// impl TerminalInput { +// /// Gets whether the given key is pressed +// pub fn is_pressed(&self, code: KeyCode) -> bool { +// self.pressed_keys.contains(&code) +// } +// +// /// Gets whether the given key was just pressed +// pub fn just_pressed(&self, code: KeyCode) -> bool { +// self.just_pressed_keys.contains(&code) +// } +// +// /// Gets whether the given key was just released +// pub fn just_released(&self, code: KeyCode) -> bool { +// self.just_released_keys.contains(&code) +// } +// +// /// Sets given key to pressed +// pub(super) fn press(&mut self, code: KeyCode) { +// if !self.pressed_keys.contains(&code) { +// self.pressed_keys.insert(code); +// self.just_pressed_keys.insert(code); +// } +// } +// +// /// Sets given key to released and removes pressed state +// pub(super) fn release(&mut self, code: KeyCode) { +// self.pressed_keys.remove(&code); +// self.just_released_keys.insert(code); +// } +// +// /// Clears all just released keys +// pub(super) fn clear_just_released(&mut self) { +// self.just_released_keys.clear(); +// } +// +// /// Clears all just pressed keys +// pub(super) fn clear_just_pressed(&mut self) { +// self.just_pressed_keys.clear(); +// } +// } /// Event queue for crossterm input event thread #[derive(Resource, Default)] -- cgit v1.2.3