Skip to content

Commit

Permalink
release v0.1.1 fix multiple devices bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yqrashawn committed Sep 8, 2018
1 parent 8e14550 commit 117aedb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ deploy:
api_key:
secure: 3xIPPkDWvHaD7Fnc/g/mmPoYb4pxcS+iZ5PtcH421Sulfuk5b8+dG64uZ+YfKpyUTuGgvnI2Fe70Ne1kku/+AJuljBBCivqb8LED4cO4+5eJYQa95YUyhtIWpxdykdexYCzLa7AFWGx1UsFvk+XU5O7WKLJxNvPKmaJ9bcWrnhm4XH94u5qICQqav4PAoSoWqRF2gK/hBqQSNDW7Voz5VS1YQUEmxoX0OoSHQGaDn0juxJzprFi/W/0aapEOPSd+G7OQ6D34ShRVQ6DBxI8t+1urm3prz0kNqum/5u+KFKXKfBkH17MmWiQIn0cQsNS/UV6T2j61XHjA3+g5HRX4Jwm7mBV3UMDASaeNvMdb3i/3zLosX74jgVDjRrm0P10U7N3UTOORmMrRI3YzOjPWluQFabGU0yplOnQ36Gw3K/++VTPmBXdY3UukATOsZ7ymO6KTAIOleOQlsqVr1sB6IrDViuCzVGpYEXNk5FaM0B13T1svY3ObANxlPITDSKgtv+cmbbzV6WHKYfBetpQV2h3Ske5LADAF4hswaNiRH7njE3ARoEBqz8nZ7pBM9gtAbzxABXyPmTjVYMZn6KekZcvqCyPHHxe0j/PzxLLbkOcFfY3Il6iNLSAAMZj+yszT4Fh/ibM3UQmDoy8zQCcfIWTF5ACXWzCw9cjn6/0Sc+M=
file: goku
skip_cleanup: true
on:
tags: true
repo: yqrashawn/GokuRakuJoudo
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. This change
- ~:mission_control~ to normal key
*** Fixed
- karabiner error while using ~:mission_control~
- multiple devices condition bug

** 0.1.0 - 2018-09-07
*** Added
Expand Down
6 changes: 3 additions & 3 deletions src/karabiner_configurator/conditions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"device_if")
result (if (and (keyword? condi) (nn? (condi (:devices conf-data))))
{:identifiers
(condi (:devices conf-data))
(into [] (condi (:devices conf-data)))
:type condi-type}
result)
condi-type (if condi!?
Expand All @@ -58,8 +58,8 @@
(do
(update-used-simlayers-config (condi (:simlayers conf-data)))
(update-used-simlayers-config (assoc-in used-simlayers-config [:from :sim]
(conj (:sim (:from used-simlayers-config))
(keyword (:key_code from)))))))
(conj (:sim (:from used-simlayers-config))
(keyword (:key_code from)))))))
{:name (name condi)
:value 1
:type condi-type})
Expand Down
23 changes: 20 additions & 3 deletions src/karabiner_configurator/rules.clj
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,30 @@
:else result)]
result))

(defn merge-multiple-device-conditions
[vec]
(update-conf-data (assoc conf-data :devices (dissoc (:devices conf-data) :temp-device)))
(let [devices-list (for [item vec
:when (and (keyword? item) (devices? item))
:let [this-device-vec (item (:devices conf-data))
temp-device-vec (if (devices? :temp-device)
(into [] (concat (:temp-device (:devices conf-data)) this-device-vec))
this-device-vec)
update-temp-device-into-conf-data (update-conf-data (assoc-in conf-data [:devices :temp-device] temp-device-vec))]]
item)
use-temp-device? (> (count devices-list) 0)
new-conditions (if use-temp-device? (conj (into [] (reduce #(remove #{%2} %1) vec devices-list)) :temp-device)
vec)]
new-conditions))

;; conditions
;; :vi-mode or [:vi-mode]
(defn conditions-key
[des conditions prev-result]
(if (conditions/is-simple-set-variable? conditions)
{:conditions (conditions/parse-conditions [conditions] (:from prev-result) (:to prev-result))}
{:conditions (conditions/parse-conditions conditions (:from prev-result) (:to prev-result))}))
(let [conditions (merge-multiple-device-conditions conditions)]
(if (conditions/is-simple-set-variable? conditions)
{:conditions (conditions/parse-conditions [conditions] (:from prev-result) (:to prev-result))}
{:conditions (conditions/parse-conditions conditions (:from prev-result) (:to prev-result))})))

;; to_if_alone | :alone
;; to_if_held_down | :held
Expand Down
9 changes: 5 additions & 4 deletions test/karabiner_configurator/rules_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[karabiner-configurator.data :refer :all]
[clojure.test :as t]))

(def example-mains [{:des "a to 1" :rules [[:a :1]]} ;; a to 1
(def example-mains [
{:des "a to 1" :rules [[:a :1]]} ;; a to 1
{:des "command a to control 1" :rules [[:!C#Pa :!T1]]} ;; command a to control 1
{:des "my spacebar to control 1" :rules [[:my-spacebar :!T1]]} ;; my-spacebar to control 1
{:des "press b to insert 12" :rules [[:b [:1 :2]]]} ;; key to key
Expand All @@ -12,7 +13,7 @@
{:des "simultaneous e f to 3" :rules [[[:e :f] :3]]} ;; simultaneous key to key
{:des "g to 4 when variable vi-mode is 1" :rules [[:g :4 :vi-mode]]} ;; vi-mode is 1
{:des "h to 5 when variable vi-mode is not 1" :rules [[:h :5 :!vi-mode]]} ;; vi-mode is not 1
{:des "i to 6 only for device hhkb-bt" :rules [[:i :6 :hhkb-bt]]} ;; key to key in layer b (in layer a) specific to hhkb-bt device
{:des "i to 6 only for device hhkb-bt" :rules [[:i :6 [:hhkb-bt :hhkb]]]} ;; key to key in layer b (in layer a) specific to hhkb-bt device
{:des "j to 7 on hhkb-bt when variable vi-mode is 1" :rules [[:j :7 [:vi-mode :hhkb-bt]]]} ;; multiple condition
{:des "press h insert 8 then set variable some-mode to 0" :rules [[:h [:8 {:set ["some-mode" 0]}]]]}
{:des "capslock to control as modifier to escape when press alone" :rules [[:##caps_lock :left_control nil {:alone :escape}]]}
Expand Down Expand Up @@ -92,8 +93,8 @@
{:description "i to 6 only for device hhkb-bt",
:manipulators [{:from {:key_code "i"},
:to [{:key_code "6"}],
:conditions [{:identifiers [{:vendor_id 1278,
:product_id 51966}],
:conditions [{:identifiers [{:vendor_id 1278 :product_id 51966}
{:vendor_id 2131 :product_id 256}],
:type "device_if"}],
:type "basic"}]}
{:description "j to 7 on hhkb-bt when variable vi-mode is 1",
Expand Down

0 comments on commit 117aedb

Please sign in to comment.