Skip to content

Commit

Permalink
Get key example
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Nov 28, 2023
1 parent 2e577f6 commit 4279759
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
use crate::cpu::CPU;
use crate::mode::GBMode;
use clap::Parser;
use std::fs::File;
use std::io::Read;
use winit::event::{ElementState, Event, WindowEvent};
use winit::keyboard::{Key, ModifiersState};
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
use winit::{event_loop::EventLoop, window::WindowBuilder};
use clap::{Parser};
use crate::cpu::CPU;
use crate::mode::GBMode;

mod cpu;
mod registers;
mod mode;
mod registers;

#[derive(Parser)]
struct Args {
rom_path: String
rom_path: String,
}

fn main() -> Result<(), impl std::error::Error> {
Expand Down Expand Up @@ -44,7 +47,26 @@ fn main() -> Result<(), impl std::error::Error> {
.build(&event_loop)
.unwrap();

let mut modifiers = ModifiersState::default();

event_loop.run(move |event, elwt| {
// println!("{event:?}");
if let Event::WindowEvent { event, .. } = event {
match event {
WindowEvent::ModifiersChanged(new) => {
modifiers = new.state();
}
WindowEvent::KeyboardInput { event, .. } => {
if event.state == ElementState::Pressed && !event.repeat {
match event.key_without_modifiers().as_ref() {
Key::Character("w") => {
println!("Got W Key!");
}
_ => (),
}
}
}
_ => (),
}
}
})
}

0 comments on commit 4279759

Please sign in to comment.