From 5bb1f1b062818ae0f4ed734cdb07a034f211e19e Mon Sep 17 00:00:00 2001 From: Tony Aldridge Date: Thu, 3 Sep 2015 13:22:09 +0100 Subject: [PATCH] Fixed controller overflow examples. Fixes #452 --- examples/game_controller.rs | 3 ++- examples/joystick.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/game_controller.rs b/examples/game_controller.rs index e66a3f83..a2e81216 100644 --- a/examples/game_controller.rs +++ b/examples/game_controller.rs @@ -52,7 +52,8 @@ fn main() { // Axis motion is an absolute value in the range // [-32768, 32767]. Let's simulate a very rough dead // zone to ignore spurious events. - if val.abs() > 10000 { + let dead_zone = 10000; + if val.abs() > dead_zone || val.abs() < -dead_zone { println!("Axis {:?} moved to {}", axis, val); } } diff --git a/examples/joystick.rs b/examples/joystick.rs index a7e87020..3a3bef03 100644 --- a/examples/joystick.rs +++ b/examples/joystick.rs @@ -39,7 +39,8 @@ fn main() { // Axis motion is an absolute value in the range // [-32768, 32767]. Let's simulate a very rough dead // zone to ignore spurious events. - if val.abs() > 10000 { + let dead_zone = 10000; + if val.abs() > dead_zone || val.abs() < -dead_zone { println!("Axis {} moved to {}", axis_idx, val); } }