forked from korkje/mow
-
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.
Merge pull request korkje#5 from iguanajuice/master
Add device "Model D-" and fix typo
- Loading branch information
Showing
17 changed files
with
86 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,7 +302,7 @@ pub enum Button { | |
Scroll, | ||
Forward, | ||
Back, | ||
DPI, | ||
DPIBtn, | ||
ScrollUp, | ||
ScrollDown, | ||
} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use colored::Colorize; | ||
use hidapi::HidDevice; | ||
use std::{thread, time::Duration}; | ||
|
||
pub fn get_bfr_r(device: &HidDevice) -> [u8;65] { | ||
let mut bfr_w = [0u8; 65]; | ||
|
||
bfr_w[3] = 0x02; | ||
bfr_w[4] = 0x02; | ||
bfr_w[6] = 0x83; | ||
|
||
device.send_feature_report(&bfr_w).unwrap(); | ||
|
||
thread::sleep(Duration::from_millis(50)); | ||
|
||
let mut bfr_r = [0u8; 65]; | ||
|
||
device.get_feature_report(&mut bfr_r).unwrap(); | ||
|
||
bfr_r | ||
} | ||
|
||
pub fn get_status(device: &HidDevice) -> usize { | ||
let mut bfr_r = get_bfr_r(device); | ||
|
||
device.get_feature_report(&mut bfr_r).unwrap(); | ||
|
||
let mut status = [0xA1, 0xA4, 0xA2, 0xA0, 0xA3] | ||
.iter() | ||
.position(|&s| s == bfr_r[1]) | ||
.unwrap(); | ||
|
||
if bfr_r[6] != 0x83 { | ||
status = 2; | ||
} | ||
|
||
status | ||
} | ||
|
||
pub fn check_sleep(device: &HidDevice) { | ||
if get_status(device) == 1 { | ||
println!("Cannot write changes to device since it is off or sleeping."); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod color; | |
pub mod key; | ||
pub mod none; | ||
pub mod range; | ||
pub mod getstatus; |
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