Skip to content

Commit 117aedb

Browse files
committed
release v0.1.1 fix multiple devices bug
1 parent 8e14550 commit 117aedb

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ deploy:
55
api_key:
66
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=
77
file: goku
8+
skip_cleanup: true
89
on:
910
tags: true
1011
repo: yqrashawn/GokuRakuJoudo

CHANGELOG.org

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. This change
88
- ~:mission_control~ to normal key
99
*** Fixed
1010
- karabiner error while using ~:mission_control~
11+
- multiple devices condition bug
1112

1213
** 0.1.0 - 2018-09-07
1314
*** Added

src/karabiner_configurator/conditions.clj

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"device_if")
3939
result (if (and (keyword? condi) (nn? (condi (:devices conf-data))))
4040
{:identifiers
41-
(condi (:devices conf-data))
41+
(into [] (condi (:devices conf-data)))
4242
:type condi-type}
4343
result)
4444
condi-type (if condi!?
@@ -58,8 +58,8 @@
5858
(do
5959
(update-used-simlayers-config (condi (:simlayers conf-data)))
6060
(update-used-simlayers-config (assoc-in used-simlayers-config [:from :sim]
61-
(conj (:sim (:from used-simlayers-config))
62-
(keyword (:key_code from)))))))
61+
(conj (:sim (:from used-simlayers-config))
62+
(keyword (:key_code from)))))))
6363
{:name (name condi)
6464
:value 1
6565
:type condi-type})

src/karabiner_configurator/rules.clj

+20-3
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,30 @@
138138
:else result)]
139139
result))
140140

141+
(defn merge-multiple-device-conditions
142+
[vec]
143+
(update-conf-data (assoc conf-data :devices (dissoc (:devices conf-data) :temp-device)))
144+
(let [devices-list (for [item vec
145+
:when (and (keyword? item) (devices? item))
146+
:let [this-device-vec (item (:devices conf-data))
147+
temp-device-vec (if (devices? :temp-device)
148+
(into [] (concat (:temp-device (:devices conf-data)) this-device-vec))
149+
this-device-vec)
150+
update-temp-device-into-conf-data (update-conf-data (assoc-in conf-data [:devices :temp-device] temp-device-vec))]]
151+
item)
152+
use-temp-device? (> (count devices-list) 0)
153+
new-conditions (if use-temp-device? (conj (into [] (reduce #(remove #{%2} %1) vec devices-list)) :temp-device)
154+
vec)]
155+
new-conditions))
156+
141157
;; conditions
142158
;; :vi-mode or [:vi-mode]
143159
(defn conditions-key
144160
[des conditions prev-result]
145-
(if (conditions/is-simple-set-variable? conditions)
146-
{:conditions (conditions/parse-conditions [conditions] (:from prev-result) (:to prev-result))}
147-
{:conditions (conditions/parse-conditions conditions (:from prev-result) (:to prev-result))}))
161+
(let [conditions (merge-multiple-device-conditions conditions)]
162+
(if (conditions/is-simple-set-variable? conditions)
163+
{:conditions (conditions/parse-conditions [conditions] (:from prev-result) (:to prev-result))}
164+
{:conditions (conditions/parse-conditions conditions (:from prev-result) (:to prev-result))})))
148165

149166
;; to_if_alone | :alone
150167
;; to_if_held_down | :held

test/karabiner_configurator/rules_test.clj

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
[karabiner-configurator.data :refer :all]
44
[clojure.test :as t]))
55

6-
(def example-mains [{:des "a to 1" :rules [[:a :1]]} ;; a to 1
6+
(def example-mains [
7+
{:des "a to 1" :rules [[:a :1]]} ;; a to 1
78
{:des "command a to control 1" :rules [[:!C#Pa :!T1]]} ;; command a to control 1
89
{:des "my spacebar to control 1" :rules [[:my-spacebar :!T1]]} ;; my-spacebar to control 1
910
{:des "press b to insert 12" :rules [[:b [:1 :2]]]} ;; key to key
@@ -12,7 +13,7 @@
1213
{:des "simultaneous e f to 3" :rules [[[:e :f] :3]]} ;; simultaneous key to key
1314
{:des "g to 4 when variable vi-mode is 1" :rules [[:g :4 :vi-mode]]} ;; vi-mode is 1
1415
{:des "h to 5 when variable vi-mode is not 1" :rules [[:h :5 :!vi-mode]]} ;; vi-mode is not 1
15-
{: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
16+
{: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
1617
{:des "j to 7 on hhkb-bt when variable vi-mode is 1" :rules [[:j :7 [:vi-mode :hhkb-bt]]]} ;; multiple condition
1718
{:des "press h insert 8 then set variable some-mode to 0" :rules [[:h [:8 {:set ["some-mode" 0]}]]]}
1819
{:des "capslock to control as modifier to escape when press alone" :rules [[:##caps_lock :left_control nil {:alone :escape}]]}
@@ -92,8 +93,8 @@
9293
{:description "i to 6 only for device hhkb-bt",
9394
:manipulators [{:from {:key_code "i"},
9495
:to [{:key_code "6"}],
95-
:conditions [{:identifiers [{:vendor_id 1278,
96-
:product_id 51966}],
96+
:conditions [{:identifiers [{:vendor_id 1278 :product_id 51966}
97+
{:vendor_id 2131 :product_id 256}],
9798
:type "device_if"}],
9899
:type "basic"}]}
99100
{:description "j to 7 on hhkb-bt when variable vi-mode is 1",

0 commit comments

Comments
 (0)