From 866db3903c8a1a2475a3bb607aa15433277ddd18 Mon Sep 17 00:00:00 2001 From: Cobrand Date: Thu, 13 Jun 2024 18:56:28 +0200 Subject: [PATCH] Update for SDL2 v0.37 --- Cargo.toml | 2 +- src/lib.rs | 114 ++++++++++++++++++++++++++--------------------------- 2 files changed, 57 insertions(+), 59 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0754a09..3be3aed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ include = ["**/*.rs", "Cargo.toml", "/shaders"] ahash = "~0.8" gl = "~0.14" egui = "~0.27" -sdl2 = { version = "~0.36" } +sdl2 = { version = ">= 0.36, < 0.38" } memoffset = "0.9.0" [dependencies.epi] diff --git a/src/lib.rs b/src/lib.rs index 8043678..f1740fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -338,65 +338,63 @@ pub fn input_to_egui( } } -pub fn translate_virtual_key_code(key: sdl2::keyboard::Keycode) -> Option { - use Keycode::*; - +pub fn translate_virtual_key_code(key: Keycode) -> Option { Some(match key { - Left => Key::ArrowLeft, - Up => Key::ArrowUp, - Right => Key::ArrowRight, - Down => Key::ArrowDown, - - Escape => Key::Escape, - Tab => Key::Tab, - Backspace => Key::Backspace, - Space => Key::Space, - Return => Key::Enter, - - Insert => Key::Insert, - Home => Key::Home, - Delete => Key::Delete, - End => Key::End, - PageDown => Key::PageDown, - PageUp => Key::PageUp, - - Kp0 | Num0 => Key::Num0, - Kp1 | Num1 => Key::Num1, - Kp2 | Num2 => Key::Num2, - Kp3 | Num3 => Key::Num3, - Kp4 | Num4 => Key::Num4, - Kp5 | Num5 => Key::Num5, - Kp6 | Num6 => Key::Num6, - Kp7 | Num7 => Key::Num7, - Kp8 | Num8 => Key::Num8, - Kp9 | Num9 => Key::Num9, - - A => Key::A, - B => Key::B, - C => Key::C, - D => Key::D, - E => Key::E, - F => Key::F, - G => Key::G, - H => Key::H, - I => Key::I, - J => Key::J, - K => Key::K, - L => Key::L, - M => Key::M, - N => Key::N, - O => Key::O, - P => Key::P, - Q => Key::Q, - R => Key::R, - S => Key::S, - T => Key::T, - U => Key::U, - V => Key::V, - W => Key::W, - X => Key::X, - Y => Key::Y, - Z => Key::Z, + Keycode::Left => Key::ArrowLeft, + Keycode::Up => Key::ArrowUp, + Keycode::Right => Key::ArrowRight, + Keycode::Down => Key::ArrowDown, + + Keycode::Escape => Key::Escape, + Keycode::Tab => Key::Tab, + Keycode::Backspace => Key::Backspace, + Keycode::Space => Key::Space, + Keycode::Return => Key::Enter, + + Keycode::Insert => Key::Insert, + Keycode::Home => Key::Home, + Keycode::Delete => Key::Delete, + Keycode::End => Key::End, + Keycode::PageDown => Key::PageDown, + Keycode::PageUp => Key::PageUp, + + Keycode::Kp0 | Keycode::Num0 => Key::Num0, + Keycode::Kp1 | Keycode::Num1 => Key::Num1, + Keycode::Kp2 | Keycode::Num2 => Key::Num2, + Keycode::Kp3 | Keycode::Num3 => Key::Num3, + Keycode::Kp4 | Keycode::Num4 => Key::Num4, + Keycode::Kp5 | Keycode::Num5 => Key::Num5, + Keycode::Kp6 | Keycode::Num6 => Key::Num6, + Keycode::Kp7 | Keycode::Num7 => Key::Num7, + Keycode::Kp8 | Keycode::Num8 => Key::Num8, + Keycode::Kp9 | Keycode::Num9 => Key::Num9, + + Keycode::A => Key::A, + Keycode::B => Key::B, + Keycode::C => Key::C, + Keycode::D => Key::D, + Keycode::E => Key::E, + Keycode::F => Key::F, + Keycode::G => Key::G, + Keycode::H => Key::H, + Keycode::I => Key::I, + Keycode::J => Key::J, + Keycode::K => Key::K, + Keycode::L => Key::L, + Keycode::M => Key::M, + Keycode::N => Key::N, + Keycode::O => Key::O, + Keycode::P => Key::P, + Keycode::Q => Key::Q, + Keycode::R => Key::R, + Keycode::S => Key::S, + Keycode::T => Key::T, + Keycode::U => Key::U, + Keycode::V => Key::V, + Keycode::W => Key::W, + Keycode::X => Key::X, + Keycode::Y => Key::Y, + Keycode::Z => Key::Z, _ => { return None;