-
Notifications
You must be signed in to change notification settings - Fork 59
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 #460 from CryZe/hotkey-resolve-macos
Implement Resolving Hotkeys on macOS
- Loading branch information
Showing
3 changed files
with
172 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#![allow(dead_code)] | ||
|
||
use super::cf::StringRef; | ||
use std::os::raw::{c_ulong, c_void}; | ||
|
||
mod opaque { | ||
pub enum TISInputSource {} | ||
pub enum UCKeyboardLayout {} | ||
} | ||
|
||
pub type TISInputSourceRef = *mut opaque::TISInputSource; | ||
|
||
pub type OptionBits = u32; | ||
pub type UniCharCount = c_ulong; | ||
pub type UniChar = u16; | ||
pub type OSStatus = i32; | ||
|
||
bitflags::bitflags! { | ||
#[repr(transparent)] | ||
pub struct UCKeyTranslateBits: OptionBits { | ||
const NO_DEAD_KEYS_BIT = 0; | ||
} | ||
} | ||
|
||
#[repr(u16)] | ||
#[non_exhaustive] | ||
pub enum UCKeyAction { | ||
Down = 0, | ||
Up = 1, | ||
AutoKey = 2, | ||
Display = 3, | ||
} | ||
|
||
#[link(name = "Carbon", kind = "framework")] | ||
extern "C" { | ||
pub static kTISPropertyUnicodeKeyLayoutData: StringRef; | ||
pub fn TISCopyCurrentKeyboardInputSource() -> TISInputSourceRef; | ||
pub fn TISCopyCurrentKeyboardLayoutInputSource() -> TISInputSourceRef; | ||
pub fn TISGetInputSourceProperty( | ||
input_source: TISInputSourceRef, | ||
property_key: StringRef, | ||
) -> *mut c_void; | ||
pub fn UCKeyTranslate( | ||
key_layout_ptr: *const opaque::UCKeyboardLayout, | ||
virtual_key_code: u16, | ||
key_action: u16, | ||
modifier_key_state: u32, | ||
keyboard_type: u32, | ||
key_translate_options: OptionBits, | ||
dead_key_state: *mut u32, | ||
max_string_length: UniCharCount, | ||
actual_string_length: *mut UniCharCount, | ||
unicode_string: *mut UniChar, | ||
) -> OSStatus; | ||
pub fn LMGetKbdType() -> u8; | ||
} |
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