Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
pentamassiv committed Jan 6, 2024
1 parent 97d0bd0 commit d08ef3d
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions src/macos/macos_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,80 +347,80 @@ impl Keyboard for Enigo {
match key {
Key::VolumeUp => {
debug!("special case for handling the VolumeUp key");
Enigo::special_keys(0)?;
Enigo::special_keys(0, direction)?;
}
Key::VolumeDown => {
debug!("special case for handling the VolumeDown key");
Enigo::special_keys(1)?;
Enigo::special_keys(1, direction)?;
}
Key::BrightnessUp => {
debug!("special case for handling the BrightnessUp key");
Enigo::special_keys(2)?;
Enigo::special_keys(2, direction)?;
}
Key::BrightnessDown => {
debug!("special case for handling the BrightnessDown key");
Enigo::special_keys(3)?;
Enigo::special_keys(3, direction)?;
}
Key::Power => {
debug!("special case for handling the VolumeMute key");
Enigo::special_keys(6)?;
Enigo::special_keys(6, direction)?;
}
Key::VolumeMute => {
debug!("special case for handling the VolumeMute key");
Enigo::special_keys(7)?;
Enigo::special_keys(7, direction)?;
}

Key::ContrastUp => {
debug!("special case for handling the VolumeUp key");
Enigo::special_keys(11)?;
Enigo::special_keys(11, direction)?;
}
Key::ContrastDown => {
debug!("special case for handling the VolumeDown key");
Enigo::special_keys(12)?;
Enigo::special_keys(12, direction)?;
}
Key::LaunchPanel => {
debug!("special case for handling the MediaPlayPause key");
Enigo::special_keys(13)?;
Enigo::special_keys(13, direction)?;
}
Key::Eject => {
debug!("special case for handling the MediaNextTrack key");
Enigo::special_keys(14)?;
Enigo::special_keys(14, direction)?;
}
Key::VidMirror => {
debug!("special case for handling the MediaPrevTrack key");
Enigo::special_keys(15)?;
Enigo::special_keys(15, direction)?;
}
Key::MediaPlayPause => {
debug!("special case for handling the MediaPlayPause key");
Enigo::special_keys(16)?;
Enigo::special_keys(16, direction)?;
}
Key::MediaNextTrack => {
debug!("special case for handling the MediaNextTrack key");
Enigo::special_keys(17)?;
Enigo::special_keys(17, direction)?;
}
Key::MediaPrevTrack => {
debug!("special case for handling the MediaPrevTrack key");
Enigo::special_keys(18)?;
Enigo::special_keys(18, direction)?;
}
Key::MediaFast => {
debug!("special case for handling the MediaNextTrack key");
Enigo::special_keys(19)?;
Enigo::special_keys(19, direction)?;
}
Key::MediaRewind => {
debug!("special case for handling the MediaPrevTrack key");
Enigo::special_keys(20)?;
Enigo::special_keys(20, direction)?;
}
Key::IlluminationUp => {
debug!("special case for handling the MediaPrevTrack key");
Enigo::special_keys(21)?;
Enigo::special_keys(21, direction)?;
}
Key::IlluminationDown => {
debug!("special case for handling the MediaNextTrack key");
Enigo::special_keys(22)?;
Enigo::special_keys(22, direction)?;
}
Key::IlluminationToggle => {
debug!("special case for handling the MediaPrevTrack key");
Enigo::special_keys(23)?;
Enigo::special_keys(23, direction)?;
}
_ => {
let Ok(keycode) = CGKeyCode::try_from(key) else {
Expand Down Expand Up @@ -569,25 +569,26 @@ impl Enigo {
nth_button_press
}

fn special_keys(code: usize) -> InputResult<()> {
// Simulate illumination up
// let code = NX_KEYTYPE_ILLUMINATION_UP;

code = code; //TODO
fn special_keys(code: usize, direction: Direction) -> InputResult<()> {
let direction = match direction {
Direction::Press => (0xa, 0xa00),
Direction::Press => (0xb, 0xb00),
};
let code = (code << 16) | (direction.0 << 8);

let event = unsafe {
AppKit::NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2(
AppKit::NSEventTypeSystemDefined,
NSPoint::ZERO,
0xa00, // NSEventModifierFlagCapsLock and NSEventModifierFlagOption
direction.2, // NSEventModifierFlagCapsLock and NSEventModifierFlagOption
0.0,
0,
None,
8,
555,
code,
0
)
}; //-> Option<Id<NSEvent>>
};

if event.is_some() {
Ok(())
Expand Down

0 comments on commit d08ef3d

Please sign in to comment.