Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darren bug fix #80

Merged
merged 8 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/constants/HIDmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ export class Hid {
}
static get NUMDECIMAL(): HidInfo {
return {
HIDcode: 99,
HIDcode: 133,
category: HIDCategory.Numpad,
displayString: 'Numpad Decimal',
webKeyId: 'NumpadDecimal',
Expand Down
6 changes: 3 additions & 3 deletions wooting-macro-backend/src/hid_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub static ref SCANCODE_TO_RDEV: HashMap<u32, Key> = {
scancode.insert(0x60, Key::Kp8); //NUMPAD8
scancode.insert(0x61, Key::Kp9); //NUMPAD9
scancode.insert(0x62, Key::Kp0); //NUMPAD0
scancode.insert(0x63, Key::Dot); //NUMPAD_DECIMAL
scancode.insert(0x85, Key::KpDelete); //NUMPAD_COMMA (KP_DELETE)

scancode.insert(0x64, Key::IntlBackslash); //INTL_BACKSLASH
scancode.insert(0x65, Key::Function); //CONTEXT_MENU
Expand All @@ -198,7 +198,7 @@ pub static ref SCANCODE_TO_RDEV: HashMap<u32, Key> = {



// scancode.insert(0x85, Key::Key); //NUMPAD_COMMA
// scancode.insert(0x85, Key::Key); //NUMPAD_COMMA (KP_DELETE)
//
// scancode.insert(0x87, Key::Key); //INTL_RO
// scancode.insert(0x88, Key::Key); //KANA_MODE
Expand Down Expand Up @@ -382,7 +382,7 @@ pub static ref SCANCODE_TO_HID: HashMap<Key, u32> = {
scancode.insert(Key::Kp8, 0x60); //NUMPAD8
scancode.insert(Key::Kp9, 0x61); //NUMPAD9
scancode.insert(Key::Kp0, 0x62); //NUMPAD0
scancode.insert(Key::Dot, 0x63); //NUMPAD_DECIMAL
scancode.insert(Key::KpDelete, 0x85); //NUMPAD_COMMA (KP_DELETE)

scancode.insert(Key::IntlBackslash, 0x64); //INTL_BACKSLASH
scancode.insert(Key::Function, 0x65); //CONTEXT_MENU
Expand Down
20 changes: 12 additions & 8 deletions wooting-macro-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,15 @@ fn check_macro_execution_efficiently(
if pressed_events == *data {
debug!("MATCHED MACRO singlekey: {:#?}", pressed_events);

// ? Kinda works for now but needs to be improved. Disabled for now as its more of a regression than a fix.
let channel_clone_lift = channel_sender.clone();
let channel_clone_execute = channel_sender.clone();
let macro_clone_execute = macros.clone();
let pressed_data_clone = data.clone();

let channel_clone = channel_sender.clone();
let macro_clone = macros.clone();
plugin::util::lift_keys(pressed_data_clone, channel_clone_lift);

task::spawn(async move {
execute_macro(macro_clone, channel_clone).await;
execute_macro(macro_clone_execute, channel_clone_execute).await;
});
output = true;
}
Expand All @@ -339,13 +341,15 @@ fn check_macro_execution_efficiently(
{
debug!("MATCHED MACRO multikey: {:#?}", pressed_events);

// ? Kinda works for now but needs to be improved. Disabled for now as its more of a regression than a fix.
let channel_clone_lift = channel_sender.clone();
let channel_clone_execute = channel_sender.clone();
let macro_clone_execute = macros.clone();
let pressed_data_clone = data.clone();

let channel_clone = channel_sender.clone();
let macro_clone = macros.clone();
plugin::util::lift_keys(pressed_data_clone, channel_clone_lift);

task::spawn(async move {
execute_macro(macro_clone, channel_clone).await;
execute_macro(macro_clone_execute, channel_clone_execute).await;
});
output = true;
}
Expand Down
11 changes: 11 additions & 0 deletions wooting-macro-backend/src/plugin/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@ pub async fn send_hotkey(send_channel: &UnboundedSender<rdev::EventType>, key: V
.unwrap();
}
}

/// Lifts the keys pressed
pub fn lift_keys(pressed_events: Vec<u32>, channel_sender: UnboundedSender<rdev::EventType>) {
for x in pressed_events {
channel_sender
.send(rdev::EventType::KeyRelease(
super::super::SCANCODE_TO_RDEV[&x],
))
.unwrap();
}
}