You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 1, 2023. It is now read-only.
Embedded driver for reading input from Sega controllers in Rust.
This library utilizes embedded-hal traits as a platform-agnostic driver.
Features
mega-drive - includes Sega Mega Drive controllers
all - includes all available features
Example
use sega_controller::mega_drive::{MegaDriveButton,MegaDriveController};use sega_controller::Error;// Using some kind of hal like `arduino_hal`// NOTE: You should have pull-up resistors on these pins (10k ohm)let controller = MegaDriveController::from_pins(
pins.d8.into_output(),// select pin
pins.d2.into_floating_input(),// data pin 0
pins.d3.into_floating_input(),// data pin 1
pins.d4.into_floating_input(),// data pin 2
pins.d5.into_floating_input(),// data pin 3
pins.d6.into_floating_input(),// data pin 4
pins.d7.into_floating_input(),// data pin 5);// Only do this once every frame (16ms)match controller.read_state(){Ok(state) => {if state.is_six_button{// do something special for six-button controllers if you like}if state.is_pressed(MegaDriveButton::Start){// start button is currently held down}}Err(Error::NotPresent) => {}// controller is not connected
_ => {}}
Hardware Reference
The Sega Mega Drive uses a standard DB9 serial port connector for controllers.