rf_rgb 0.8.0 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/examples/readme_1.rb +19 -0
- data/examples/readme_2.rb +9 -0
- data/examples/set_colors_all.rb +118 -0
- data/examples/set_colors_circus.rb +122 -0
- data/examples/set_colors_complex.rb +23 -0
- data/examples/set_colors_simple.rb +7 -0
- data/lib/rf_rgb/keyboard.rb +12 -0
- data/lib/rf_rgb/protocol.rb +22 -2
- data/lib/rf_rgb/version.rb +1 -1
- data/rf_rgb.gemspec +1 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 022a90cca27c54f809efb688194bb1acea19ce8b
|
4
|
+
data.tar.gz: 117569fefbe5f2b6ca5d179912029c1a8321ad79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb21fbaf33c2fe1a9f1ca81aa0e135020f4a23eec58ebb301c7b1b9cd4d63d69318777348de46e54e979bf771d8b98a0aee80dbe47507c3b2a0d775a900cef1
|
7
|
+
data.tar.gz: 03b28f38f84e443f8236cedf88c3b465c0162c3df49bd5c8cc0fac61bd1d397f3ae26fdee3ab5d335875f8bf51ce3807ea1b7e97a642602e5c6e932111137d9c
|
data/README.md
CHANGED
@@ -31,6 +31,8 @@ Or install it yourself with:
|
|
31
31
|
## Usage
|
32
32
|
|
33
33
|
```ruby
|
34
|
+
require 'rf_rgb'
|
35
|
+
|
34
36
|
keyboard = nil
|
35
37
|
begin
|
36
38
|
# .new without an arg will automatically find and initialize the first Realforce RGB keyboard it finds.
|
@@ -38,8 +40,8 @@ begin
|
|
38
40
|
keyboard = RfRgb::Keyboard.new
|
39
41
|
|
40
42
|
keyboard.effect_rainbow_wave
|
41
|
-
# keyboard.effect_shooting_star("
|
42
|
-
# keyboard.effect_pressed_key("
|
43
|
+
# keyboard.effect_shooting_star("ff00ff", RfRgb::Protocol::INTERVAL_6)
|
44
|
+
# keyboard.effect_pressed_key("aaeeff")
|
43
45
|
# keyboard.disable_effect
|
44
46
|
keyboard.brightness = RfRgb::Protocol::BRIGHTNESS_LOW
|
45
47
|
keyboard.actuation_height = RfRgb::Protocol::HEIGHT_22
|
@@ -53,6 +55,8 @@ end
|
|
53
55
|
OR
|
54
56
|
|
55
57
|
```ruby
|
58
|
+
require 'rf_rgb'
|
59
|
+
|
56
60
|
RfRgb::Keyboard.run_and_release do |keyboard|
|
57
61
|
keyboard.effect_rainbow_wave
|
58
62
|
keyboard.brightness = RfRgb::Protocol::BRIGHTNESS_LOW
|
@@ -62,6 +66,8 @@ RfRgb::Keyboard.run_and_release do |keyboard|
|
|
62
66
|
end
|
63
67
|
```
|
64
68
|
|
69
|
+
Additional examples can be found in the `examples` directory.
|
70
|
+
|
65
71
|
See `lib/rf_rgb/keyboard.rb` for effects and arguments, and
|
66
72
|
`lib/rf_rgb/protocol.rb` for any needed constants.
|
67
73
|
|
@@ -84,7 +90,7 @@ be read from IN endpoint #3, but this module ignores these responses completely
|
|
84
90
|
time of writing.
|
85
91
|
|
86
92
|
Some effects have a User 1-3 setting in the Windows UI. It's not clear what these
|
87
|
-
are actually for, and are ignored in this module for now.
|
93
|
+
are actually for, and are mostly ignored in this module for now.
|
88
94
|
|
89
95
|
## Development
|
90
96
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rf_rgb'
|
2
|
+
|
3
|
+
keyboard = nil
|
4
|
+
begin
|
5
|
+
# .new without an arg will automatically find and initialize the first Realforce RGB keyboard it finds.
|
6
|
+
# Keyboard cannot be used at this point, as it's owned by this program until .release_to_os is called.
|
7
|
+
keyboard = RfRgb::Keyboard.new
|
8
|
+
|
9
|
+
keyboard.effect_rainbow_wave
|
10
|
+
# keyboard.effect_shooting_star("ff00ff", RfRgb::Protocol::INTERVAL_6)
|
11
|
+
# keyboard.effect_pressed_key("aaeeff")
|
12
|
+
# keyboard.disable_effect
|
13
|
+
keyboard.brightness = RfRgb::Protocol::BRIGHTNESS_LOW
|
14
|
+
keyboard.actuation_height = RfRgb::Protocol::HEIGHT_22
|
15
|
+
keyboard.swap_caps_ctrl
|
16
|
+
keyboard.save
|
17
|
+
ensure
|
18
|
+
keyboard&.release_to_os
|
19
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'rf_rgb'
|
2
|
+
|
3
|
+
# full listing of keys for per-key color settings
|
4
|
+
colors = {
|
5
|
+
a: '000000',
|
6
|
+
actuation: '000000',
|
7
|
+
apostrophe: '000000',
|
8
|
+
b: '000000',
|
9
|
+
backslash: '000000',
|
10
|
+
backspace: '000000',
|
11
|
+
c: '000000',
|
12
|
+
capslock: '000000',
|
13
|
+
comma: '000000',
|
14
|
+
d: '000000',
|
15
|
+
del: '000000',
|
16
|
+
down: '000000',
|
17
|
+
e: '000000',
|
18
|
+
eight: '000000',
|
19
|
+
end: '000000',
|
20
|
+
enter: '000000',
|
21
|
+
equals: '000000',
|
22
|
+
esc: '000000',
|
23
|
+
f: '000000',
|
24
|
+
f1: '000000',
|
25
|
+
f10: '000000',
|
26
|
+
f11: '000000',
|
27
|
+
f12: '000000',
|
28
|
+
f2: '000000',
|
29
|
+
f3: '000000',
|
30
|
+
f4: '000000',
|
31
|
+
f5: '000000',
|
32
|
+
f6: '000000',
|
33
|
+
f7: '000000',
|
34
|
+
f8: '000000',
|
35
|
+
f9: '000000',
|
36
|
+
five: '000000',
|
37
|
+
fn: '000000',
|
38
|
+
four: '000000',
|
39
|
+
g: '000000',
|
40
|
+
grave: '000000',
|
41
|
+
h: '000000',
|
42
|
+
home: '000000',
|
43
|
+
hyphen: '000000',
|
44
|
+
i: '000000',
|
45
|
+
ins: '000000',
|
46
|
+
j: '000000',
|
47
|
+
k: '000000',
|
48
|
+
l: '000000',
|
49
|
+
lalt: '000000',
|
50
|
+
lbracket: '000000',
|
51
|
+
lctrl: '000000',
|
52
|
+
left: '000000',
|
53
|
+
lshift: '000000',
|
54
|
+
lwin: '000000',
|
55
|
+
m: '000000',
|
56
|
+
mute: '000000',
|
57
|
+
n: '000000',
|
58
|
+
nine: '000000',
|
59
|
+
np_div: '000000',
|
60
|
+
np_dot: '000000',
|
61
|
+
np_eight: '000000',
|
62
|
+
np_enter: '000000',
|
63
|
+
np_five: '000000',
|
64
|
+
np_four: '000000',
|
65
|
+
np_minus: '000000',
|
66
|
+
np_mult: '000000',
|
67
|
+
np_nine: '000000',
|
68
|
+
np_one: '000000',
|
69
|
+
np_plus: '000000',
|
70
|
+
np_seven: '000000',
|
71
|
+
np_six: '000000',
|
72
|
+
np_three: '000000',
|
73
|
+
np_two: '000000',
|
74
|
+
np_zero: '000000',
|
75
|
+
numlk: '000000',
|
76
|
+
o: '000000',
|
77
|
+
one: '000000',
|
78
|
+
p: '000000',
|
79
|
+
pause: '000000',
|
80
|
+
period: '000000',
|
81
|
+
pgdn: '000000',
|
82
|
+
pgup: '000000',
|
83
|
+
prtsc: '000000',
|
84
|
+
q: '000000',
|
85
|
+
r: '000000',
|
86
|
+
ralt: '000000',
|
87
|
+
rbracket: '000000',
|
88
|
+
rctrl: '000000',
|
89
|
+
right: '000000',
|
90
|
+
rshift: '000000',
|
91
|
+
rwin: '000000',
|
92
|
+
s: '000000',
|
93
|
+
scrlk: '000000',
|
94
|
+
semicolon: '000000',
|
95
|
+
seven: '000000',
|
96
|
+
six: '000000',
|
97
|
+
slash: '000000',
|
98
|
+
space: '000000',
|
99
|
+
t: '000000',
|
100
|
+
tab: '000000',
|
101
|
+
three: '000000',
|
102
|
+
two: '000000',
|
103
|
+
u: '000000',
|
104
|
+
up: '000000',
|
105
|
+
v: '000000',
|
106
|
+
voldown: '000000',
|
107
|
+
volup: '000000',
|
108
|
+
w: '000000',
|
109
|
+
x: '000000',
|
110
|
+
y: '000000',
|
111
|
+
z: '000000',
|
112
|
+
zero: '000000'
|
113
|
+
}
|
114
|
+
|
115
|
+
RfRgb::Keyboard.run_and_release do |keyboard|
|
116
|
+
keyboard.colors = colors
|
117
|
+
keyboard.save
|
118
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'rf_rgb'
|
2
|
+
|
3
|
+
# set each key to a random color
|
4
|
+
names = [
|
5
|
+
:a,
|
6
|
+
:actuation,
|
7
|
+
:apostrophe,
|
8
|
+
:b,
|
9
|
+
:backslash,
|
10
|
+
:backspace,
|
11
|
+
:c,
|
12
|
+
:capslock,
|
13
|
+
:comma,
|
14
|
+
:d,
|
15
|
+
:del,
|
16
|
+
:down,
|
17
|
+
:e,
|
18
|
+
:eight,
|
19
|
+
:end,
|
20
|
+
:enter,
|
21
|
+
:equals,
|
22
|
+
:esc,
|
23
|
+
:f,
|
24
|
+
:f1,
|
25
|
+
:f10,
|
26
|
+
:f11,
|
27
|
+
:f12,
|
28
|
+
:f2,
|
29
|
+
:f3,
|
30
|
+
:f4,
|
31
|
+
:f5,
|
32
|
+
:f6,
|
33
|
+
:f7,
|
34
|
+
:f8,
|
35
|
+
:f9,
|
36
|
+
:five,
|
37
|
+
:fn,
|
38
|
+
:four,
|
39
|
+
:g,
|
40
|
+
:grave,
|
41
|
+
:h,
|
42
|
+
:home,
|
43
|
+
:hyphen,
|
44
|
+
:i,
|
45
|
+
:ins,
|
46
|
+
:j,
|
47
|
+
:k,
|
48
|
+
:l,
|
49
|
+
:lalt,
|
50
|
+
:lbracket,
|
51
|
+
:lctrl,
|
52
|
+
:left,
|
53
|
+
:lshift,
|
54
|
+
:lwin,
|
55
|
+
:m,
|
56
|
+
:mute,
|
57
|
+
:n,
|
58
|
+
:nine,
|
59
|
+
:np_div,
|
60
|
+
:np_dot,
|
61
|
+
:np_eight,
|
62
|
+
:np_enter,
|
63
|
+
:np_five,
|
64
|
+
:np_four,
|
65
|
+
:np_minus,
|
66
|
+
:np_mult,
|
67
|
+
:np_nine,
|
68
|
+
:np_one,
|
69
|
+
:np_plus,
|
70
|
+
:np_seven,
|
71
|
+
:np_six,
|
72
|
+
:np_three,
|
73
|
+
:np_two,
|
74
|
+
:np_zero,
|
75
|
+
:numlk,
|
76
|
+
:o,
|
77
|
+
:one,
|
78
|
+
:p,
|
79
|
+
:pause,
|
80
|
+
:period,
|
81
|
+
:pgdn,
|
82
|
+
:pgup,
|
83
|
+
:prtsc,
|
84
|
+
:q,
|
85
|
+
:r,
|
86
|
+
:ralt,
|
87
|
+
:rbracket,
|
88
|
+
:rctrl,
|
89
|
+
:right,
|
90
|
+
:rshift,
|
91
|
+
:rwin,
|
92
|
+
:s,
|
93
|
+
:scrlk,
|
94
|
+
:semicolon,
|
95
|
+
:seven,
|
96
|
+
:six,
|
97
|
+
:slash,
|
98
|
+
:space,
|
99
|
+
:t,
|
100
|
+
:tab,
|
101
|
+
:three,
|
102
|
+
:two,
|
103
|
+
:u,
|
104
|
+
:up,
|
105
|
+
:v,
|
106
|
+
:voldown,
|
107
|
+
:volup,
|
108
|
+
:w,
|
109
|
+
:x,
|
110
|
+
:y,
|
111
|
+
:z,
|
112
|
+
:zero
|
113
|
+
]
|
114
|
+
|
115
|
+
colors = names.each_with_object({}) do |color, ob|
|
116
|
+
ob[color] = '%06x' % (rand * 0xffffff)
|
117
|
+
end
|
118
|
+
|
119
|
+
RfRgb::Keyboard.run_and_release do |keyboard|
|
120
|
+
keyboard.colors = colors
|
121
|
+
keyboard.save
|
122
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rf_rgb'
|
2
|
+
|
3
|
+
# Set all keys based on a passed-in mapping
|
4
|
+
colors = {
|
5
|
+
# Any key not specified will be set to the default value of the mapping.
|
6
|
+
# If no default is set in the mapping, will default to 000000 (i.e. not lit)
|
7
|
+
default: '11aa43',
|
8
|
+
|
9
|
+
a: 'ff00ff',
|
10
|
+
s: 'ff00ff',
|
11
|
+
d: 'ff00ff',
|
12
|
+
f: 'ff00ff',
|
13
|
+
|
14
|
+
j: '00ffff',
|
15
|
+
k: '00ffff',
|
16
|
+
l: '00ffff',
|
17
|
+
semicolon: '00ffff'
|
18
|
+
}
|
19
|
+
|
20
|
+
RfRgb::Keyboard.run_and_release do |keyboard|
|
21
|
+
keyboard.colors = colors
|
22
|
+
keyboard.save
|
23
|
+
end
|
data/lib/rf_rgb/keyboard.rb
CHANGED
@@ -47,6 +47,18 @@ module RfRgb
|
|
47
47
|
send_message RfRgb::Protocol.disable_effects
|
48
48
|
end
|
49
49
|
|
50
|
+
def colors=(new_colors)
|
51
|
+
if new_colors.is_a? String
|
52
|
+
new_colors = {default: new_colors}
|
53
|
+
end
|
54
|
+
|
55
|
+
calls = RfRgb::Protocol.user_specified_colors(new_colors)
|
56
|
+
reset_effect
|
57
|
+
calls.each do |call|
|
58
|
+
send_message call
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
50
62
|
def effect_rainbow_wave
|
51
63
|
reset_effect
|
52
64
|
send_message RfRgb::Protocol.rainbow_wave
|
data/lib/rf_rgb/protocol.rb
CHANGED
@@ -35,14 +35,28 @@ module RfRgb
|
|
35
35
|
"\xaa\xaa\x04".force_encoding(Encoding::BINARY).freeze
|
36
36
|
end
|
37
37
|
|
38
|
+
def self.user_specified_colors(mapping, user = USER_1)
|
39
|
+
m = lambda { |sym| color_transform(mapping[sym]) || color_transform(mapping[:default]) || "\x00\x00\x00" }
|
40
|
+
|
41
|
+
[
|
42
|
+
"\xaa\xaa\x40\x41\x3a#{user}\x00\x00\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\x00\x00#{m[:backspace]}#{m[:tab]}#{m[:q]}#{m[:w]}\x00".force_encoding(Encoding::BINARY).freeze,
|
43
|
+
"\xaa\xaa\x40\x82\x3a#{user}#{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]}\x00".force_encoding(Encoding::BINARY).freeze,
|
44
|
+
"\xaa\xaa\x40\x83\x3a#{user}#{m[:k]}#{m[:l]}#{m[:semicolon]}#{m[:apostrophe]}\x00\x00\x00#{m[:enter]}#{m[:lshift]}\x00\x00\x00#{m[:z]}#{m[:x]}#{m[:c]}#{m[:v]}#{m[:b]}#{m[:n]}#{m[:m]}#{m[:comma]}#{m[:period]}#{m[:slash]}\x00\x00\x00\x00".force_encoding(Encoding::BINARY).freeze,
|
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
|
+
"\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
|
+
"\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
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
38
52
|
def self.pressed_key_lighting(rgb_hex, user = :user0)
|
39
53
|
# byte number 6 (just before rgb) determines user. 0x00-0x03
|
40
|
-
"\xaa\xaa\x62\x00\x04\x00#{rgb_hex}".force_encoding(Encoding::BINARY).freeze
|
54
|
+
"\xaa\xaa\x62\x00\x04\x00#{color_transform rgb_hex}".force_encoding(Encoding::BINARY).freeze
|
41
55
|
end
|
42
56
|
|
43
57
|
# Backlight color can't be changed AFAICT. Always white.
|
44
58
|
def self.pressed_key_lighting_with_backlight(rgb_hex, user = :user0)
|
45
|
-
"\xaa\xaa\x63\x00\x04\x00#{rgb_hex}".force_encoding(Encoding::BINARY).freeze
|
59
|
+
"\xaa\xaa\x63\x00\x04\x00#{color_transform rgb_hex}".force_encoding(Encoding::BINARY).freeze
|
46
60
|
end
|
47
61
|
|
48
62
|
def self.rainbow_wave
|
@@ -92,5 +106,11 @@ module RfRgb
|
|
92
106
|
def self.unswap_caps_ctrl
|
93
107
|
"\xaa\xaa\x84\x00\x01\x00".force_encoding(Encoding::BINARY).freeze
|
94
108
|
end
|
109
|
+
|
110
|
+
def self.color_transform(color)
|
111
|
+
return nil unless color
|
112
|
+
return color unless color.length == 6 # rrggbb string
|
113
|
+
[color].pack('H*').force_encoding(Encoding::UTF_8)
|
114
|
+
end
|
95
115
|
end
|
96
116
|
end
|
data/lib/rf_rgb/version.rb
CHANGED
data/rf_rgb.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/xxx/rf_rgb"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
+
spec.required_ruby_version = ">= 2.3"
|
17
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
20
|
if spec.respond_to?(:metadata)
|
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.8.
|
4
|
+
version: 0.8.5
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libusb
|
@@ -84,6 +84,12 @@ files:
|
|
84
84
|
- Rakefile
|
85
85
|
- bin/console
|
86
86
|
- bin/setup
|
87
|
+
- examples/readme_1.rb
|
88
|
+
- examples/readme_2.rb
|
89
|
+
- examples/set_colors_all.rb
|
90
|
+
- examples/set_colors_circus.rb
|
91
|
+
- examples/set_colors_complex.rb
|
92
|
+
- examples/set_colors_simple.rb
|
87
93
|
- lib/rf_rgb.rb
|
88
94
|
- lib/rf_rgb/keyboard.rb
|
89
95
|
- lib/rf_rgb/protocol.rb
|
@@ -102,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
108
|
requirements:
|
103
109
|
- - ">="
|
104
110
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
111
|
+
version: '2.3'
|
106
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
113
|
requirements:
|
108
114
|
- - ">="
|