Backlight control works!

This commit is contained in:
sebgab 2022-12-06 07:14:31 +01:00
parent 3c3d0ac036
commit 3e8e4def73

View File

@ -109,7 +109,7 @@ fn main() {
} }
// USB Code // USB Code
fn send_lighting_update(col: u8, _row: u8, r: u8, g: u8, b: u8, _a: u8) { fn send_lighting_update(col: u8, row: u8, r: u8, g: u8, b: u8, _a: u8) {
let config: KeyboardConfig = parse_config(&Path::new("numpad_config.json")); let config: KeyboardConfig = parse_config(&Path::new("numpad_config.json"));
let context = libusb::Context::new().unwrap(); // Get a new USB context let context = libusb::Context::new().unwrap(); // Get a new USB context
@ -130,7 +130,7 @@ fn send_lighting_update(col: u8, _row: u8, r: u8, g: u8, b: u8, _a: u8) {
match device_handle.write_control( match device_handle.write_control(
libusb::request_type(libusb::Direction::Out, libusb::RequestType::Class, libusb::Recipient::Interface), // The request is outband and uses HID specific features tergeting an interface libusb::request_type(libusb::Direction::Out, libusb::RequestType::Class, libusb::Recipient::Interface), // The request is outband and uses HID specific features tergeting an interface
0x09, 0x0301, 0, // We want to send a SET_REPORT request, that is a custom feature, with the feature being lighting, we want to send it to endpoint 0 0x09, 0x0301, 0, // We want to send a SET_REPORT request, that is a custom feature, with the feature being lighting, we want to send it to endpoint 0
&[r, g, b, col], std::time::Duration::from_secs(1)) { // First we send the row, then the column, then the Red, Green, Blue, and lastly the brightness &[r, g, b, row, col], std::time::Duration::from_secs(1)) { // First we send the row, then the column, then the Red, Green, Blue, and lastly the brightness
Ok(n) => { Ok(n) => {
println!("{}", format!("Successfully wrote {} bytes!", n).green()); println!("{}", format!("Successfully wrote {} bytes!", n).green());
}, },