Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for rust-sdl2 v0.37 #41

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
114 changes: 56 additions & 58 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
}
match event {
// handle when window Resized and SizeChanged.
Window { win_event, .. } => match win_event {

Check failure on line 174 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Hygiene (ubuntu-latest, nightly)

this `match` can be collapsed into the outer `match`
WindowEvent::Resized(_, _) | sdl2::event::WindowEvent::SizeChanged(_, _) => {
painter.update_screen_rect(window.drawable_size());
state.input.screen_rect = Some(painter.screen_rect);
Expand Down Expand Up @@ -338,65 +338,63 @@
}
}

pub fn translate_virtual_key_code(key: sdl2::keyboard::Keycode) -> Option<egui::Key> {
use Keycode::*;

pub fn translate_virtual_key_code(key: Keycode) -> Option<egui::Key> {
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;
Expand Down
Loading