Mercurial > tablet-emu
changeset 16:478cf2a7d577
Reformat with rustfmt.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 26 Aug 2021 19:45:30 +0200 |
parents | d103f7cca0bd |
children | 0bce7fe96937 |
files | src/gtk.rs src/main.rs src/server.rs src/state.rs src/uinput.rs |
diffstat | 5 files changed, 16 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtk.rs +++ b/src/gtk.rs @@ -14,18 +14,13 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +use crate::{state::State, DEFAULT_HEIGHT, DEFAULT_WIDTH}; use gio::prelude::*; use glib::clone; use gtk::prelude::*; - +use input_linux::Key; use std::io::ErrorKind; use std::sync::{Arc, Mutex}; -use input_linux::Key; - -use crate::{ - state::State, - DEFAULT_WIDTH, DEFAULT_HEIGHT, -}; fn build_main_menu(app: >k::Application) { let quit = gio::SimpleAction::new("quit", None); @@ -121,10 +116,8 @@ fn build_ui(app: >k::Application) { .content_height(DEFAULT_HEIGHT) .hexpand(true) .build(); - let gesture_click = gtk::GestureClick::builder() - .build(); - let event_controller = gtk::EventControllerMotion::builder() - .build(); + let gesture_click = gtk::GestureClick::new(); + let event_controller = gtk::EventControllerMotion::new(); let state_weak = Arc::downgrade(&state); drawing_area.connect_resize(move |_, width, height| { let state = state_weak.upgrade().unwrap();
--- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,8 @@ #[cfg(feature = "gui")] mod gtk; mod server; +mod state; mod uinput; -mod state; use std::env::args; @@ -40,7 +40,9 @@ fn main() { args.remove(1) } else { String::from("gui") - }.as_str() { + } + .as_str() + { "gui" => Ui::Gtk, "server" => Ui::Server, name => {
--- a/src/server.rs +++ b/src/server.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -use std::net::UdpSocket; -use std::io::{self, ErrorKind}; use crate::state::State; use bitflags::bitflags; use input_linux::Key; +use std::io::{self, ErrorKind}; +use std::net::UdpSocket; bitflags! { /// This is the memory layout of the buttons on the 3DS.
--- a/src/state.rs +++ b/src/state.rs @@ -14,11 +14,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -use std::fs::File; - +use crate::uinput::{ + create_uinput_device, input_axis_new, input_key_new, input_misc_new, input_synchronize_new, +}; +use crate::{DEFAULT_HEIGHT, DEFAULT_WIDTH, MAX_X, MAX_Y}; use input_linux::{AbsoluteAxis, Key, MiscKind, SynchronizeKind, UInputHandle}; -use crate::{DEFAULT_WIDTH, DEFAULT_HEIGHT, MAX_X, MAX_Y}; -use crate::uinput::{create_uinput_device, input_axis_new, input_misc_new, input_key_new, input_synchronize_new}; +use std::fs::File; pub struct State { dev: UInputHandle<File>,
--- a/src/uinput.rs +++ b/src/uinput.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -use std::fs::{File, OpenOptions}; use crate::{MAX_X, MAX_Y}; use input_linux::{ sys::input_event, sys::timeval, AbsoluteAxis, AbsoluteInfo, AbsoluteInfoSetup, EventKind, InputId, InputProperty, Key, MiscKind, SynchronizeKind, UInputHandle, }; +use std::fs::{File, OpenOptions}; pub fn create_uinput_device() -> std::io::Result<UInputHandle<File>> { let file = OpenOptions::new().write(true).open("/dev/uinput")?;