Skip to content

Commit 252512d

Browse files
committed
Only consider gamepad button down events
1 parent 9c285e2 commit 252512d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/controller.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{collections::HashMap, sync::Arc};
22

33
use anyhow::Result;
44
use futures::{prelude::*, Stream};
5-
use lighthouse_client::protocol::{EventSource, InputEvent, ServerMessage};
5+
use lighthouse_client::protocol::{EventSource, GamepadButtonEvent, GamepadControlEvent, GamepadEvent, InputEvent, ServerMessage};
66
use tokio::sync::Mutex;
77
use tracing::info;
88

@@ -27,7 +27,9 @@ pub async fn run<const W: usize, const H: usize>(
2727
state.move_paddle(1, dir);
2828
}
2929
},
30-
InputEvent::Gamepad(gamepad) => {
30+
InputEvent::Gamepad(gamepad) if !matches!(gamepad, GamepadEvent { control: GamepadControlEvent::Button(GamepadButtonEvent { down: false, .. }), .. }) => {
31+
// TODO: Improve gamepad mechanics (e.g. keep moving paddle when key is held)
32+
3133
let opt_dir = gamepad.direction();
3234
let source = gamepad.source;
3335

0 commit comments

Comments
 (0)