aboutsummaryrefslogtreecommitdiffstats
path: root/src/cocoa_bridge.rs
diff options
context:
space:
mode:
authorTeddy Wing2018-09-29 01:19:45 +0200
committerTeddy Wing2018-09-29 01:19:45 +0200
commita6f5f275e781bfa443e69b74a6c776eb6d970ded (patch)
tree828a13eb704c85f54bf104075bb166e3d79a35e1 /src/cocoa_bridge.rs
parent16cd3895f7b111544927d71904aab912d9abbf59 (diff)
downloaddome-key-map-a6f5f275e781bfa443e69b74a6c776eb6d970ded.tar.bz2
Revert "Try to propagate KeyCodeConvertible from Action to everywhere"
This reverts commit 16cd3895f7b111544927d71904aab912d9abbf59. See that commit message for details.
Diffstat (limited to 'src/cocoa_bridge.rs')
-rw-r--r--src/cocoa_bridge.rs30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs
index a4a072f..8718e58 100644
--- a/src/cocoa_bridge.rs
+++ b/src/cocoa_bridge.rs
@@ -4,7 +4,7 @@ use std::mem;
use std::ptr;
use std::slice;
-use autopilot::key::{KeyCodeConvertible, type_string};
+use autopilot::key::type_string;
// use cocoa::base::nil;
// use cocoa::foundation::{NSArray, NSAutoreleasePool, NSDictionary};
use libc::{c_char, size_t};
@@ -97,10 +97,9 @@ pub struct CKeyActionResult {
}
#[derive(Default)]
-pub struct State<K: KeyCodeConvertible>
-where K: Default {
+pub struct State {
in_mode: Option<Vec<HeadphoneButton>>,
- map_group: Option<MapGroup<K>>,
+ map_group: Option<MapGroup>,
}
#[no_mangle]
@@ -114,21 +113,18 @@ pub extern "C" fn logger_init() {
}
#[no_mangle]
-pub extern "C" fn state_new<K>() -> *mut State<K>
-where K: KeyCodeConvertible {
+pub extern "C" fn state_new() -> *mut State {
Box::into_raw(Box::new(State::default()))
}
#[no_mangle]
-pub extern "C" fn state_free<K>(ptr: *mut State<K>)
-where K: KeyCodeConvertible {
+pub extern "C" fn state_free(ptr: *mut State) {
if ptr.is_null() { return }
unsafe { Box::from_raw(ptr); }
}
#[no_mangle]
-pub extern "C" fn state_load_map_group<K>(ptr: *mut State<K>)
-where K: KeyCodeConvertible {
+pub extern "C" fn state_load_map_group(ptr: *mut State) {
match xdg::BaseDirectories::with_prefix("dome-key") {
Ok(xdg_dirs) => {
match xdg_dirs.find_config_file("mappings.dkmap") {
@@ -166,12 +162,11 @@ where K: KeyCodeConvertible {
}
#[no_mangle]
-pub extern "C" fn c_run_key_action<K>(
- state: *mut State<K>,
+pub extern "C" fn c_run_key_action(
+ state: *mut State,
trigger: Trigger,
mode: *const Trigger,
-) -> *const CKeyActionResult
-where K: KeyCodeConvertible {
+) -> *const CKeyActionResult {
let trigger = unsafe {
assert!(!trigger.buttons.is_null());
@@ -263,12 +258,11 @@ where K: KeyCodeConvertible {
}
#[no_mangle]
-pub extern "C" fn run_key_action_for_mode<'a, K>(
- state: &mut State<K>,
+pub extern "C" fn run_key_action_for_mode<'a>(
+ state: &mut State,
trigger: &'a [HeadphoneButton],
in_mode: Option<&[HeadphoneButton]>
-) -> Option<KeyActionResult<'a>>
-where K: KeyCodeConvertible {
+) -> Option<KeyActionResult<'a>> {
let sample_maps = "map <up> k
map <down> j
map <play><down> works!