Fix just pressed

This commit is contained in:
Silas Bartha 2024-07-31 21:06:04 -04:00
parent 15c97f12e9
commit 130ddd8117
Signed by: soaos
GPG Key ID: 9BD3DCC0D56A09B2
2 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "bevy_terminal_display"
version = "0.4.0"
version = "0.4.1"
edition = "2021"
license = "0BSD OR MIT OR Apache-2.0"
description = "A plugin for the Bevy game engine which enables rendering to a terminal using unicode braille characters."

View File

@ -1,4 +1,4 @@
use bevy::{prelude:: *, utils::HashSet};
use bevy::{prelude::*, utils::HashSet};
use crossterm::event::{Event, KeyCode};
use std::sync::{Arc, Mutex};
@ -28,8 +28,10 @@ impl TerminalInput {
/// Sets given key to pressed
pub(super) fn press(&mut self, code: KeyCode) {
self.pressed_keys.insert(code);
self.just_pressed_keys.insert(code);
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
@ -42,7 +44,7 @@ impl TerminalInput {
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();