Fix row 9 issue

Signed-off-by: fly <merspieler@alwaysdata.net>
This commit is contained in:
fly 2024-12-03 00:18:50 +01:00
parent 4ad1ae2799
commit cddcaef9cf

View file

@ -105,7 +105,7 @@ fn main() -> ! {
.freeze(&mut flash.acr); .freeze(&mut flash.acr);
let mut afio = p.AFIO.constrain(); let mut afio = p.AFIO.constrain();
let (pa15, pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4); // To allow us to use pa15 and pb4 let (pa15, _pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4); // To allow us to use pa15 and pb4
// ====================== USB setup ================= // ====================== USB setup =================
assert!(clocks.usbclk_valid()); assert!(clocks.usbclk_valid());
@ -226,11 +226,24 @@ fn main() -> ! {
if io_pins.pb13.is_high() { buttons_read += 0x20; } if io_pins.pb13.is_high() { buttons_read += 0x20; }
if io_pins.pb14.is_high() { buttons_read += 0x40; } if io_pins.pb14.is_high() { buttons_read += 0x40; }
if io_pins.pc9.is_high() { buttons_read += 0x80; } if io_pins.pc9.is_high() { buttons_read += 0x80; }
// if io_pins.pa8.is_high() { buttons_read += 0x100; }
buttons1 = buttons1 & (0xFFFFFFFFFFFFFFFF - (0xFF << (col_select * 8))); buttons1 = buttons1 & (0xFFFFFFFFFFFFFFFF - (0xFF << (col_select * 8)));
buttons1 += buttons_read << (col_select * 8); buttons1 += buttons_read << (col_select * 8);
// Treat row 9 special so it fits into the 64 bit block
if col_select == 1 {
if io_pins.pa8.is_high() { buttons2 = (buttons2 & 0xFFFFEFFF) + 0x1000; }
else { buttons2 = buttons2 & 0xFFFFEFFF; }
}
if col_select == 2 {
if io_pins.pa8.is_high() { buttons2 = (buttons2 & 0xFFFFDFFF) + 0x2000; }
else { buttons2 = buttons2 & 0xFFFFDFFF; }
}
if col_select == 3 {
if io_pins.pa8.is_high() { buttons2 = (buttons2 & 0xFFFFBFFF) + 0x4000; }
else { buttons2 = buttons2 & 0xFFFFBFFF; }
}
let report = CustomInputReport { let report = CustomInputReport {
report_id: 1, report_id: 1,
buttons1, buttons1,
@ -244,7 +257,7 @@ fn main() -> ! {
io_pins.pb6.set_high(); io_pins.pb6.set_high();
io_pins.pb7.set_low(); io_pins.pb7.set_low();
} }
else if lsk_col_select == 1 { else {
io_pins.pc15.set_low(); io_pins.pc15.set_low();
io_pins.pa5.set_high(); io_pins.pa5.set_high();
io_pins.pb6.set_low(); io_pins.pb6.set_low();