-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move data/functions from common into core
- Loading branch information
Showing
15 changed files
with
67 additions
and
70 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,44 @@ | ||
pub mod classic; | ||
pub mod nunchuk; | ||
|
||
/// Standard input report | ||
pub type ExtReport = [u8; 6]; | ||
/// HD input report | ||
pub type ExtHdReport = [u8; 8]; | ||
/// Controller ID report | ||
pub type ControllerIdReport = [u8; 6]; | ||
|
||
#[cfg_attr(feature = "defmt_print", derive(defmt::Format))] | ||
#[derive(Debug)] | ||
pub enum ControllerType { | ||
Nunchuk, | ||
Classic, | ||
ClassicPro, | ||
} | ||
|
||
/// All Wii extension controllers use i2c address 52 | ||
pub const EXT_I2C_ADDR: u16 = 0x52; | ||
|
||
/// There needs to be some time between i2c messages or the | ||
/// wii ext device will abort the i2c transaction | ||
/// 200 microseconds works in my tests - need to test with more devices | ||
pub const INTERMESSAGE_DELAY_MICROSEC_U32: u32 = 200; | ||
|
||
pub fn identify_controller(id: ControllerIdReport) -> Option<ControllerType> { | ||
if id[2] != 0xA4 || id[3] != 0x20 { | ||
// Not an extension controller | ||
None | ||
} else if id[0] == 0 && id[1] == 0 && id[4] == 0 && id[5] == 0 { | ||
// It's a nunchuck | ||
Some(ControllerType::Nunchuk) | ||
} else if id[0] == 0 && id[1] == 0 && id[4] == 3 && id[5] == 1 { | ||
// It's a wii classic controller | ||
Some(ControllerType::Classic) | ||
} else if id[0] == 1 && id[1] == 0 && id[4] == 1 && id[5] == 1 { | ||
// It's a wii classic pro (or compatible) controller | ||
// This is most wii classic extension controllers (NES/SNES/Clones) | ||
Some(ControllerType::ClassicPro) | ||
} else { | ||
None | ||
} | ||
} |
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