Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
f9ef7c59db | |||
bfca616a16 | |||
4c904b07f3 | |||
e71f51687b |
45
Cargo.lock
generated
45
Cargo.lock
generated
@ -15,6 +15,44 @@ name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.17.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "getopts"
|
||||
version = "0.2.21"
|
||||
@ -88,6 +126,8 @@ dependencies = [
|
||||
name = "rusty-keys"
|
||||
version = "0.0.3"
|
||||
dependencies = [
|
||||
"core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -182,6 +222,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
|
||||
"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be"
|
||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
|
||||
"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
|
||||
"checksum core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9"
|
||||
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
"checksum getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
|
||||
"checksum inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8"
|
||||
"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0"
|
||||
|
@ -25,6 +25,13 @@ getopts = "0.2.21"
|
||||
toml = "0.5.3"
|
||||
serde = { version = "1.0.101", features = ["derive"] }
|
||||
|
||||
#[target.'cfg(target_os="macos")'.dependencies]
|
||||
core-graphics = "0.17"
|
||||
core-foundation-sys = "0.6.2"
|
||||
#rustkit = "0.0.1"
|
||||
lazy_static = "1.4.0"
|
||||
libc = "0.2"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3", features = ["winuser", "wincon"] }
|
||||
lazy_static = "1.4.0"
|
||||
|
909
Events.h
Normal file
909
Events.h
Normal file
@ -0,0 +1,909 @@
|
||||
/*
|
||||
File: HIToolbox/Events.h
|
||||
|
||||
Contains: Event Manager Interfaces.
|
||||
|
||||
Copyright: © 1985-2008 by Apple Computer, Inc., all rights reserved
|
||||
|
||||
Bugs?: For bug reports, consult the following page on
|
||||
the World Wide Web:
|
||||
|
||||
http://developer.apple.com/bugreporter/
|
||||
|
||||
*/
|
||||
#ifndef __EVENTS__
|
||||
#define __EVENTS__
|
||||
|
||||
#ifndef __APPLICATIONSERVICES__
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#if PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma pack(push, 2)
|
||||
|
||||
typedef UInt16 EventKind;
|
||||
typedef UInt16 EventMask;
|
||||
enum {
|
||||
nullEvent = 0,
|
||||
mouseDown = 1,
|
||||
mouseUp = 2,
|
||||
keyDown = 3,
|
||||
keyUp = 4,
|
||||
autoKey = 5,
|
||||
updateEvt = 6,
|
||||
diskEvt = 7, /* Not sent in Carbon. See kEventClassVolume in CarbonEvents.h*/
|
||||
activateEvt = 8,
|
||||
osEvt = 15,
|
||||
kHighLevelEvent = 23
|
||||
};
|
||||
|
||||
enum {
|
||||
mDownMask = 1 << mouseDown, /* mouse button pressed*/
|
||||
mUpMask = 1 << mouseUp, /* mouse button released*/
|
||||
keyDownMask = 1 << keyDown, /* key pressed*/
|
||||
keyUpMask = 1 << keyUp, /* key released*/
|
||||
autoKeyMask = 1 << autoKey, /* key repeatedly held down*/
|
||||
updateMask = 1 << updateEvt, /* window needs updating*/
|
||||
diskMask = 1 << diskEvt, /* disk inserted*/
|
||||
activMask = 1 << activateEvt, /* activate/deactivate window*/
|
||||
highLevelEventMask = 0x0400, /* high-level events (includes AppleEvents)*/
|
||||
osMask = 1 << osEvt, /* operating system events (suspend, resume)*/
|
||||
everyEvent = 0xFFFF /* all of the above*/
|
||||
};
|
||||
|
||||
enum {
|
||||
charCodeMask = 0x000000FF,
|
||||
keyCodeMask = 0x0000FF00,
|
||||
adbAddrMask = 0x00FF0000,
|
||||
osEvtMessageMask = (UInt32)0xFF000000
|
||||
};
|
||||
|
||||
enum {
|
||||
/* OS event messages. Event (sub)code is in the high byte of the message field.*/
|
||||
mouseMovedMessage = 0x00FA,
|
||||
suspendResumeMessage = 0x0001
|
||||
};
|
||||
|
||||
enum {
|
||||
resumeFlag = 1 /* Bit 0 of message indicates resume vs suspend*/
|
||||
};
|
||||
|
||||
#if CALL_NOT_IN_CARBON
|
||||
/* convertClipboardFlag is not ever set under Carbon. This is because scrap conversion is */
|
||||
/* not tied to suspend/resume events any longer. Your application should instead use the */
|
||||
/* scrap promise mechanism and fulfill scrap requests only when your promise keeper proc */
|
||||
/* is called. If you need to know if the scrap has changed, you can cache the last */
|
||||
/* ScrapRef you received and compare it with the current ScrapRef */
|
||||
enum {
|
||||
convertClipboardFlag = 2 /* Bit 1 in resume message indicates clipboard change*/
|
||||
};
|
||||
|
||||
#endif /* CALL_NOT_IN_CARBON */
|
||||
|
||||
/*
|
||||
CARBON ALERT! BATTLESTATIONS!
|
||||
|
||||
The EventModifiers bits defined here are also used in the newer Carbon Event
|
||||
key modifiers parameters. There are two main differences:
|
||||
|
||||
1) The Carbon key modifiers parameter is a UInt32, not a UInt16. Never try to
|
||||
extract the key modifiers parameter from a Carbon Event into an EventModifiers
|
||||
type. You will probably get your stack trashed.
|
||||
2) The Carbon key modifiers is just that: key modifiers. That parameter will
|
||||
never contain the button state bit.
|
||||
*/
|
||||
typedef UInt16 EventModifiers;
|
||||
enum {
|
||||
/* modifiers */
|
||||
activeFlagBit = 0, /* activate? (activateEvt and mouseDown)*/
|
||||
btnStateBit = 7, /* state of button?*/
|
||||
cmdKeyBit = 8, /* command key down?*/
|
||||
shiftKeyBit = 9, /* shift key down?*/
|
||||
alphaLockBit = 10, /* alpha lock down?*/
|
||||
optionKeyBit = 11, /* option key down?*/
|
||||
controlKeyBit = 12, /* control key down?*/
|
||||
rightShiftKeyBit = 13, /* right shift key down? Not supported on Mac OS X.*/
|
||||
rightOptionKeyBit = 14, /* right Option key down? Not supported on Mac OS X.*/
|
||||
rightControlKeyBit = 15 /* right Control key down? Not supported on Mac OS X.*/
|
||||
};
|
||||
|
||||
enum {
|
||||
activeFlag = 1 << activeFlagBit,
|
||||
btnState = 1 << btnStateBit,
|
||||
cmdKey = 1 << cmdKeyBit,
|
||||
shiftKey = 1 << shiftKeyBit,
|
||||
alphaLock = 1 << alphaLockBit,
|
||||
optionKey = 1 << optionKeyBit,
|
||||
controlKey = 1 << controlKeyBit,
|
||||
rightShiftKey = 1 << rightShiftKeyBit, /* Not supported on Mac OS X.*/
|
||||
rightOptionKey = 1 << rightOptionKeyBit, /* Not supported on Mac OS X.*/
|
||||
rightControlKey = 1 << rightControlKeyBit /* Not supported on Mac OS X.*/
|
||||
};
|
||||
|
||||
/* MacRoman character codes*/
|
||||
enum {
|
||||
kNullCharCode = 0,
|
||||
kHomeCharCode = 1,
|
||||
kEnterCharCode = 3,
|
||||
kEndCharCode = 4,
|
||||
kHelpCharCode = 5,
|
||||
kBellCharCode = 7,
|
||||
kBackspaceCharCode = 8,
|
||||
kTabCharCode = 9,
|
||||
kLineFeedCharCode = 10,
|
||||
kVerticalTabCharCode = 11,
|
||||
kPageUpCharCode = 11,
|
||||
kFormFeedCharCode = 12,
|
||||
kPageDownCharCode = 12,
|
||||
kReturnCharCode = 13,
|
||||
kFunctionKeyCharCode = 16,
|
||||
kCommandCharCode = 17, /* glyph available only in system fonts*/
|
||||
kCheckCharCode = 18, /* glyph available only in system fonts*/
|
||||
kDiamondCharCode = 19, /* glyph available only in system fonts*/
|
||||
kAppleLogoCharCode = 20, /* glyph available only in system fonts*/
|
||||
kEscapeCharCode = 27,
|
||||
kClearCharCode = 27,
|
||||
kLeftArrowCharCode = 28,
|
||||
kRightArrowCharCode = 29,
|
||||
kUpArrowCharCode = 30,
|
||||
kDownArrowCharCode = 31,
|
||||
kSpaceCharCode = 32,
|
||||
kDeleteCharCode = 127,
|
||||
kBulletCharCode = 165,
|
||||
kNonBreakingSpaceCharCode = 202
|
||||
};
|
||||
|
||||
/* useful Unicode code points*/
|
||||
enum {
|
||||
kShiftUnicode = 0x21E7, /* Unicode UPWARDS WHITE ARROW*/
|
||||
kControlUnicode = 0x2303, /* Unicode UP ARROWHEAD*/
|
||||
kOptionUnicode = 0x2325, /* Unicode OPTION KEY*/
|
||||
kCommandUnicode = 0x2318, /* Unicode PLACE OF INTEREST SIGN*/
|
||||
kPencilUnicode = 0x270E, /* Unicode LOWER RIGHT PENCIL; actually pointed left until Mac OS X 10.3*/
|
||||
kPencilLeftUnicode = 0xF802, /* Unicode LOWER LEFT PENCIL; available in Mac OS X 10.3 and later*/
|
||||
kCheckUnicode = 0x2713, /* Unicode CHECK MARK*/
|
||||
kDiamondUnicode = 0x25C6, /* Unicode BLACK DIAMOND*/
|
||||
kBulletUnicode = 0x2022, /* Unicode BULLET*/
|
||||
kAppleLogoUnicode = 0xF8FF /* Unicode APPLE LOGO*/
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Summary:
|
||||
* Virtual keycodes
|
||||
*
|
||||
* Discussion:
|
||||
* These constants are the virtual keycodes defined originally in
|
||||
* Inside Mac Volume V, pg. V-191. They identify physical keys on a
|
||||
* keyboard. Those constants with "ANSI" in the name are labeled
|
||||
* according to the key position on an ANSI-standard US keyboard.
|
||||
* For example, kVK_ANSI_A indicates the virtual keycode for the key
|
||||
* with the letter 'A' in the US keyboard layout. Other keyboard
|
||||
* layouts may have the 'A' key label on a different physical key;
|
||||
* in this case, pressing 'A' will generate a different virtual
|
||||
* keycode.
|
||||
*/
|
||||
enum {
|
||||
kVK_ANSI_A = 0x00,
|
||||
kVK_ANSI_S = 0x01,
|
||||
kVK_ANSI_D = 0x02,
|
||||
kVK_ANSI_F = 0x03,
|
||||
kVK_ANSI_H = 0x04,
|
||||
kVK_ANSI_G = 0x05,
|
||||
kVK_ANSI_Z = 0x06,
|
||||
kVK_ANSI_X = 0x07,
|
||||
kVK_ANSI_C = 0x08,
|
||||
kVK_ANSI_V = 0x09,
|
||||
kVK_ANSI_B = 0x0B,
|
||||
kVK_ANSI_Q = 0x0C,
|
||||
kVK_ANSI_W = 0x0D,
|
||||
kVK_ANSI_E = 0x0E,
|
||||
kVK_ANSI_R = 0x0F,
|
||||
kVK_ANSI_Y = 0x10,
|
||||
kVK_ANSI_T = 0x11,
|
||||
kVK_ANSI_1 = 0x12,
|
||||
kVK_ANSI_2 = 0x13,
|
||||
kVK_ANSI_3 = 0x14,
|
||||
kVK_ANSI_4 = 0x15,
|
||||
kVK_ANSI_6 = 0x16,
|
||||
kVK_ANSI_5 = 0x17,
|
||||
kVK_ANSI_Equal = 0x18,
|
||||
kVK_ANSI_9 = 0x19,
|
||||
kVK_ANSI_7 = 0x1A,
|
||||
kVK_ANSI_Minus = 0x1B,
|
||||
kVK_ANSI_8 = 0x1C,
|
||||
kVK_ANSI_0 = 0x1D,
|
||||
kVK_ANSI_RightBracket = 0x1E,
|
||||
kVK_ANSI_O = 0x1F,
|
||||
kVK_ANSI_U = 0x20,
|
||||
kVK_ANSI_LeftBracket = 0x21,
|
||||
kVK_ANSI_I = 0x22,
|
||||
kVK_ANSI_P = 0x23,
|
||||
kVK_ANSI_L = 0x25,
|
||||
kVK_ANSI_J = 0x26,
|
||||
kVK_ANSI_Quote = 0x27,
|
||||
kVK_ANSI_K = 0x28,
|
||||
kVK_ANSI_Semicolon = 0x29,
|
||||
kVK_ANSI_Backslash = 0x2A,
|
||||
kVK_ANSI_Comma = 0x2B,
|
||||
kVK_ANSI_Slash = 0x2C,
|
||||
kVK_ANSI_N = 0x2D,
|
||||
kVK_ANSI_M = 0x2E,
|
||||
kVK_ANSI_Period = 0x2F,
|
||||
kVK_ANSI_Grave = 0x32,
|
||||
kVK_ANSI_KeypadDecimal = 0x41,
|
||||
kVK_ANSI_KeypadMultiply = 0x43,
|
||||
kVK_ANSI_KeypadPlus = 0x45,
|
||||
kVK_ANSI_KeypadClear = 0x47,
|
||||
kVK_ANSI_KeypadDivide = 0x4B,
|
||||
kVK_ANSI_KeypadEnter = 0x4C,
|
||||
kVK_ANSI_KeypadMinus = 0x4E,
|
||||
kVK_ANSI_KeypadEquals = 0x51,
|
||||
kVK_ANSI_Keypad0 = 0x52,
|
||||
kVK_ANSI_Keypad1 = 0x53,
|
||||
kVK_ANSI_Keypad2 = 0x54,
|
||||
kVK_ANSI_Keypad3 = 0x55,
|
||||
kVK_ANSI_Keypad4 = 0x56,
|
||||
kVK_ANSI_Keypad5 = 0x57,
|
||||
kVK_ANSI_Keypad6 = 0x58,
|
||||
kVK_ANSI_Keypad7 = 0x59,
|
||||
kVK_ANSI_Keypad8 = 0x5B,
|
||||
kVK_ANSI_Keypad9 = 0x5C
|
||||
};
|
||||
|
||||
/* keycodes for keys that are independent of keyboard layout*/
|
||||
enum {
|
||||
kVK_Return = 0x24,
|
||||
kVK_Tab = 0x30,
|
||||
kVK_Space = 0x31,
|
||||
kVK_Delete = 0x33,
|
||||
kVK_Escape = 0x35,
|
||||
kVK_Command = 0x37,
|
||||
kVK_Shift = 0x38,
|
||||
kVK_CapsLock = 0x39,
|
||||
kVK_Option = 0x3A,
|
||||
kVK_Control = 0x3B,
|
||||
kVK_RightCommand = 0x36,
|
||||
kVK_RightShift = 0x3C,
|
||||
kVK_RightOption = 0x3D,
|
||||
kVK_RightControl = 0x3E,
|
||||
kVK_Function = 0x3F,
|
||||
kVK_F17 = 0x40,
|
||||
kVK_VolumeUp = 0x48,
|
||||
kVK_VolumeDown = 0x49,
|
||||
kVK_Mute = 0x4A,
|
||||
kVK_F18 = 0x4F,
|
||||
kVK_F19 = 0x50,
|
||||
kVK_F20 = 0x5A,
|
||||
kVK_F5 = 0x60,
|
||||
kVK_F6 = 0x61,
|
||||
kVK_F7 = 0x62,
|
||||
kVK_F3 = 0x63,
|
||||
kVK_F8 = 0x64,
|
||||
kVK_F9 = 0x65,
|
||||
kVK_F11 = 0x67,
|
||||
kVK_F13 = 0x69,
|
||||
kVK_F16 = 0x6A,
|
||||
kVK_F14 = 0x6B,
|
||||
kVK_F10 = 0x6D,
|
||||
kVK_F12 = 0x6F,
|
||||
kVK_F15 = 0x71,
|
||||
kVK_Help = 0x72,
|
||||
kVK_Home = 0x73,
|
||||
kVK_PageUp = 0x74,
|
||||
kVK_ForwardDelete = 0x75,
|
||||
kVK_F4 = 0x76,
|
||||
kVK_End = 0x77,
|
||||
kVK_F2 = 0x78,
|
||||
kVK_PageDown = 0x79,
|
||||
kVK_F1 = 0x7A,
|
||||
kVK_LeftArrow = 0x7B,
|
||||
kVK_RightArrow = 0x7C,
|
||||
kVK_DownArrow = 0x7D,
|
||||
kVK_UpArrow = 0x7E
|
||||
};
|
||||
|
||||
/* ISO keyboards only*/
|
||||
enum {
|
||||
kVK_ISO_Section = 0x0A
|
||||
};
|
||||
|
||||
/* JIS keyboards only*/
|
||||
enum {
|
||||
kVK_JIS_Yen = 0x5D,
|
||||
kVK_JIS_Underscore = 0x5E,
|
||||
kVK_JIS_KeypadComma = 0x5F,
|
||||
kVK_JIS_Eisu = 0x66,
|
||||
kVK_JIS_Kana = 0x68
|
||||
};
|
||||
|
||||
struct EventRecord {
|
||||
EventKind what;
|
||||
unsigned long message;
|
||||
UInt32 when;
|
||||
Point where;
|
||||
EventModifiers modifiers;
|
||||
};
|
||||
typedef struct EventRecord EventRecord;
|
||||
typedef CALLBACK_API( void , FKEYProcPtr )(void);
|
||||
typedef STACK_UPP_TYPE(FKEYProcPtr) FKEYUPP;
|
||||
/*
|
||||
* NewFKEYUPP()
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: not available
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: available as macro/inline
|
||||
*/
|
||||
|
||||
/*
|
||||
* DisposeFKEYUPP()
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: not available
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: available as macro/inline
|
||||
*/
|
||||
|
||||
/*
|
||||
* InvokeFKEYUPP()
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: not available
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: available as macro/inline
|
||||
*/
|
||||
|
||||
#if !__LP64__
|
||||
/*
|
||||
* GetMouse() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use HIGetMousePosition instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.5
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
GetMouse(Point * mouseLoc) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;
|
||||
|
||||
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
* Button() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use GetCurrentButtonState or GetCurrentEventButtonState instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework but deprecated in 10.6
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern Boolean
|
||||
Button(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
|
||||
|
||||
|
||||
#if !__LP64__
|
||||
/*
|
||||
* StillDown()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern Boolean
|
||||
StillDown(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
/*
|
||||
* WaitMouseUp()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern Boolean
|
||||
WaitMouseUp(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
/*
|
||||
* KeyTranslate() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use UCKeyTranslate instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern UInt32
|
||||
KeyTranslate(
|
||||
const void * transData,
|
||||
UInt16 keycode,
|
||||
UInt32 * state) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
|
||||
|
||||
|
||||
/*
|
||||
* GetCaretTime()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern UInt32
|
||||
GetCaretTime(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
QuickTime 3.0 supports GetKeys() on unix and win32
|
||||
But, on little endian machines you will have to be
|
||||
careful about bit numberings and/or use a KeyMapByteArray
|
||||
instead.
|
||||
*/
|
||||
#if TARGET_API_MAC_OS8
|
||||
|
||||
typedef UInt32 KeyMap[4];
|
||||
#else
|
||||
typedef BigEndianUInt32 KeyMap[4];
|
||||
#endif /* TARGET_API_MAC_OS8 */
|
||||
|
||||
typedef UInt8 KeyMapByteArray[16];
|
||||
/*
|
||||
* GetKeys()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
GetKeys(KeyMap theKeys) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
/* Obsolete event types & masks */
|
||||
enum {
|
||||
networkEvt = 10,
|
||||
driverEvt = 11,
|
||||
app1Evt = 12,
|
||||
app2Evt = 13,
|
||||
app3Evt = 14,
|
||||
app4Evt = 15,
|
||||
networkMask = 0x0400,
|
||||
driverMask = 0x0800,
|
||||
app1Mask = 0x1000,
|
||||
app2Mask = 0x2000,
|
||||
app3Mask = 0x4000,
|
||||
app4Mask = 0x8000
|
||||
};
|
||||
|
||||
struct EvQEl {
|
||||
QElemPtr qLink;
|
||||
SInt16 qType;
|
||||
EventKind evtQWhat; /* this part is identical to the EventRecord as defined above */
|
||||
unsigned long evtQMessage;
|
||||
UInt32 evtQWhen;
|
||||
Point evtQWhere;
|
||||
EventModifiers evtQModifiers;
|
||||
};
|
||||
typedef struct EvQEl EvQEl;
|
||||
typedef EvQEl * EvQElPtr;
|
||||
typedef CALLBACK_API( void , GetNextEventFilterProcPtr )(EventRecord *theEvent, Boolean *result);
|
||||
typedef STACK_UPP_TYPE(GetNextEventFilterProcPtr) GetNextEventFilterUPP;
|
||||
/*
|
||||
* NewGetNextEventFilterUPP()
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: not available
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: available as macro/inline
|
||||
*/
|
||||
|
||||
/*
|
||||
* DisposeGetNextEventFilterUPP()
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: not available
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: available as macro/inline
|
||||
*/
|
||||
|
||||
/*
|
||||
* InvokeGetNextEventFilterUPP()
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: not available
|
||||
* CarbonLib: not available
|
||||
* Non-Carbon CFM: available as macro/inline
|
||||
*/
|
||||
|
||||
typedef GetNextEventFilterUPP GNEFilterUPP;
|
||||
#if !__LP64__
|
||||
/*
|
||||
* GetDblTime()
|
||||
*
|
||||
* Summary:
|
||||
* Returns the maximum time (in units of 1/60th of a second) allowed
|
||||
* between two consecutive mouse-down events in order for the second
|
||||
* click to be considered a double-click.
|
||||
*
|
||||
* Discussion:
|
||||
* In 64-bit applications, you may replace calls to this API with
|
||||
* calls to NXClickTime (declared in
|
||||
* <IOKit/hidsystem/event_status_driver.h>) or with +[NSEvent
|
||||
* doubleClickInterval] (available in Mac OS X 10.6 and later).
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Result:
|
||||
* The maximum time between mouse-downs allowed for a double-click.
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern UInt32
|
||||
GetDblTime(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
/*
|
||||
* SetEventMask()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
SetEventMask(EventMask value) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
/*
|
||||
* GetNextEvent() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use ReceiveNextEvent instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern Boolean
|
||||
GetNextEvent(
|
||||
EventMask eventMask,
|
||||
EventRecord * theEvent) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
|
||||
|
||||
|
||||
/*
|
||||
* WaitNextEvent() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use ReceiveNextEvent instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern Boolean
|
||||
WaitNextEvent(
|
||||
EventMask eventMask,
|
||||
EventRecord * theEvent,
|
||||
UInt32 sleep,
|
||||
RgnHandle mouseRgn) /* can be NULL */ AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
|
||||
|
||||
|
||||
/*
|
||||
* EventAvail() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use FindSpecificEventInQueue instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern Boolean
|
||||
EventAvail(
|
||||
EventMask eventMask,
|
||||
EventRecord * theEvent) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
|
||||
|
||||
|
||||
/*
|
||||
* PostEvent() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use PostEventToQueue or CGEventPost instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.6
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern OSErr
|
||||
PostEvent(
|
||||
EventKind eventNum,
|
||||
UInt32 eventMsg) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
|
||||
|
||||
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
* FlushEvents() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use FlushEventsMatchingListFromQueue,
|
||||
* FlushSpecificEventsFromQueue, or FlushEventQueue instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework but deprecated in 10.6
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
FlushEvents(
|
||||
EventMask whichMask,
|
||||
EventMask stopMask) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
|
||||
|
||||
|
||||
#if OLDROUTINENAMES
|
||||
#define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
|
||||
#endif /* OLDROUTINENAMES */
|
||||
|
||||
#if !__LP64__
|
||||
/*
|
||||
* KeyScript() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use TISSelectInputSource API for positive verbs (ScriptCode).
|
||||
* Use TSMDocument properties to restrict input sources:
|
||||
* kTSMDocumentEnabledInputSourcesPropertyTag
|
||||
* kTSMDocumentInputSourceOverridePropertyTag
|
||||
*
|
||||
* Summary:
|
||||
* Switch to the specified script's default (last used) input source.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only] but deprecated in 10.5
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
KeyScript(short code) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;
|
||||
|
||||
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
* IsCmdChar() *** DEPRECATED ***
|
||||
*
|
||||
* Deprecated:
|
||||
* Use IsUserCancelEventRef or CheckEventQueueForUserCancel instead.
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework but deprecated in 10.6
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern Boolean
|
||||
IsCmdChar(
|
||||
const EventRecord * event,
|
||||
short test) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
LowMem accessor functions previously in LowMem.h
|
||||
*/
|
||||
/*
|
||||
* LMGetKeyThresh()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern SInt16
|
||||
LMGetKeyThresh(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
#if !__LP64__
|
||||
/*
|
||||
* LMSetKeyThresh()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
LMSetKeyThresh(SInt16 value) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
* LMGetKeyRepThresh()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern SInt16
|
||||
LMGetKeyRepThresh(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
#if !__LP64__
|
||||
/*
|
||||
* LMSetKeyRepThresh()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
LMSetKeyRepThresh(SInt16 value) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
* LMGetKbdLast()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern UInt8
|
||||
LMGetKbdLast(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
#if !__LP64__
|
||||
/*
|
||||
* LMSetKbdLast()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
LMSetKbdLast(UInt8 value) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
/*
|
||||
* LMGetKbdType()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern UInt8
|
||||
LMGetKbdType(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
#if !__LP64__
|
||||
/*
|
||||
* LMSetKbdType()
|
||||
*
|
||||
* Mac OS X threading:
|
||||
* Not thread safe
|
||||
*
|
||||
* Availability:
|
||||
* Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
|
||||
* CarbonLib: in CarbonLib 1.0 and later
|
||||
* Non-Carbon CFM: in InterfaceLib 7.1 and later
|
||||
*/
|
||||
extern void
|
||||
LMSetKbdType(UInt8 value) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;
|
||||
|
||||
|
||||
#endif /* !__LP64__ */
|
||||
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __EVENTS__ */
|
||||
|
10
build.sh
Normal file
10
build.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# https://github.com/millerjs/modelm
|
||||
# mount.cifs -o user=mopar,pass=,uid=1000,gid=1000,forceuid //mojave/mopar /mnt/mojave/
|
||||
|
||||
ssh mojave bash -s "$@" <<EOF
|
||||
. .profile
|
||||
cd /Users/mopar/IdeaProjects/rusty-keys
|
||||
cargo "\$@"
|
||||
EOF
|
12
keymap.toml
12
keymap.toml
@ -17,31 +17,31 @@ default_keymap_index = 2
|
||||
keymaps = [
|
||||
# default key layout, QWERTY in this case
|
||||
"""
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,TAB,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
|
||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
|
||||
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
|
||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
|
||||
LCTL,TAB,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
|
||||
""",
|
||||
# Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard
|
||||
# https://www.moparisthebest.com/kbs/standard-dvorak-QwertySecondary.svg
|
||||
"""
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,TAB,
|
||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
|
||||
TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, DEL, END, PGDN, P7, P8, P9,
|
||||
CAPS,A, O, E, U, I, D, H, T, N, S, MINS, ENT, P4, P5, P6, PPLS,
|
||||
LSFT,SCLN,Q, J, K, X, B, M, W, V, Z, RSFT, UP, P1, P2, P3,
|
||||
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
|
||||
LCTL,TAB,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
|
||||
""",
|
||||
# Unix Programmer Dvorak - for unix developers who are switching from dvorak
|
||||
# https://www.moparisthebest.com/kbs/programmer-dvorak-NoSecondary-NumpadStandard-NoSwap-StandardNums-SwapAt-SwapPipe.svg
|
||||
"""
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
|
||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,TAB,
|
||||
*^4:*^GRV, *^7:*1, *LBRC:*2, *^LBRC:*3, *^RBRC:*4, *^9:*5, *^2:*6, *^8:*7, *^0:*8, *^EQL:*9, *RBRC:*0, *^1:*^5, *^3:*GRV, BSPC, INS, HOME,PGUP, NLCK, *PSLS:*^9, *PAST:*^0, *PMNS:*^4,
|
||||
TAB, *QUOT, *COMM, *DOT, P, Y, F, G, C, R, L, *SLSH, *EQL:*^6, *^BSLS, DEL, END, PGDN, *P7:^A, *P8:^B, *P9:^C,
|
||||
CAPS, A, O, E, U, I, D, H, T, N, S, *MINS, ENT, *P4:^D, *P5:^E, *P6:^F, *PPLS:*COMM,
|
||||
LSFT, *SCLN, Q, J, K, X, B, M, W, V, Z, RSFT, UP, *P1:*EQL, *P2:X, *P3:*^SCLN,
|
||||
LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT,DOWN,RGHT, *P0:*BSLS, *PDOT:*SCLN, PENT
|
||||
LCTL, TAB, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT,DOWN,RGHT, *P0:*BSLS, *PDOT:*SCLN, PENT
|
||||
""",
|
||||
]
|
||||
|
179
keys.txt
Normal file
179
keys.txt
Normal file
@ -0,0 +1,179 @@
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
|
||||
Running `target/debug/rusty-keys`
|
||||
chosen config file: keymap.toml
|
||||
Created event tap...
|
||||
KEY 53
|
||||
KEY 18
|
||||
KEY 19
|
||||
KEY 20
|
||||
KEY 21
|
||||
KEY 23
|
||||
KEY 22
|
||||
KEY 26
|
||||
KEY 28
|
||||
KEY 25
|
||||
KEY 29
|
||||
KEY 27
|
||||
KEY 24
|
||||
KEY 51
|
||||
KEY 48
|
||||
KEY 12
|
||||
KEY 13
|
||||
KEY 14
|
||||
KEY 15
|
||||
KEY 17
|
||||
KEY 16
|
||||
KEY 32
|
||||
KEY 34
|
||||
KEY 31
|
||||
KEY 35
|
||||
KEY 33
|
||||
KEY 30
|
||||
KEY 36
|
||||
KEY 59
|
||||
KEY 59
|
||||
KEY 0
|
||||
KEY 1
|
||||
KEY 2
|
||||
KEY 3
|
||||
KEY 5
|
||||
KEY 4
|
||||
KEY 38
|
||||
KEY 40
|
||||
KEY 37
|
||||
KEY 41
|
||||
KEY 39
|
||||
KEY 50
|
||||
KEY 56
|
||||
KEY 56
|
||||
KEY 42
|
||||
KEY 6
|
||||
KEY 7
|
||||
KEY 8
|
||||
KEY 9
|
||||
KEY 11
|
||||
KEY 45
|
||||
KEY 46
|
||||
KEY 43
|
||||
KEY 47
|
||||
KEY 44
|
||||
KEY 60
|
||||
KEY 60
|
||||
KEY 67
|
||||
KEY 58
|
||||
KEY 58
|
||||
KEY 49
|
||||
KEY 122
|
||||
KEY 120
|
||||
KEY 99
|
||||
KEY 118
|
||||
KEY 96
|
||||
KEY 97
|
||||
KEY 98
|
||||
KEY 100
|
||||
KEY 101
|
||||
KEY 109
|
||||
KEY 71
|
||||
KEY 107
|
||||
KEY 89
|
||||
KEY 91
|
||||
KEY 92
|
||||
KEY 78
|
||||
KEY 107
|
||||
KEY 86
|
||||
KEY 87
|
||||
KEY 88
|
||||
KEY 69
|
||||
KEY 83
|
||||
KEY 84
|
||||
KEY 85
|
||||
KEY 82
|
||||
KEY 65
|
||||
KEY 10
|
||||
KEY 103
|
||||
KEY 111
|
||||
KEY 76
|
||||
KEY 62
|
||||
KEY 62
|
||||
KEY 75
|
||||
KEY 105
|
||||
KEY 61
|
||||
KEY 61
|
||||
KEY 113
|
||||
KEY 115
|
||||
KEY 126
|
||||
KEY 116
|
||||
KEY 123
|
||||
KEY 124
|
||||
KEY 119
|
||||
KEY 125
|
||||
KEY 121
|
||||
KEY 114
|
||||
KEY 117
|
||||
KEY 105
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 54
|
||||
KEY 113
|
||||
KEY 54
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 71
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 55
|
||||
KEY 55
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 55
|
||||
KEY 55
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 54
|
||||
KEY 54
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 113
|
||||
KEY 110
|
||||
KEY 71
|
120
out2.txt
Normal file
120
out2.txt
Normal file
@ -0,0 +1,120 @@
|
||||
KEY 0x0035
|
||||
KEY 0x0012
|
||||
KEY 0x0013
|
||||
KEY 0x0014
|
||||
KEY 0x0015
|
||||
KEY 0x0017
|
||||
KEY 0x0016
|
||||
KEY 0x001A
|
||||
KEY 0x001C
|
||||
KEY 0x0019
|
||||
KEY 0x001D
|
||||
KEY 0x001B
|
||||
KEY 0x0018
|
||||
KEY 0x0033
|
||||
KEY 0x0030
|
||||
KEY 0x000C
|
||||
KEY 0x000D
|
||||
KEY 0x000E
|
||||
KEY 0x000F
|
||||
KEY 0x0011
|
||||
KEY 0x0010
|
||||
KEY 0x0020
|
||||
KEY 0x0022
|
||||
KEY 0x001F
|
||||
KEY 0x0023
|
||||
KEY 0x0021
|
||||
KEY 0x001E
|
||||
KEY 0x0024
|
||||
KEY 0x003B
|
||||
KEY 0x003B
|
||||
KEY 0x0000
|
||||
KEY 0x0001
|
||||
KEY 0x0002
|
||||
KEY 0x0003
|
||||
KEY 0x0005
|
||||
KEY 0x0004
|
||||
KEY 0x0026
|
||||
KEY 0x0028
|
||||
KEY 0x0025
|
||||
KEY 0x0029
|
||||
KEY 0x0027
|
||||
KEY 0x0032
|
||||
KEY 0x0038
|
||||
KEY 0x0038
|
||||
KEY 0x002A
|
||||
KEY 0x0006
|
||||
KEY 0x0007
|
||||
KEY 0x0008
|
||||
KEY 0x0009
|
||||
KEY 0x000B
|
||||
KEY 0x002D
|
||||
KEY 0x002E
|
||||
KEY 0x002B
|
||||
KEY 0x002F
|
||||
KEY 0x002C
|
||||
KEY 0x003C
|
||||
KEY 0x003C
|
||||
KEY 0x0043
|
||||
KEY 0x003A
|
||||
KEY 0x003A
|
||||
KEY 0x0031
|
||||
KEY 0x007A
|
||||
KEY 0x0078
|
||||
KEY 0x0063
|
||||
KEY 0x0076
|
||||
KEY 0x0060
|
||||
KEY 0x0061
|
||||
KEY 0x0062
|
||||
KEY 0x0064
|
||||
KEY 0x0065
|
||||
KEY 0x006D
|
||||
KEY 0x0047
|
||||
KEY 0x006B
|
||||
KEY 0x006B
|
||||
KEY 0x0059
|
||||
KEY 0x005B
|
||||
KEY 0x005C
|
||||
KEY 0x004E
|
||||
KEY 0x0056
|
||||
KEY 0x0057
|
||||
KEY 0x0058
|
||||
KEY 0x0045
|
||||
KEY 0x0053
|
||||
KEY 0x0054
|
||||
KEY 0x0055
|
||||
KEY 0x0052
|
||||
KEY 0x0041
|
||||
KEY 0x000A
|
||||
KEY 0x0067
|
||||
KEY 0x006F
|
||||
KEY 0x004C
|
||||
KEY 0x003E
|
||||
KEY 0x003E
|
||||
KEY 0x004B
|
||||
KEY 0x0069
|
||||
KEY 0x003D
|
||||
KEY 0x003D
|
||||
KEY 0x0071
|
||||
KEY 0x0073
|
||||
KEY 0x007E
|
||||
KEY 0x0074
|
||||
KEY 0x007B
|
||||
KEY 0x007C
|
||||
KEY 0x0077
|
||||
KEY 0x007D
|
||||
KEY 0x0079
|
||||
KEY 0x0072
|
||||
KEY 0x0075
|
||||
KEY 0x0069
|
||||
KEY 0x0047
|
||||
KEY 0x0036
|
||||
KEY 0x0036
|
||||
KEY 0x0037
|
||||
KEY 0x0037
|
||||
KEY 0x0037
|
||||
KEY 0x0037
|
||||
KEY 0x0036
|
||||
KEY 0x0036
|
||||
KEY 0x006E
|
||||
KEY 0x0047
|
10
src/lib.rs
10
src/lib.rs
@ -15,7 +15,17 @@ mod windows;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub use windows::*;
|
||||
|
||||
/*
|
||||
#[cfg(target_os = "linux")]
|
||||
mod linux;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use linux::*;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
mod macos;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use macos::*;
|
||||
*/
|
||||
|
||||
mod macos;
|
||||
pub use macos::*;
|
568
src/macos/codes.rs
Normal file
568
src/macos/codes.rs
Normal file
@ -0,0 +1,568 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use core_graphics::event::CGKeyCode;
|
||||
|
||||
pub const KEY_RESERVED: CGKeyCode = 0x31;
|
||||
pub const KEY_ESC: CGKeyCode = 0x00;
|
||||
pub const KEY_1: CGKeyCode = 0x0012;
|
||||
pub const KEY_2: CGKeyCode = 0x0013;
|
||||
pub const KEY_3: CGKeyCode = 0x0014;
|
||||
pub const KEY_4: CGKeyCode = 0x0015;
|
||||
pub const KEY_5: CGKeyCode = 0x0017;
|
||||
pub const KEY_6: CGKeyCode = 0x0016;
|
||||
pub const KEY_7: CGKeyCode = 0x001A;
|
||||
pub const KEY_8: CGKeyCode = 0x001C;
|
||||
pub const KEY_9: CGKeyCode = 0x0019;
|
||||
pub const KEY_10: CGKeyCode = 0x001D;
|
||||
pub const KEY_MINUS: CGKeyCode = 0x001B;
|
||||
pub const KEY_EQUAL: CGKeyCode = 0x0018;
|
||||
pub const KEY_BACKSPACE: CGKeyCode = 0x0033;
|
||||
pub const KEY_TAB: CGKeyCode = 0x0030;
|
||||
pub const KEY_Q: CGKeyCode = 0x000C;
|
||||
pub const KEY_W: CGKeyCode = 0x000D;
|
||||
pub const KEY_E: CGKeyCode = 0x000E;
|
||||
pub const KEY_R: CGKeyCode = 0x000F;
|
||||
pub const KEY_T: CGKeyCode = 0x0011;
|
||||
pub const KEY_Y: CGKeyCode = 0x0010;
|
||||
pub const KEY_U: CGKeyCode = 0x0020;
|
||||
pub const KEY_I: CGKeyCode = 0x0022;
|
||||
pub const KEY_O: CGKeyCode = 0x001F;
|
||||
pub const KEY_P: CGKeyCode = 0x0023;
|
||||
pub const KEY_LEFTBRACE: CGKeyCode = 0x0021;
|
||||
pub const KEY_RIGHTBRACE: CGKeyCode = 0x001E;
|
||||
pub const KEY_ENTER: CGKeyCode = 0x0024;
|
||||
pub const KEY_LEFTCTRL: CGKeyCode = 0x003B;
|
||||
pub const KEY_A: CGKeyCode = 0x0000;
|
||||
pub const KEY_S: CGKeyCode = 0x0001;
|
||||
pub const KEY_D: CGKeyCode = 0x0002;
|
||||
pub const KEY_F: CGKeyCode = 0x0003;
|
||||
pub const KEY_G: CGKeyCode = 0x0005;
|
||||
pub const KEY_H: CGKeyCode = 0x0004;
|
||||
pub const KEY_J: CGKeyCode = 0x0026;
|
||||
pub const KEY_K: CGKeyCode = 0x0028;
|
||||
pub const KEY_L: CGKeyCode = 0x0025;
|
||||
pub const KEY_SEMICOLON: CGKeyCode = 0x0029;
|
||||
pub const KEY_APOSTROPHE: CGKeyCode = 0x0027;
|
||||
pub const KEY_GRAVE: CGKeyCode = 0x0032;
|
||||
pub const KEY_LEFTSHIFT: CGKeyCode = 0x0038;
|
||||
pub const KEY_BACKSLASH: CGKeyCode = 0x002A;
|
||||
pub const KEY_Z: CGKeyCode = 0x0006;
|
||||
pub const KEY_X: CGKeyCode = 0x0007;
|
||||
pub const KEY_C: CGKeyCode = 0x0008;
|
||||
pub const KEY_V: CGKeyCode = 0x0009;
|
||||
pub const KEY_B: CGKeyCode = 0x000B;
|
||||
pub const KEY_N: CGKeyCode = 0x002D;
|
||||
pub const KEY_M: CGKeyCode = 0x002E;
|
||||
pub const KEY_COMMA: CGKeyCode = 0x002B;
|
||||
pub const KEY_DOT: CGKeyCode = 0x002F;
|
||||
pub const KEY_SLASH: CGKeyCode = 0x002C;
|
||||
pub const KEY_RIGHTSHIFT: CGKeyCode = 0x003C;
|
||||
pub const KEY_KPASTERISK: CGKeyCode = 0x0043;
|
||||
pub const KEY_LEFTALT: CGKeyCode = 0x003A;
|
||||
pub const KEY_SPACE: CGKeyCode = 0x0031;
|
||||
pub const KEY_CAPSLOCK: CGKeyCode = 0x0039;
|
||||
pub const KEY_F1: CGKeyCode = 0x007A;
|
||||
pub const KEY_F2: CGKeyCode = 0x0078;
|
||||
pub const KEY_F3: CGKeyCode = 0x0063;
|
||||
pub const KEY_F4: CGKeyCode = 0x0076;
|
||||
pub const KEY_F5: CGKeyCode = 0x0060;
|
||||
pub const KEY_F6: CGKeyCode = 0x0061;
|
||||
pub const KEY_F7: CGKeyCode = 0x0062;
|
||||
pub const KEY_F8: CGKeyCode = 0x0064;
|
||||
pub const KEY_F9: CGKeyCode = 0x0065;
|
||||
pub const KEY_F10: CGKeyCode = 0x006D;
|
||||
pub const KEY_NUMLOCK: CGKeyCode = 0x0047;
|
||||
pub const KEY_SCROLLLOCK: CGKeyCode = 0x006B;
|
||||
pub const KEY_KP7: CGKeyCode = 0x0059;
|
||||
pub const KEY_KP8: CGKeyCode = 0x005B;
|
||||
pub const KEY_KP9: CGKeyCode = 0x005C;
|
||||
pub const KEY_KPMINUS: CGKeyCode = 0x004E;
|
||||
pub const KEY_KP4: CGKeyCode = 0x0056;
|
||||
pub const KEY_KP5: CGKeyCode = 0x0057;
|
||||
pub const KEY_KP6: CGKeyCode = 0x0058;
|
||||
pub const KEY_KPPLUS: CGKeyCode = 0x0045;
|
||||
pub const KEY_KP1: CGKeyCode = 0x0053;
|
||||
pub const KEY_KP2: CGKeyCode = 0x0054;
|
||||
pub const KEY_KP3: CGKeyCode = 0x0055;
|
||||
pub const KEY_KP0: CGKeyCode = 0x0052;
|
||||
pub const KEY_KPDOT: CGKeyCode = 0x0041;
|
||||
// pub const KEY_ZENKAKUHANKAKU: CGKeyCode = NOT_FOUND;
|
||||
pub const KEY_102ND: CGKeyCode = 0x000A;
|
||||
pub const KEY_F11: CGKeyCode = 0x0067;
|
||||
pub const KEY_F12: CGKeyCode = 0x006F;
|
||||
// pub const KEY_RO: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_KATAKANA: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_HIRAGANA: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_HENKAN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_KATAKANAHIRAGANA: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_MUHENKAN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_KPJPCOMMA: CGKeyCode = NOT_FOUND;
|
||||
pub const KEY_KPENTER: CGKeyCode = 0x004C;
|
||||
pub const KEY_RIGHTCTRL: CGKeyCode = 0x003E;
|
||||
pub const KEY_KPSLASH: CGKeyCode = 0x004B;
|
||||
pub const KEY_SYSRQ: CGKeyCode = 0x0069;
|
||||
pub const KEY_RIGHTALT: CGKeyCode = 0x003D;
|
||||
pub const KEY_LINEFEED: CGKeyCode = 0x0071;
|
||||
pub const KEY_HOME: CGKeyCode = 0x0073;
|
||||
pub const KEY_UP: CGKeyCode = 0x007E;
|
||||
pub const KEY_PAGEUP: CGKeyCode = 0x0074;
|
||||
pub const KEY_LEFT: CGKeyCode = 0x007B;
|
||||
pub const KEY_RIGHT: CGKeyCode = 0x007C;
|
||||
pub const KEY_END: CGKeyCode = 0x0077;
|
||||
pub const KEY_DOWN: CGKeyCode = 0x007D;
|
||||
pub const KEY_PAGEDOWN: CGKeyCode = 0x0079;
|
||||
pub const KEY_INSERT: CGKeyCode = 0x0072;
|
||||
pub const KEY_DELETE: CGKeyCode = 0x0075;
|
||||
// pub const KEY_MACRO: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_MUTE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_VOLUMEDOWN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_VOLUMEUP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_POWER: CGKeyCode = NOT_FOUND;
|
||||
pub const KEY_KPEQUAL: CGKeyCode = 0x0069;
|
||||
// pub const KEY_KPPLUSMINUS: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PAUSE: CGKeyCode = NOT_FOUND;
|
||||
pub const KEY_SCALE: CGKeyCode = 0x0047;
|
||||
pub const KEY_KPCOMMA: CGKeyCode = 0x0036;
|
||||
// pub const KEY_HANGEUL: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_HANGUEL: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_HANGEUL: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_HANJA: CGKeyCode = NOT_FOUND;
|
||||
pub const KEY_YEN: CGKeyCode = 0x0037;
|
||||
// pub const KEY_LEFTMETA: CGKeyCode = NOT_FOUND;
|
||||
pub const KEY_RIGHTMETA: CGKeyCode = 0x0036;
|
||||
pub const KEY_COMPOSE: CGKeyCode = 0x006E;
|
||||
// pub const KEY_STOP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_AGAIN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PROPS: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_UNDO: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_FRONT: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_COPY: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_OPEN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PASTE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_FIND: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CUT: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_HELP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_MENU: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CALC: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SETUP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SLEEP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_WAKEUP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_FILE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SENDFILE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_DELETEFILE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_XFER: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PROG1: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PROG2: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_WWW: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_MSDOS: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_COFFEE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SCREENLOCK: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_COFFEE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_ROTATE_DISPLAY: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_DIRECTION: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_ROTATE_DISPLAY: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CYCLEWINDOWS: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_MAIL: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BOOKMARKS: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_COMPUTER: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BACK: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_FORWARD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CLOSECD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_EJECTCD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_EJECTCLOSECD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_NEXTSONG: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PLAYPAUSE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PREVIOUSSONG: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_STOPCD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_RECORD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_REWIND: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PHONE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_ISO: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CONFIG: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_HOMEPAGE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_REFRESH: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_EXIT: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_MOVE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_EDIT: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SCROLLUP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SCROLLDOWN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_KPLEFTPAREN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_KPRIGHTPAREN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_NEW: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_REDO: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F13: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F14: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F15: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F16: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F17: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F18: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F19: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F20: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F21: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F22: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F23: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_F24: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PLAYCD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PAUSECD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PROG3: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PROG4: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_DASHBOARD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SUSPEND: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CLOSE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PLAY: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_FASTFORWARD: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BASSBOOST: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_PRINT: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_HP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CAMERA: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SOUND: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_QUESTION: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_EMAIL: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CHAT: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SEARCH: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_CONNECT: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_FINANCE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SPORT: CGKeyCode = NOT_FOUND;
|
||||
//pub const KEY_SHOP: CGKeyCode = NOT_FOUND;
|
||||
pub const KEY_ALTERASE: CGKeyCode = 0x0047;
|
||||
// pub const KEY_CANCEL: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BRIGHTNESSDOWN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BRIGHTNESSUP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_MEDIA: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SWITCHVIDEOMODE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_KBDILLUMTOGGLE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_KBDILLUMDOWN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_KBDILLUMUP: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SEND: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_REPLY: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_FORWARDMAIL: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_SAVE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_DOCUMENTS: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BATTERY: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BLUETOOTH: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_UWB: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_UNKNOWN: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_VIDEO_NEXT: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_VIDEO_PREV: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BRIGHTNESS_CYCLE: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BRIGHTNESS_AUTO: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BRIGHTNESS_ZERO: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_BRIGHTNESS_AUTO: CGKeyCode = NOT_FOUND;
|
||||
// pub const KEY_DISPLAY_OFF: CGKeyCode = NOT_FOUND;
|
||||
|
||||
pub fn key_map() -> HashMap<&'static str, CGKeyCode> {
|
||||
[
|
||||
// grep 'Key => 0x' ../rusty-keys-win/src/windows/inputs.rs | tr '[a-z]' '[A-Z]' | sed -r -e 's/KEY => 0X/: CGKeyCode = 0x/' -e 's/^[ ]+/pub const KEY_/' | tr ',' ';'
|
||||
("ESC", KEY_ESC),
|
||||
("1", KEY_1),
|
||||
("2", KEY_2),
|
||||
("3", KEY_3),
|
||||
("4", KEY_4),
|
||||
("5", KEY_5),
|
||||
("6", KEY_6),
|
||||
("7", KEY_7),
|
||||
("8", KEY_8),
|
||||
("9", KEY_9),
|
||||
("10", KEY_10),
|
||||
("MINUS", KEY_MINUS),
|
||||
("EQUAL", KEY_EQUAL),
|
||||
("BACKSPACE", KEY_BACKSPACE),
|
||||
("TAB", KEY_TAB),
|
||||
("Q", KEY_Q),
|
||||
("W", KEY_W),
|
||||
("E", KEY_E),
|
||||
("R", KEY_R),
|
||||
("T", KEY_T),
|
||||
("Y", KEY_Y),
|
||||
("U", KEY_U),
|
||||
("I", KEY_I),
|
||||
("O", KEY_O),
|
||||
("P", KEY_P),
|
||||
("LEFTBRACE", KEY_LEFTBRACE),
|
||||
("RIGHTBRACE", KEY_RIGHTBRACE),
|
||||
("ENTER", KEY_ENTER),
|
||||
("LEFTCTRL", KEY_LEFTCTRL),
|
||||
("A", KEY_A),
|
||||
("S", KEY_S),
|
||||
("D", KEY_D),
|
||||
("F", KEY_F),
|
||||
("G", KEY_G),
|
||||
("H", KEY_H),
|
||||
("J", KEY_J),
|
||||
("K", KEY_K),
|
||||
("L", KEY_L),
|
||||
("SEMICOLON", KEY_SEMICOLON),
|
||||
("APOSTROPHE", KEY_APOSTROPHE),
|
||||
("GRAVE", KEY_GRAVE),
|
||||
("LEFTSHIFT", KEY_LEFTSHIFT),
|
||||
("BACKSLASH", KEY_BACKSLASH),
|
||||
("Z", KEY_Z),
|
||||
("X", KEY_X),
|
||||
("C", KEY_C),
|
||||
("V", KEY_V),
|
||||
("B", KEY_B),
|
||||
("N", KEY_N),
|
||||
("M", KEY_M),
|
||||
("COMMA", KEY_COMMA),
|
||||
("DOT", KEY_DOT),
|
||||
("SLASH", KEY_SLASH),
|
||||
("RIGHTSHIFT", KEY_RIGHTSHIFT),
|
||||
("KPASTERISK", KEY_KPASTERISK),
|
||||
("LEFTALT", KEY_LEFTALT),
|
||||
("SPACE", KEY_SPACE),
|
||||
("CAPSLOCK", KEY_CAPSLOCK),
|
||||
("F1", KEY_F1),
|
||||
("F2", KEY_F2),
|
||||
("F3", KEY_F3),
|
||||
("F4", KEY_F4),
|
||||
("F5", KEY_F5),
|
||||
("F6", KEY_F6),
|
||||
("F7", KEY_F7),
|
||||
("F8", KEY_F8),
|
||||
("F9", KEY_F9),
|
||||
("F10", KEY_F10),
|
||||
("NUMLOCK", KEY_NUMLOCK),
|
||||
("SCROLLLOCK", KEY_SCROLLLOCK),
|
||||
("KP7", KEY_KP7),
|
||||
("KP8", KEY_KP8),
|
||||
("KP9", KEY_KP9),
|
||||
("KPMINUS", KEY_KPMINUS),
|
||||
("KP4", KEY_KP4),
|
||||
("KP5", KEY_KP5),
|
||||
("KP6", KEY_KP6),
|
||||
("KPPLUS", KEY_KPPLUS),
|
||||
("KP1", KEY_KP1),
|
||||
("KP2", KEY_KP2),
|
||||
("KP3", KEY_KP3),
|
||||
("KP0", KEY_KP0),
|
||||
("KPDOT", KEY_KPDOT),
|
||||
/*
|
||||
("ZENKAKUHANKAKU", KEY_ZENKAKUHANKAKU),
|
||||
("102ND", KEY_102ND),
|
||||
*/
|
||||
("F11", KEY_F11),
|
||||
("F12", KEY_F12),
|
||||
/*
|
||||
("RO", KEY_RO),
|
||||
("KATAKANA", KEY_KATAKANA),
|
||||
("HIRAGANA", KEY_HIRAGANA),
|
||||
("HENKAN", KEY_HENKAN),
|
||||
("KATAKANAHIRAGANA", KEY_KATAKANAHIRAGANA),
|
||||
("MUHENKAN", KEY_MUHENKAN),
|
||||
("KPJPCOMMA", KEY_KPJPCOMMA),
|
||||
*/
|
||||
("KPENTER", KEY_KPENTER),
|
||||
("RIGHTCTRL", KEY_RIGHTCTRL),
|
||||
("KPSLASH", KEY_KPSLASH),
|
||||
("SYSRQ", KEY_SYSRQ),
|
||||
("RIGHTALT", KEY_RIGHTALT),
|
||||
/*
|
||||
("LINEFEED", KEY_LINEFEED),
|
||||
*/
|
||||
("HOME", KEY_HOME),
|
||||
("UP", KEY_UP),
|
||||
("PAGEUP", KEY_PAGEUP),
|
||||
("LEFT", KEY_LEFT),
|
||||
("RIGHT", KEY_RIGHT),
|
||||
("END", KEY_END),
|
||||
("DOWN", KEY_DOWN),
|
||||
("PAGEDOWN", KEY_PAGEDOWN),
|
||||
("INSERT", KEY_INSERT),
|
||||
("DELETE", KEY_DELETE),
|
||||
/*
|
||||
("MACRO", KEY_MACRO),
|
||||
("MUTE", KEY_MUTE),
|
||||
("VOLUMEDOWN", KEY_VOLUMEDOWN),
|
||||
("VOLUMEUP", KEY_VOLUMEUP),
|
||||
("POWER", KEY_POWER),
|
||||
("KPEQUAL", KEY_KPEQUAL),
|
||||
("KPPLUSMINUS", KEY_KPPLUSMINUS),
|
||||
("PAUSE", KEY_PAUSE),
|
||||
("SCALE", KEY_SCALE),
|
||||
("KPCOMMA", KEY_KPCOMMA),
|
||||
("HANGEUL", KEY_HANGEUL),
|
||||
("HANGUEL", KEY_HANGUEL),
|
||||
("HANGEUL", KEY_HANGEUL),
|
||||
("HANJA", KEY_HANJA),
|
||||
("YEN", KEY_YEN),
|
||||
("LEFTMETA", KEY_LEFTMETA),
|
||||
("RIGHTMETA", KEY_RIGHTMETA),
|
||||
("COMPOSE", KEY_COMPOSE),
|
||||
("STOP", KEY_STOP),
|
||||
("AGAIN", KEY_AGAIN),
|
||||
("PROPS", KEY_PROPS),
|
||||
("UNDO", KEY_UNDO),
|
||||
("FRONT", KEY_FRONT),
|
||||
("COPY", KEY_COPY),
|
||||
("OPEN", KEY_OPEN),
|
||||
("PASTE", KEY_PASTE),
|
||||
("FIND", KEY_FIND),
|
||||
("CUT", KEY_CUT),
|
||||
("HELP", KEY_HELP),
|
||||
("MENU", KEY_MENU),
|
||||
("CALC", KEY_CALC),
|
||||
("SETUP", KEY_SETUP),
|
||||
("SLEEP", KEY_SLEEP),
|
||||
("WAKEUP", KEY_WAKEUP),
|
||||
("FILE", KEY_FILE),
|
||||
("SENDFILE", KEY_SENDFILE),
|
||||
("DELETEFILE", KEY_DELETEFILE),
|
||||
("XFER", KEY_XFER),
|
||||
("PROG1", KEY_PROG1),
|
||||
("PROG2", KEY_PROG2),
|
||||
("WWW", KEY_WWW),
|
||||
("MSDOS", KEY_MSDOS),
|
||||
("COFFEE", KEY_COFFEE),
|
||||
("SCREENLOCK", KEY_SCREENLOCK),
|
||||
("COFFEE", KEY_COFFEE),
|
||||
("ROTATE_DISPLAY", KEY_ROTATE_DISPLAY),
|
||||
("DIRECTION", KEY_DIRECTION),
|
||||
("ROTATE_DISPLAY", KEY_ROTATE_DISPLAY),
|
||||
("CYCLEWINDOWS", KEY_CYCLEWINDOWS),
|
||||
("MAIL", KEY_MAIL),
|
||||
("BOOKMARKS", KEY_BOOKMARKS),
|
||||
("COMPUTER", KEY_COMPUTER),
|
||||
("BACK", KEY_BACK),
|
||||
("FORWARD", KEY_FORWARD),
|
||||
("CLOSECD", KEY_CLOSECD),
|
||||
("EJECTCD", KEY_EJECTCD),
|
||||
("EJECTCLOSECD", KEY_EJECTCLOSECD),
|
||||
("NEXTSONG", KEY_NEXTSONG),
|
||||
("PLAYPAUSE", KEY_PLAYPAUSE),
|
||||
("PREVIOUSSONG", KEY_PREVIOUSSONG),
|
||||
("STOPCD", KEY_STOPCD),
|
||||
("RECORD", KEY_RECORD),
|
||||
("REWIND", KEY_REWIND),
|
||||
("PHONE", KEY_PHONE),
|
||||
("ISO", KEY_ISO),
|
||||
("CONFIG", KEY_CONFIG),
|
||||
("HOMEPAGE", KEY_HOMEPAGE),
|
||||
("REFRESH", KEY_REFRESH),
|
||||
("EXIT", KEY_EXIT),
|
||||
("MOVE", KEY_MOVE),
|
||||
("EDIT", KEY_EDIT),
|
||||
("SCROLLUP", KEY_SCROLLUP),
|
||||
("SCROLLDOWN", KEY_SCROLLDOWN),
|
||||
("KPLEFTPAREN", KEY_KPLEFTPAREN),
|
||||
("KPRIGHTPAREN", KEY_KPRIGHTPAREN),
|
||||
("NEW", KEY_NEW),
|
||||
("REDO", KEY_REDO),
|
||||
("F13", KEY_F13),
|
||||
("F14", KEY_F14),
|
||||
("F15", KEY_F15),
|
||||
("F16", KEY_F16),
|
||||
("F17", KEY_F17),
|
||||
("F18", KEY_F18),
|
||||
("F19", KEY_F19),
|
||||
("F20", KEY_F20),
|
||||
("F21", KEY_F21),
|
||||
("F22", KEY_F22),
|
||||
("F23", KEY_F23),
|
||||
("F24", KEY_F24),
|
||||
("PLAYCD", KEY_PLAYCD),
|
||||
("PAUSECD", KEY_PAUSECD),
|
||||
("PROG3", KEY_PROG3),
|
||||
("PROG4", KEY_PROG4),
|
||||
("DASHBOARD", KEY_DASHBOARD),
|
||||
("SUSPEND", KEY_SUSPEND),
|
||||
("CLOSE", KEY_CLOSE),
|
||||
("PLAY", KEY_PLAY),
|
||||
("FASTFORWARD", KEY_FASTFORWARD),
|
||||
("BASSBOOST", KEY_BASSBOOST),
|
||||
("PRINT", KEY_PRINT),
|
||||
("HP", KEY_HP),
|
||||
("CAMERA", KEY_CAMERA),
|
||||
("SOUND", KEY_SOUND),
|
||||
("QUESTION", KEY_QUESTION),
|
||||
("EMAIL", KEY_EMAIL),
|
||||
("CHAT", KEY_CHAT),
|
||||
("SEARCH", KEY_SEARCH),
|
||||
("CONNECT", KEY_CONNECT),
|
||||
("FINANCE", KEY_FINANCE),
|
||||
("SPORT", KEY_SPORT),
|
||||
("SHOP", KEY_SHOP),
|
||||
("ALTERASE", KEY_ALTERASE),
|
||||
("CANCEL", KEY_CANCEL),
|
||||
("BRIGHTNESSDOWN", KEY_BRIGHTNESSDOWN),
|
||||
("BRIGHTNESSUP", KEY_BRIGHTNESSUP),
|
||||
("MEDIA", KEY_MEDIA),
|
||||
("SWITCHVIDEOMODE", KEY_SWITCHVIDEOMODE),
|
||||
("KBDILLUMTOGGLE", KEY_KBDILLUMTOGGLE),
|
||||
("KBDILLUMDOWN", KEY_KBDILLUMDOWN),
|
||||
("KBDILLUMUP", KEY_KBDILLUMUP),
|
||||
("SEND", KEY_SEND),
|
||||
("REPLY", KEY_REPLY),
|
||||
("FORWARDMAIL", KEY_FORWARDMAIL),
|
||||
("SAVE", KEY_SAVE),
|
||||
("DOCUMENTS", KEY_DOCUMENTS),
|
||||
("BATTERY", KEY_BATTERY),
|
||||
("BLUETOOTH", KEY_BLUETOOTH),
|
||||
("WLAN", KEY_WLAN),
|
||||
("UWB", KEY_UWB),
|
||||
("UNKNOWN", KEY_UNKNOWN),
|
||||
("VIDEO_NEXT", KEY_VIDEO_NEXT),
|
||||
("VIDEO_PREV", KEY_VIDEO_PREV),
|
||||
("BRIGHTNESS_CYCLE", KEY_BRIGHTNESS_CYCLE),
|
||||
("BRIGHTNESS_AUTO", KEY_BRIGHTNESS_AUTO),
|
||||
("BRIGHTNESS_ZERO", KEY_BRIGHTNESS_ZERO),
|
||||
("BRIGHTNESS_AUTO", KEY_BRIGHTNESS_AUTO),
|
||||
("DISPLAY_OFF", KEY_DISPLAY_OFF),
|
||||
("WWAN", KEY_WWAN),
|
||||
("WIMAX", KEY_WIMAX),
|
||||
("WWAN", KEY_WWAN),
|
||||
("RFKILL", KEY_RFKILL),
|
||||
("MICMUTE", KEY_MICMUTE),
|
||||
*/
|
||||
// below manual shortcuts
|
||||
("PSCR", KEY_SYSRQ),
|
||||
("SLCK", KEY_SCROLLLOCK),
|
||||
//("BRK", KEY_PAUSE),
|
||||
("GRV", KEY_GRAVE),
|
||||
("0", KEY_10), // dumb or named wrong?
|
||||
("MINS", KEY_MINUS),
|
||||
("EQL", KEY_EQUAL),
|
||||
("BSPC", KEY_BACKSPACE),
|
||||
("LBRC", KEY_LEFTBRACE),
|
||||
("RBRC", KEY_RIGHTBRACE),
|
||||
("BSLS", KEY_BACKSLASH),
|
||||
("SCLN", KEY_SEMICOLON),
|
||||
("QUOT", KEY_APOSTROPHE),
|
||||
("ENT", KEY_ENTER),
|
||||
("COMM", KEY_COMMA),
|
||||
("DOT", KEY_DOT),
|
||||
("SLSH", KEY_SLASH),
|
||||
("CAPS", KEY_CAPSLOCK),
|
||||
("LSFT", KEY_LEFTSHIFT),
|
||||
("RSFT", KEY_RIGHTSHIFT),
|
||||
("SPC", KEY_SPACE),
|
||||
("APP", KEY_COMPOSE),
|
||||
("LCTL", KEY_LEFTCTRL),
|
||||
("RCTL", KEY_RIGHTCTRL),
|
||||
("LALT", KEY_LEFTALT),
|
||||
("RALT", KEY_RIGHTALT),
|
||||
//("LGUI", KEY_LEFTMETA),
|
||||
("RGUI", KEY_RIGHTMETA),
|
||||
("INS", KEY_INSERT),
|
||||
("PGUP", KEY_PAGEUP),
|
||||
("PGDN", KEY_PAGEDOWN),
|
||||
("DEL", KEY_DELETE),
|
||||
("RGHT", KEY_RIGHT),
|
||||
("NLCK", KEY_NUMLOCK),
|
||||
("PSLS", KEY_KPSLASH),
|
||||
("PAST", KEY_KPASTERISK),
|
||||
("PMNS", KEY_KPMINUS),
|
||||
("P7", KEY_KP7),
|
||||
("P8", KEY_KP8),
|
||||
("P9", KEY_KP9),
|
||||
("P4", KEY_KP4),
|
||||
("P5", KEY_KP5),
|
||||
("P6", KEY_KP6),
|
||||
("PPLS", KEY_KPPLUS),
|
||||
("P1", KEY_KP1),
|
||||
("P2", KEY_KP2),
|
||||
("P3", KEY_KP3),
|
||||
("P0", KEY_KP0),
|
||||
("PDOT", KEY_KPDOT),
|
||||
("PENT", KEY_KPENTER),
|
||||
].iter().cloned().map(|(m, v)| (m, v)).collect()
|
||||
}
|
591
src/macos/mod.rs
Normal file
591
src/macos/mod.rs
Normal file
@ -0,0 +1,591 @@
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
use crate::*;
|
||||
use std::env;
|
||||
use std::process::exit;
|
||||
|
||||
use getopts::Options;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
pub mod codes;
|
||||
use codes::*;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::Mutex;
|
||||
use core_graphics::event::CGKeyCode;
|
||||
use core_graphics::event::*;
|
||||
use core_graphics::event_source::*;
|
||||
use core_foundation_sys::*;
|
||||
use core_foundation_sys::base::*;
|
||||
use core_foundation_sys::runloop::*;
|
||||
|
||||
/*
|
||||
extern {
|
||||
/// Return the type identifier for the opaque type `CGEventRef'.
|
||||
//fn CGEventGetTypeID() -> CFTypeID;
|
||||
pub fn CFRunLoopRun();
|
||||
}
|
||||
*/
|
||||
|
||||
type MacOSKeyMaps = KeyMaps<Device, CGKeyCode, InputEvent, Option<CGEventRef>>;
|
||||
|
||||
// this is used for identifying the fake keypresses we insert, so we don't process them in an infinite loop
|
||||
//const FAKE_EXTRA_INFO: ULONG_PTR = 332;
|
||||
|
||||
//const BLOCK_KEY: *const CGEventRef = std::ptr::null();
|
||||
//const BLOCK_KEY: *mut CGEventRef = std::ptr::null_mut();
|
||||
|
||||
pub struct InputEvent {
|
||||
event_type: CGEventType,
|
||||
event: CGEventRef,
|
||||
}
|
||||
|
||||
impl KeyEvent<CGKeyCode> for InputEvent {
|
||||
fn code(&self) -> CGKeyCode {
|
||||
//1
|
||||
//self.event.to_owned().get_integer_value_field(EventField::KEYBOARD_EVENT_KEYCODE) as CGKeyCode
|
||||
unsafe { CGEventGetIntegerValueField(self.event, kCGKeyboardEventKeycode) }
|
||||
}
|
||||
/*
|
||||
fn set_code(&self, code: CGKeyCode) {
|
||||
//1
|
||||
//self.event.to_owned().get_integer_value_field(EventField::KEYBOARD_EVENT_KEYCODE) as CGKeyCode
|
||||
unsafe { CGEventSetIntegerValueField(self.event, kCGKeyboardEventKeycode) }
|
||||
}
|
||||
*/
|
||||
fn value(&self) -> KeyState {
|
||||
match self.event_type {
|
||||
kCGEventFlagsChanged => KeyState::DOWN,
|
||||
kCGEventKeyDown => KeyState::DOWN,
|
||||
kCGEventKeyUp => KeyState::UP,
|
||||
kCGEventTapDisabledByTimeout => {
|
||||
println!("Quartz event tap disabled because of timeout; attempting to reregister.");
|
||||
//register_listener(channel);
|
||||
KeyState::OTHER
|
||||
},
|
||||
_ => {
|
||||
println!("Received unknown EventType: {}", self.event_type);
|
||||
KeyState::OTHER
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum DeviceRet {
|
||||
EVENT(CGEventRef),
|
||||
NULL,
|
||||
}
|
||||
|
||||
pub struct Device;
|
||||
|
||||
impl Keyboard<CGKeyCode, InputEvent, Option<CGEventRef>> for Device {
|
||||
fn send(&self, event: &mut InputEvent) -> Result<Option<CGEventRef>> {
|
||||
println!("send orig: {}", event.code());
|
||||
Ok(Some(event.event))
|
||||
}
|
||||
|
||||
fn send_mod_code(&self, code: CGKeyCode, event: &mut InputEvent) -> Result<Option<CGEventRef>> {
|
||||
// event.value should only ever be UP/DOWN when this method is called
|
||||
println!("send_mod_code orig: {} code: {}", event.code(), code);
|
||||
//event.event.set_integer_value_field();
|
||||
//unsafe { CGEventSetIntegerValueField(event.event, kCGKeyboardEventKeycode, code as i64) };
|
||||
|
||||
//Ok(Some(event.event))
|
||||
//Ok(None)
|
||||
|
||||
self.send_mod_code_value(code, event.value() == KeyState::UP, event)
|
||||
}
|
||||
|
||||
fn send_mod_code_value(&self, code: CGKeyCode, up_not_down: bool, event: &mut InputEvent) -> Result<Option<CGEventRef>> {
|
||||
println!("send_mod_code_value orig: {} code: {}, up_not_down: {}", event.code(), code, up_not_down);
|
||||
|
||||
// https://github.com/enigo-rs/enigo/blob/master/src/macos/macos_impl.rs
|
||||
/*
|
||||
let event_source = CGEventSource::new(CGEventSourceStateID::CombinedSessionState)
|
||||
.expect("Failed creating event source");
|
||||
|
||||
let event =
|
||||
CGEvent::new_keyboard_event(event_source.clone(), code, !up_not_down)
|
||||
.expect("Failed creating event");
|
||||
event.post(CGEventTapLocation::HID);
|
||||
*/
|
||||
|
||||
unsafe { CGEventSetIntegerValueField(event.event, kCGKeyboardEventKeycode, code as i64) };
|
||||
|
||||
|
||||
let flags = unsafe { CGEventGetFlags(event.event) };
|
||||
print_flags(flags);
|
||||
let flags = flags >> NX_DEVICERSHIFTKEYMASK;
|
||||
print_flags(flags);
|
||||
//CGEventSetFlags(event, flags);
|
||||
|
||||
Ok(Some(event.event))
|
||||
//Ok(None)
|
||||
}
|
||||
|
||||
fn synchronize(&self) -> Result<Option<CGEventRef>> {
|
||||
// no-op here
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn left_shift_code(&self) -> CGKeyCode {
|
||||
KEY_LEFTSHIFT
|
||||
}
|
||||
|
||||
fn right_shift_code(&self) -> CGKeyCode {
|
||||
KEY_RIGHTSHIFT
|
||||
}
|
||||
|
||||
fn caps_lock_code(&self) -> CGKeyCode {
|
||||
KEY_CAPSLOCK
|
||||
}
|
||||
|
||||
fn block_key(&self) -> Result<Option<CGEventRef>> {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for MacOSKeyMaps {
|
||||
// windows promises us keybd_proc will only be called by a single thread at a time
|
||||
// but rust makes us wrap in mutex anyway, so we are extra safe...
|
||||
}
|
||||
|
||||
const DEVICE: Device = Device;
|
||||
|
||||
/*
|
||||
lazy_static! {
|
||||
static ref KEY_MAPPER: Mutex<MacOSKeyMaps> = {
|
||||
|
||||
let config = parse_args();
|
||||
//println!("Config: {:?}", config);
|
||||
|
||||
let key_map = key_map();
|
||||
//println!("key_map: {:?}", key_map);
|
||||
|
||||
println!("chosen config file: {}", config.config_file);
|
||||
|
||||
Mutex::new(MacOSKeyMaps::from_cfg(&key_map, &config.config_file))
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
pub fn main_res() -> Result<()> {
|
||||
// this is just to cause the lazy_static init to run first, so if -h or -v is wanted, we do that
|
||||
// and exit immediately... todo: how to avoid mutex/lazy_static entirely???
|
||||
//let _ = KEY_MAPPER.lock().unwrap();
|
||||
|
||||
let config = parse_args();
|
||||
println!("Config: {:?}", config);
|
||||
|
||||
let key_map = key_map();
|
||||
println!("key_map: {:?}", key_map);
|
||||
|
||||
println!("chosen config file: {}", config.config_file);
|
||||
|
||||
let key_maps = MacOSKeyMaps::from_cfg(&key_map, &config.config_file);
|
||||
//println!("key_maps: {}", key_maps);
|
||||
|
||||
let mask = CGEventMaskBit(kCGEventKeyDown)
|
||||
| CGEventMaskBit(kCGEventKeyUp)
|
||||
| CGEventMaskBit(kCGEventFlagsChanged)
|
||||
;
|
||||
|
||||
unsafe {
|
||||
let options = 0;
|
||||
|
||||
// Create the event tap
|
||||
let event_tap = CGEventTapCreate(
|
||||
kCGSessionEventTap,
|
||||
kCGHeadInsertEventTap,
|
||||
options,
|
||||
mask,
|
||||
callback,
|
||||
&key_maps,
|
||||
);
|
||||
assert!(!event_tap.is_null(),
|
||||
"Unable to create event tap. Please make sure you have the correct permissions");
|
||||
println!("Created event tap...");
|
||||
|
||||
let allocator = kCFAllocatorDefault;
|
||||
let current_event_loop = CFRunLoopGetCurrent();
|
||||
let mode = kCFRunLoopCommonModes;
|
||||
|
||||
// Create Run Loop Source
|
||||
let run_loop_source = CFMachPortCreateRunLoopSource(allocator, event_tap, 0);
|
||||
|
||||
// Add Run Loop Source to the current event loop
|
||||
CFRunLoopAddSource(current_event_loop, run_loop_source, mode);
|
||||
|
||||
// Enable the tap
|
||||
CGEventTapEnable(event_tap, true);
|
||||
|
||||
CFRunLoopRun();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Config {
|
||||
config_file: String
|
||||
}
|
||||
|
||||
impl Config {
|
||||
fn new(config_file: String) -> Self {
|
||||
Config { config_file: config_file }
|
||||
}
|
||||
}
|
||||
|
||||
fn get_env_push(key: &str, to_push: &str, vec: &mut Vec<String>) {
|
||||
if let Some(var) = env::var_os(key) {
|
||||
if let Ok(str) = var.into_string() {
|
||||
let mut str = str.to_owned();
|
||||
str.push_str(to_push);
|
||||
vec.push(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_args() -> Config {
|
||||
fn print_usage(program: &str, opts: Options) {
|
||||
let brief = format!("Usage: {} [options] [keymap.toml]", program);
|
||||
println!("{}", opts.usage(&brief));
|
||||
}
|
||||
|
||||
let args: Vec<_> = env::args().collect();
|
||||
|
||||
let mut default_configs = Vec::new();
|
||||
get_env_push("USERPROFILE", "\\keymap.toml", &mut default_configs);
|
||||
get_env_push("APPDATA", "\\keymap.toml", &mut default_configs);
|
||||
|
||||
default_configs.push("keymap.toml".to_string());
|
||||
|
||||
let c_msg = format!("specify the keymap config file to use (default in order: {:?})", default_configs);
|
||||
|
||||
let mut opts = Options::new();
|
||||
opts.optflag("h", "help", "prints this help message");
|
||||
opts.optflag("v", "version", "prints the version");
|
||||
opts.optopt("c", "config", &c_msg, "FILE");
|
||||
|
||||
let matches = opts.parse(&args[1..]);
|
||||
if matches.is_err() {
|
||||
print_usage(&args[0], opts);
|
||||
exit(1);
|
||||
}
|
||||
let matches = matches.unwrap();
|
||||
if matches.opt_present("h") {
|
||||
print_usage(&args[0], opts);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if matches.opt_present("v") {
|
||||
println!("rusty-keys {}", VERSION);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
let config_file = matches.opt_str("c").unwrap_or_else(|| {
|
||||
let remaining_args = matches.free;
|
||||
if remaining_args.len() > 0 {
|
||||
remaining_args[0].clone()
|
||||
} else {
|
||||
for keymap in default_configs.drain(..) {
|
||||
if File::open(&keymap).is_ok() {
|
||||
return keymap;
|
||||
}
|
||||
}
|
||||
println!("Error: no keymap.toml found...");
|
||||
print_usage(&args[0], opts);
|
||||
exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
Config::new(config_file)
|
||||
}
|
||||
|
||||
use libc;
|
||||
use core_graphics::event::CGEventType::Null;
|
||||
|
||||
// Opaque Pointer Types
|
||||
pub type Pointer = *mut libc::c_void;
|
||||
pub type CGEventRef = Pointer;
|
||||
pub type CFMachPortRef = Pointer;
|
||||
|
||||
// Integer Types
|
||||
pub type CGEventField = u32;
|
||||
pub type CGEventMask = u64;
|
||||
pub type CGEventTapLocation = u32;
|
||||
pub type CGEventTapOptions = u32;
|
||||
pub type CGEventTapPlacement = u32;
|
||||
pub type CGEventType = u32;
|
||||
pub type CGEventFlags = u64;
|
||||
//pub type CGKeyCode = u16;
|
||||
|
||||
// Callback Type
|
||||
pub type CGEventTapCallBack = extern "C"
|
||||
fn(Pointer, CGEventType, CGEventRef, &mut MacOSKeyMaps) -> CGEventRef;
|
||||
|
||||
// Constants
|
||||
/*
|
||||
pub const kCGEventKeyDown: CGEventType = CGEventType::KeyDown;
|
||||
pub const kCGEventKeyUp: CGEventType = CGEventType::KeyUp;
|
||||
pub const kCGEventFlagsChanged: CGEventType = CGEventType::FlagsChanged;
|
||||
pub const kCGSessionEventTap: CGEventTapLocation = 1;
|
||||
pub const kCGHeadInsertEventTap: CGEventTapPlacement = 0;
|
||||
pub const kCGKeyboardEventKeycode: CGEventField = 9;
|
||||
pub const kCGEventTapDisabledByTimeout: CGEventType = CGEventType::TapDisabledByTimeout;
|
||||
*/
|
||||
pub const kCGEventKeyDown: CGEventType = 10;
|
||||
pub const kCGEventKeyUp: CGEventType = 11;
|
||||
pub const kCGEventFlagsChanged: CGEventType = 12;
|
||||
pub const kCGSessionEventTap: CGEventTapLocation = 1;
|
||||
pub const kCGHeadInsertEventTap: CGEventTapPlacement = 0;
|
||||
pub const kCGKeyboardEventKeycode: CGEventField = 9;
|
||||
pub const kCGEventTapDisabledByTimeout: CGEventType = 0xFFFFFFFE;
|
||||
|
||||
// Link to ApplicationServices/ApplicationServices.h and Carbon/Carbon.h
|
||||
#[link(name = "ApplicationServices", kind = "framework")]
|
||||
#[link(name = "Carbon", kind = "framework")]
|
||||
extern {
|
||||
|
||||
/// Pass through to the default loop modes
|
||||
pub static kCFRunLoopCommonModes: Pointer;
|
||||
|
||||
/// Pass through to the default allocator
|
||||
pub static kCFAllocatorDefault: Pointer;
|
||||
|
||||
/// Run the current threads loop in default mode
|
||||
pub fn CFRunLoopRun();
|
||||
|
||||
/// Obtain the current threads loop
|
||||
pub fn CFRunLoopGetCurrent() -> Pointer;
|
||||
|
||||
/// Get the code of the event back, e.g. the key code
|
||||
pub fn CGEventGetIntegerValueField(
|
||||
event: CGEventRef,
|
||||
field: CGEventField,
|
||||
) -> CGKeyCode;
|
||||
|
||||
fn CGEventSetIntegerValueField(event: CGEventRef, field: CGEventField, value: i64);
|
||||
|
||||
/// Create an event tap
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `place` - The location of the new event tap. Pass one of
|
||||
/// the constants listed in Event Tap Locations. Only
|
||||
/// processes running as the root user may locate an
|
||||
/// event tap at the point where HID events enter the
|
||||
/// window server; for other users, this function
|
||||
/// returns NULL.
|
||||
///
|
||||
/// * `options` - The placement of the new event tap in the
|
||||
/// list of active event taps. Pass one of the
|
||||
/// constants listed in Event Tap Placement.
|
||||
///
|
||||
/// * `eventsOfInterest` - A constant that specifies whether
|
||||
/// the new event tap is a passive listener or an
|
||||
/// active filter.
|
||||
///
|
||||
/// * `callback` - A bit mask that specifies the set of events
|
||||
/// to be observed. For a list of possible events,
|
||||
/// see Event Types. For information on how to
|
||||
/// specify the mask, see CGEventMask. If the event
|
||||
/// tap is not permitted to monitor one or more of
|
||||
/// the events specified in the eventsOfInterest
|
||||
/// parameter, then the appropriate bits in the mask
|
||||
/// are cleared. If that action results in an empty
|
||||
/// mask, this function returns NULL. callback
|
||||
///
|
||||
/// * `refcon` - An event tap callback function that you
|
||||
/// provide. Your callback function is invoked from
|
||||
/// the run loop to which the event tap is added as a
|
||||
/// source. The thread safety of the callback is
|
||||
/// defined by the run loop’s environment. To learn
|
||||
/// more about event tap callbacks, see
|
||||
/// CGEventTapCallBack. refcon
|
||||
///
|
||||
/// * `channel` - A pointer to user-defined data. This pointer
|
||||
/// is passed into the callback function specified in
|
||||
/// the callback parameter. Here we use it as a mpsc
|
||||
/// channel.
|
||||
pub fn CGEventTapCreate(
|
||||
tap: CGEventTapLocation,
|
||||
place: CGEventTapPlacement,
|
||||
options: CGEventTapOptions,
|
||||
eventsOfInterest: CGEventMask,
|
||||
callback: CGEventTapCallBack,
|
||||
channel: &MacOSKeyMaps,
|
||||
) -> CFMachPortRef;
|
||||
|
||||
/// Creates a CFRunLoopSource object for a CFMachPort
|
||||
/// object.
|
||||
///
|
||||
/// The run loop source is not automatically added to
|
||||
/// a run loop. To add the source to a run loop, use
|
||||
/// CFRunLoopAddSource
|
||||
pub fn CFMachPortCreateRunLoopSource(
|
||||
allocator: Pointer,
|
||||
port: CFMachPortRef,
|
||||
order: libc::c_int,
|
||||
) -> Pointer;
|
||||
|
||||
/// Adds a CFRunLoopSource object to a run loop mode.
|
||||
pub fn CFRunLoopAddSource(
|
||||
run_loop: Pointer,
|
||||
run_loop_source: Pointer,
|
||||
mode: Pointer,
|
||||
);
|
||||
|
||||
pub fn CGEventTapEnable(port: CFMachPortRef, enable: bool);
|
||||
|
||||
pub fn CGEventGetType(event: CGEventRef) -> CGEventType;
|
||||
pub fn CGEventGetFlags(event: CGEventRef) -> CGEventFlags;
|
||||
pub fn CGEventSetFlags(event: CGEventRef, flags: CGEventFlags);
|
||||
}
|
||||
|
||||
const CGEventFlagNull: u64 = 0;
|
||||
|
||||
// Device-independent modifier key bits.
|
||||
const CGEventFlagAlphaShift: u64 = 0x00010000;
|
||||
const CGEventFlagShift: u64 = 0x00020000;
|
||||
const CGEventFlagControl: u64 = 0x00040000;
|
||||
const CGEventFlagAlternate: u64 = 0x00080000;
|
||||
const CGEventFlagCommand: u64 = 0x00100000;
|
||||
|
||||
// Special key identifiers.
|
||||
const CGEventFlagHelp: u64 = 0x00400000;
|
||||
const CGEventFlagSecondaryFn: u64 = 0x00800000;
|
||||
|
||||
// Identifies key events from numeric keypad area on extended keyboards.
|
||||
const CGEventFlagNumericPad: u64 = 0x00200000;
|
||||
|
||||
// Indicates if mouse/pen movement events are not being coalesced
|
||||
const CGEventFlagNonCoalesced: u64 = 0x00000100;
|
||||
|
||||
const NX_DEVICELCTLKEYMASK: u64 = 0x00000001;
|
||||
const NX_DEVICELSHIFTKEYMASK: u64 = 0x00000002;
|
||||
const NX_DEVICERSHIFTKEYMASK: u64 = 0x00000004;
|
||||
const NX_DEVICELCMDKEYMASK: u64 = 0x00000008;
|
||||
const NX_DEVICERCMDKEYMASK: u64 = 0x00000010;
|
||||
const NX_DEVICELALTKEYMASK: u64 = 0x00000020;
|
||||
const NX_DEVICERALTKEYMASK: u64 = 0x00000040;
|
||||
const NX_DEVICERCTLKEYMASK: u64 = 0x00002000;
|
||||
|
||||
fn print_flags(flags: CGEventFlags) {
|
||||
println!("flags: {}", flags);
|
||||
println!("flags: {:#064b}", flags);
|
||||
|
||||
println!("EventFlags: {:x} ({} {} {} {} {} {} {} {})\n",
|
||||
flags,
|
||||
if (flags & NX_DEVICELCTLKEYMASK) != 0 { "lcontrol" } else { "" },
|
||||
if (flags & NX_DEVICERCTLKEYMASK) != 0 { "rcontrol" } else { "" },
|
||||
if (flags & NX_DEVICELSHIFTKEYMASK) != 0 { "lshift" } else { "" },
|
||||
if (flags & NX_DEVICERSHIFTKEYMASK) != 0 { "rshift" } else { "" },
|
||||
if (flags & NX_DEVICELCMDKEYMASK) != 0 { "lcommand" } else { "" },
|
||||
if (flags & NX_DEVICERCMDKEYMASK) != 0 { "rcommand" } else { "" },
|
||||
if (flags & NX_DEVICELALTKEYMASK) != 0 { "lalt" } else { "" },
|
||||
if (flags & NX_DEVICERALTKEYMASK) != 0 { "ralt" } else { "" },
|
||||
);
|
||||
}
|
||||
|
||||
/// This callback will be registered to be invoked from the run loop
|
||||
/// to which the event tap is added as a source.
|
||||
#[no_mangle]
|
||||
#[allow(unused_variables)]
|
||||
pub extern fn callback(proxy: Pointer, event_type: CGEventType, event: CGEventRef, key_maps: &mut MacOSKeyMaps)
|
||||
-> CGEventRef {
|
||||
//print_flags(event);
|
||||
/*
|
||||
println!("+++++++++++++++++++++++++++++++++++++++");
|
||||
let event_type2 = unsafe { CGEventGetType(event) };
|
||||
println!("event_type2: {}", event_type2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
match event_type {
|
||||
kCGEventKeyDown => println!("key down"),
|
||||
kCGEventKeyUp => println!("key up"),
|
||||
kCGEventFlagsChanged => println!("flags changed"),
|
||||
kCGEventTapDisabledByTimeout => {
|
||||
println!("Quartz event tap disabled because of timeout; attempting to reregister.");
|
||||
//register_listener(channel);
|
||||
//return event;
|
||||
},
|
||||
_ => {
|
||||
println!("Received unknown EventType: {}", event_type as u32);
|
||||
//return event;
|
||||
},
|
||||
};
|
||||
*/
|
||||
|
||||
unsafe {
|
||||
let mut input_event = InputEvent {
|
||||
event_type,
|
||||
event,
|
||||
};
|
||||
println!("got keyCode: {}", input_event.code());
|
||||
/*
|
||||
println!("---------------------------------------");
|
||||
if input_event.value() == KeyState::DOWN {
|
||||
let code = input_event.code();
|
||||
println!("KEY 0x{:04X}", code);
|
||||
write_key_file(code).expect("error writing key file");
|
||||
}
|
||||
std::ptr::null_mut()
|
||||
*/
|
||||
|
||||
|
||||
//input_event.event.set
|
||||
//input_event.event
|
||||
//Null.
|
||||
//Some(input_event.event)
|
||||
key_maps.send_event(&mut input_event, &DEVICE).expect("macos shouldn't error...")
|
||||
.unwrap_or_else(|| {
|
||||
println!("returning NULL from hook");
|
||||
std::ptr::null_mut()
|
||||
}) // None means return NULL
|
||||
//let keyCode = CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
|
||||
//println!("got keyCode: {}", keyCode);
|
||||
/*
|
||||
let event = KeyEvent {
|
||||
etype: match etype as u32 {
|
||||
kCGEventKeyDown => EventType::KeyDown,
|
||||
kCGEventKeyUp => EventType::KeyUp,
|
||||
kCGEventFlagsChanged => EventType::FlagsChanged,
|
||||
kCGEventTapDisabledByTimeout => {
|
||||
warn!("Quartz event tap disabled because of timeout; attempting to reregister.");
|
||||
register_listener(channel);
|
||||
return event;
|
||||
},
|
||||
_ => {
|
||||
error!("Received unknown EventType: {:}", etype);
|
||||
return event;
|
||||
},
|
||||
},
|
||||
code: keyCode,
|
||||
};
|
||||
println!("Received event: {:?}", event);
|
||||
let _ = channel.send(event);
|
||||
*/
|
||||
}
|
||||
//event
|
||||
}
|
||||
|
||||
fn write_key_file(code: CGKeyCode) -> std::io::Result<()> {
|
||||
let mut buffer = File::create("/Users/mopar/key.txt")?;
|
||||
write!(buffer, "0x{:04X}", code)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Redefine macro for bitshifting from header as function here
|
||||
pub fn CGEventMaskBit(eventType: u32) -> CGEventMask {
|
||||
1 << (eventType)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
fn main() {
|
||||
let ret = rusty_keys::main_res();
|
||||
if let Err(e) = ret {
|
||||
@ -7,7 +7,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
|
||||
#[cfg(not(any(target_os = "windows", target_os = "linux", target_os = "macos")))]
|
||||
fn main() {
|
||||
panic!("sorry no main impl for this platform");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user