aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
authorTeddy Wing2018-10-18 01:18:20 +0200
committerTeddy Wing2018-10-18 01:18:20 +0200
commit6bf82d2e5f1a7721cee670f244ef838ef6275cbe (patch)
treec57163b43782311fdc579a7f08f1961c6b1b055a /src/parser.rs
parente5dae0bc586092acbd05ba70e514c62c461fcb1a (diff)
downloaddome-key-map-6bf82d2e5f1a7721cee670f244ef838ef6275cbe.tar.bz2
Add `NXKey` to `KeyboardKeyWithModifiers`
Add this new key type to the enum and enable it to be `tap()`ped like the others. Made `NXKey` a type alias instead of a struct to allow us to refer to any of the NX key constants using the `NXKey` type. This also meant moving those NX constants outside of the `NXKey` impl and into the top level. May end up wrapping them back up in some kind of namespace later. Adjusted the public-ness of some functions to support this change.
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 3b5a8e4..95cca4d 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -15,6 +15,9 @@ use combine::parser::char::{
use combine::parser::repeat::take_until;
use combine::stream::state::{SourcePosition, State};
+use autopilot_internal::cg_event_mask_for_flags;
+use key_code::{NXKey, dkess_press_key};
+
#[repr(C)]
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub enum HeadphoneButton {
@@ -68,6 +71,7 @@ impl KeyCode {
pub enum KeyboardKey {
Character(Character),
KeyCode(KeyCode),
+ NXKey(NXKey),
}
#[derive(Debug, PartialEq)]
@@ -92,6 +96,17 @@ impl KeyboardKeyWithModifiers {
KeyboardKey::KeyCode(ref k) => {
autopilot::key::tap(k.0, &self.flags, 0)
},
+ KeyboardKey::NXKey(nx) => {
+ // let flags = self.flags.iter().fold(
+ // CGEventFlags::CGEventFlagNull,
+ // |acc, f| acc | cg_event_flags_from_flag(f)
+ // );
+ let flags = cg_event_mask_for_flags(&self.flags);
+
+ unsafe {
+ dkess_press_key(nx, flags);
+ }
+ },
}
}
}