upgrade winit
This commit is contained in:
Generated
+1413
-451
File diff suppressed because it is too large
Load Diff
@@ -59,11 +59,11 @@ impl<'a> PairExt for Pair<'a> {
|
|||||||
pub trait PairsExt {
|
pub trait PairsExt {
|
||||||
/// Peek the next sibling but only if it matches a given rule: used for things
|
/// Peek the next sibling but only if it matches a given rule: used for things
|
||||||
/// with optional modifiers following
|
/// with optional modifiers following
|
||||||
fn next_if_rule(&mut self, rule: PestRule) -> Option<Pair>;
|
fn next_if_rule(&mut self, rule: PestRule) -> Option<Pair<'_>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PairsExt for Peekable<Pairs<'_>> {
|
impl PairsExt for Peekable<Pairs<'_>> {
|
||||||
fn next_if_rule(&mut self, rule: PestRule) -> Option<Pair> {
|
fn next_if_rule(&mut self, rule: PestRule) -> Option<Pair<'_>> {
|
||||||
self.next_if(|p| p.as_rule() == rule)
|
self.next_if(|p| p.as_rule() == rule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -10,5 +10,5 @@ vcore = { path = "../vcore" }
|
|||||||
vgfx = { path = "../vgfx" }
|
vgfx = { path = "../vgfx" }
|
||||||
vasm_core = { path = "../vasm_core" }
|
vasm_core = { path = "../vasm_core" }
|
||||||
rand = "0.8.0"
|
rand = "0.8.0"
|
||||||
winit = "0.26.1"
|
winit = "0.30.12"
|
||||||
pixels = "0.9.0"
|
pixels = "0.15.0"
|
||||||
+108
-107
@@ -1,117 +1,118 @@
|
|||||||
use winit::event::VirtualKeyCode;
|
use winit::keyboard::{KeyCode};
|
||||||
|
|
||||||
pub fn convert_keycode(vkey: VirtualKeyCode) -> u8 {
|
pub fn convert_keycode(vkey: KeyCode) -> u8 {
|
||||||
|
use KeyCode::*;
|
||||||
match vkey {
|
match vkey {
|
||||||
VirtualKeyCode::A => 0x04,
|
KeyA => 0x04,
|
||||||
VirtualKeyCode::B => 0x05,
|
KeyB => 0x05,
|
||||||
VirtualKeyCode::C => 0x06,
|
KeyC => 0x06,
|
||||||
VirtualKeyCode::D => 0x07,
|
KeyD => 0x07,
|
||||||
VirtualKeyCode::E => 0x08,
|
KeyE => 0x08,
|
||||||
VirtualKeyCode::F => 0x09,
|
KeyF => 0x09,
|
||||||
VirtualKeyCode::G => 0x0a,
|
KeyG => 0x0a,
|
||||||
VirtualKeyCode::H => 0x0b,
|
KeyH => 0x0b,
|
||||||
VirtualKeyCode::I => 0x0c,
|
KeyI => 0x0c,
|
||||||
VirtualKeyCode::J => 0x0d,
|
KeyJ => 0x0d,
|
||||||
VirtualKeyCode::K => 0x0e,
|
KeyK => 0x0e,
|
||||||
VirtualKeyCode::L => 0x0f,
|
KeyL => 0x0f,
|
||||||
VirtualKeyCode::M => 0x10,
|
KeyM => 0x10,
|
||||||
VirtualKeyCode::N => 0x11,
|
KeyN => 0x11,
|
||||||
VirtualKeyCode::O => 0x12,
|
KeyO => 0x12,
|
||||||
VirtualKeyCode::P => 0x13,
|
KeyP => 0x13,
|
||||||
VirtualKeyCode::Q => 0x14,
|
KeyQ => 0x14,
|
||||||
VirtualKeyCode::R => 0x15,
|
KeyR => 0x15,
|
||||||
VirtualKeyCode::S => 0x16,
|
KeyS => 0x16,
|
||||||
VirtualKeyCode::T => 0x17,
|
KeyT => 0x17,
|
||||||
VirtualKeyCode::U => 0x18,
|
KeyU => 0x18,
|
||||||
VirtualKeyCode::V => 0x19,
|
KeyV => 0x19,
|
||||||
VirtualKeyCode::W => 0x1a,
|
KeyW => 0x1a,
|
||||||
VirtualKeyCode::X => 0x1b,
|
KeyX => 0x1b,
|
||||||
VirtualKeyCode::Y => 0x1c,
|
KeyY => 0x1c,
|
||||||
VirtualKeyCode::Z => 0x1d,
|
KeyZ => 0x1d,
|
||||||
VirtualKeyCode::Key1 => 0x1e,
|
Digit1 => 0x1e,
|
||||||
VirtualKeyCode::Key2 => 0x1f,
|
Digit2 => 0x1f,
|
||||||
VirtualKeyCode::Key3 => 0x20,
|
Digit3 => 0x20,
|
||||||
VirtualKeyCode::Key4 => 0x21,
|
Digit4 => 0x21,
|
||||||
VirtualKeyCode::Key5 => 0x22,
|
Digit5 => 0x22,
|
||||||
VirtualKeyCode::Key6 => 0x23,
|
Digit6 => 0x23,
|
||||||
VirtualKeyCode::Key7 => 0x24,
|
Digit7 => 0x24,
|
||||||
VirtualKeyCode::Key8 => 0x25,
|
Digit8 => 0x25,
|
||||||
VirtualKeyCode::Key9 => 0x26,
|
Digit9 => 0x26,
|
||||||
VirtualKeyCode::Key0 => 0x27,
|
Digit0 => 0x27,
|
||||||
VirtualKeyCode::Return => 0x28,
|
Enter => 0x28,
|
||||||
VirtualKeyCode::Escape => 0x29,
|
Escape => 0x29,
|
||||||
VirtualKeyCode::Back => 0x2a,
|
BrowserBack => 0x2a,
|
||||||
VirtualKeyCode::Tab => 0x2b,
|
Tab => 0x2b,
|
||||||
VirtualKeyCode::Space => 0x2c,
|
Space => 0x2c,
|
||||||
VirtualKeyCode::Minus => 0x2d,
|
Minus => 0x2d,
|
||||||
VirtualKeyCode::Equals => 0x2e,
|
Equal => 0x2e,
|
||||||
VirtualKeyCode::LBracket => 0x2f,
|
BracketLeft => 0x2f,
|
||||||
VirtualKeyCode::RBracket => 0x30,
|
BracketRight => 0x30,
|
||||||
VirtualKeyCode::Backslash => 0x31,
|
Backslash => 0x31,
|
||||||
// 0x32 is a non-US keyboard key: hash and tilde
|
// 0x32 is a non-US keyboard key: hash and tilde
|
||||||
VirtualKeyCode::Semicolon => 0x33,
|
Semicolon => 0x33,
|
||||||
VirtualKeyCode::Apostrophe => 0x34,
|
Quote => 0x34,
|
||||||
VirtualKeyCode::Grave => 0x35,
|
Backquote => 0x35,
|
||||||
VirtualKeyCode::Comma => 0x36,
|
Comma => 0x36,
|
||||||
VirtualKeyCode::Period => 0x37,
|
Period => 0x37,
|
||||||
VirtualKeyCode::Slash => 0x38,
|
Slash => 0x38,
|
||||||
VirtualKeyCode::Capital => 0x39,
|
CapsLock => 0x39,
|
||||||
VirtualKeyCode::F1 => 0x3a,
|
F1 => 0x3a,
|
||||||
VirtualKeyCode::F2 => 0x3b,
|
F2 => 0x3b,
|
||||||
VirtualKeyCode::F3 => 0x3c,
|
F3 => 0x3c,
|
||||||
VirtualKeyCode::F4 => 0x3d,
|
F4 => 0x3d,
|
||||||
VirtualKeyCode::F5 => 0x3e,
|
F5 => 0x3e,
|
||||||
VirtualKeyCode::F6 => 0x3f,
|
F6 => 0x3f,
|
||||||
VirtualKeyCode::F7 => 0x40,
|
F7 => 0x40,
|
||||||
VirtualKeyCode::F8 => 0x41,
|
F8 => 0x41,
|
||||||
VirtualKeyCode::F9 => 0x42,
|
F9 => 0x42,
|
||||||
VirtualKeyCode::F10 => 0x43,
|
F10 => 0x43,
|
||||||
VirtualKeyCode::F11 => 0x44,
|
F11 => 0x44,
|
||||||
VirtualKeyCode::F12 => 0x45,
|
F12 => 0x45,
|
||||||
VirtualKeyCode::Sysrq => 0x46,
|
PrintScreen => 0x46,
|
||||||
VirtualKeyCode::Scroll => 0x47,
|
ScrollLock => 0x47,
|
||||||
VirtualKeyCode::Pause => 0x48,
|
Pause => 0x48,
|
||||||
VirtualKeyCode::Insert => 0x49,
|
Insert => 0x49,
|
||||||
VirtualKeyCode::Home => 0x4a,
|
Home => 0x4a,
|
||||||
VirtualKeyCode::PageUp => 0x4b,
|
PageUp => 0x4b,
|
||||||
VirtualKeyCode::Delete => 0x4c,
|
Delete => 0x4c,
|
||||||
VirtualKeyCode::End => 0x4d,
|
End => 0x4d,
|
||||||
VirtualKeyCode::PageDown => 0x4e,
|
PageDown => 0x4e,
|
||||||
VirtualKeyCode::Right => 0x4f,
|
ArrowRight => 0x4f,
|
||||||
VirtualKeyCode::Left => 0x50,
|
ArrowLeft => 0x50,
|
||||||
VirtualKeyCode::Down => 0x51,
|
ArrowDown => 0x51,
|
||||||
VirtualKeyCode::Up => 0x52,
|
ArrowUp => 0x52,
|
||||||
VirtualKeyCode::Numlock => 0x53,
|
NumLock => 0x53,
|
||||||
VirtualKeyCode::NumpadDivide => 0x54,
|
NumpadDivide => 0x54,
|
||||||
VirtualKeyCode::NumpadMultiply => 0x55,
|
NumpadMultiply => 0x55,
|
||||||
VirtualKeyCode::NumpadSubtract => 0x56,
|
NumpadSubtract => 0x56,
|
||||||
VirtualKeyCode::NumpadAdd => 0x57,
|
NumpadAdd => 0x57,
|
||||||
VirtualKeyCode::NumpadEnter => 0x58,
|
NumpadEnter => 0x58,
|
||||||
VirtualKeyCode::Numpad1 => 0x59,
|
Numpad1 => 0x59,
|
||||||
VirtualKeyCode::Numpad2 => 0x5a,
|
Numpad2 => 0x5a,
|
||||||
VirtualKeyCode::Numpad3 => 0x5b,
|
Numpad3 => 0x5b,
|
||||||
VirtualKeyCode::Numpad4 => 0x5c,
|
Numpad4 => 0x5c,
|
||||||
VirtualKeyCode::Numpad5 => 0x5d,
|
Numpad5 => 0x5d,
|
||||||
VirtualKeyCode::Numpad6 => 0x5e,
|
Numpad6 => 0x5e,
|
||||||
VirtualKeyCode::Numpad7 => 0x5f,
|
Numpad7 => 0x5f,
|
||||||
VirtualKeyCode::Numpad8 => 0x60,
|
Numpad8 => 0x60,
|
||||||
VirtualKeyCode::Numpad9 => 0x61,
|
Numpad9 => 0x61,
|
||||||
VirtualKeyCode::Numpad0 => 0x62,
|
Numpad0 => 0x62,
|
||||||
VirtualKeyCode::NumpadDecimal => 0x63,
|
NumpadDecimal => 0x63,
|
||||||
// 0x64 is a non-US keyboard key: backslash and bar
|
// 0x64 is a non-US keyboard key: backslash and bar
|
||||||
VirtualKeyCode::Compose => 0x65,
|
Hiragana => 0x65,
|
||||||
// 0x66 is a non-standard key: power
|
// 0x66 is a non-standard key: power
|
||||||
VirtualKeyCode::NumpadEquals => 0x67,
|
NumpadEqual => 0x67,
|
||||||
// 0x68-0x73 is extended function keys
|
// 0x68-0x73 is extended function keys
|
||||||
// 0x74-0xdf is a bunch of international stuff and keypad stuff
|
// 0x74-0xdf is a bunch of international stuff and keypad stuff
|
||||||
VirtualKeyCode::LControl => 0xe0,
|
ControlLeft => 0xe0,
|
||||||
VirtualKeyCode::LShift => 0xe1,
|
ShiftLeft => 0xe1,
|
||||||
VirtualKeyCode::LAlt => 0xe2,
|
AltLeft => 0xe2,
|
||||||
VirtualKeyCode::LWin => 0xe3,
|
SuperLeft => 0xe3,
|
||||||
VirtualKeyCode::RControl => 0xe4,
|
ControlRight => 0xe4,
|
||||||
VirtualKeyCode::RShift => 0xe5,
|
ShiftRight => 0xe5,
|
||||||
VirtualKeyCode::RAlt => 0xe6,
|
AltRight => 0xe6,
|
||||||
VirtualKeyCode::RWin => 0xe7,
|
SuperRight => 0xe7,
|
||||||
_ => 0xff,
|
_ => 0xff,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+107
-80
@@ -4,128 +4,155 @@ use winit::{
|
|||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
window::WindowBuilder,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::keyboard::convert_keycode;
|
use crate::keyboard::convert_keycode;
|
||||||
use pixels::{Pixels, SurfaceTexture};
|
use pixels::{Pixels, SurfaceTexture};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
use std::sync::Arc;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
use winit::application::ApplicationHandler;
|
||||||
use vasm_core::assemble_snippet;
|
use vasm_core::assemble_snippet;
|
||||||
use vcore::cpu::CPU;
|
use vcore::cpu::CPU;
|
||||||
use vcore::memory::{Memory, PeekPoke};
|
use vcore::memory::{Memory, PeekPoke};
|
||||||
use vcore::word::Word;
|
use vcore::word::Word;
|
||||||
use winit::event::{DeviceEvent, ElementState};
|
use winit::event::{DeviceEvent, DeviceId, ElementState, StartCause};
|
||||||
use winit::window::Window;
|
use winit::event_loop::ActiveEventLoop;
|
||||||
|
use winit::keyboard::PhysicalKey;
|
||||||
|
use winit::window::{Window, WindowId};
|
||||||
use vgfx::display;
|
use vgfx::display;
|
||||||
|
|
||||||
fn main() {
|
struct App<'a> {
|
||||||
let event_loop = EventLoop::new();
|
cpu: CPU,
|
||||||
|
pixels: Option<Pixels<'a>>,
|
||||||
|
window: Option<Arc<Window>>,
|
||||||
|
interrupt_events: VecDeque<(usize, Option<Word>)>,
|
||||||
|
focused: bool
|
||||||
|
}
|
||||||
|
|
||||||
let window = {
|
impl<'a> App<'a> {
|
||||||
|
fn new() -> Self {
|
||||||
|
let rng = rand::thread_rng();
|
||||||
|
let memory = Memory::from(rng);
|
||||||
|
|
||||||
|
Self {
|
||||||
|
cpu: CPU::new(memory),
|
||||||
|
pixels: None,
|
||||||
|
window: None,
|
||||||
|
interrupt_events: VecDeque::new(),
|
||||||
|
focused: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<'a> ApplicationHandler for App<'a> {
|
||||||
|
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
||||||
let size = LogicalSize::new(640, 480);
|
let size = LogicalSize::new(640, 480);
|
||||||
WindowBuilder::new()
|
|
||||||
|
let attrs = Window::default_attributes()
|
||||||
.with_title("Vulcan")
|
.with_title("Vulcan")
|
||||||
.with_inner_size(size)
|
.with_inner_size(size)
|
||||||
.with_min_inner_size(size)
|
.with_min_inner_size(size);
|
||||||
.build(&event_loop)
|
|
||||||
.unwrap()
|
|
||||||
};
|
|
||||||
|
|
||||||
let pixels = {
|
self.window = Some(event_loop.create_window(attrs).expect("Failed to create window").into());
|
||||||
let winit::dpi::PhysicalSize { width, height } = window.inner_size();
|
|
||||||
let surface_texture = SurfaceTexture::new(width, height, &window);
|
|
||||||
Pixels::new(640, 480, surface_texture).unwrap()
|
|
||||||
};
|
|
||||||
|
|
||||||
let rng = rand::thread_rng();
|
display::init_gfx(&mut self.cpu);
|
||||||
|
|
||||||
let memory = Memory::from(rng);
|
|
||||||
let mut cpu = CPU::new(memory);
|
|
||||||
display::init_gfx(&mut cpu);
|
|
||||||
let code = assemble_snippet(include_str!("typewriter.asm").lines().map(String::from))
|
let code = assemble_snippet(include_str!("typewriter.asm").lines().map(String::from))
|
||||||
.expect("Assemble error");
|
.expect("Assemble error");
|
||||||
|
|
||||||
// let code = assemble_file("init.asm").expect("Assemble error");
|
// let code = assemble_file("init.asm").expect("Assemble error");
|
||||||
// let mut file = File::open("4th.rom").expect("ROM not found");
|
// let mut file = File::open("4th.rom").expect("ROM not found");
|
||||||
// let mut code = Vec::new();
|
// let mut code = Vec::new();
|
||||||
// file.read_to_end(&mut code).expect("Couldn't read ROM");
|
// file.read_to_end(&mut code).expect("Couldn't read ROM");
|
||||||
println!("ROM size: {} bytes", code.len());
|
println!("ROM size: {} bytes", code.len());
|
||||||
cpu.poke_slice(0x400.into(), code.as_slice());
|
self.cpu.poke_slice(0x400.into(), code.as_slice());
|
||||||
cpu.start();
|
self.cpu.start();
|
||||||
window_loop(event_loop, window, pixels, cpu)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn window_loop(event_loop: EventLoop<()>, window: Window, mut pixels: Pixels, mut cpu: CPU) -> ! {
|
let winit::dpi::PhysicalSize { width, height } = self.window.as_ref().unwrap().inner_size();
|
||||||
let mut interrupt_events: VecDeque<(usize, Option<Word>)> = VecDeque::new();
|
let surface_texture = SurfaceTexture::new(width, height, self.window.as_ref().unwrap().clone());
|
||||||
let mut focused = true;
|
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
self.pixels = Some(Pixels::new(640, 480, surface_texture).unwrap());
|
||||||
*control_flow = ControlFlow::Poll;
|
event_loop.set_control_flow(ControlFlow::WaitUntil(Instant::now() + Duration::from_millis(15)))
|
||||||
|
|
||||||
match event {
|
|
||||||
Event::WindowEvent {
|
|
||||||
event: WindowEvent::CloseRequested,
|
|
||||||
window_id,
|
|
||||||
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
|
|
||||||
|
|
||||||
Event::WindowEvent {
|
|
||||||
event: WindowEvent::Resized(new_size),
|
|
||||||
window_id,
|
|
||||||
} if window_id == window.id() => {
|
|
||||||
pixels.resize_surface(new_size.width, new_size.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are sent regardless of whether the window is focused or not, and are the same regardless of keyboard
|
fn new_events(&mut self, event_loop: &ActiveEventLoop, cause: StartCause) {
|
||||||
// layout, so, we have to separately track focus and this will only work as expected for normal US Sholes
|
if let StartCause::ResumeTimeReached { .. } = cause {
|
||||||
// keyboards.
|
event_loop.set_control_flow(ControlFlow::WaitUntil(Instant::now() + Duration::from_millis(15)));
|
||||||
// If we use the WindowEvent equivalent of this, however, shifted non-letter characters will send no vkeys
|
|
||||||
// at all on Linux. Which is actually worse: this way, someone with a "normal" keyboard can use the app on
|
|
||||||
// any OS, and there are probably more Linux users than Dvorak users.
|
|
||||||
// Also, this won't actually affect me, even on Linux, because the KMAC handles the dvorak mapping in the
|
|
||||||
// keyboard itself, rather than an input map; it generates scancodes as though it were a Sholes board.
|
|
||||||
// See this bug: https://github.com/rust-windowing/winit/issues/1443
|
|
||||||
Event::DeviceEvent {
|
|
||||||
event: DeviceEvent::Key(input),
|
|
||||||
device_id: _device_id,
|
|
||||||
} => {
|
|
||||||
if let (Some(vk), state, true) = (input.virtual_keycode, input.state, focused) {
|
|
||||||
let byte = convert_keycode(vk);
|
|
||||||
let word = Word::from_bytes([
|
|
||||||
byte,
|
|
||||||
if state == ElementState::Pressed { 1 } else { 0 },
|
|
||||||
0,
|
|
||||||
]);
|
|
||||||
interrupt_events.push_back((5, Some(word)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Event::WindowEvent {
|
|
||||||
event: WindowEvent::Focused(new_focus),
|
|
||||||
window_id,
|
|
||||||
} if window_id == window.id() => focused = new_focus,
|
|
||||||
|
|
||||||
Event::MainEventsCleared => {
|
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
draw(pixels.get_frame(), &mut cpu);
|
|
||||||
pixels.render().expect("Problem displaying framebuffer");
|
draw(self.pixels.as_mut().unwrap().frame_mut(), &mut self.cpu);
|
||||||
|
self.pixels.as_mut().unwrap().render().expect("Problem displaying framebuffer");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// TODO: this will run the CPU at 100%, need to not spin while halted
|
// TODO: this will run the CPU at 100%, need to not spin while halted
|
||||||
if let Some((int, arg)) = interrupt_events.pop_front() {
|
if let Some((int, arg)) = self.interrupt_events.pop_front() {
|
||||||
cpu.interrupt(int, arg)
|
self.cpu.interrupt(int, arg)
|
||||||
}
|
}
|
||||||
if cpu.running() {
|
if self.cpu.running() {
|
||||||
for _ in 1..1000 {
|
for _ in 1..1000 {
|
||||||
cpu.tick()
|
self.cpu.tick()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if Instant::now() > start + Duration::from_millis(14) {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if Instant::now() > start + Duration::from_millis(25) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn window_event(&mut self, event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent) {
|
||||||
|
match event {
|
||||||
|
WindowEvent::CloseRequested => event_loop.exit(),
|
||||||
|
|
||||||
|
WindowEvent::Resized(new_size) => {
|
||||||
|
self.pixels.as_mut().unwrap().resize_surface(new_size.width, new_size.height).expect("Resize");
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowEvent::Focused(new_focus) => self.focused = new_focus,
|
||||||
|
|
||||||
|
WindowEvent::KeyboardInput { event, .. } => {
|
||||||
|
if let PhysicalKey::Code(key_code) = event.physical_key {
|
||||||
|
let byte = convert_keycode(key_code);
|
||||||
|
let word = Word::from_bytes([
|
||||||
|
byte,
|
||||||
|
if event.state == ElementState::Pressed { 1 } else { 0 },
|
||||||
|
0,
|
||||||
|
]);
|
||||||
|
self.interrupt_events.push_back((5, Some(word)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
// fn device_event(&mut self, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent) {
|
||||||
|
// match event {
|
||||||
|
// // These are sent regardless of whether the window is focused or not, and are the same regardless of keyboard
|
||||||
|
// // layout, so, we have to separately track focus and this will only work as expected for normal US Sholes
|
||||||
|
// // keyboards.
|
||||||
|
// // If we use the WindowEvent equivalent of this, however, shifted non-letter characters will send no vkeys
|
||||||
|
// // at all on Linux. Which is actually worse: this way, someone with a "normal" keyboard can use the app on
|
||||||
|
// // any OS, and there are probably more Linux users than Dvorak users.
|
||||||
|
// // Also, this won't actually affect me, even on Linux, because the KMAC handles the dvorak mapping in the
|
||||||
|
// // keyboard itself, rather than an input map; it generates scancodes as though it were a Sholes board.
|
||||||
|
// // See this bug: https://github.com/rust-windowing/winit/issues/1443
|
||||||
|
// DeviceEvent::Key(input) => {
|
||||||
|
// println!("foo");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// _ => {}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let event_loop = EventLoop::new().expect("Failed to create event loop");
|
||||||
|
let mut app = App::new();
|
||||||
|
if let Err(e) = event_loop.run_app(&mut app) {
|
||||||
|
println!("Event loop error: {}", e.to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw(frame: &mut [u8], cpu: &mut CPU) {
|
fn draw(frame: &mut [u8], cpu: &mut CPU) {
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ use vcore::memory::{PeekPoke, PeekPokeExt};
|
|||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
|
||||||
#[mlua::lua_module]
|
#[mlua::lua_module]
|
||||||
fn libvlua(lua: &Lua) -> LuaResult<LuaTable> {
|
fn libvlua(lua: &Lua) -> LuaResult<LuaTable<'_>> {
|
||||||
let exports = lua.create_table()?;
|
let exports = lua.create_table()?;
|
||||||
let cpu_constructor = lua.create_function(|_, _: ()| Ok(LuaCPU(CPU::new_random())))?;
|
let cpu_constructor = lua.create_function(|_, _: ()| Ok(LuaCPU(CPU::new_random())))?;
|
||||||
exports.set("new", cpu_constructor)?;
|
exports.set("new", cpu_constructor)?;
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ vgfx = { path = "../vgfx" }
|
|||||||
vasm_core = { path = "../vasm_core" }
|
vasm_core = { path = "../vasm_core" }
|
||||||
forge_core = { path = "../forge_core" }
|
forge_core = { path = "../forge_core" }
|
||||||
novaforth = { path = "../novaforth" }
|
novaforth = { path = "../novaforth" }
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2.105"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde-wasm-bindgen = "0.4"
|
serde-wasm-bindgen = "0.4"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user