aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/bin/luchie.rs40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/bin/luchie.rs b/src/bin/luchie.rs
index bbe06d4..4195746 100755
--- a/src/bin/luchie.rs
+++ b/src/bin/luchie.rs
@@ -105,6 +105,15 @@ fn main() -> ! {
logln!("⏲️ init timer");
let mut sys_timer = SysTimer::new(cp.SYST, clocks.sysclk().to_MHz());
+ logln!("🎹 init buttons");
+ // fusion mouse button labels
+ let mut gpiob = dp.GPIOB.split();
+ let left_button = gpiob.pb9.into_pull_up_input(&mut gpiob.crh);
+ let middle_button = gpiob.pb8.into_pull_up_input(&mut gpiob.crh);
+ let forward_button = gpiob.pb7.into_pull_up_input(&mut gpiob.crl);
+ let back_button = gpiob.pb6.into_pull_up_input(&mut gpiob.crl);
+ let dpi_button = gpiob.pb5.into_pull_up_input(&mut gpiob.crl);
+
// cirque spi connections to spi1:
//
// pb0 - dr
@@ -166,8 +175,12 @@ fn main() -> ! {
.device_class(USB_CLASS_CDC)
.build();
+ while usb_dev.state() != UsbDeviceState::Configured {
+ usb_dev.poll(&mut [&mut serial, &mut mouse]);
+ }
+
+
logln!("💡 init led");
- let mut gpiob = dp.GPIOB.split();
let mut led = gpiob.pb2.into_push_pull_output(&mut gpiob.crl);
led.set_low();
@@ -175,6 +188,7 @@ fn main() -> ! {
let mut abs_to_rel = AbsToRel::new();
let mut trackball = TrackBall::new(1);
+ let mut last_buttons = 0;
loop {
let elapsed = sys_timer.update();
@@ -210,6 +224,27 @@ fn main() -> ! {
_ => {}
}
+ if left_button.is_low() {
+ logln!("lb");
+ mouse_report.buttons |= 1;
+ }
+ if middle_button.is_low() {
+ logln!("mb");
+ mouse_report.buttons |= 2;
+ }
+ if forward_button.is_low() {
+ logln!("fb");
+ mouse_report.buttons |= 4;
+ }
+ if back_button.is_low() {
+ logln!("bb");
+ mouse_report.buttons |= 8;
+ }
+ if dpi_button.is_low() {
+ logln!("db");
+ mouse_report.buttons |= 16;
+ }
+
let rel_p = cirque
.poll(&mut spi)
.ok()
@@ -222,7 +257,7 @@ fn main() -> ! {
logln!("rel_p: {:?}", p);
}
let p = trackball.update(rel_p, elapsed);
- if p.0 != 0 || p.1 != 0 {
+ if p.0 != 0 || p.1 != 0 || mouse_report.buttons ^ last_buttons != 0 {
mouse_report.x = p.0;
mouse_report.y = p.1;
logln!("p: {:?}", p);
@@ -234,6 +269,7 @@ fn main() -> ! {
_ => {}
}
}
+ last_buttons = mouse_report.buttons;
}
}