rf_rgb 0.8.5 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -4
- data/examples/lock_keys_all.rb +121 -0
- data/examples/mpd_keyboard.rb +8 -0
- data/examples/set_actuation_heights_all.rb +119 -0
- data/lib/rf_rgb.rb +2 -0
- data/lib/rf_rgb/keyboard.rb +68 -19
- data/lib/rf_rgb/protocol.rb +36 -1
- data/lib/rf_rgb/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de3bca0c1dcc7586fdd67e8b54377fed9fb8c63
|
4
|
+
data.tar.gz: c72977403f7fd253030b96f570b094c6dbd6042a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e00beabab63e5b13041e7f6e70d9e5d76d1096703f2ea98def0b6ee8e585d369665a370a8bc55e2f266fc0edaf08dfe9b0bd2ef064425d0cf7c6e8fc7a0fcb9
|
7
|
+
data.tar.gz: d306229e143d44e97dded2de0e73213a51cd6dbd919e92b07d692abb7f0a0baeb9726ec9e81f75e9cced3e5ddd2f1dc257c302a4495e77f3b5fbf32fe0dd20f1
|
data/README.md
CHANGED
@@ -85,10 +85,6 @@ and prevent `usbhid` from taking the device over. If you're in that boat, try th
|
|
85
85
|
|
86
86
|
## Protocol Notes
|
87
87
|
|
88
|
-
When commands are sent from the host to the OUT endpoint, there is a response that can
|
89
|
-
be read from IN endpoint #3, but this module ignores these responses completely at
|
90
|
-
time of writing.
|
91
|
-
|
92
88
|
Some effects have a User 1-3 setting in the Windows UI. It's not clear what these
|
93
89
|
are actually for, and are mostly ignored in this module for now.
|
94
90
|
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'rf_rgb'
|
2
|
+
|
3
|
+
# Valid values are true and false.
|
4
|
+
# This hash can also accept a :default key, a la colors
|
5
|
+
keys = {
|
6
|
+
a: true,
|
7
|
+
actuation: true,
|
8
|
+
apostrophe: true,
|
9
|
+
b: true,
|
10
|
+
backslash: true,
|
11
|
+
backspace: true,
|
12
|
+
c: true,
|
13
|
+
capslock: true,
|
14
|
+
comma: true,
|
15
|
+
d: true,
|
16
|
+
del: true,
|
17
|
+
down: true,
|
18
|
+
e: true,
|
19
|
+
eight: true,
|
20
|
+
end: true,
|
21
|
+
enter: true,
|
22
|
+
equals: true,
|
23
|
+
esc: true,
|
24
|
+
f: true,
|
25
|
+
f1: true,
|
26
|
+
f10: true,
|
27
|
+
f11: true,
|
28
|
+
f12: true,
|
29
|
+
f2: true,
|
30
|
+
f3: true,
|
31
|
+
f4: true,
|
32
|
+
f5: true,
|
33
|
+
f6: true,
|
34
|
+
f7: true,
|
35
|
+
f8: true,
|
36
|
+
f9: true,
|
37
|
+
five: true,
|
38
|
+
fn: true,
|
39
|
+
four: true,
|
40
|
+
g: true,
|
41
|
+
grave: true,
|
42
|
+
h: true,
|
43
|
+
home: true,
|
44
|
+
hyphen: true,
|
45
|
+
i: true,
|
46
|
+
ins: true,
|
47
|
+
j: true,
|
48
|
+
k: true,
|
49
|
+
l: true,
|
50
|
+
lalt: true,
|
51
|
+
lbracket: true,
|
52
|
+
lctrl: true,
|
53
|
+
left: true,
|
54
|
+
lshift: true,
|
55
|
+
lwin: true,
|
56
|
+
m: true,
|
57
|
+
mute: true,
|
58
|
+
n: true,
|
59
|
+
nine: true,
|
60
|
+
np_div: true,
|
61
|
+
np_dot: true,
|
62
|
+
np_eight: true,
|
63
|
+
np_enter: true,
|
64
|
+
np_five: true,
|
65
|
+
np_four: true,
|
66
|
+
np_minus: true,
|
67
|
+
np_mult: true,
|
68
|
+
np_nine: true,
|
69
|
+
np_one: true,
|
70
|
+
np_plus: true,
|
71
|
+
np_seven: true,
|
72
|
+
np_six: true,
|
73
|
+
np_three: true,
|
74
|
+
np_two: true,
|
75
|
+
np_zero: true,
|
76
|
+
numlk: true,
|
77
|
+
o: true,
|
78
|
+
one: true,
|
79
|
+
p: true,
|
80
|
+
pause: true,
|
81
|
+
period: true,
|
82
|
+
pgdn: true,
|
83
|
+
pgup: true,
|
84
|
+
prtsc: true,
|
85
|
+
q: true,
|
86
|
+
r: true,
|
87
|
+
ralt: true,
|
88
|
+
rbracket: true,
|
89
|
+
rctrl: true,
|
90
|
+
right: true,
|
91
|
+
rshift: true,
|
92
|
+
rwin: true,
|
93
|
+
s: true,
|
94
|
+
scrlk: true,
|
95
|
+
semicolon: true,
|
96
|
+
seven: true,
|
97
|
+
six: true,
|
98
|
+
slash: true,
|
99
|
+
space: true,
|
100
|
+
t: true,
|
101
|
+
tab: true,
|
102
|
+
three: true,
|
103
|
+
two: true,
|
104
|
+
u: true,
|
105
|
+
up: true,
|
106
|
+
v: true,
|
107
|
+
voldown: true,
|
108
|
+
volup: true,
|
109
|
+
w: true,
|
110
|
+
x: true,
|
111
|
+
y: true,
|
112
|
+
z: true,
|
113
|
+
zero: true
|
114
|
+
}
|
115
|
+
|
116
|
+
RfRgb::Keyboard.run_and_release do |keyboard|
|
117
|
+
keyboard.locked_keys = keys
|
118
|
+
# keyboard.lock_keys
|
119
|
+
# keyboard.unlock_keys
|
120
|
+
keyboard.save
|
121
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'rf_rgb'
|
2
|
+
|
3
|
+
# Valid values are 15, 22, and 30.
|
4
|
+
# This hash can also accept a :default key, a la colors
|
5
|
+
heights = {
|
6
|
+
a: 30,
|
7
|
+
actuation: 30,
|
8
|
+
apostrophe: 30,
|
9
|
+
b: 30,
|
10
|
+
backslash: 30,
|
11
|
+
backspace: 30,
|
12
|
+
c: 30,
|
13
|
+
capslock: 30,
|
14
|
+
comma: 30,
|
15
|
+
d: 30,
|
16
|
+
del: 30,
|
17
|
+
down: 30,
|
18
|
+
e: 30,
|
19
|
+
eight: 30,
|
20
|
+
end: 30,
|
21
|
+
enter: 30,
|
22
|
+
equals: 30,
|
23
|
+
esc: 30,
|
24
|
+
f: 30,
|
25
|
+
f1: 30,
|
26
|
+
f10: 30,
|
27
|
+
f11: 30,
|
28
|
+
f12: 30,
|
29
|
+
f2: 30,
|
30
|
+
f3: 30,
|
31
|
+
f4: 30,
|
32
|
+
f5: 30,
|
33
|
+
f6: 30,
|
34
|
+
f7: 30,
|
35
|
+
f8: 30,
|
36
|
+
f9: 30,
|
37
|
+
five: 30,
|
38
|
+
fn: 30,
|
39
|
+
four: 30,
|
40
|
+
g: 30,
|
41
|
+
grave: 30,
|
42
|
+
h: 30,
|
43
|
+
home: 30,
|
44
|
+
hyphen: 30,
|
45
|
+
i: 30,
|
46
|
+
ins: 30,
|
47
|
+
j: 30,
|
48
|
+
k: 30,
|
49
|
+
l: 30,
|
50
|
+
lalt: 30,
|
51
|
+
lbracket: 30,
|
52
|
+
lctrl: 30,
|
53
|
+
left: 30,
|
54
|
+
lshift: 30,
|
55
|
+
lwin: 30,
|
56
|
+
m: 30,
|
57
|
+
mute: 30,
|
58
|
+
n: 30,
|
59
|
+
nine: 30,
|
60
|
+
np_div: 30,
|
61
|
+
np_dot: 30,
|
62
|
+
np_eight: 30,
|
63
|
+
np_enter: 30,
|
64
|
+
np_five: 30,
|
65
|
+
np_four: 30,
|
66
|
+
np_minus: 30,
|
67
|
+
np_mult: 30,
|
68
|
+
np_nine: 30,
|
69
|
+
np_one: 30,
|
70
|
+
np_plus: 30,
|
71
|
+
np_seven: 30,
|
72
|
+
np_six: 30,
|
73
|
+
np_three: 30,
|
74
|
+
np_two: 30,
|
75
|
+
np_zero: 30,
|
76
|
+
numlk: 30,
|
77
|
+
o: 30,
|
78
|
+
one: 30,
|
79
|
+
p: 30,
|
80
|
+
pause: 30,
|
81
|
+
period: 30,
|
82
|
+
pgdn: 30,
|
83
|
+
pgup: 30,
|
84
|
+
prtsc: 30,
|
85
|
+
q: 30,
|
86
|
+
r: 30,
|
87
|
+
ralt: 30,
|
88
|
+
rbracket: 30,
|
89
|
+
rctrl: 30,
|
90
|
+
right: 30,
|
91
|
+
rshift: 30,
|
92
|
+
rwin: 30,
|
93
|
+
s: 30,
|
94
|
+
scrlk: 30,
|
95
|
+
semicolon: 30,
|
96
|
+
seven: 30,
|
97
|
+
six: 30,
|
98
|
+
slash: 30,
|
99
|
+
space: 30,
|
100
|
+
t: 30,
|
101
|
+
tab: 30,
|
102
|
+
three: 30,
|
103
|
+
two: 30,
|
104
|
+
u: 30,
|
105
|
+
up: 30,
|
106
|
+
v: 30,
|
107
|
+
voldown: 30,
|
108
|
+
volup: 30,
|
109
|
+
w: 30,
|
110
|
+
x: 30,
|
111
|
+
y: 30,
|
112
|
+
z: 30,
|
113
|
+
zero: 30
|
114
|
+
}
|
115
|
+
|
116
|
+
RfRgb::Keyboard.run_and_release do |keyboard|
|
117
|
+
keyboard.actuation_height = heights
|
118
|
+
keyboard.save
|
119
|
+
end
|
data/lib/rf_rgb.rb
CHANGED
data/lib/rf_rgb/keyboard.rb
CHANGED
@@ -2,7 +2,8 @@ module RfRgb
|
|
2
2
|
class Keyboard
|
3
3
|
VENDOR_ID = 0x0853
|
4
4
|
PRODUCT_ID = 0x013a
|
5
|
-
|
5
|
+
ENDPOINT_OUT = 0x04
|
6
|
+
ENDPOINT_IN = 0x83
|
6
7
|
INTERFACE = 0
|
7
8
|
|
8
9
|
attr_reader :device, :handle
|
@@ -33,7 +34,7 @@ module RfRgb
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def save
|
36
|
-
|
37
|
+
send_and_verify RfRgb::Protocol.save_changes
|
37
38
|
end
|
38
39
|
|
39
40
|
def release_to_os
|
@@ -44,7 +45,7 @@ module RfRgb
|
|
44
45
|
|
45
46
|
def disable_effect
|
46
47
|
reset_effect
|
47
|
-
|
48
|
+
send_and_verify RfRgb::Protocol.disable_effects
|
48
49
|
end
|
49
50
|
|
50
51
|
def colors=(new_colors)
|
@@ -55,69 +56,86 @@ module RfRgb
|
|
55
56
|
calls = RfRgb::Protocol.user_specified_colors(new_colors)
|
56
57
|
reset_effect
|
57
58
|
calls.each do |call|
|
58
|
-
|
59
|
+
send_and_verify call
|
59
60
|
end
|
60
61
|
end
|
62
|
+
alias_method :color=, :colors=
|
61
63
|
|
62
64
|
def effect_rainbow_wave
|
63
65
|
reset_effect
|
64
|
-
|
66
|
+
send_and_verify RfRgb::Protocol.rainbow_wave
|
65
67
|
end
|
66
68
|
|
67
69
|
def effect_pressed_key(rgb_hex)
|
68
70
|
reset_effect
|
69
|
-
|
71
|
+
send_and_verify RfRgb::Protocol.pressed_key_lighting(rgb_hex)
|
70
72
|
end
|
71
73
|
|
72
74
|
def effect_pressed_key_with_backlight(rgb_hex)
|
73
75
|
reset_effect
|
74
|
-
|
76
|
+
send_and_verify RfRgb::Protocol.pressed_key_lighting_with_backlight(rgb_hex)
|
75
77
|
end
|
76
78
|
|
77
79
|
def effect_shooting_star(rgb_hex, interval)
|
78
80
|
reset_effect
|
79
|
-
|
81
|
+
send_and_verify RfRgb::Protocol.shooting_star(rgb_hex, interval)
|
80
82
|
end
|
81
83
|
|
82
84
|
def effect_demo_mode
|
83
85
|
reset_effect
|
84
|
-
|
86
|
+
send_and_verify RfRgb::Protocol.demo_mode
|
85
87
|
end
|
86
88
|
|
87
89
|
def effect_random_lights
|
88
90
|
reset_effect
|
89
|
-
|
91
|
+
send_and_verify RfRgb::Protocol.random_lights
|
90
92
|
end
|
91
93
|
|
92
94
|
def effect_color_bar
|
93
95
|
reset_effect
|
94
|
-
|
96
|
+
send_and_verify RfRgb::Protocol.color_bar
|
95
97
|
end
|
96
98
|
|
97
99
|
# There's more to key locking than just this, but the way it's done is odd
|
98
100
|
# and is among the lowest of priorities on this project.
|
99
101
|
def lock_keys
|
100
|
-
|
102
|
+
send_and_verify RfRgb::Protocol.key_lock
|
103
|
+
end
|
104
|
+
|
105
|
+
def locked_keys=(keys)
|
106
|
+
calls = RfRgb::Protocol.user_specified_key_locks(keys)
|
107
|
+
calls.each do |call|
|
108
|
+
send_and_verify call
|
109
|
+
end
|
101
110
|
end
|
102
111
|
|
103
112
|
def unlock_keys
|
104
|
-
|
113
|
+
send_and_verify RfRgb::Protocol.key_unlock
|
105
114
|
end
|
106
115
|
|
107
116
|
def brightness=(new_brightness)
|
108
|
-
|
117
|
+
send_and_verify RfRgb::Protocol.change_brightness(new_brightness)
|
109
118
|
end
|
110
119
|
|
111
120
|
def actuation_height=(new_height)
|
112
|
-
|
121
|
+
if new_height.is_a? String
|
122
|
+
send_and_verify RfRgb::Protocol.change_actuation_height_all(new_height)
|
123
|
+
else
|
124
|
+
calls = RfRgb::Protocol.user_specified_actuation_heights(new_height)
|
125
|
+
reset_effect
|
126
|
+
calls.each do |call|
|
127
|
+
send_and_verify call
|
128
|
+
end
|
129
|
+
end
|
113
130
|
end
|
131
|
+
alias_method :actuation_heights=, :actuation_height=
|
114
132
|
|
115
133
|
def swap_caps_ctrl
|
116
|
-
|
134
|
+
send_and_verify RfRgb::Protocol.swap_caps_ctrl
|
117
135
|
end
|
118
136
|
|
119
137
|
def unswap_caps_ctrl
|
120
|
-
|
138
|
+
send_and_verify RfRgb::Protocol.unswap_caps_ctrl
|
121
139
|
end
|
122
140
|
|
123
141
|
private
|
@@ -125,7 +143,7 @@ module RfRgb
|
|
125
143
|
# I don't know what this actually does, but the Windows software
|
126
144
|
# sends this message before any effect change.
|
127
145
|
def reset_effect
|
128
|
-
|
146
|
+
send_and_verify RfRgb::Protocol.reset_effect
|
129
147
|
end
|
130
148
|
|
131
149
|
def initialize_device(device)
|
@@ -139,10 +157,41 @@ module RfRgb
|
|
139
157
|
|
140
158
|
def send_message(data)
|
141
159
|
@handle.interrupt_transfer(
|
142
|
-
endpoint:
|
160
|
+
endpoint: ENDPOINT_OUT,
|
143
161
|
dataOut: data,
|
144
162
|
timeout: 10_000
|
145
163
|
)
|
146
164
|
end
|
165
|
+
|
166
|
+
def receive_message
|
167
|
+
@handle.interrupt_transfer(
|
168
|
+
endpoint: ENDPOINT_IN,
|
169
|
+
dataIn: 64,
|
170
|
+
timeout: 10_000
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
def send_and_verify(data, retries = 2)
|
175
|
+
retry_count = 0
|
176
|
+
begin
|
177
|
+
send_message data
|
178
|
+
ack = receive_message
|
179
|
+
verify_message!(data, ack)
|
180
|
+
rescue RfRgb::VerificationError
|
181
|
+
retry_count += 1
|
182
|
+
retry if retry_count <= retries
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# The keyboard acknowledges each packet sent with a response of \x55\x55\x<third byte of sent packet>
|
187
|
+
def verify_message(data, ack)
|
188
|
+
ack.bytes[0..2] == "\x55\x55#{data[2]}".bytes
|
189
|
+
end
|
190
|
+
|
191
|
+
def verify_message!(data, ack)
|
192
|
+
unless verify_message(data, ack)
|
193
|
+
raise RfRgb::VerificationError, "Ack[#{ack.bytes}] did not match data[#{data.bytes}]!"
|
194
|
+
end
|
195
|
+
end
|
147
196
|
end
|
148
197
|
end
|
data/lib/rf_rgb/protocol.rb
CHANGED
@@ -45,7 +45,42 @@ module RfRgb
|
|
45
45
|
"\xaa\xaa\x40\x84\x3a#{user}#{m[:rshift]}#{m[:lctrl]}\x00\x00\x00#{m[:lalt]}#{m[:space]}#{m[:ralt]}\x00\x00\x00#{m[:rctrl]}\x00\x00\x00\x00\x00\x00\x00\x00\x00#{m[:lwin]}#{m[:rwin]}#{m[:fn]}#{m[:mute]}#{m[:voldown]}#{m[:volup]}#{m[:actuation]}#{m[:ins]}\x00".force_encoding(Encoding::BINARY).freeze,
|
46
46
|
"\xaa\xaa\x40\x85\x3a#{user}#{m[:del]}\x00\x00\x00\x00\x00\x00#{m[:left]}#{m[:home]}#{m[:end]}\x00\x00\x00#{m[:up]}#{m[:down]}#{m[:pgup]}#{m[:pgdn]}\x00\x00\x00\x00\x00\x00#{m[:right]}#{m[:numlk]}#{m[:np_seven]}#{m[:np_four]}#{m[:np_one]}\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze,
|
47
47
|
"\xaa\xaa\x40\x86\x3a#{user}#{m[:np_div]}#{m[:np_eight]}#{m[:np_five]}#{m[:np_two]}#{m[:np_zero]}#{m[:np_mult]}#{m[:np_nine]}#{m[:np_six]}#{m[:np_three]}#{m[:np_dot]}#{m[:np_minus]}#{m[:np_plus]}\x00\x00\x00#{m[:np_enter]}\x00\x00\x00#{m[:esc]}\x00\x00\x00#{m[:f1]}#{m[:f2]}\x00".force_encoding(Encoding::BINARY).freeze,
|
48
|
-
"\xaa\xaa\x40\xc7\x2b#{user}#{m[:f3]}#{m[:f4]}#{m[:f5]}#{m[:f6]}#{m[:f7]}#{m[:f8]}#{m[:f9]}#{m[:f10]}#{m[:f11]}#{m[:f12]}#{m[:prtsc]}#{m[:scrlk]}#{m[:pause]}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze
|
48
|
+
"\xaa\xaa\x40\xc7\x2b#{user}#{m[:f3]}#{m[:f4]}#{m[:f5]}#{m[:f6]}#{m[:f7]}#{m[:f8]}#{m[:f9]}#{m[:f10]}#{m[:f11]}#{m[:f12]}#{m[:prtsc]}#{m[:scrlk]}#{m[:pause]}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze,
|
49
|
+
"\xaa\xaa\x44\x00\x0d#{user}".force_encoding(Encoding::BINARY).freeze
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.user_specified_actuation_heights(mapping)
|
54
|
+
bytes = {
|
55
|
+
'15' => HEIGHT_15,
|
56
|
+
'22' => HEIGHT_22,
|
57
|
+
'30' => HEIGHT_30
|
58
|
+
}
|
59
|
+
|
60
|
+
m = lambda { |sym| bytes[mapping[sym].to_s] || bytes[mapping[:default].to_s] || HEIGHT_15 }
|
61
|
+
|
62
|
+
[
|
63
|
+
"\xaa\xaa\x21\x41\x3b\x00#{m[:grave]}#{m[:one]}#{m[:two]}#{m[:three]}#{m[:four]}#{m[:five]}#{m[:six]}#{m[:seven]}#{m[:eight]}#{m[:nine]}#{m[:zero]}#{m[:hyphen]}#{m[:equals]}\x00#{m[:backspace]}#{m[:tab]}#{m[:q]}#{m[:w]}#{m[:e]}#{m[:r]}#{m[:t]}#{m[:y]}#{m[:u]}#{m[:i]}#{m[:o]}#{m[:p]}#{m[:lbracket]}#{m[:rbracket]}#{m[:backslash]}#{m[:capslock]}#{m[:a]}#{m[:s]}#{m[:d]}#{m[:f]}#{m[:g]}#{m[:h]}#{m[:j]}#{m[:k]}#{m[:l]}#{m[:semicolon]}#{m[:apostrophe]}\x00#{m[:enter]}#{m[:lshift]}\x00#{m[:z]}#{m[:x]}#{m[:c]}#{m[:v]}#{m[:b]}#{m[:n]}#{m[:m]}#{m[:comma]}#{m[:period]}#{m[:slash]}\x00#{m[:rshift]}#{m[:lctrl]}".force_encoding(Encoding::BINARY).freeze,
|
64
|
+
"\xaa\xaa\x21\x82\x3b\x00#{m[:lalt]}#{m[:space]}#{m[:ralt]}\x00#{m[:rctrl]}\x00\x00\x00#{m[:lwin]}#{m[:rwin]}#{m[:fn]}#{m[:mute]}#{m[:voldown]}#{m[:volup]}#{m[:actuation]}#{m[:ins]}#{m[:del]}\x00\x00#{m[:left]}#{m[:home]}#{m[:end]}\x00#{m[:up]}#{m[:down]}#{m[:pgup]}#{m[:pgdn]}\x00\x00#{m[:right]}#{m[:numlk]}#{m[:np_seven]}#{m[:np_four]}#{m[:np_one]}\x00#{m[:np_div]}#{m[:np_eight]}#{m[:np_five]}#{m[:np_two]}#{m[:np_zero]}#{m[:np_mult]}#{m[:np_nine]}#{m[:np_six]}#{m[:np_three]}#{m[:np_dot]}#{m[:np_minus]}#{m[:np_plus]}\x00#{m[:np_enter]}\x00#{m[:esc]}\x00#{m[:f1]}#{m[:f2]}#{m[:f3]}#{m[:f4]}#{m[:f5]}#{m[:f6]}".force_encoding(Encoding::BINARY).freeze,
|
65
|
+
"\xaa\xaa\x21\xc3\x0a#{m[:f7]}#{m[:f8]}#{m[:f9]}#{m[:f10]}#{m[:f11]}#{m[:f12]}#{m[:prtsc]}#{m[:scrlk]}#{m[:pause]}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
69
|
+
# TODO this doesn't seem to do anything.
|
70
|
+
def self.user_specified_key_locks(mapping)
|
71
|
+
# aa:aa:80:41:3b:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
|
72
|
+
# aa:aa:80:82:3b:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01:00:01:00:00:00:00:00
|
73
|
+
# aa:aa:80:c3:0a:00:01:00:00:01:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01:00:01:00:00:00:00:00
|
74
|
+
bytes = {
|
75
|
+
true: "\x01",
|
76
|
+
false: "\x00"
|
77
|
+
}
|
78
|
+
m = lambda { |sym| bytes[mapping[sym]] || bytes[mapping[:default]] || false }
|
79
|
+
|
80
|
+
[
|
81
|
+
"\xaa\xaa\x80\x41\x3b\x00#{m[:grave]}#{m[:one]}#{m[:two]}#{m[:three]}#{m[:four]}#{m[:five]}#{m[:six]}#{m[:seven]}#{m[:eight]}#{m[:nine]}#{m[:zero]}#{m[:hyphen]}#{m[:equals]}\x00#{m[:backspace]}#{m[:tab]}#{m[:q]}#{m[:w]}#{m[:e]}#{m[:r]}#{m[:t]}#{m[:y]}#{m[:u]}#{m[:i]}#{m[:o]}#{m[:p]}#{m[:lbracket]}#{m[:rbracket]}#{m[:backslash]}#{m[:capslock]}#{m[:a]}#{m[:s]}#{m[:d]}#{m[:f]}#{m[:g]}#{m[:h]}#{m[:j]}#{m[:k]}#{m[:l]}#{m[:semicolon]}#{m[:apostrophe]}\x00#{m[:enter]}#{m[:lshift]}\x00#{m[:z]}#{m[:x]}#{m[:c]}#{m[:v]}#{m[:b]}#{m[:n]}#{m[:m]}#{m[:comma]}#{m[:period]}#{m[:slash]}\x00#{m[:rshift]}#{m[:lctrl]}".force_encoding(Encoding::BINARY).freeze,
|
82
|
+
"\xaa\xaa\x80\x82\x3b\x00#{m[:lalt]}#{m[:space]}#{m[:ralt]}\x00#{m[:rctrl]}\x00\x00\x00#{m[:lwin]}#{m[:rwin]}#{m[:fn]}#{m[:mute]}#{m[:voldown]}#{m[:volup]}#{m[:actuation]}#{m[:ins]}#{m[:del]}\x00\x00#{m[:left]}#{m[:home]}#{m[:end]}\x00#{m[:up]}#{m[:down]}#{m[:pgup]}#{m[:pgdn]}\x00\x00#{m[:right]}#{m[:numlk]}#{m[:np_seven]}#{m[:np_four]}#{m[:np_one]}\x00#{m[:np_div]}#{m[:np_eight]}#{m[:np_five]}#{m[:np_two]}#{m[:np_zero]}#{m[:np_mult]}#{m[:np_nine]}#{m[:np_six]}#{m[:np_three]}#{m[:np_dot]}#{m[:np_minus]}#{m[:np_plus]}\x00#{m[:np_enter]}\x00#{m[:esc]}\x00#{m[:f1]}#{m[:f2]}#{m[:f3]}#{m[:f4]}#{m[:f5]}#{m[:f6]}".force_encoding(Encoding::BINARY).freeze,
|
83
|
+
"\xaa\xaa\x80\xc3\x0a#{m[:f7]}#{m[:f8]}#{m[:f9]}#{m[:f10]}#{m[:f11]}#{m[:f12]}#{m[:prtsc]}#{m[:scrlk]}#{m[:pause]}\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze
|
49
84
|
]
|
50
85
|
end
|
51
86
|
|
data/lib/rf_rgb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rf_rgb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mpd
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libusb
|
@@ -84,8 +84,11 @@ files:
|
|
84
84
|
- Rakefile
|
85
85
|
- bin/console
|
86
86
|
- bin/setup
|
87
|
+
- examples/lock_keys_all.rb
|
88
|
+
- examples/mpd_keyboard.rb
|
87
89
|
- examples/readme_1.rb
|
88
90
|
- examples/readme_2.rb
|
91
|
+
- examples/set_actuation_heights_all.rb
|
89
92
|
- examples/set_colors_all.rb
|
90
93
|
- examples/set_colors_circus.rb
|
91
94
|
- examples/set_colors_complex.rb
|