mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Updated to winit 20
This commit is contained in:
parent
5d18fc26f5
commit
807a27328c
163
Cargo.lock
generated
163
Cargo.lock
generated
@ -428,6 +428,17 @@ dependencies = [
|
||||
"winapi 0.3.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "calloop"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7aa2097be53a00de9e8fc349fea6d76221f398f5c4fa550d420669906962d160"
|
||||
dependencies = [
|
||||
"mio",
|
||||
"mio-extras",
|
||||
"nix 0.14.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
version = "0.2.3"
|
||||
@ -471,6 +482,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cgl"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.11"
|
||||
@ -536,8 +556,8 @@ checksum = "1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"block",
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"core-foundation 0.6.4",
|
||||
"core-graphics 0.17.3",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"objc",
|
||||
@ -551,8 +571,8 @@ checksum = "f29f7768b2d1be17b96158e3285951d366b40211320fb30826a76cb7a0da6400"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"block",
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"core-foundation 0.6.4",
|
||||
"core-graphics 0.17.3",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"objc",
|
||||
@ -561,7 +581,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "conrod_core"
|
||||
version = "0.63.0"
|
||||
source = "git+https://gitlab.com/veloren/conrod.git?branch=pre-winit-20#46b374edc9537300e5278905ebd14dff45cfd927"
|
||||
source = "git+https://gitlab.com/veloren/conrod.git?branch=hide_text#92925b122dfed139169c7d7687b3ca15c0cb5a2e"
|
||||
dependencies = [
|
||||
"conrod_derive",
|
||||
"copypasta",
|
||||
@ -576,7 +596,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "conrod_derive"
|
||||
version = "0.63.0"
|
||||
source = "git+https://gitlab.com/veloren/conrod.git?branch=pre-winit-20#46b374edc9537300e5278905ebd14dff45cfd927"
|
||||
source = "git+https://gitlab.com/veloren/conrod.git?branch=hide_text#92925b122dfed139169c7d7687b3ca15c0cb5a2e"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30",
|
||||
"quote 0.6.13",
|
||||
@ -586,7 +606,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "conrod_winit"
|
||||
version = "0.63.0"
|
||||
source = "git+https://gitlab.com/veloren/conrod.git?branch=pre-winit-20#46b374edc9537300e5278905ebd14dff45cfd927"
|
||||
source = "git+https://gitlab.com/veloren/conrod.git?branch=hide_text#92925b122dfed139169c7d7687b3ca15c0cb5a2e"
|
||||
|
||||
[[package]]
|
||||
name = "const-random"
|
||||
@ -673,7 +693,17 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"core-foundation-sys 0.6.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.7.0",
|
||||
"libc",
|
||||
]
|
||||
|
||||
@ -683,6 +713,12 @@ version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.17.3"
|
||||
@ -690,11 +726,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation",
|
||||
"core-foundation 0.6.4",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.19.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation 0.7.0",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-video-sys"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"core-foundation-sys 0.7.0",
|
||||
"core-graphics 0.19.2",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "coreaudio-rs"
|
||||
version = "0.9.1"
|
||||
@ -721,7 +782,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b55d55d69f403f62a95bd3c04b431e0aedf5120c70f15d07a8edd234443dd59"
|
||||
dependencies = [
|
||||
"alsa-sys",
|
||||
"core-foundation-sys",
|
||||
"core-foundation-sys 0.6.2",
|
||||
"coreaudio-rs",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
@ -1513,7 +1574,7 @@ checksum = "310ff66f08b5a55854b18fea2f48bdbb75c94458207ba574c9723be78e97a646"
|
||||
dependencies = [
|
||||
"gfx_core",
|
||||
"gfx_device_gl",
|
||||
"glutin",
|
||||
"glutin 0.21.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1537,7 +1598,7 @@ version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43c758daf46af26d6872fe55507e3b2339779a160a06ad7a9b2a082f221209cd"
|
||||
dependencies = [
|
||||
"core-foundation",
|
||||
"core-foundation 0.6.4",
|
||||
"io-kit-sys",
|
||||
"libc",
|
||||
"libudev-sys",
|
||||
@ -1677,10 +1738,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5371b35b309dace06be1b81b5f6adb1c9de578b7dbe1e74bf7e4ef762cf6febd"
|
||||
dependencies = [
|
||||
"android_glue",
|
||||
"cgl",
|
||||
"cgl 0.2.3",
|
||||
"cocoa 0.18.5",
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"core-foundation 0.6.4",
|
||||
"core-graphics 0.17.3",
|
||||
"glutin_egl_sys",
|
||||
"glutin_emscripten_sys",
|
||||
"glutin_gles2_sys",
|
||||
@ -1693,7 +1754,34 @@ dependencies = [
|
||||
"parking_lot 0.9.0",
|
||||
"wayland-client 0.21.13",
|
||||
"winapi 0.3.8",
|
||||
"winit",
|
||||
"winit 0.19.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glutin"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "639246c8838b02a83b9339bd87da3714e73e52ecfaa758e15d761eb77b2290b5"
|
||||
dependencies = [
|
||||
"android_glue",
|
||||
"cgl 0.3.2",
|
||||
"cocoa 0.19.1",
|
||||
"core-foundation 0.6.4",
|
||||
"core-graphics 0.17.3",
|
||||
"glutin_egl_sys",
|
||||
"glutin_emscripten_sys",
|
||||
"glutin_gles2_sys",
|
||||
"glutin_glx_sys",
|
||||
"glutin_wgl_sys",
|
||||
"lazy_static",
|
||||
"libloading 0.5.2",
|
||||
"log",
|
||||
"objc",
|
||||
"osmesa-sys",
|
||||
"parking_lot 0.10.2",
|
||||
"wayland-client 0.23.6",
|
||||
"winapi 0.3.8",
|
||||
"winit 0.20.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2048,7 +2136,7 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f21dcc74995dd4cd090b147e79789f8d65959cbfb5f0b118002db869ea3bd0a0"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"core-foundation-sys 0.6.2",
|
||||
"mach",
|
||||
]
|
||||
|
||||
@ -4516,7 +4604,7 @@ dependencies = [
|
||||
"gilrs",
|
||||
"git2",
|
||||
"glsl-include",
|
||||
"glutin",
|
||||
"glutin 0.22.1",
|
||||
"guillotiere",
|
||||
"hashbrown",
|
||||
"image",
|
||||
@ -4541,7 +4629,7 @@ dependencies = [
|
||||
"veloren-server",
|
||||
"veloren-voxygen-anim",
|
||||
"veloren-world",
|
||||
"winit",
|
||||
"winit 0.20.0",
|
||||
"winres",
|
||||
]
|
||||
|
||||
@ -4728,8 +4816,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1080ebe0efabcf12aef2132152f616038f2d7dcbbccf7b2d8c5270fe14bcda"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"calloop",
|
||||
"downcast-rs",
|
||||
"libc",
|
||||
"mio",
|
||||
"nix 0.14.1",
|
||||
"wayland-commons 0.23.6",
|
||||
"wayland-scanner 0.23.6",
|
||||
@ -4905,8 +4995,8 @@ dependencies = [
|
||||
"backtrace",
|
||||
"bitflags",
|
||||
"cocoa 0.18.5",
|
||||
"core-foundation",
|
||||
"core-graphics",
|
||||
"core-foundation 0.6.4",
|
||||
"core-graphics 0.17.3",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
@ -4914,13 +5004,42 @@ dependencies = [
|
||||
"parking_lot 0.9.0",
|
||||
"percent-encoding 2.1.0",
|
||||
"raw-window-handle",
|
||||
"serde",
|
||||
"smithay-client-toolkit 0.4.6",
|
||||
"wayland-client 0.21.13",
|
||||
"winapi 0.3.8",
|
||||
"x11-dl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ba128780050481f453bec2a115b916dbc6ae79c303dee9bad8b9080bdccd4f5"
|
||||
dependencies = [
|
||||
"android_glue",
|
||||
"bitflags",
|
||||
"cocoa 0.19.1",
|
||||
"core-foundation 0.6.4",
|
||||
"core-graphics 0.17.3",
|
||||
"core-video-sys",
|
||||
"dispatch",
|
||||
"instant",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"mio",
|
||||
"mio-extras",
|
||||
"objc",
|
||||
"parking_lot 0.10.2",
|
||||
"percent-encoding 2.1.0",
|
||||
"raw-window-handle",
|
||||
"serde",
|
||||
"smithay-client-toolkit 0.6.6",
|
||||
"wayland-client 0.23.6",
|
||||
"winapi 0.3.8",
|
||||
"x11-dl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winres"
|
||||
version = "0.1.11"
|
||||
|
@ -26,10 +26,10 @@ anim = { package = "veloren-voxygen-anim", path = "src/anim", default-features =
|
||||
gfx = "0.18.2"
|
||||
gfx_device_gl = { version = "0.16.2", optional = true }
|
||||
gfx_window_glutin = "0.31.0"
|
||||
glutin = "0.21.1"
|
||||
winit = { version = "0.19.4", features = ["serde"] }
|
||||
conrod_core = { git = "https://gitlab.com/veloren/conrod.git", branch = "pre-winit-20" }
|
||||
conrod_winit = { git = "https://gitlab.com/veloren/conrod.git", branch = "pre-winit-20" }
|
||||
glutin = "0.22.0-alpha3"
|
||||
winit = { version = "0.20.0-alpha4", features = ["serde"] }
|
||||
conrod_core = { git = "https://gitlab.com/veloren/conrod.git", branch = "hide_text" }
|
||||
conrod_winit = { git = "https://gitlab.com/veloren/conrod.git", branch = "hide_text" }
|
||||
euc = { git = "https://github.com/zesterer/euc.git" }
|
||||
|
||||
# ECS
|
||||
|
@ -6,11 +6,11 @@ use crate::{
|
||||
window::{GameInput, KeyMouse},
|
||||
};
|
||||
use directories_next::{ProjectDirs, UserDirs};
|
||||
use glutin::{MouseButton, VirtualKeyCode};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::{fs, io::prelude::*, path::PathBuf};
|
||||
use tracing::warn;
|
||||
use winit::event::{MouseButton, VirtualKeyCode};
|
||||
|
||||
// ControlSetting-like struct used by Serde, to handle not serializing/building
|
||||
// post-deserializing the inverse_keybindings hashmap
|
||||
|
@ -5,24 +5,24 @@ use vek::*;
|
||||
pub struct Event(pub Input);
|
||||
impl Event {
|
||||
pub fn try_from(
|
||||
event: glutin::Event,
|
||||
window: &glutin::ContextWrapper<glutin::PossiblyCurrent, winit::Window>,
|
||||
event: glutin::event::Event<()>,
|
||||
window: &glutin::ContextWrapper<glutin::PossiblyCurrent, winit::window::Window>,
|
||||
) -> Option<Self> {
|
||||
use conrod_winit::*;
|
||||
// A wrapper around the winit window that allows us to implement the trait
|
||||
// necessary for enabling the winit <-> conrod conversion functions.
|
||||
struct WindowRef<'a>(&'a winit::Window);
|
||||
struct WindowRef<'a>(&'a winit::window::Window);
|
||||
|
||||
// Implement the `WinitWindow` trait for `WindowRef` to allow for generating
|
||||
// compatible conversion functions.
|
||||
impl<'a> conrod_winit::WinitWindow for WindowRef<'a> {
|
||||
fn get_inner_size(&self) -> Option<(u32, u32)> {
|
||||
winit::Window::get_inner_size(&self.0).map(Into::into)
|
||||
Some(winit::window::Window::inner_size(&self.0).into())
|
||||
}
|
||||
|
||||
fn hidpi_factor(&self) -> f32 { winit::Window::get_hidpi_factor(&self.0) as _ }
|
||||
fn hidpi_factor(&self) -> f32 { winit::window::Window::get_hidpi_factor(&self.0) as _ }
|
||||
}
|
||||
convert_event!(event, &WindowRef(window.window())).map(Self)
|
||||
convert_event!(event, &WindowRef(window.window())).map(|input| Self(input))
|
||||
}
|
||||
|
||||
pub fn is_keyboard_or_mouse(&self) -> bool {
|
||||
|
@ -280,19 +280,19 @@ pub enum Event {
|
||||
ScreenshotMessage(String),
|
||||
}
|
||||
|
||||
pub type MouseButton = winit::MouseButton;
|
||||
pub type PressState = winit::ElementState;
|
||||
pub type MouseButton = winit::event::MouseButton;
|
||||
pub type PressState = winit::event::ElementState;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
|
||||
pub enum KeyMouse {
|
||||
Key(glutin::VirtualKeyCode),
|
||||
Mouse(glutin::MouseButton),
|
||||
Key(glutin::event::VirtualKeyCode),
|
||||
Mouse(glutin::event::MouseButton),
|
||||
}
|
||||
|
||||
impl fmt::Display for KeyMouse {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use self::KeyMouse::*;
|
||||
use glutin::{MouseButton, VirtualKeyCode::*};
|
||||
use glutin::event::{MouseButton, VirtualKeyCode::*};
|
||||
write!(f, "{}", match self {
|
||||
Key(Key1) => "1",
|
||||
Key(Key2) => "2",
|
||||
@ -466,9 +466,9 @@ impl fmt::Display for KeyMouse {
|
||||
}
|
||||
|
||||
pub struct Window {
|
||||
events_loop: glutin::EventsLoop,
|
||||
events_loop: glutin::event_loop::EventLoop<()>,
|
||||
renderer: Renderer,
|
||||
window: glutin::ContextWrapper<glutin::PossiblyCurrent, winit::Window>,
|
||||
window: glutin::ContextWrapper<glutin::PossiblyCurrent, winit::window::Window>,
|
||||
cursor_grabbed: bool,
|
||||
pub pan_sensitivity: u32,
|
||||
pub zoom_sensitivity: u32,
|
||||
@ -476,7 +476,7 @@ pub struct Window {
|
||||
pub mouse_y_inversion: bool,
|
||||
fullscreen: bool,
|
||||
needs_refresh_resize: bool,
|
||||
keypress_map: HashMap<GameInput, glutin::ElementState>,
|
||||
keypress_map: HashMap<GameInput, winit::event::ElementState>,
|
||||
pub remapping_keybindings: Option<GameInput>,
|
||||
supplement_events: Vec<Event>,
|
||||
focused: bool,
|
||||
@ -491,11 +491,11 @@ pub struct Window {
|
||||
|
||||
impl Window {
|
||||
pub fn new(settings: &Settings) -> Result<Window, Error> {
|
||||
let events_loop = glutin::EventsLoop::new();
|
||||
let events_loop = glutin::event_loop::EventLoop::new();
|
||||
|
||||
let size = settings.graphics.window_size;
|
||||
|
||||
let win_builder = glutin::WindowBuilder::new()
|
||||
let win_builder = glutin::window::WindowBuilder::new()
|
||||
.with_title("Veloren")
|
||||
.with_dimensions(glutin::dpi::LogicalSize::new(
|
||||
size[0] as f64,
|
||||
@ -644,19 +644,22 @@ impl Window {
|
||||
}
|
||||
|
||||
match event {
|
||||
glutin::Event::WindowEvent { event, .. } => match event {
|
||||
glutin::WindowEvent::CloseRequested => events.push(Event::Close),
|
||||
glutin::WindowEvent::Resized(glutin::dpi::LogicalSize { width, height }) => {
|
||||
glutin::event::Event::WindowEvent { event, .. } => match event {
|
||||
glutin::event::WindowEvent::CloseRequested => events.push(Event::Close),
|
||||
glutin::event::WindowEvent::Resized(glutin::dpi::LogicalSize {
|
||||
width,
|
||||
height,
|
||||
}) => {
|
||||
let (mut color_view, mut depth_view) = renderer.win_views_mut();
|
||||
gfx_window_glutin::update_views(window, &mut color_view, &mut depth_view);
|
||||
renderer.on_resize().unwrap();
|
||||
events.push(Event::Resize(Vec2::new(width as u32, height as u32)));
|
||||
},
|
||||
glutin::WindowEvent::Moved(glutin::dpi::LogicalPosition { x, y }) => {
|
||||
glutin::event::WindowEvent::Moved(glutin::dpi::LogicalPosition { x, y }) => {
|
||||
events.push(Event::Moved(Vec2::new(x as u32, y as u32)))
|
||||
},
|
||||
glutin::WindowEvent::ReceivedCharacter(c) => events.push(Event::Char(c)),
|
||||
glutin::WindowEvent::MouseInput { button, state, .. } => {
|
||||
glutin::event::WindowEvent::ReceivedCharacter(c) => events.push(Event::Char(c)),
|
||||
glutin::event::WindowEvent::MouseInput { button, state, .. } => {
|
||||
if let (true, Some(game_inputs)) = (
|
||||
cursor_grabbed,
|
||||
Window::map_input(
|
||||
@ -668,13 +671,13 @@ impl Window {
|
||||
for game_input in game_inputs {
|
||||
events.push(Event::InputUpdate(
|
||||
*game_input,
|
||||
state == glutin::ElementState::Pressed,
|
||||
state == glutin::event::ElementState::Pressed,
|
||||
));
|
||||
}
|
||||
}
|
||||
events.push(Event::MouseButton(button, state));
|
||||
},
|
||||
glutin::WindowEvent::KeyboardInput { input, .. } => {
|
||||
glutin::event::WindowEvent::KeyboardInput { input, .. } => {
|
||||
if let Some(key) = input.virtual_keycode {
|
||||
if let Some(game_inputs) = Window::map_input(
|
||||
KeyMouse::Key(key),
|
||||
@ -684,7 +687,7 @@ impl Window {
|
||||
for game_input in game_inputs {
|
||||
match game_input {
|
||||
GameInput::Fullscreen => {
|
||||
if input.state == glutin::ElementState::Pressed
|
||||
if input.state == glutin::event::ElementState::Pressed
|
||||
&& !Self::is_pressed(
|
||||
keypress_map,
|
||||
GameInput::Fullscreen,
|
||||
@ -700,7 +703,7 @@ impl Window {
|
||||
},
|
||||
GameInput::Screenshot => {
|
||||
take_screenshot = input.state
|
||||
== glutin::ElementState::Pressed
|
||||
== glutin::event::ElementState::Pressed
|
||||
&& !Self::is_pressed(
|
||||
keypress_map,
|
||||
GameInput::Screenshot,
|
||||
@ -713,25 +716,24 @@ impl Window {
|
||||
},
|
||||
_ => events.push(Event::InputUpdate(
|
||||
*game_input,
|
||||
input.state == glutin::ElementState::Pressed,
|
||||
input.state == glutin::event::ElementState::Pressed,
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
glutin::WindowEvent::Focused(state) => {
|
||||
glutin::event::WindowEvent::Focused(state) => {
|
||||
*focused = state;
|
||||
events.push(Event::Focused(state));
|
||||
},
|
||||
glutin::WindowEvent::CursorMoved { position, .. } => {
|
||||
glutin::event::WindowEvent::CursorMoved { position, .. } => {
|
||||
cursor_position = Some(position);
|
||||
},
|
||||
_ => {},
|
||||
},
|
||||
glutin::Event::DeviceEvent { event, .. } => match event {
|
||||
glutin::DeviceEvent::MouseMotion {
|
||||
glutin::event::Event::DeviceEvent { event, .. } => match event {
|
||||
glutin::event::DeviceEvent::MouseMotion {
|
||||
delta: (dx, dy), ..
|
||||
} if *focused => {
|
||||
let delta = Vec2::new(
|
||||
@ -745,7 +747,9 @@ impl Window {
|
||||
events.push(Event::CursorMove(delta));
|
||||
}
|
||||
},
|
||||
glutin::DeviceEvent::MouseWheel { delta, .. } if cursor_grabbed && *focused => {
|
||||
glutin::event::DeviceEvent::MouseWheel { delta, .. }
|
||||
if cursor_grabbed && *focused =>
|
||||
{
|
||||
events.push(Event::Zoom({
|
||||
// Since scrolling apparently acts different depending on platform
|
||||
#[cfg(target_os = "windows")]
|
||||
@ -754,17 +758,19 @@ impl Window {
|
||||
const PLATFORM_FACTOR: f32 = 1.0;
|
||||
|
||||
let y = match delta {
|
||||
glutin::MouseScrollDelta::LineDelta(_x, y) => y,
|
||||
glutin::event::MouseScrollDelta::LineDelta(_x, y) => y,
|
||||
// TODO: Check to see if there is a better way to find the "line
|
||||
// height" than just hardcoding 16.0 pixels. Alternately we could
|
||||
// get rid of this and have the user set zoom sensitivity, since
|
||||
// it's unlikely people would expect a configuration file to work
|
||||
// across operating systems.
|
||||
glutin::MouseScrollDelta::PixelDelta(pos) => (pos.y / 16.0) as f32,
|
||||
glutin::event::MouseScrollDelta::PixelDelta(pos) => {
|
||||
(pos.y / 16.0) as f32
|
||||
},
|
||||
};
|
||||
y * (zoom_sensitivity as f32 / 100.0) * zoom_inversion * PLATFORM_FACTOR
|
||||
}))
|
||||
},
|
||||
}
|
||||
_ => {},
|
||||
},
|
||||
_ => {},
|
||||
@ -1004,8 +1010,8 @@ impl Window {
|
||||
|
||||
pub fn grab_cursor(&mut self, grab: bool) {
|
||||
self.cursor_grabbed = grab;
|
||||
self.window.window().hide_cursor(grab);
|
||||
let _ = self.window.window().grab_cursor(grab);
|
||||
self.window.window().set_cursor_visible(!grab);
|
||||
let _ = self.window.window().set_cursor_grab(grab);
|
||||
}
|
||||
|
||||
pub fn toggle_fullscreen(&mut self, settings: &mut Settings) {
|
||||
@ -1020,7 +1026,9 @@ impl Window {
|
||||
let window = self.window.window();
|
||||
self.fullscreen = fullscreen;
|
||||
if fullscreen {
|
||||
window.set_fullscreen(Some(window.get_current_monitor()));
|
||||
window.set_fullscreen(Some(winit::window::Fullscreen::Borderless(
|
||||
window.current_monitor(),
|
||||
)));
|
||||
} else {
|
||||
window.set_fullscreen(None);
|
||||
}
|
||||
@ -1030,12 +1038,7 @@ impl Window {
|
||||
|
||||
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
|
||||
pub fn logical_size(&self) -> Vec2<f64> {
|
||||
let (w, h) = self
|
||||
.window
|
||||
.window()
|
||||
.get_inner_size()
|
||||
.unwrap_or(glutin::dpi::LogicalSize::new(0.0, 0.0))
|
||||
.into();
|
||||
let (w, h) = self.window.window().inner_size().into();
|
||||
Vec2::new(w, h)
|
||||
}
|
||||
|
||||
@ -1086,15 +1089,20 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_pressed(map: &mut HashMap<GameInput, glutin::ElementState>, input: GameInput) -> bool {
|
||||
*(map.entry(input).or_insert(glutin::ElementState::Released))
|
||||
== glutin::ElementState::Pressed
|
||||
fn is_pressed(
|
||||
map: &mut HashMap<GameInput, glutin::event::ElementState>,
|
||||
input: GameInput,
|
||||
) -> bool {
|
||||
*(map
|
||||
.entry(input)
|
||||
.or_insert(glutin::event::ElementState::Released))
|
||||
== glutin::event::ElementState::Pressed
|
||||
}
|
||||
|
||||
fn set_pressed(
|
||||
map: &mut HashMap<GameInput, glutin::ElementState>,
|
||||
map: &mut HashMap<GameInput, glutin::event::ElementState>,
|
||||
input: GameInput,
|
||||
state: glutin::ElementState,
|
||||
state: glutin::event::ElementState,
|
||||
) {
|
||||
map.insert(input, state);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user