rkremap 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/example/mac-shortcut.rb +11 -5
- data/example/tmtms.rb +11 -6
- data/lib/rkremap/evdev.rb +6 -2
- data/lib/rkremap/evdev_list.rb +10 -4
- data/lib/rkremap/event.rb +21 -31
- data/lib/rkremap/version.rb +1 -1
- data/lib/rkremap.rb +1 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6476d10293c91c5afb744c6ebe1162d26ab253ad06aade6f5f2568db05bb7631
|
4
|
+
data.tar.gz: 35fd73d5a2d71ca797fd626397a789e8f22b5bd54cfa2ef0ca08f46adc6efa7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdf4f1364db8aa24dc49dab823e4f16200994058a6ff8d8e3323272d0783139af49f6fcdbb7f22b573dab92554d39d92429d24aa7b5fedf80e27139cf62bd120
|
7
|
+
data.tar.gz: d868e6b7af37edfa90324014669ff7de5595f392116bedeaf011cf95cd49ce9621782f1dda6e402c4e6117509ae0a0337322447028975ab743324da318479d0b
|
data/README.md
CHANGED
data/example/mac-shortcut.rb
CHANGED
@@ -48,18 +48,24 @@ rk.match(app: /terminal/i) do |event, mod|
|
|
48
48
|
# Super+Ctrl はそのまま
|
49
49
|
if (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && (mod[KEY_LEFTCTRL] || mod[KEY_RIGHTCTRL])
|
50
50
|
rk.event(code: event.code, type: event.type)
|
51
|
-
|
51
|
+
# Super+0/Minus は Ctrl+0/Minus に変換
|
52
|
+
elsif (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && Rkremap::CODE_KEY[event.code] =~ /\AKEY_(0|MINUS)\z/
|
53
|
+
rk.with_modifier(mod_disable_all.merge(KEY_LEFTCTRL => true)) do
|
54
|
+
rk.event(code: event.code, type: event.type)
|
55
|
+
end
|
52
56
|
# Super+KEY は Ctrl+Shift+KEY に変換
|
53
|
-
|
57
|
+
elsif (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && Rkremap::CODE_KEY[event.code] =~ /\AKEY_([A-Z]|EQUAL)\z/
|
54
58
|
rk.with_modifier(mod_disable_meta.merge(KEY_LEFTCTRL => true, KEY_LEFTSHIFT => true)) do
|
55
59
|
rk.event(code: event.code, type: event.type)
|
56
60
|
end
|
57
|
-
|
61
|
+
# それ以外はそのまま
|
62
|
+
else # rubocop:disable Lint/DuplicateBranch
|
58
63
|
rk.event(code: event.code, type: event.type)
|
59
64
|
end
|
60
65
|
event.skip
|
61
66
|
end
|
62
67
|
|
68
|
+
# その他のウィンドウ
|
63
69
|
rk.start do |code, mod|
|
64
70
|
# Super + Ctrl + 何か はそのまま
|
65
71
|
if (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && (mod[KEY_LEFTCTRL] || mod[KEY_RIGHTCTRL])
|
@@ -67,8 +73,8 @@ rk.start do |code, mod|
|
|
67
73
|
next
|
68
74
|
end
|
69
75
|
|
70
|
-
#
|
71
|
-
if (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && (Rkremap::CODE_KEY[code] =~ /\AKEY_[
|
76
|
+
# Super+[A-Z]/Minus/Equal/Enter を Ctrl+[A-Z]/Minus/Equal/Enter に変換
|
77
|
+
if (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && (Rkremap::CODE_KEY[code] =~ /\AKEY_([0-9A-Z]|MINUS|EQUAL|ENTER)\z/)
|
72
78
|
rk.key(code, mod.merge(mod_disable_meta, KEY_LEFTCTRL => true))
|
73
79
|
next
|
74
80
|
end
|
data/example/tmtms.rb
CHANGED
@@ -5,7 +5,7 @@ require 'tmtms_timer'
|
|
5
5
|
|
6
6
|
include Rkremap::KeyCode
|
7
7
|
|
8
|
-
rk = Rkremap.new(*ARGV, mouse: true, exclude: /touchpad/)
|
8
|
+
rk = Rkremap.new(*ARGV, mouse: true, exclude: /touchpad/i)
|
9
9
|
rk.grab = true
|
10
10
|
rk.x11 = true
|
11
11
|
|
@@ -107,13 +107,18 @@ rk.match(app: /terminal/i) do |event, mod|
|
|
107
107
|
# Super+Ctrl はそのまま
|
108
108
|
if (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && (mod[KEY_LEFTCTRL] || mod[KEY_RIGHTCTRL])
|
109
109
|
rk.event(code: event.code, type: event.type)
|
110
|
-
|
110
|
+
# Super+0/Minus は Ctrl+0/Minus に変換
|
111
|
+
elsif (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && Rkremap::CODE_KEY[event.code] =~ /\AKEY_(0|MINUS)\z/
|
112
|
+
rk.with_modifier(mod_disable_all.merge(KEY_LEFTCTRL => true)) do
|
113
|
+
rk.event(code: event.code, type: event.type)
|
114
|
+
end
|
111
115
|
# Super+KEY は Ctrl+Shift+KEY に変換
|
112
|
-
|
116
|
+
elsif (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && Rkremap::CODE_KEY[event.code] =~ /\AKEY_([A-Z]|EQUAL)\z/
|
113
117
|
rk.with_modifier(mod_disable_meta.merge(KEY_LEFTCTRL => true, KEY_LEFTSHIFT => true)) do
|
114
118
|
rk.event(code: event.code, type: event.type)
|
115
119
|
end
|
116
|
-
|
120
|
+
# それ以外はそのまま
|
121
|
+
else # rubocop:disable Lint/DuplicateBranch
|
117
122
|
rk.event(code: event.code, type: event.type)
|
118
123
|
end
|
119
124
|
event.skip
|
@@ -139,8 +144,8 @@ rk.start do |code, mod|
|
|
139
144
|
next
|
140
145
|
end
|
141
146
|
|
142
|
-
# Super+[A-Z]/Enter を Ctrl+[A-Z]/Enter に変換
|
143
|
-
if (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && (Rkremap::CODE_KEY[code] =~ /\AKEY_[
|
147
|
+
# Super+[A-Z]/Minus/Equal/Enter を Ctrl+[A-Z]/Minus/Equal/Enter に変換
|
148
|
+
if (mod[KEY_LEFTMETA] || mod[KEY_RIGHTMETA]) && (Rkremap::CODE_KEY[code] =~ /\AKEY_([0-9A-Z]|MINUS|EQUAL|ENTER)\z/)
|
144
149
|
rk.key(code, mod.merge(mod_disable_meta, KEY_LEFTCTRL => true))
|
145
150
|
next
|
146
151
|
end
|
data/lib/rkremap/evdev.rb
CHANGED
@@ -18,6 +18,10 @@ class Rkremap
|
|
18
18
|
@grab = false
|
19
19
|
end
|
20
20
|
|
21
|
+
def inspect
|
22
|
+
"#<Rkremap::Evdev: #{name} (#{path})>"
|
23
|
+
end
|
24
|
+
|
21
25
|
def eql?(other)
|
22
26
|
other.is_a?(Evdev) && self.path == other.path
|
23
27
|
end
|
@@ -92,12 +96,12 @@ class Rkremap
|
|
92
96
|
# unsigned short code;
|
93
97
|
# unsigned int value;
|
94
98
|
# };
|
95
|
-
# @return [
|
99
|
+
# @return [Rkremap::Event]
|
96
100
|
def read_event
|
97
101
|
raw = io.sysread(24) # sizeof(struct input_event)
|
98
102
|
sec, usec, type, code, value = raw.unpack('Q!Q!SSl')
|
99
103
|
time = Time.at(sec, usec)
|
100
|
-
|
104
|
+
Event.new(self, time, type, code, value)
|
101
105
|
end
|
102
106
|
|
103
107
|
# @param pattern [Symbol, Regexp]
|
data/lib/rkremap/evdev_list.rb
CHANGED
@@ -44,19 +44,25 @@ class Rkremap
|
|
44
44
|
new_devs -= @device_list.keys
|
45
45
|
new_devs.each do |path|
|
46
46
|
ev = Evdev.new(path)
|
47
|
-
|
48
|
-
if
|
47
|
+
stat = nil
|
48
|
+
if @exclude && ev.name =~ @exclude
|
49
|
+
stat = 'excluded'
|
50
|
+
elsif ev.keyboard? || (@detect_mouse && ev.mouse?)
|
49
51
|
ev.grab if ev.match?(@grab)
|
50
|
-
puts "detect: #{ev.name} (#{ev.path}) #{ev.grab? ? 'grab' : 'not grab'}" if $VERBOSE
|
51
52
|
@io2evdev[ev.io] = ev
|
52
53
|
@device_list[path] = ev
|
54
|
+
stat = ev.grab? ? 'grabbed' : 'not grabbed'
|
55
|
+
else
|
56
|
+
stat = 'ignored'
|
53
57
|
end
|
58
|
+
puts "detect: #{ev.name} (#{ev.path}) #{stat}" if $VERBOSE
|
54
59
|
end
|
55
60
|
end
|
56
61
|
|
57
62
|
# @param evdev [path]
|
58
63
|
def remove_device(path)
|
59
64
|
evdev = @device_list[path]
|
65
|
+
puts "disconnect: #{evdev.name} (#{evdev.path})" if $VERBOSE
|
60
66
|
@io2evdev.delete evdev.io
|
61
67
|
evdev.close
|
62
68
|
@device_list.delete path
|
@@ -74,7 +80,7 @@ class Rkremap
|
|
74
80
|
evdev = select(3)
|
75
81
|
next unless evdev
|
76
82
|
begin
|
77
|
-
return
|
83
|
+
return evdev.read_event
|
78
84
|
rescue Errno::ENODEV
|
79
85
|
remove_device(evdev.path)
|
80
86
|
end
|
data/lib/rkremap/event.rb
CHANGED
@@ -1,39 +1,29 @@
|
|
1
1
|
class Rkremap
|
2
2
|
class Event
|
3
|
-
Raw = Struct.new(:time, :type, :code, :value)
|
4
|
-
|
5
3
|
attr_accessor :app
|
6
|
-
attr_reader :
|
7
|
-
|
4
|
+
attr_reader :device
|
5
|
+
attr_reader :time
|
6
|
+
attr_reader :ev_type
|
7
|
+
attr_accessor :code
|
8
|
+
attr_accessor :value
|
8
9
|
|
9
10
|
# @param evdev [Rkremap::Evdev]
|
10
|
-
# @param
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def device
|
28
|
-
@evdev
|
29
|
-
end
|
30
|
-
|
31
|
-
def code
|
32
|
-
@code ||= key.code
|
33
|
-
end
|
34
|
-
|
35
|
-
def value
|
36
|
-
key.value
|
11
|
+
# @param time [Time]
|
12
|
+
# @param type [Integer]
|
13
|
+
# @param code [Integer]
|
14
|
+
# @param value [Integer]
|
15
|
+
def initialize(evdev, time, type, code, value)
|
16
|
+
@device = evdev
|
17
|
+
@time = time
|
18
|
+
@ev_type = type
|
19
|
+
@code = code
|
20
|
+
@value = value
|
21
|
+
@app = nil
|
22
|
+
@skipped = false
|
23
|
+
end
|
24
|
+
|
25
|
+
def inspect
|
26
|
+
"#<Rkremap::Event: #{code}(#{CODE_KEY[code]}) #{value} #{device.inspect}>"
|
37
27
|
end
|
38
28
|
|
39
29
|
def type
|
data/lib/rkremap/version.rb
CHANGED
data/lib/rkremap.rb
CHANGED
@@ -76,9 +76,7 @@ class Rkremap
|
|
76
76
|
event = @evdev_list.read_event
|
77
77
|
if event.ev_type != EV_KEY
|
78
78
|
if event.device.grab?
|
79
|
-
event.
|
80
|
-
@uinput.write_event(r.type, r.code, r.value)
|
81
|
-
end
|
79
|
+
@uinput.write_event(event.ev_type, event.code, event.value)
|
82
80
|
end
|
83
81
|
next
|
84
82
|
end
|
@@ -158,7 +156,6 @@ class Rkremap
|
|
158
156
|
# @param value [Integer] 0:release / 1:press / 2:repeat
|
159
157
|
def write_event(code, value)
|
160
158
|
@uinput.write_event(EV_KEY, code, value)
|
161
|
-
@uinput.write_event(EV_SYN, SYN_REPORT, 0)
|
162
159
|
end
|
163
160
|
|
164
161
|
class App
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rkremap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TOMITA Masahiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tmtms_timer
|