-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from rust3ds/camera-and-more
Camera rework and small fixes
- Loading branch information
Showing
39 changed files
with
1,242 additions
and
591 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//! Movement example. | ||
//! | ||
//! Simple application to showcase the use of the accelerometer and gyroscope. | ||
use ctru::prelude::*; | ||
|
||
fn main() { | ||
let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); | ||
let mut hid = Hid::new().expect("Couldn't obtain HID controller"); | ||
let apt = Apt::new().expect("Couldn't obtain APT controller"); | ||
|
||
let _console = Console::new(gfx.top_screen.borrow_mut()); | ||
|
||
println!("Move the console around!"); | ||
println!("\x1b[29;16HPress Start to exit"); | ||
|
||
// Activate the accelerometer and the gyroscope. | ||
// Because of the complex nature of the movement sensors, they aren't activated by default with the `Hid` service. | ||
// However, they can simply be turned on and off whenever necessary. | ||
hid.set_accelerometer(true) | ||
.expect("Couldn't activate accelerometer"); | ||
hid.set_gyroscope(true) | ||
.expect("Couldn't activate gyroscope"); | ||
|
||
while apt.main_loop() { | ||
// Scan all the controller inputs. | ||
// Accelerometer and gyroscope require this step to update the readings. | ||
hid.scan_input(); | ||
|
||
if hid.keys_down().contains(KeyPad::START) { | ||
break; | ||
} | ||
|
||
// Be careful: reading without activating the sensors (as done before this loop) will result in a panic. | ||
println!( | ||
"\x1b[3;0HAcceleration: {:?} ", | ||
<(i16, i16, i16)>::from( | ||
hid.accelerometer_vector() | ||
.expect("could not retrieve acceleration vector") | ||
) | ||
); | ||
println!( | ||
"\x1b[4;0HGyroscope angular rate: {:?} ", | ||
Into::<(i16, i16, i16)>::into( | ||
hid.gyroscope_rate() | ||
.expect("could not retrieve angular rate") | ||
) | ||
); | ||
|
||
gfx.wait_for_vblank(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.