feat: update to bevy 13.2; rework input collection system

This commit is contained in:
2024-04-05 12:56:32 +02:00
parent 1812be6ae3
commit 7e00ce3fda
12 changed files with 1324 additions and 919 deletions
Generated
+337 -121
View File
@@ -337,20 +337,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c3efee9165f9be9c6a180c6a9bbb4bd39ee0a98a594f4cb7127704e15415cdd" checksum = "1c3efee9165f9be9c6a180c6a9bbb4bd39ee0a98a594f4cb7127704e15415cdd"
dependencies = [ dependencies = [
"bevy-inspector-egui-derive", "bevy-inspector-egui-derive",
"bevy_app", "bevy_app 0.12.1",
"bevy_asset", "bevy_asset",
"bevy_core", "bevy_core",
"bevy_core_pipeline", "bevy_core_pipeline",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_egui", "bevy_egui",
"bevy_hierarchy", "bevy_hierarchy",
"bevy_log", "bevy_log",
"bevy_math", "bevy_math 0.12.1",
"bevy_pbr", "bevy_pbr",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_render", "bevy_render",
"bevy_time", "bevy_time",
"bevy_utils", "bevy_utils 0.12.1",
"bevy_window", "bevy_window",
"egui", "egui",
"image", "image",
@@ -377,9 +377,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68080288c932634f6563d3a8299efe0ddc9ea6787539c4c771ba250d089a94f0" checksum = "68080288c932634f6563d3a8299efe0ddc9ea6787539c4c771ba250d089a94f0"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"bevy_app", "bevy_app 0.12.1",
"bevy_derive", "bevy_derive 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
] ]
[[package]] [[package]]
@@ -388,11 +388,27 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d41731817993f92e4363dd3335558e779e290bc71eefc0b5547052b85810907e" checksum = "d41731817993f92e4363dd3335558e779e290bc71eefc0b5547052b85810907e"
dependencies = [ dependencies = [
"bevy_derive", "bevy_derive 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_tasks", "bevy_tasks 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"downcast-rs",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "bevy_app"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab348a32e46d21c5d61794294a92d415a770d26c7ba8951830b127b40b53ccc4"
dependencies = [
"bevy_derive 0.13.2",
"bevy_ecs 0.13.2",
"bevy_reflect 0.13.2",
"bevy_tasks 0.13.2",
"bevy_utils 0.13.2",
"downcast-rs", "downcast-rs",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@@ -407,13 +423,13 @@ dependencies = [
"async-broadcast", "async-broadcast",
"async-fs", "async-fs",
"async-lock 2.8.0", "async-lock 2.8.0",
"bevy_app", "bevy_app 0.12.1",
"bevy_asset_macros", "bevy_asset_macros",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_log", "bevy_log",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_tasks", "bevy_tasks 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"bevy_winit", "bevy_winit",
"blake3", "blake3",
"crossbeam-channel", "crossbeam-channel",
@@ -436,7 +452,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f48b9bbe4ec605e4910b5cd1e1a0acbfbe0b80af5f3bcc4489a9fdd1e80058c" checksum = "3f48b9bbe4ec605e4910b5cd1e1a0acbfbe0b80af5f3bcc4489a9fdd1e80058c"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils 0.12.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.48",
@@ -447,13 +463,13 @@ name = "bevy_controls"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bevy-inspector-egui", "bevy-inspector-egui",
"bevy_app", "bevy_app 0.13.2",
"bevy_controls_macros", "bevy_controls_macros",
"bevy_derive", "bevy_derive 0.13.2",
"bevy_ecs", "bevy_ecs 0.13.2",
"bevy_input", "bevy_input 0.13.2",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"env_logger", "env_logger",
"log", "log",
"serde", "serde",
@@ -486,12 +502,12 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3daa24502a14839509f02407bc7e48299fe84d260877de23b60662de0f4f4b6c" checksum = "3daa24502a14839509f02407bc7e48299fe84d260877de23b60662de0f4f4b6c"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_math", "bevy_math 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_tasks", "bevy_tasks 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"bytemuck", "bytemuck",
] ]
@@ -501,17 +517,17 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4b77c4fca6e90edbe2e72da7bc9aa7aed7dfdfded0920ae0a0c845f5e11084a" checksum = "b4b77c4fca6e90edbe2e72da7bc9aa7aed7dfdfded0920ae0a0c845f5e11084a"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_asset", "bevy_asset",
"bevy_core", "bevy_core",
"bevy_derive", "bevy_derive 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_log", "bevy_log",
"bevy_math", "bevy_math 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_render", "bevy_render",
"bevy_transform", "bevy_transform",
"bevy_utils", "bevy_utils 0.12.1",
"bitflags 2.4.1", "bitflags 2.4.1",
"radsort", "radsort",
"serde", "serde",
@@ -523,7 +539,18 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f484318350462c58ba3942a45a656c1fd6b6e484a6b6b7abc3a787ad1a51e500" checksum = "f484318350462c58ba3942a45a656c1fd6b6e484a6b6b7abc3a787ad1a51e500"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils 0.12.1",
"quote",
"syn 2.0.48",
]
[[package]]
name = "bevy_derive"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0e01f8343f391e2d6a63b368b82fb5b252ed43c8713fc87f9a8f2d59407dd00"
dependencies = [
"bevy_macro_utils 0.13.2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.48",
] ]
@@ -534,12 +561,12 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa38ca5967d335cc1006a0e0f1a86c350e2f15fd1878449f61d04cd57a7c4060" checksum = "fa38ca5967d335cc1006a0e0f1a86c350e2f15fd1878449f61d04cd57a7c4060"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_core", "bevy_core",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_log", "bevy_log",
"bevy_time", "bevy_time",
"bevy_utils", "bevy_utils 0.12.1",
"sysinfo", "sysinfo",
] ]
@@ -550,11 +577,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709fbd22f81fb681534cd913c41e1cd18b17143368743281195d7f024b61aea" checksum = "7709fbd22f81fb681534cd913c41e1cd18b17143368743281195d7f024b61aea"
dependencies = [ dependencies = [
"async-channel 1.9.0", "async-channel 1.9.0",
"bevy_ecs_macros", "bevy_ecs_macros 0.12.1",
"bevy_ptr", "bevy_ptr 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_tasks", "bevy_tasks 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"downcast-rs", "downcast-rs",
"event-listener 2.5.3", "event-listener 2.5.3",
"fixedbitset", "fixedbitset",
@@ -564,13 +591,45 @@ dependencies = [
"thread_local", "thread_local",
] ]
[[package]]
name = "bevy_ecs"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98e612a8e7962ead849e370f3a7e972b88df879ced05cd9dad6a0286d14650cf"
dependencies = [
"async-channel 2.1.1",
"bevy_ecs_macros 0.13.2",
"bevy_ptr 0.13.2",
"bevy_reflect 0.13.2",
"bevy_tasks 0.13.2",
"bevy_utils 0.13.2",
"downcast-rs",
"fixedbitset",
"rustc-hash",
"serde",
"thiserror",
"thread_local",
]
[[package]] [[package]]
name = "bevy_ecs_macros" name = "bevy_ecs_macros"
version = "0.12.1" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8843aa489f159f25cdcd9fee75cd7d221a7098a71eaa72cb2d6b40ac4e3f1ba" checksum = "a8843aa489f159f25cdcd9fee75cd7d221a7098a71eaa72cb2d6b40ac4e3f1ba"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils 0.12.1",
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]]
name = "bevy_ecs_macros"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "807b5106c3410e58f4f523b55ea3c071e2a09e31e9510f3c22021c6a04732b5b"
dependencies = [
"bevy_macro_utils 0.13.2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.48",
@@ -595,7 +654,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5328a3715e933ebbff07d0e99528dc423c4f7a53590ed1ac19a120348b028990" checksum = "5328a3715e933ebbff07d0e99528dc423c4f7a53590ed1ac19a120348b028990"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils 0.12.1",
"encase_derive_impl", "encase_derive_impl",
] ]
@@ -605,12 +664,12 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06bd477152ce2ae1430f5e0a4f19216e5785c22fee1ab23788b5982dc59d1a55" checksum = "06bd477152ce2ae1430f5e0a4f19216e5785c22fee1ab23788b5982dc59d1a55"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_core", "bevy_core",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_log", "bevy_log",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"smallvec", "smallvec",
] ]
@@ -620,12 +679,27 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cab9a599189b2a694c182d60cd52219dd9364f9892ff542d87799b8e45d9e6dc" checksum = "cab9a599189b2a694c182d60cd52219dd9364f9892ff542d87799b8e45d9e6dc"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_math", "bevy_math 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"thiserror",
]
[[package]]
name = "bevy_input"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47f2b2b3df168c6ef661d25e09abf5bd4fecaacd400f27e5db650df1c3fa3a3b"
dependencies = [
"bevy_app 0.13.2",
"bevy_ecs 0.13.2",
"bevy_math 0.13.2",
"bevy_reflect 0.13.2",
"bevy_utils 0.13.2",
"serde", "serde",
"smol_str",
"thiserror", "thiserror",
] ]
@@ -636,24 +710,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f124bece9831afd80897815231072d51bfe3ac58c6bb58eca8880963b6d0487c" checksum = "f124bece9831afd80897815231072d51bfe3ac58c6bb58eca8880963b6d0487c"
dependencies = [ dependencies = [
"bevy_a11y", "bevy_a11y",
"bevy_app", "bevy_app 0.12.1",
"bevy_asset", "bevy_asset",
"bevy_core", "bevy_core",
"bevy_derive", "bevy_derive 0.12.1",
"bevy_diagnostic", "bevy_diagnostic",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_hierarchy", "bevy_hierarchy",
"bevy_input", "bevy_input 0.12.1",
"bevy_log", "bevy_log",
"bevy_math", "bevy_math 0.12.1",
"bevy_ptr", "bevy_ptr 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_render", "bevy_render",
"bevy_scene", "bevy_scene",
"bevy_tasks", "bevy_tasks 0.12.1",
"bevy_time", "bevy_time",
"bevy_transform", "bevy_transform",
"bevy_utils", "bevy_utils 0.12.1",
"bevy_window", "bevy_window",
] ]
@@ -664,9 +738,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dc10ba1d225a8477b9e80a1bf797d8a8b8274e83c9b24fb4d9351aec9229755" checksum = "0dc10ba1d225a8477b9e80a1bf797d8a8b8274e83c9b24fb4d9351aec9229755"
dependencies = [ dependencies = [
"android_log-sys", "android_log-sys",
"bevy_app", "bevy_app 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"console_error_panic_hook", "console_error_panic_hook",
"tracing-log 0.1.4", "tracing-log 0.1.4",
"tracing-subscriber", "tracing-subscriber",
@@ -686,23 +760,45 @@ dependencies = [
"toml_edit 0.20.7", "toml_edit 0.20.7",
] ]
[[package]]
name = "bevy_macro_utils"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb270c98a96243b29465139ed10bda2f675d00a11904f6588a5f7fc4774119c7"
dependencies = [
"proc-macro2",
"quote",
"rustc-hash",
"syn 2.0.48",
"toml_edit 0.21.1",
]
[[package]] [[package]]
name = "bevy_math" name = "bevy_math"
version = "0.12.1" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58ddc2b76783939c530178f88e5711a1b01044d7b02db4033e2eb8b43b6cf4ec" checksum = "58ddc2b76783939c530178f88e5711a1b01044d7b02db4033e2eb8b43b6cf4ec"
dependencies = [ dependencies = [
"glam", "glam 0.24.2",
"serde", "serde",
] ]
[[package]]
name = "bevy_math"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f06daa26ffb82d90ba772256c0ba286f6c305c392f6976c9822717974805837c"
dependencies = [
"glam 0.25.0",
]
[[package]] [[package]]
name = "bevy_mikktspace" name = "bevy_mikktspace"
version = "0.12.1" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ec4962977a746d870170532fc92759e04d3dbcae8b7b82e7ca3bb83b1d75277" checksum = "8ec4962977a746d870170532fc92759e04d3dbcae8b7b82e7ca3bb83b1d75277"
dependencies = [ dependencies = [
"glam", "glam 0.24.2",
] ]
[[package]] [[package]]
@@ -711,16 +807,16 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "520bfd2a898c74f84ea52cfb8eb061f37373ad15e623489d5f75d27ebd6138fe" checksum = "520bfd2a898c74f84ea52cfb8eb061f37373ad15e623489d5f75d27ebd6138fe"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_asset", "bevy_asset",
"bevy_core_pipeline", "bevy_core_pipeline",
"bevy_derive", "bevy_derive 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_math", "bevy_math 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_render", "bevy_render",
"bevy_transform", "bevy_transform",
"bevy_utils", "bevy_utils 0.12.1",
"bevy_window", "bevy_window",
"bitflags 2.4.1", "bitflags 2.4.1",
"bytemuck", "bytemuck",
@@ -737,32 +833,68 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c77ec20c8fafcdc196508ef5ccb4f0400a8d193cb61f7b14a36ed9a25ad423cf" checksum = "c77ec20c8fafcdc196508ef5ccb4f0400a8d193cb61f7b14a36ed9a25ad423cf"
[[package]]
name = "bevy_ptr"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8050e2869fe341db6874203b5a01ff12673807a2c7c80cb829f6c7bea6997268"
[[package]] [[package]]
name = "bevy_reflect" name = "bevy_reflect"
version = "0.12.1" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7921f15fc944c9c8ad01d7dbcea6505b8909c6655cd9382bab1407181556038" checksum = "d7921f15fc944c9c8ad01d7dbcea6505b8909c6655cd9382bab1407181556038"
dependencies = [ dependencies = [
"bevy_math", "bevy_math 0.12.1",
"bevy_ptr", "bevy_ptr 0.12.1",
"bevy_reflect_derive", "bevy_reflect_derive 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"downcast-rs", "downcast-rs",
"erased-serde", "erased-serde 0.3.31",
"glam", "glam 0.24.2",
"serde", "serde",
"smallvec", "smallvec",
"smol_str", "smol_str",
"thiserror", "thiserror",
] ]
[[package]]
name = "bevy_reflect"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccbd7de21d586457a340a0962ad0747dc5098ff925eb6b27a918c4bdd8252f7b"
dependencies = [
"bevy_ptr 0.13.2",
"bevy_reflect_derive 0.13.2",
"bevy_utils 0.13.2",
"downcast-rs",
"erased-serde 0.4.4",
"glam 0.25.0",
"serde",
"smol_str",
"thiserror",
]
[[package]] [[package]]
name = "bevy_reflect_derive" name = "bevy_reflect_derive"
version = "0.12.1" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4a8c5475f216e751ef4452a1306b00711f33d2d04d9f149e4c845dfeb6753a0" checksum = "b4a8c5475f216e751ef4452a1306b00711f33d2d04d9f149e4c845dfeb6753a0"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils 0.12.1",
"proc-macro2",
"quote",
"syn 2.0.48",
"uuid",
]
[[package]]
name = "bevy_reflect_derive"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ce33051bd49036d4a5a62aa3f2068672ec55f3ebe92aa0d003a341f15cc37ac"
dependencies = [
"bevy_macro_utils 0.13.2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.48",
@@ -776,22 +908,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdefdd3737125b0d94a6ff20bb70fa8cfe9d7d5dcd72ba4dfe6c5f1d30d9f6e4" checksum = "bdefdd3737125b0d94a6ff20bb70fa8cfe9d7d5dcd72ba4dfe6c5f1d30d9f6e4"
dependencies = [ dependencies = [
"async-channel 1.9.0", "async-channel 1.9.0",
"bevy_app", "bevy_app 0.12.1",
"bevy_asset", "bevy_asset",
"bevy_core", "bevy_core",
"bevy_derive", "bevy_derive 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_encase_derive", "bevy_encase_derive",
"bevy_hierarchy", "bevy_hierarchy",
"bevy_log", "bevy_log",
"bevy_math", "bevy_math 0.12.1",
"bevy_mikktspace", "bevy_mikktspace",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_render_macros", "bevy_render_macros",
"bevy_tasks", "bevy_tasks 0.12.1",
"bevy_time", "bevy_time",
"bevy_transform", "bevy_transform",
"bevy_utils", "bevy_utils 0.12.1",
"bevy_window", "bevy_window",
"bitflags 2.4.1", "bitflags 2.4.1",
"bytemuck", "bytemuck",
@@ -819,7 +951,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64d86bfc5a1e7fbeeaec0c4ceab18155530f5506624670965db3415f75826bea" checksum = "64d86bfc5a1e7fbeeaec0c4ceab18155530f5506624670965db3415f75826bea"
dependencies = [ dependencies = [
"bevy_macro_utils", "bevy_macro_utils 0.12.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.48",
@@ -831,15 +963,15 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7df078b5e406e37c8a1c6ba0d652bf105fde713ce3c3efda7263fe27467eee5" checksum = "e7df078b5e406e37c8a1c6ba0d652bf105fde713ce3c3efda7263fe27467eee5"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_asset", "bevy_asset",
"bevy_derive", "bevy_derive 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_hierarchy", "bevy_hierarchy",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_render", "bevy_render",
"bevy_transform", "bevy_transform",
"bevy_utils", "bevy_utils 0.12.1",
"ron", "ron",
"serde", "serde",
"thiserror", "thiserror",
@@ -860,16 +992,30 @@ dependencies = [
"wasm-bindgen-futures", "wasm-bindgen-futures",
] ]
[[package]]
name = "bevy_tasks"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f07fcc4969b357de143509925b39c9a2c56eaa8750828d97f319ca9ed41897cb"
dependencies = [
"async-channel 2.1.1",
"async-executor",
"async-task",
"concurrent-queue",
"futures-lite 2.1.0",
"wasm-bindgen-futures",
]
[[package]] [[package]]
name = "bevy_time" name = "bevy_time"
version = "0.12.1" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6250d76eed3077128b6a3d004f9f198b01107800b9824051e32bb658054e837" checksum = "e6250d76eed3077128b6a3d004f9f198b01107800b9824051e32bb658054e837"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"crossbeam-channel", "crossbeam-channel",
"thiserror", "thiserror",
] ]
@@ -880,11 +1026,11 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d541e0c292edbd96afae816ee680e02247422423ccd5dc635c1e211a20ed64be" checksum = "d541e0c292edbd96afae816ee680e02247422423ccd5dc635c1e211a20ed64be"
dependencies = [ dependencies = [
"bevy_app", "bevy_app 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_hierarchy", "bevy_hierarchy",
"bevy_math", "bevy_math 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"thiserror", "thiserror",
] ]
@@ -895,7 +1041,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7915222f4a08ccc782e08d10b751b42e5f9d786e697d0cb3fd09333cb7e8b6ea" checksum = "7915222f4a08ccc782e08d10b751b42e5f9d786e697d0cb3fd09333cb7e8b6ea"
dependencies = [ dependencies = [
"ahash", "ahash",
"bevy_utils_proc_macros", "bevy_utils_proc_macros 0.12.1",
"getrandom", "getrandom",
"hashbrown 0.14.3", "hashbrown 0.14.3",
"instant", "instant",
@@ -906,6 +1052,25 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "bevy_utils"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a9f845a985c00e0ee8dc2d8af3f417be925fb52aad4bda5b96e2e58a2b4d2eb"
dependencies = [
"ahash",
"bevy_utils_proc_macros 0.13.2",
"getrandom",
"hashbrown 0.14.3",
"nonmax",
"petgraph",
"smallvec",
"thiserror",
"tracing",
"uuid",
"web-time",
]
[[package]] [[package]]
name = "bevy_utils_proc_macros" name = "bevy_utils_proc_macros"
version = "0.12.1" version = "0.12.1"
@@ -917,6 +1082,17 @@ dependencies = [
"syn 2.0.48", "syn 2.0.48",
] ]
[[package]]
name = "bevy_utils_proc_macros"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef158627f30503d5c18c20c60b444829f698d343516eeaf6eeee078c9a45163"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
]
[[package]] [[package]]
name = "bevy_window" name = "bevy_window"
version = "0.12.1" version = "0.12.1"
@@ -924,12 +1100,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41ee72bf7f974000e9b31bb971a89387f1432ba9413f35c4fef59fef49767260" checksum = "41ee72bf7f974000e9b31bb971a89387f1432ba9413f35c4fef59fef49767260"
dependencies = [ dependencies = [
"bevy_a11y", "bevy_a11y",
"bevy_app", "bevy_app 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_input", "bevy_input 0.12.1",
"bevy_math", "bevy_math 0.12.1",
"bevy_reflect", "bevy_reflect 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"raw-window-handle", "raw-window-handle",
] ]
@@ -942,14 +1118,14 @@ dependencies = [
"accesskit_winit", "accesskit_winit",
"approx", "approx",
"bevy_a11y", "bevy_a11y",
"bevy_app", "bevy_app 0.12.1",
"bevy_derive", "bevy_derive 0.12.1",
"bevy_ecs", "bevy_ecs 0.12.1",
"bevy_hierarchy", "bevy_hierarchy",
"bevy_input", "bevy_input 0.12.1",
"bevy_math", "bevy_math 0.12.1",
"bevy_tasks", "bevy_tasks 0.12.1",
"bevy_utils", "bevy_utils 0.12.1",
"bevy_window", "bevy_window",
"crossbeam-channel", "crossbeam-channel",
"raw-window-handle", "raw-window-handle",
@@ -1331,7 +1507,7 @@ checksum = "8fce2eeef77fd4a293a54b62aa00ac9daebfbcda4bf8998c5a815635b004aa1c"
dependencies = [ dependencies = [
"const_panic", "const_panic",
"encase_derive", "encase_derive",
"glam", "glam 0.24.2",
"thiserror", "thiserror",
] ]
@@ -1398,6 +1574,15 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "erased-serde"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b73807008a3c7f171cc40312f37d95ef0396e048b5848d775f54b1a4dd4a0d3"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.8" version = "0.3.8"
@@ -1615,6 +1800,16 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "glam"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3"
dependencies = [
"bytemuck",
"serde",
]
[[package]] [[package]]
name = "glow" name = "glow"
version = "0.12.3" version = "0.12.3"
@@ -1730,7 +1925,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cb3df16a7bcb1b5bc092abd55e14f77ca70aea14445026e264586fc62889a10" checksum = "7cb3df16a7bcb1b5bc092abd55e14f77ca70aea14445026e264586fc62889a10"
dependencies = [ dependencies = [
"constgebra", "constgebra",
"glam", "glam 0.24.2",
] ]
[[package]] [[package]]
@@ -2818,6 +3013,17 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "toml_edit"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
dependencies = [
"indexmap 2.1.0",
"toml_datetime",
"winnow",
]
[[package]] [[package]]
name = "tracing" name = "tracing"
version = "0.1.40" version = "0.1.40"
@@ -3082,6 +3288,16 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "web-time"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]] [[package]]
name = "webbrowser" name = "webbrowser"
version = "0.8.12" version = "0.8.12"
+4 -4
View File
@@ -11,10 +11,10 @@ inspector-egui = ["reflect", "dep:bevy-inspector-egui"]
[dependencies] [dependencies]
bevy-inspector-egui = { version = "0.22.1", optional = true } bevy-inspector-egui = { version = "0.22.1", optional = true }
bevy_app = "0.12.1" bevy_app = "0.13.2"
bevy_derive = "0.12.1" bevy_derive = "0.13.2"
bevy_ecs = "0.12.1" bevy_ecs = "0.13.2"
bevy_input = "0.12.1" bevy_input = "0.13.2"
bevy_reflect = { version = "0.12.1", optional = true } bevy_reflect = { version = "0.12.1", optional = true }
bevy_utils = "0.12.1" bevy_utils = "0.12.1"
log = "0.4.20" log = "0.4.20"
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -12,7 +12,7 @@ wayland = ["bevy/wayland"]
windows = ["bevy/bevy_winit"] windows = ["bevy/bevy_winit"]
[dependencies] [dependencies]
bevy = { version = "0.12.1", default-features = false, features = [ bevy = { version = "0.13.2", default-features = false, features = [
"bevy_asset", "bevy_asset",
"bevy_text", "bevy_text",
"bevy_ui", "bevy_ui",
+9 -9
View File
@@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1705309234, "lastModified": 1710146030,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1707092692, "lastModified": 1712163089,
"narHash": "sha256-ZbHsm+mGk/izkWtT4xwwqz38fdlwu7nUUKXTOmm4SyE=", "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "faf912b086576fd1a15fca610166c98d47bc667e", "rev": "fd281bd6b7d3e32ddfa399853946f782553163b5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -51,11 +51,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1707358215, "lastModified": 1712196778,
"narHash": "sha256-Nuhi8KEJ2e+2nTimSyEIPqN5eh7ECVWd+AnPXG6L+SY=", "narHash": "sha256-SOiwCr2HtmYpw8OvQQVRPtiCBWwndbIoPqtsamZK3J8=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "dd917bb1b67fc049fd56fe6de70266a9ab74a4aa", "rev": "20e7895d1873cc64c14a9f024a8e04f5824bed28",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -1,2 +1,2 @@
[toolchain] [toolchain]
channel = '1.72.0' channel = '1.76.0'
+20 -30
View File
@@ -11,7 +11,7 @@ use bevy_controls::{
plugin::ControlsPlugin, plugin::ControlsPlugin,
resource::{ resource::{
ActivationMode, ActivationOptions, Binding, BindingCondition, BindingConfig, Bindings, ActivationMode, ActivationOptions, Binding, BindingCondition, BindingConfig, Bindings,
ButtonCombination, Controls, InputType, InputValue, Keyboard, OptionsMode, PlayerInputs, ButtonCombination, Controls, InputType, InputValue, OptionsMode, PlayerActions,
}, },
}; };
use bevy_controls_derive::{Action, GameState}; use bevy_controls_derive::{Action, GameState};
@@ -37,19 +37,19 @@ enum MyGameState {
#[derive(Resource, Default, Clone, Debug)] #[derive(Resource, Default, Clone, Debug)]
struct MyInputsContainer { struct MyInputsContainer {
// When the game does not provide multiplayer, one field is enough // When the game does not provide multiplayer, one field is enough
player_inputs: PlayerInputs<MyAction>, player_inputs: PlayerActions<MyAction>,
} }
impl InputsContainer<MyAction> for MyInputsContainer { impl InputsContainer<MyAction> for MyInputsContainer {
fn iter_inputs<'a>(&'a self) -> Box<dyn Iterator<Item = &'a PlayerInputs<MyAction>> + 'a> { fn iter_inputs<'a>(&'a self) -> Box<dyn Iterator<Item = &'a PlayerActions<MyAction>> + 'a> {
todo!() todo!()
} }
fn me<'a>(&'a self) -> Option<&'a PlayerInputs<MyAction>> { fn me<'a>(&'a self) -> Option<&'a PlayerActions<MyAction>> {
Some(&self.player_inputs) Some(&self.player_inputs)
} }
fn me_mut<'a>(&'a mut self) -> Option<&'a mut PlayerInputs<MyAction>> { fn me_mut<'a>(&'a mut self) -> Option<&'a mut PlayerActions<MyAction>> {
Some(&mut self.player_inputs) Some(&mut self.player_inputs)
} }
} }
@@ -78,12 +78,7 @@ fn main() {
BindingConfig::new(Bindings::new(vec![ BindingConfig::new(Bindings::new(vec![
// this way input will work only on latin layout only on `A`, because it uses `Keyboard::KeyCode` // this way input will work only on latin layout only on `A`, because it uses `Keyboard::KeyCode`
Binding::new(ButtonCombination::Single(InputType::Keyboard( Binding::new(ButtonCombination::Single(InputType::Keyboard(
Keyboard::KeyCode(KeyCode::A), KeyCode::KeyA,
))),
// this way input will work only on any layout on same button, 35 is `H` for `us` layout or
// `О` for `ru` layout, because it uses `Keyboard::ScanCode`
Binding::new(ButtonCombination::Single(InputType::Keyboard(
Keyboard::ScanCode(ScanCode(35)),
))) )))
.with_condition(BindingCondition::InGameState(MyGameState::InGame)), .with_condition(BindingCondition::InGameState(MyGameState::InGame)),
])) ]))
@@ -94,37 +89,32 @@ fn main() {
// the rest will be simplified // the rest will be simplified
.with( .with(
MyAction::Back, MyAction::Back,
BindingConfig::from_vec(vec![ BindingConfig::from_vec(vec![Binding::from_single(InputType::Keyboard(
Binding::from_single(InputType::from_key_code(KeyCode::S)), KeyCode::KeyS,
Binding::from_single(InputType::from_scan_code(ScanCode(36))), ))]),
]),
) )
.with( .with(
MyAction::Forward, MyAction::Forward,
BindingConfig::from_vec(vec![ BindingConfig::from_vec(vec![Binding::from_single(InputType::Keyboard(
Binding::from_single(InputType::from_key_code(KeyCode::W)), KeyCode::KeyW,
Binding::from_single(InputType::from_scan_code(ScanCode(37))), ))]),
]),
) )
.with( .with(
MyAction::Right, MyAction::Right,
BindingConfig::from_vec(vec![ BindingConfig::from_vec(vec![Binding::from_single(InputType::Keyboard(
Binding::from_single(InputType::from_key_code(KeyCode::D)), KeyCode::KeyD,
Binding::from_single(InputType::from_scan_code(ScanCode(38))), ))]),
]),
) )
.with( .with(
MyAction::Up, MyAction::Up,
BindingConfig::from_bind(Binding::from_single(InputType::from_key_code( BindingConfig::from_bind(Binding::from_single(InputType::Keyboard(KeyCode::Space))),
KeyCode::Space,
))),
) )
.with( .with(
MyAction::Down, MyAction::Down,
BindingConfig::from_bind(Binding::from_chord(vec![ BindingConfig::from_bind(Binding::from_single(
InputType::from_key_code(KeyCode::ShiftLeft), InputType::Keyboard(KeyCode::ShiftLeft),
InputType::from_key_code(KeyCode::Space), //InputType::Keyboard(KeyCode::Space),
])), )),
) )
.build(), .build(),
), ),
+5 -82
View File
@@ -6,13 +6,13 @@ use bevy_inspector_egui::inspector_options::InspectorOptionsType;
use strum::IntoEnumIterator; use strum::IntoEnumIterator;
// #[cfg(all(feature = "reflect", feature = "serialize"))] // #[cfg(all(feature = "reflect", feature = "serialize"))]
// use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; // use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
use bevy_controls_macros::{cfg_feature_trait_bounds, supertraits}; use bevy_controls_macros::supertraits;
#[cfg(feature = "reflect")] #[cfg(feature = "reflect")]
use bevy_reflect::{FromReflect, Reflect, TypePath}; use bevy_reflect::{FromReflect, Reflect, TypePath};
#[cfg(feature = "serialize")] #[cfg(feature = "serialize")]
use serde::{de::DeserializeOwned, Serialize}; use serde::{de::DeserializeOwned, Serialize};
use crate::resource::PlayerInputs; use crate::resource::PlayerActions;
// ===== Action ===== // ===== Action =====
// SAFETY: inspector-egui includes reflect // SAFETY: inspector-egui includes reflect
@@ -52,86 +52,9 @@ pub trait InputsContainer<A: Action>:
{ {
/// The method returning an iterator over references to the PlayerInputs. /// The method returning an iterator over references to the PlayerInputs.
/// Note: the use of 'a for both the method's lifetime and the returned Iterator's lifetime. /// Note: the use of 'a for both the method's lifetime and the returned Iterator's lifetime.
fn iter_inputs<'a>(&'a self) -> Box<dyn Iterator<Item = &'a PlayerInputs<A>> + 'a>; fn iter_inputs<'a>(&'a self) -> Box<dyn Iterator<Item = &'a PlayerActions<A>> + 'a>;
/// The method returning an player inputs of this client. /// The method returning an player inputs of this client.
fn me<'a>(&'a self) -> Option<&'a PlayerInputs<A>>; fn me<'a>(&'a self) -> Option<&'a PlayerActions<A>>;
/// The method returning an mutable player inputs of this client. /// The method returning an mutable player inputs of this client.
fn me_mut<'a>(&'a mut self) -> Option<&'a mut PlayerInputs<A>>; fn me_mut<'a>(&'a mut self) -> Option<&'a mut PlayerActions<A>>;
} }
// #[cfg(test)]
// mod test {
// use bevy_ecs::{entity::Entity, schedule::States};
// use bevy_utils::{HashMap, prelude::default};
// use strum_macros::EnumIter;
// #[cfg(feature = "serialize")]
// use serde::{Serialize, Deserialize};
// use crate::{hashmap, resource::PlayerInputs, common_traits_conditions};
// common_traits_conditions! {
// #[derive(Debug, Clone, PartialEq)]
// #[cfg_attr(feature = "reflect", reflect(Resource))]
// pub struct Lobby {
// pub me: PlayerId,
// pub players: HashMap<PlayerId, Player>,
// }
// }
// impl Default for Lobby {
// fn default() -> Self {
// Self {
// me: PlayerId::Host,
// players: hashmap! {
// PlayerId::Host => Player::default()
// },
// }
// }
// }
// common_traits_conditions! {
// #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
// pub enum PlayerId {
// /// Host or alone
// Host,
// /// Client
// Client(()),
// }
// #[derive(Default, Debug, PartialEq, Clone)]
// pub struct Player {
// /// Client do not need to know about other clients
// #[cfg_attr(feature = "serialize", serde(skip))]
// pub inputs: PlayerInputs<Action>,
// #[cfg_attr(feature = "serialize", serde(skip))]
// pub entity: Option<Entity>,
// }
// }
// #[derive(Debug, PartialEq, Clone, States, Default, Hash, Eq)]
// pub enum GameState {
// #[default]
// LevelEditor,
// InGame,
// }
// impl super::GameState for GameState {}
// // TODO: it is just plug, it must be a trait
// /// Actions that can be performed by player
// #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug, EnumIter)]
// pub enum Action {
// /// Move forward
// LeverEditorForward,
// /// Move backward
// LevelEditorBackward,
// /// Move left
// LevelEditorLeft,
// /// Move right
// LevelEditorRight,
// LevelEditorFly,
// }
// impl super::Action for Action {}
// }
+115 -80
View File
@@ -1,13 +1,18 @@
use bevy_app::{App, Plugin, PreUpdate, Update}; use bevy_app::{App, Plugin, PreUpdate};
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::schedule::IntoSystemConfigs;
use bevy_ecs::system::{In, IntoSystem};
use bevy_ecs::{ use bevy_ecs::{
event::EventReader,
schedule::State, schedule::State,
system::{Res, ResMut}, system::{Res, ResMut, Resource},
}; };
use bevy_input::{ use bevy_input::{
keyboard::{KeyCode, ScanCode}, keyboard::KeyCode,
mouse::MouseButton, mouse::{MouseButton, MouseMotion, MouseScrollUnit, MouseWheel},
Input, ButtonInput,
}; };
use bevy_utils::HashMap;
use crate::{ use crate::{
contract::{Action, GameState, InputsContainer}, contract::{Action, GameState, InputsContainer},
@@ -43,13 +48,20 @@ impl<A: Action, Ic: InputsContainer<A>, Gs: GameState> ControlsPlugin<A, Ic, Gs>
} }
} }
#[derive(Resource, Default, Debug, Deref, DerefMut)]
struct TrigeredInputs(HashMap<InputType, InputValue>);
impl<A: Action, Ic: InputsContainer<A>, Gs: GameState> Plugin for ControlsPlugin<A, Ic, Gs> { impl<A: Action, Ic: InputsContainer<A>, Gs: GameState> Plugin for ControlsPlugin<A, Ic, Gs> {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app app
.insert_resource(self.controls.clone()) .insert_resource(self.controls.clone())
.init_resource::<Ic>() .init_resource::<Ic>()
.add_state::<Gs>() .init_resource::<TrigeredInputs>()
.add_systems(PreUpdate, Self::collect_inputs); .insert_state::<Gs>(Gs::default())
.add_systems(
PreUpdate,
Self::collect_inputs.pipe(Self::fill_players_inputs),
);
#[cfg(feature = "reflect")] #[cfg(feature = "reflect")]
app.register_type::<Controls<A, Gs>>(); app.register_type::<Controls<A, Gs>>();
@@ -57,83 +69,106 @@ impl<A: Action, Ic: InputsContainer<A>, Gs: GameState> Plugin for ControlsPlugin
} }
impl<A: Action, Ic: InputsContainer<A>, Gs: GameState> ControlsPlugin<A, Ic, Gs> { impl<A: Action, Ic: InputsContainer<A>, Gs: GameState> ControlsPlugin<A, Ic, Gs> {
// Separate collecting and filling is necessary becouse order of complicate imputs in future
fn collect_inputs( fn collect_inputs(
keyboard_input_keycode: Res<Input<KeyCode>>, keyboard_button: Res<ButtonInput<KeyCode>>,
keyboard_input_scancode: Res<Input<ScanCode>>, mouse_buttons: Res<ButtonInput<MouseButton>>,
mut scroll_evr: EventReader<MouseWheel>,
mut motion_evr: EventReader<MouseMotion>,
// mut collected_inputs: ResMut<TrigeredInputs>,
) -> TrigeredInputs {
let mut collected_inputs = TrigeredInputs(HashMap::new());
for key in keyboard_button.get_pressed() {
collected_inputs.insert(InputType::Keyboard(*key), InputValue::Boolean(true));
}
// buttons.get_just_released()
for button in mouse_buttons.get_pressed() {
collected_inputs.insert(
InputType::Mouse(MouseInput::Button(*button)),
InputValue::Boolean(true),
);
}
for ev in motion_evr.read() {
collected_inputs.insert(
InputType::Mouse(MouseInput::Axis(AxisName::Horizontal)),
InputValue::Float(ev.delta.x),
);
collected_inputs.insert(
InputType::Mouse(MouseInput::Axis(AxisName::Vertical)),
InputValue::Float(ev.delta.y),
);
}
for ev in scroll_evr.read() {
match ev.unit {
MouseScrollUnit::Line => {
collected_inputs.insert(
InputType::Mouse(MouseInput::Wheel(AxisName::Horizontal)),
InputValue::Float(ev.x),
);
collected_inputs.insert(
InputType::Mouse(MouseInput::Wheel(AxisName::Vertical)),
InputValue::Float(ev.y),
);
}
MouseScrollUnit::Pixel => {
panic!("I'm do not accept you to use touch pad in my game");
}
}
}
collected_inputs
}
// TODO: ! Zero out values that did not arrive
fn fill_players_inputs(
In(collected_inputs): In<TrigeredInputs>,
mut inputs_container: ResMut<Ic>,
controls: Res<Controls<A, Gs>>,
game_state: Res<State<Gs>>,
) { ) {
if let Some(inputs) = inputs_container.me_mut() {
let a: Vec<(InputType, InputValue)> = vec![]; // TODO: only on controls change
for key in keyboard_input_keycode.get_pressed() { let mut action_binding_pairs: Vec<(&A, &BindingConfig<Gs>, &Binding<Gs>)> = Vec::new();
for (action, config) in controls.iter() {
for binding in config.bindings.iter() {
action_binding_pairs.push((action, config, binding));
} }
} }
fn fill_players_inputs() {} action_binding_pairs.sort_by(|a, b| b.2.input.len().cmp(&a.2.input.len()));
// /// Process all hard inputs and bindings to update [`PlayerInputs`] 'bindings_loop: for (action, config, binding) in action_binding_pairs.iter() {
// fn save_input( // check binding conditions
// keyboard_input_keycode: Res<Input<KeyCode>>, for condition in &binding.conditions {
// keyboard_input_scancode: Res<Input<ScanCode>>, match condition {
// mouse_input: Res<Input<MouseButton>>, BindingCondition::InGameState(state) => {
// mut inputs_container: ResMut<Ic>, if *state != *game_state.get() {
// controls: Res<Controls<A, Gs>>, continue 'bindings_loop;
// game_state: Res<State<Gs>>, }
// ) { }
// // get current client inputs }
// if let Some(inputs) = inputs_container.me_mut() { }
// for (action, config) in controls.iter() {
// 'bindings_loop: for binding in config.bindings.iter() { //log::info!("{:#?}", collected_inputs);
// // check binding conditions //log::info!("{:#?}", action_binding_pairs[0]);
// for condition in &binding.conditions {
// match condition { match &binding.input {
// BindingCondition::InGameState(state) => { ButtonCombination::Single(input_type) => {
// if *state != *game_state.get() { if collected_inputs.contains_key(&*input_type) {
// continue 'bindings_loop; inputs.forced_set(**action, true);
// } } else {
// } inputs.forced_set(**action, false);
// } }
// } }
// }
// log::trace!("action binding {:?} {:?} in condition", action, binding); }
// } else {
// // check inputs & mark actions // TODO: print onece
// match &binding.input { log::warn!("cannot find me in inputs container");
// ButtonCombination::Single(button) => match button { }
// InputType::Keyboard(Keyboard::KeyCode(key)) => { }
// if keyboard_input_keycode.pressed(*key) {
// inputs.forced_set(*action, true);
// break; // when on binding trigered no sence check another
// }
// inputs.forced_set(*action, false); // FIXME: this is happening on every pass so maybe too frequently
// }
// InputType::Keyboard(Keyboard::ScanCode(code)) => {
// log::trace!("presed?: {:?}", keyboard_input_scancode.pressed(*code));
// log::trace!("active");
// if keyboard_input_scancode.pressed(*code) {
// inputs.forced_set(*action, true);
// break; // when on binding trigered no sence check another
// }
// inputs.forced_set(*action, false); // FIXME: this is happening on every pass so maybe too frequently
// }
// InputType::Mouse(input) => match input {
// MouseInput::Axis(_axis) => {
// todo!();
// }
// MouseInput::Button(button) => {
// if !mouse_input.get_pressed().any(|b| b == button) {
// continue 'bindings_loop;
// }
// }
// MouseInput::Wheel(_axis) => {
// todo!();
// }
// },
// },
// }
// }
// }
// } else {
// log::error!("cannot find me in inputs container")
// }
// }
} }
+19 -22
View File
@@ -3,7 +3,7 @@ use std::error;
use bevy_derive::{Deref, DerefMut}; use bevy_derive::{Deref, DerefMut};
use bevy_ecs::system::Resource; use bevy_ecs::system::Resource;
use bevy_input::{ use bevy_input::{
keyboard::{KeyCode, ScanCode}, keyboard::KeyCode,
mouse::MouseButton, mouse::MouseButton,
}; };
#[cfg(feature = "inspector-egui")] #[cfg(feature = "inspector-egui")]
@@ -200,42 +200,27 @@ impl<A: Action> PlayerActions<A> {
} }
common_traits_conditions! { common_traits_conditions! {
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq, Hash)]
pub enum InputType { pub enum InputType {
Keyboard(Keyboard), Keyboard(KeyCode),
Mouse(MouseInput), Mouse(MouseInput),
// TODO: Gamepad(GamepadButtonType), // TODO: Gamepad(GamepadButtonType),
// TODO: Touch screen // TODO: Touch screen
} // TODO: TouchPad inputs
}
impl InputType {
pub fn from_key_code(key_code: KeyCode) -> Self {
InputType::Keyboard(Keyboard::KeyCode(key_code))
}
pub fn from_scan_code(scan_code: ScanCode) -> Self {
InputType::Keyboard(Keyboard::ScanCode(scan_code))
} }
} }
common_traits_conditions! { common_traits_conditions! {
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq, Hash)]
pub enum Keyboard {
KeyCode(KeyCode),
ScanCode(ScanCode),
}
#[derive(Debug, PartialEq, Clone)]
pub enum MouseInput { pub enum MouseInput {
Button(MouseButton), Button(MouseButton),
Axis(AxisName), Axis(AxisName),
Wheel(AxisName) Wheel(AxisName)
// TODO: CursorPosition // TODO: CursorPosition
// TODO: TouchPad inputs
} }
/// Name of axis /// Name of axis
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone, Eq, Hash)]
pub enum AxisName { pub enum AxisName {
Horizontal, Horizontal,
Vertical, Vertical,
@@ -311,7 +296,19 @@ common_traits_conditions! {
// /// Chord is a combination of buttons that must be pressed at the same time // /// Chord is a combination of buttons that must be pressed at the same time
// Chord(Vec<InputType>), // Chord(Vec<InputType>),
} }
}
impl ButtonCombination {
pub fn len(&self) -> usize {
use crate::resource::ButtonCombination::*;
match self {
Single(_) => 1
// TODO: Chord
}
}
}
common_traits_conditions! {
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]
pub enum BindingCondition<Gs: GameState> { pub enum BindingCondition<Gs: GameState> {
/// During specific game state /// During specific game state
@@ -572,7 +569,7 @@ impl<A: Action, Gs: GameState> ControlsBuilder<A, Gs> {
// or make sure that you have only one Menufor<'a> Action<'a> with the same name in the Menufor<'a> Action<'a>s // or make sure that you have only one Menufor<'a> Action<'a> with the same name in the Menufor<'a> Action<'a>s
assert!(validate_hash_map(&**self)); assert!(validate_hash_map(&**self));
std::mem::take(&mut self) std::mem::take(&mut self) // TODO
} }
} }
Generated
+9 -9
View File
@@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1705309234, "lastModified": 1710146030,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1706191920, "lastModified": 1712163089,
"narHash": "sha256-eLihrZAPZX0R6RyM5fYAWeKVNuQPYjAkCUBr+JNvtdE=", "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "ae5c332cbb5827f6b1f02572496b141021de335f", "rev": "fd281bd6b7d3e32ddfa399853946f782553163b5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -51,11 +51,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1706235145, "lastModified": 1712196778,
"narHash": "sha256-3jh5nahTlcsX6QFcMPqxtLn9p9CgT9RSce5GLqjcpi4=", "narHash": "sha256-SOiwCr2HtmYpw8OvQQVRPtiCBWwndbIoPqtsamZK3J8=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "3a57c4e29cb2beb777b2e6ae7309a680585b8b2f", "rev": "20e7895d1873cc64c14a9f024a8e04f5824bed28",
"type": "github" "type": "github"
}, },
"original": { "original": {
+1 -1
View File
@@ -1,2 +1,2 @@
[toolchain] [toolchain]
channel = '1.72.0' channel = '1.76.0'