From fc6516cbb2d35eb431b3b397c88ec38067302036 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 27 May 2022 15:40:35 -0300 Subject: [PATCH] chore: work towards backend rewrite egui now has egui-winit and egui-wgpu, which I can use instead of the community-run libraries. Unfortunately, despite being based on community work, not all the necessary features made it over, as of 5 days ago (according to the commit date) the necessary APIs were implemented, but until egui-winit and egui-wgpu are updated there's not much I can do --- Cargo.lock | 632 +++++++++++++++++++++++++++++--------------------- Cargo.toml | 9 +- src/emu.rs | 4 +- src/gui.rs | 64 ++--- src/joypad.rs | 2 +- src/main.rs | 49 ++-- 6 files changed, 416 insertions(+), 344 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d71ebea..9280132 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,6 +66,23 @@ version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" +[[package]] +name = "arboard" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc120354d1b5ec6d7aaf4876b602def75595937b5e15d356eb554ab5177e08bb" +dependencies = [ + "clipboard-win", + "log", + "objc", + "objc-foundation", + "objc_id", + "parking_lot 0.12.0", + "thiserror", + "winapi", + "x11rb", +] + [[package]] name = "arrayvec" version = "0.7.2" @@ -74,9 +91,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "ash" -version = "0.33.3+1.2.191" +version = "0.34.0+1.2.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4f1d82f164f838ae413296d1131aa6fa79b917d25bebaa7033d25620c09219" +checksum = "b0f780da53d0063880d45554306489f09dd8d1bda47688b4a57bc579119356df" dependencies = [ "libloading", ] @@ -104,12 +121,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base-x" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc19a4937b4fbd3fe3379793130e42060d10627a360f2127802b10b87e7baf74" - [[package]] name = "bindgen" version = "0.59.2" @@ -173,6 +184,20 @@ name = "bytemuck" version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562e382481975bc61d11275ac5e62a19abd00b0547d99516a415336f183dcd0e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "byteorder" @@ -246,9 +271,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "clang-sys" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21" +checksum = "bf6b561dcf059c85bbe388e0a7b0a1469acb3934cc0cfa148613a830629e3049" dependencies = [ "glob", "libc", @@ -257,9 +282,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.1.12" +version = "3.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c167e37342afc5f33fd87bbc870cedd020d2a6dffa05d45ccd9241fbdd146db" +checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" dependencies = [ "atty", "bitflags", @@ -273,9 +298,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "189ddd3b5d32a70b35e7686054371742a937b0d99128e76dde6340210e966669" +checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" dependencies = [ "os_str_bytes", ] @@ -286,6 +311,17 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bfbf56724aa9eca8afa4fcfadeb479e722935bb2a0900c2d37e0cc477af0688" +[[package]] +name = "clipboard-win" +version = "4.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3e1238132dc01f081e1cbb9dace14e5ef4c3a51ee244bd982275fb514605db" +dependencies = [ + "error-code", + "str-buf", + "winapi", +] + [[package]] name = "cocoa" version = "0.24.0" @@ -478,8 +514,8 @@ dependencies = [ "ndk-glue 0.6.2", "nix 0.23.1", "oboe", - "parking_lot", - "stdweb 0.1.3", + "parking_lot 0.11.2", + "stdweb", "thiserror", "web-sys", "winapi", @@ -558,12 +594,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "dispatch" version = "0.2.0" @@ -587,62 +617,74 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "egui" -version = "0.15.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c8d416a3343cbfc6f4d17bb1cba46b4d7efecb9ee541967763e0b5e04e5fae7" +checksum = "eb095a8b9feb9b7ff8f00b6776dffcef059538a3f4a91238e03c900e9c9ad9a2" dependencies = [ "ahash", "epaint", "nohash-hasher", + "tracing", ] [[package]] -name = "egui_wgpu_backend" -version = "0.14.0" +name = "egui-wgpu" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7d53df01ecac5951500cd5637b99c0334dad353fce9b203a9bf66b5f791a6b" +checksum = "0d64e1b1fba45469a947a2ce2c8d8acbed64717cde2c65c14625b3e497da6e50" dependencies = [ "bytemuck", - "epi", + "egui", + "tracing", "wgpu", ] [[package]] -name = "egui_winit_platform" -version = "0.12.0" +name = "egui-winit" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060a783c2f05a8ff8f02ade860e8bfcc6153d62104097938b1192405b7039973" +checksum = "b040afd583fd95a9b9578d4399214a13d948ed26bc0ff7cc0104502501f34e68" dependencies = [ + "arboard", "egui", + "instant", + "tracing", + "webbrowser", "winit", ] [[package]] name = "emath" -version = "0.15.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a1aaa922d55da6a2bf32957c3d153e7fb9d52ed8d69777a75092240172eb6e" +checksum = "c223f58c7e38abe1770f367b969f1b3fbd4704b67666bcb65dbb1adb0980ba72" +dependencies = [ + "bytemuck", +] [[package]] name = "epaint" -version = "0.15.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16bb4d3b8bbbd132c99d2a5efec8567e8b6d09b742f758ae6cf1e4b104fe0231" +checksum = "0c29567088888e8ac3e8f61bbb2ddc820207ebb8d69eefde5bcefa06d65e4e89" dependencies = [ "ab_glyph", "ahash", "atomic_refcell", + "bytemuck", "emath", "nohash-hasher", + "parking_lot 0.12.0", ] [[package]] -name = "epi" -version = "0.15.0" +name = "error-code" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f5e4e08127f9b86e2c450c96a3032764b63546eb170c2fc54684dc70ff3fc82" +checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" dependencies = [ - "egui", + "libc", + "str-buf", ] [[package]] @@ -666,6 +708,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -683,9 +735,8 @@ dependencies = [ "bitfield", "clap", "directories-next", - "egui", - "egui_wgpu_backend", - "egui_winit_platform", + "egui-wgpu", + "egui-winit", "gilrs", "once_cell", "pollster", @@ -694,8 +745,16 @@ dependencies = [ "thiserror", "tracing", "tracing-subscriber", - "wgpu", - "winit", +] + +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", ] [[package]] @@ -711,9 +770,9 @@ dependencies = [ [[package]] name = "gilrs" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1550c8bdebc993576e343d600a954654708a9a1182396ee1e805d6fe60c72909" +checksum = "1d6ba7c37bf8ea7ba0c3e3795dfa1a7771b1e47c4bb417c4d27c7b338d79685f" dependencies = [ "fnv", "gilrs-core", @@ -724,20 +783,22 @@ dependencies = [ [[package]] name = "gilrs-core" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c7262ce1e88429c9b1d847820c9d2ba00adafc955218393d9c0861d5aaab88" +checksum = "a0c214d09d0219c9d18073ec5ef2cc6a96c59ba1f767accc765372adcb78390a" dependencies = [ "core-foundation 0.6.4", "io-kit-sys", + "js-sys", "libc", "libudev-sys", "log", - "nix 0.23.1", + "nix 0.24.1", "rusty-xinput", - "stdweb 0.4.20", "uuid", "vec_map", + "wasm-bindgen", + "web-sys", "winapi", ] @@ -834,6 +895,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indexmap" version = "1.8.1" @@ -872,12 +944,6 @@ dependencies = [ "mach 0.2.3", ] -[[package]] -name = "itoa" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" - [[package]] name = "jni" version = "0.19.0" @@ -951,9 +1017,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.124" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "libloading" @@ -987,9 +1053,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if 1.0.0", ] @@ -1031,10 +1097,16 @@ dependencies = [ ] [[package]] -name = "memchr" -version = "2.4.1" +name = "matches" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" @@ -1096,41 +1168,30 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" +checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799" dependencies = [ "libc", "log", - "miow", - "ntapi", "wasi 0.11.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", + "windows-sys", ] [[package]] name = "naga" -version = "0.7.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806f448a7ce662ca79ef5484ef8f451a9b7c51b8166c95f5a667228b3825a6ca" +checksum = "3012f2dbcc79e8e0b5825a4836a7106a75dd9b2fe42c528163be0f572538c705" dependencies = [ "bit-set", "bitflags", "codespan-reporting", - "fxhash", "hexf-parse", "indexmap", "log", "num-traits", + "rustc-hash", "spirv", "thiserror", ] @@ -1251,6 +1312,18 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nix" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "libc", + "memoffset", +] + [[package]] name = "nohash-hasher" version = "0.2.0" @@ -1267,15 +1340,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "ntapi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", -] - [[package]] name = "num-derive" version = "0.3.3" @@ -1289,9 +1353,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] @@ -1327,6 +1391,17 @@ dependencies = [ "objc_exception", ] +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + [[package]] name = "objc_exception" version = "0.1.2" @@ -1337,14 +1412,23 @@ dependencies = [ ] [[package]] -name = "oboe" -version = "0.4.5" +name = "objc_id" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2463c8f2e19b4e0d0710a21f8e4011501ff28db1c95d7a5482a553b2100502d2" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + +[[package]] +name = "oboe" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f63c358b4fa0fbcfefd7c8be5cfc39c08ce2389f5325687e7762a48d30a5c1" dependencies = [ "jni", "ndk 0.6.0", - "ndk-glue 0.6.2", + "ndk-context", "num-derive", "num-traits", "oboe-sys", @@ -1370,15 +1454,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" [[package]] name = "os_str_bytes" -version = "6.0.0" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" [[package]] name = "owned_ttf_parser" @@ -1397,7 +1481,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.3", ] [[package]] @@ -1414,6 +1508,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -1456,18 +1563,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.37" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9145ac0af1d93c638c98c40cf7d25665f427b2a44ad0a99b1dccf3e2f25bb987" +checksum = "2f61dcf0b917cd75d4521d7343d1ffff3d1583054133c9b5cbea3375c703c40d" [[package]] name = "quote" @@ -1484,16 +1591,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e935c45e09cc6dcf00d2f0b2d630a58f4095320223d47fc68918722f0538b6" -[[package]] -name = "raw-window-handle" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28f55143d0548dad60bb4fbdc835a3d7ac6acc3324506450c5fdd6e42903a76" -dependencies = [ - "libc", - "raw-window-handle 0.4.3", -] - [[package]] name = "raw-window-handle" version = "0.4.3" @@ -1525,9 +1622,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.5" +version = "1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" dependencies = [ "regex-syntax", ] @@ -1543,9 +1640,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" [[package]] name = "renderdoc-sys" @@ -1581,15 +1678,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - [[package]] name = "rusty-xinput" version = "1.2.0" @@ -1601,12 +1689,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "ryu" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" - [[package]] name = "same-file" version = "1.0.6" @@ -1628,63 +1710,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" -version = "1.0.136" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" - -[[package]] -name = "serde_derive" -version = "1.0.136" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" [[package]] name = "sharded-slab" @@ -1763,55 +1793,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" [[package]] -name = "stdweb" -version = "0.4.20" +name = "str-buf" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version", - "serde", - "serde_json", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" +checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" [[package]] name = "strsim" @@ -1821,13 +1806,13 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.91" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" +checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1847,18 +1832,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", @@ -1912,9 +1897,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.20" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" +checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c" dependencies = [ "proc-macro2", "quote", @@ -1966,6 +1951,27 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c74c96594835e10fa545e2a51e8709f30b173a092bfd6036ef2cec53376244f3" +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-width" version = "0.1.9" @@ -1973,16 +1979,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "url" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] [[package]] name = "uuid" -version = "0.8.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "93bbc61e655a4833cf400d0d15bf3649313422fa7572886ad6dab16d79886365" [[package]] name = "valuable" @@ -2175,16 +2187,31 @@ dependencies = [ ] [[package]] -name = "wgpu" -version = "0.11.1" +name = "webbrowser" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7181fe6ba5f4b632a9079cc9e922a64555156c87def72c063f94b180c7d68" +checksum = "fc6a3cffdb686fbb24d9fb8f03a213803277ed2300f11026a3afe1f108dc021b" +dependencies = [ + "jni", + "ndk-glue 0.6.2", + "url", + "web-sys", + "widestring", + "winapi", +] + +[[package]] +name = "wgpu" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97cd781ff044d6d697b632a2e212032c2e957d1afaa21dbf58069cbb8f78567" dependencies = [ "arrayvec", "js-sys", "log", - "parking_lot", - "raw-window-handle 0.3.4", + "naga", + "parking_lot 0.11.2", + "raw-window-handle", "smallvec", "wasm-bindgen", "wasm-bindgen-futures", @@ -2196,20 +2223,21 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.11.3" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35600627b6c718ad0e23ed75fb6140bfe32cdf21c8f539ce3c9ab8180e2cb38e" +checksum = "c4688c000eb841ca55f7b35db659b78d6e1cd77d7caf8fb929f4e181f754047d" dependencies = [ "arrayvec", "bitflags", "cfg_aliases", + "codespan-reporting", "copyless", "fxhash", "log", "naga", - "parking_lot", + "parking_lot 0.11.2", "profiling", - "raw-window-handle 0.3.4", + "raw-window-handle", "smallvec", "thiserror", "wgpu-hal", @@ -2218,9 +2246,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.11.5" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af28b29ef0b44cd22dd9895d4349b9d5a687df42f58da234871198637eabe328" +checksum = "d684ea6a34974a2fc19f1dfd183d11a62e22d75c4f187a574bb1224df8e056c2" dependencies = [ "arrayvec", "ash", @@ -2242,10 +2270,10 @@ dependencies = [ "metal", "naga", "objc", - "parking_lot", + "parking_lot 0.11.2", "profiling", "range-alloc", - "raw-window-handle 0.3.4", + "raw-window-handle", "renderdoc-sys", "thiserror", "wasm-bindgen", @@ -2256,13 +2284,19 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e15e44ba88ec415466e18e91881319e7c9e96cb905dc623305168aea65b85ccc" +checksum = "549533d9e1cdd4b4cda7718d33ff500fc4c34b5467b71d76b547ae0324f3b2a2" dependencies = [ "bitflags", ] +[[package]] +name = "widestring" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" + [[package]] name = "winapi" version = "0.3.9" @@ -2288,12 +2322,64 @@ dependencies = [ "winapi", ] +[[package]] +name = "winapi-wsapoll" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + [[package]] name = "winit" version = "0.26.1" @@ -2315,9 +2401,9 @@ dependencies = [ "ndk-glue 0.5.2", "ndk-sys 0.2.2", "objc", - "parking_lot", + "parking_lot 0.11.2", "percent-encoding", - "raw-window-handle 0.4.3", + "raw-window-handle", "smithay-client-toolkit", "wasm-bindgen", "wayland-client", @@ -2338,6 +2424,18 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "x11rb" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e99be55648b3ae2a52342f9a870c0e138709a3493261ce9b469afe6e4df6d8a" +dependencies = [ + "gethostname", + "nix 0.22.3", + "winapi", + "winapi-wsapoll", +] + [[package]] name = "xcursor" version = "0.3.4" diff --git a/Cargo.toml b/Cargo.toml index 3fa0a10..ba3d044 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,11 +11,8 @@ anyhow = "1.0" bitfield = "0.13" clap = { version = "3.1", features = ["cargo"] } gilrs = "0.9" -winit = "0.26" -egui = "0.15" -wgpu = "0.11" -egui_wgpu_backend = "0.14" -egui_winit_platform = "0.12" +egui-wgpu = "0.18" +egui-winit = "0.18" pollster = "0.2" rodio = "0.15" rtrb = "0.2" @@ -23,7 +20,7 @@ directories-next = "2.0" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["std", "env-filter"] } thiserror = "1.0" -once_cell = "1.10" +once_cell = "1.12" [profile.release] debug = true diff --git a/src/emu.rs b/src/emu.rs index 89f08ec..352d29f 100644 --- a/src/emu.rs +++ b/src/emu.rs @@ -4,14 +4,14 @@ use crate::cartridge::Cartridge; use crate::cpu::Cpu; use crate::{Cycle, GB_HEIGHT, GB_WIDTH}; use clap::crate_name; +use egui_winit::winit::event::KeyboardInput; +use egui_winit::winit::event_loop::ControlFlow; use gilrs::Gilrs; use std::fs::File; use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use std::time::Duration; use thiserror::Error; -use winit::event::KeyboardInput; -use winit::event_loop::ControlFlow; pub const SM83_CYCLE_TIME: Duration = Duration::from_nanos(1_000_000_000 / SM83_CLOCK_SPEED); pub const CYCLES_IN_FRAME: Cycle = 456 * 154; // 456 Cycles times 154 scanlines diff --git a/src/gui.rs b/src/gui.rs index d11bc8b..8868235 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,6 +1,9 @@ -use egui::{ClippedMesh, CtxRef, TextureId}; -use egui_wgpu_backend::{BackendError, RenderPass, ScreenDescriptor}; -use egui_winit_platform::Platform; +use egui_wgpu::wgpu; +use egui_winit::egui; +use egui_winit::winit; + +use egui::{ClippedPrimitive, Context, TextureId}; +use egui_wgpu::renderer::{RenderPass, ScreenDescriptor}; use wgpu::{ Adapter, CommandEncoder, Device, Extent3d, FilterMode, Instance, Queue, RequestDeviceError, Surface, SurfaceConfiguration, SurfaceTexture, Texture, TextureFormat, TextureUsages, @@ -121,20 +124,6 @@ pub fn surface_config(window: &Window, format: TextureFormat) -> SurfaceConfigur } } -pub fn platform_desc(window: &Window) -> Platform { - use egui::FontDefinitions; - use egui_winit_platform::PlatformDescriptor; - - let size = window.inner_size(); - Platform::new(PlatformDescriptor { - physical_width: size.width as u32, - physical_height: size.height as u32, - scale_factor: window.scale_factor(), - font_definitions: FontDefinitions::default(), - ..Default::default() - }) -} - pub fn texture_size() -> Extent3d { Extent3d { width: GB_WIDTH as u32, @@ -184,14 +173,6 @@ pub fn write_to_texture( ); } -pub fn expose_texture_to_egui( - render_pass: &mut RenderPass, - device: &Device, - texture: &Texture, -) -> TextureId { - render_pass.egui_texture_from_wgpu_texture(device, texture, FILTER_MODE) -} - #[inline] pub fn create_view(frame: &SurfaceTexture) -> TextureView { use wgpu::TextureViewDescriptor; @@ -208,31 +189,19 @@ pub fn create_command_encoder(device: &Device) -> CommandEncoder { }) } -#[inline] -pub fn create_screen_descriptor( - window: &Window, - config: &SurfaceConfiguration, -) -> ScreenDescriptor { - ScreenDescriptor { - physical_width: config.width, - physical_height: config.height, - scale_factor: window.scale_factor() as f32, - } -} - -#[inline] +car#[inline] pub fn execute_render_pass( render_pass: &mut RenderPass, encoder: &mut CommandEncoder, view: &TextureView, - jobs: Vec, + jobs: Vec, descriptor: &ScreenDescriptor, -) -> Result<(), BackendError> { +) { render_pass.execute(encoder, view, &jobs, descriptor, Some(wgpu::Color::BLACK)) } #[inline] -pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &CtxRef, texture_id: TextureId) { +pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &Context, texture_id: TextureId) { use crate::{cpu, instruction, ppu}; fn selectable_text(ui: &mut egui::Ui, mut text: &str) -> egui::Response { @@ -240,7 +209,7 @@ pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &CtxRef, texture_id: Textur } egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { - egui::menu::menu(ui, "File", |ui| { + ui.menu_button("File", |ui| { if ui.button("Quit").clicked() { app.quit = true; } @@ -322,9 +291,12 @@ pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &CtxRef, texture_id: Textur ui.horizontal(|ui| { let ie = cpu.int_enable(); - let r_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'R'); - let e_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'E'); - let q_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'Q'); + let style = ctx.style(); + let font_id = egui::TextStyle::Body.resolve(&style); + + let r_len = ctx.fonts().glyph_width(&font_id, 'R'); + let e_len = ctx.fonts().glyph_width(&font_id, 'E'); + let q_len = ctx.fonts().glyph_width(&font_id, 'Q'); ui.label("IE:"); ui.add_space(q_len - (e_len - r_len)); @@ -350,7 +322,7 @@ pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &CtxRef, texture_id: Textur } pub mod kbd { - use winit::event::{ElementState, KeyboardInput, VirtualKeyCode}; + use egui_winit::winit::event::{ElementState, KeyboardInput, VirtualKeyCode}; pub fn space_released(input: &KeyboardInput) -> bool { let keycode = input.virtual_keycode; diff --git a/src/joypad.rs b/src/joypad.rs index ff072f1..92b3c17 100644 --- a/src/joypad.rs +++ b/src/joypad.rs @@ -1,5 +1,5 @@ +use egui_winit::winit::event::{ElementState, KeyboardInput, VirtualKeyCode}; use gilrs::{Button, Event as GamepadEvent, EventType as GamepadEventType}; -use winit::event::{ElementState, KeyboardInput, VirtualKeyCode}; #[derive(Debug)] pub struct Joypad { diff --git a/src/main.rs b/src/main.rs index b4e0972..fe7ad5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,16 @@ use std::time::Instant; use clap::{crate_authors, crate_description, crate_name, crate_version, Arg, Command}; -use egui_wgpu_backend::RenderPass; +use egui_wgpu::renderer::RenderPass; use gb::gui::EmuMode; use gb::{emu, gui}; use gilrs::Gilrs; use gui::GuiState; use rodio::{OutputStream, Sink}; use tracing_subscriber::EnvFilter; -use winit::event::{Event, WindowEvent}; -use winit::event_loop::EventLoop; + +use egui_winit::winit::event::{Event, WindowEvent}; +use egui_winit::winit::event_loop::{EventLoop, EventLoopProxy}; const AUDIO_ENABLED: bool = true; @@ -48,7 +49,7 @@ fn main() { // --Here lies a lot of winit + wgpu Boilerplate-- let event_loop: EventLoop> = EventLoop::with_user_event(); - let window = gui::build_window(&event_loop).expect("build window"); + let window = gui::build_window(&event_loop).expect("create winit window"); let (instance, surface) = gui::create_surface(&window); let adapter = gui::request_adapter(&instance, &surface).expect("request adaptor"); @@ -59,7 +60,7 @@ fn main() { let mut config = gui::surface_config(&window, format); surface.configure(&device, &config); - let mut platform = gui::platform_desc(&window); + let mut state = egui_winit::State::new(8192, &window); let mut render_pass = RenderPass::new(&device, format, 1); // We interrupt your boiler plate to initialize the emulator so that @@ -79,7 +80,9 @@ fn main() { let texture_size = gui::texture_size(); let texture = gui::create_texture(&device, texture_size); gui::write_to_texture(&queue, &texture, emu::pixel_buf(&cpu), texture_size); - let texture_id = gui::expose_texture_to_egui(&mut render_pass, &device, &texture); + let texture_id = todo!("Expose Texture ID to egui"); + + render_pass. // Load ROM if filepath was provided if let Some(path) = m.value_of("rom") { @@ -116,14 +119,13 @@ fn main() { // Set up state for the Immediate-mode GUI let mut app = GuiState::new(rom_title); + let mut ctx = egui_winit::egui::Context::default(); let mut last_key = gui::unused_key(); // used for egui animations let start_time = Instant::now(); event_loop.run(move |event, _, control_flow| { - platform.handle_event(&event); - match event { Event::MainEventsCleared => { if app.quit { @@ -147,8 +149,6 @@ fn main() { window.request_redraw(); } Event::RedrawRequested(..) => { - platform.update_time(start_time.elapsed().as_secs_f64()); - let data = emu::pixel_buf(&cpu); gui::write_to_texture(&queue, &texture, data, texture_size); @@ -172,7 +172,7 @@ fn main() { let screen_descriptor = gui::create_screen_descriptor(&window, &config); // Upload all resources for the GPU. - render_pass.update_texture(&device, &queue, &platform.context().texture()); + render_pass.update_texture(&device, &queue, todo!(), todo!()); render_pass.update_user_textures(&device, &queue); render_pass.update_buffers(&device, &queue, &paint_jobs, &screen_descriptor); @@ -192,18 +192,23 @@ fn main() { // Redraw egui output_frame.present(); } - Event::WindowEvent { event, .. } => match event { - WindowEvent::Resized(size) => { - config.width = size.width; - config.height = size.height; - surface.configure(&device, &config); + Event::WindowEvent { event, .. } => { + let exclusive_use = state.on_event(&ctx, &event); + if !exclusive_use { + match event { + WindowEvent::Resized(size) => { + config.width = size.width; + config.height = size.height; + surface.configure(&device, &config); + } + WindowEvent::CloseRequested => { + emu::save_and_exit(&cpu, control_flow); + } + WindowEvent::KeyboardInput { input, .. } => last_key = input, + _ => {} + } } - WindowEvent::CloseRequested => { - emu::save_and_exit(&cpu, control_flow); - } - WindowEvent::KeyboardInput { input, .. } => last_key = input, - _ => {} - }, + } _ => {} } });