diff options
| author | Fenrir <[email protected]> | 2018-02-06 23:06:43 -0700 |
|---|---|---|
| committer | FenrirWolf <[email protected]> | 2018-02-06 23:17:14 -0700 |
| commit | fc0e124f4390deba03193d277dd4fe93ae5443a3 (patch) | |
| tree | 8cdfccf5658381cb66256068cff7a4994385c0f8 /examples/src | |
| parent | Fix unsoundness in Console's API (diff) | |
| download | ctru-rs-fc0e124f4390deba03193d277dd4fe93ae5443a3.tar.xz ctru-rs-fc0e124f4390deba03193d277dd4fe93ae5443a3.zip | |
Use bitflags 1.0 for button presses
Diffstat (limited to 'examples/src')
| -rw-r--r-- | examples/src/bin/buttons.rs | 14 | ||||
| -rw-r--r-- | examples/src/bin/hello-both-screens.rs | 8 | ||||
| -rw-r--r-- | examples/src/bin/hello-world.rs | 4 |
3 files changed, 13 insertions, 13 deletions
diff --git a/examples/src/bin/buttons.rs b/examples/src/bin/buttons.rs index 00dd33e..b906e59 100644 --- a/examples/src/bin/buttons.rs +++ b/examples/src/bin/buttons.rs @@ -3,14 +3,14 @@ extern crate ctru; use ctru::gfx::Gfx; use ctru::console::Console; use ctru::services::apt::Apt; -use ctru::services::hid::{self, Hid, KeyPad}; +use ctru::services::hid::{Hid, KeyPad}; fn main() { // Setup services let apt = Apt::init().unwrap(); let hid = Hid::init().unwrap(); let mut gfx = Gfx::default(); - let mut console = Console::default(); + let console = Console::default(); println!("Hi there! Try pressing a button"); println!("\x1b[29;16HPress Start to exit"); @@ -47,19 +47,19 @@ fn main() { // You can also use the .bits() method to do direct comparisons on // the underlying bits - if keys.contains(hid::KEY_A) { + if keys.contains(KeyPad::KEY_A) { println!("You held A!"); } - if keys.bits() & hid::KEY_B.bits() != 0 { + if keys.bits() & KeyPad::KEY_B.bits() != 0 { println!("You held B!"); } - if keys.contains(hid::KEY_X | hid::KEY_Y) { + if keys.contains(KeyPad::KEY_X | KeyPad::KEY_Y) { println!("You held X and Y!"); } - if keys.intersects(hid::KEY_L | hid::KEY_R | hid::KEY_ZL | hid::KEY_ZR) { + if keys.intersects(KeyPad::KEY_L | KeyPad::KEY_R | KeyPad::KEY_ZL | KeyPad::KEY_ZR) { println!("You held a shoulder button!"); } - if keys.intersects(hid::KEY_START) { + if keys.intersects(KeyPad::KEY_START) { println!("See ya!"); break } diff --git a/examples/src/bin/hello-both-screens.rs b/examples/src/bin/hello-both-screens.rs index 627d9b0..1c214e9 100644 --- a/examples/src/bin/hello-both-screens.rs +++ b/examples/src/bin/hello-both-screens.rs @@ -3,7 +3,7 @@ extern crate ctru; use ctru::gfx::{Gfx, Screen}; use ctru::console::Console; use ctru::services::apt::Apt; -use ctru::services::hid::{self, Hid}; +use ctru::services::hid::{Hid, KeyPad}; fn main() { // Initialize services @@ -12,11 +12,11 @@ fn main() { let mut gfx = Gfx::default(); // Start a console on the top screen - let mut top_screen = Console::init(Screen::Top); + let top_screen = Console::init(Screen::Top); // Start a console on the bottom screen. // The most recently initialized console will be active by default - let mut bottom_screen = Console::init(Screen::Bottom); + let bottom_screen = Console::init(Screen::Bottom); // Let's print on the top screen first top_screen.select(); @@ -35,7 +35,7 @@ fn main() { gfx.swap_buffers(); hid.scan_input(); - if hid.keys_down().contains(hid::KEY_START) { + if hid.keys_down().contains(KeyPad::KEY_START) { break; } } diff --git a/examples/src/bin/hello-world.rs b/examples/src/bin/hello-world.rs index 6daee98..fa70c1d 100644 --- a/examples/src/bin/hello-world.rs +++ b/examples/src/bin/hello-world.rs @@ -3,7 +3,7 @@ extern crate ctru; use ctru::gfx::Gfx; use ctru::console::Console; use ctru::services::apt::Apt; -use ctru::services::hid::{self, Hid}; +use ctru::services::hid::{Hid, KeyPad}; fn main() { // Initialize ctrulib service handles. @@ -45,7 +45,7 @@ fn main() { hid.scan_input(); // Check if the user has pressed the given button on this frame. // If so, break out of the loop. - if hid.keys_down().contains(hid::KEY_START) { + if hid.keys_down().contains(KeyPad::KEY_START) { break; } } |