Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add missing wayland keyboard input #388

Merged
merged 2 commits into from Jul 19, 2023
Merged

Add missing wayland keyboard input #388

merged 2 commits into from Jul 19, 2023

Conversation

narodnik
Copy link
Contributor

@narodnik narodnik commented Jul 19, 2023

Add missing keyboard input support. The only thing I didn't like was using the static global EVENTS to communicate with the
handlers. Unfortunately, I'm not able to store the event handler in display, and cannot pass it as data since it happens where the seat is attached.

You can test this code by modifiying examples/triangle.rs like so

diff --git a/examples/triangle.rs b/examples/triangle.rs
index a1b1104..0b4e6a5 100644
--- a/examples/triangle.rs
+++ b/examples/triangle.rs
@@ -82,9 +82,14 @@ impl EventHandler for Stage {
 
         self.ctx.commit_frame();
     }
+
+    fn key_down_event(&mut self, keycode: KeyCode, modifiers: KeyMods, repeat: bool) {
+        println!("hello {:?} {:?} {}", keycode, modifiers, repeat);
+    }
 }
 
 fn main() {
+    /*
     let mut conf = conf::Conf::default();
     let metal = std::env::args().nth(1).as_deref() == Some("metal");
     conf.platform.apple_gfx_api = if metal {
@@ -94,6 +99,19 @@ fn main() {
     };
 
     miniquad::start(conf, move || Box::new(Stage::new()));
+    */
+    miniquad::start(
+        miniquad::conf::Conf {
+            window_resizable: true,
+            platform: miniquad::conf::Platform {
+                linux_backend: miniquad::conf::LinuxBackend::WaylandOnly,
+                wayland_use_fallback_decorations: false,
+                ..Default::default()
+            },
+            ..Default::default()
+        },
+        || Box::new(Stage::new()),
+    );
 }
 
 mod shader {

like was using the static global EVENTS to communicate with the
handlers. Unfortunately, I'm not able to store the event handler in
display, and cannot pass it as data since it happens where the seat is
attached.
@not-fl3
Copy link
Owner

not-fl3 commented Jul 19, 2023

Great work, thanks!

For the statics - well, thats not ideal, but I also do not see the way to do it better (see SEAT_HANDLER that was a static already).

@not-fl3 not-fl3 merged commit ec43ac1 into not-fl3:master Jul 19, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants