fusuma-plugin-remap 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fusuma/plugin/inputs/remap_keyboard_input.rb +6 -3
- data/lib/fusuma/plugin/inputs/remap_touchpad_input.rb +5 -3
- data/lib/fusuma/plugin/remap/keyboard_remapper.rb +6 -1
- data/lib/fusuma/plugin/remap/touchpad_remapper.rb +21 -2
- data/lib/fusuma/plugin/remap/uinput_touchpad.rb +4 -4
- data/lib/fusuma/plugin/remap/version.rb +1 -1
- 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: bf0c73f3292a88f1488fc06d1c45c5bca19250df7e257063dcc78dbd74a78fb6
|
4
|
+
data.tar.gz: a78d663ef4cf53629c6b0d9dec965b1494e782814691564f5ce917bb02262e6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c79bdd354f1188569afd8fe45d7b4e42b5d2463307c8ef26ed74191113d8b38a639ab7c846223a6d30821cc012bb82a1a3b17eeb5d61e8198eb8abe76b785c4
|
7
|
+
data.tar.gz: 3c915a96eb1f285c294e368f25390864534c3ed0ba792a42722083f9796cb3717042e45a8adea477363aa805e38a66996c49820f5aa88636659e72cf6a6485ba
|
@@ -18,8 +18,6 @@ module Fusuma
|
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
|
-
attr_reader :pid
|
22
|
-
|
23
21
|
def initialize
|
24
22
|
super
|
25
23
|
setup_remapper
|
@@ -39,12 +37,17 @@ module Fusuma
|
|
39
37
|
|
40
38
|
status = (data["status"] == 1) ? "pressed" : "released"
|
41
39
|
Events::Records::KeypressRecord.new(status: status, code: data["key"], layer: data["layer"])
|
40
|
+
rescue EOFError => e
|
41
|
+
MultiLogger.error "#{self.class.name}: #{e}"
|
42
|
+
MultiLogger.error "Shutdown fusuma process..."
|
43
|
+
Process.kill("TERM", Process.pid)
|
42
44
|
end
|
43
45
|
|
44
46
|
private
|
45
47
|
|
46
48
|
def setup_remapper
|
47
49
|
config = {
|
50
|
+
|
48
51
|
keyboard_name_patterns: config_params(:keyboard_name_patterns),
|
49
52
|
touchpad_name_patterns: config_params(:touchpad_name_patterns)
|
50
53
|
}
|
@@ -54,7 +57,7 @@ module Fusuma
|
|
54
57
|
# physical keyboard input event
|
55
58
|
@fusuma_reader, fusuma_writer = IO.pipe
|
56
59
|
|
57
|
-
|
60
|
+
fork do
|
58
61
|
layer_manager.writer.close
|
59
62
|
@fusuma_reader.close
|
60
63
|
remapper = Remap::KeyboardRemapper.new(
|
@@ -17,8 +17,6 @@ module Fusuma
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
attr_reader :pid
|
21
|
-
|
22
20
|
def initialize
|
23
21
|
super
|
24
22
|
setup_remapper
|
@@ -56,6 +54,10 @@ module Fusuma
|
|
56
54
|
end
|
57
55
|
|
58
56
|
Events::Records::GestureRecord.new(gesture: gesture, status: status, finger: finger, delta: nil)
|
57
|
+
rescue EOFError => e
|
58
|
+
MultiLogger.error "#{self.class.name}: #{e}"
|
59
|
+
MultiLogger.error "Shutdown fusuma process..."
|
60
|
+
Process.kill("TERM", Process.pid)
|
59
61
|
end
|
60
62
|
|
61
63
|
private
|
@@ -75,7 +77,7 @@ module Fusuma
|
|
75
77
|
# physical touchpad input event
|
76
78
|
@fusuma_reader, fusuma_writer = IO.pipe
|
77
79
|
|
78
|
-
|
80
|
+
fork do
|
79
81
|
# layer_manager.writer.close
|
80
82
|
@fusuma_reader.close
|
81
83
|
remapper = Remap::TouchpadRemapper.new(
|
@@ -92,7 +92,7 @@ module Fusuma
|
|
92
92
|
rescue EOFError => e # device is closed
|
93
93
|
MultiLogger.error "Device is closed: #{e.message}"
|
94
94
|
ensure
|
95
|
-
@destroy
|
95
|
+
@destroy&.call
|
96
96
|
end
|
97
97
|
|
98
98
|
private
|
@@ -302,10 +302,15 @@ module Fusuma
|
|
302
302
|
# If no device is found, it will wait for 3 seconds and try again
|
303
303
|
# @return [Array<Revdev::EventDevice>]
|
304
304
|
def select
|
305
|
+
displayed_no_keyboard = false
|
305
306
|
loop do
|
306
307
|
Fusuma::Device.reset # reset cache to get the latest device information
|
307
308
|
devices = Fusuma::Device.all.select { |d| Array(@names).any? { |name| d.name =~ /#{name}/ } }
|
308
309
|
if devices.empty?
|
310
|
+
unless displayed_no_keyboard
|
311
|
+
MultiLogger.warn "No keyboard found: #{@names}"
|
312
|
+
displayed_no_keyboard = true
|
313
|
+
end
|
309
314
|
wait_for_device
|
310
315
|
|
311
316
|
next
|
@@ -18,6 +18,8 @@ module Fusuma
|
|
18
18
|
@source_touchpad = source_touchpad # original touchpad
|
19
19
|
@fusuma_writer = fusuma_writer # write event to fusuma_input
|
20
20
|
@palm_detector ||= PalmDetection.new(source_touchpad)
|
21
|
+
|
22
|
+
set_trap
|
21
23
|
end
|
22
24
|
|
23
25
|
# TODO: grab touchpad events and remap them
|
@@ -125,6 +127,10 @@ module Fusuma
|
|
125
127
|
@fusuma_writer.write(data.to_msgpack)
|
126
128
|
end
|
127
129
|
end
|
130
|
+
rescue => e
|
131
|
+
MultiLogger.error "An error occurred: #{e.message}"
|
132
|
+
ensure
|
133
|
+
@destroy&.call
|
128
134
|
end
|
129
135
|
|
130
136
|
private
|
@@ -134,11 +140,24 @@ module Fusuma
|
|
134
140
|
end
|
135
141
|
|
136
142
|
def create_virtual_touchpad
|
137
|
-
MultiLogger.info "Create virtual
|
138
|
-
|
143
|
+
MultiLogger.info "Create virtual touchpad: #{VIRTUAL_TOUCHPAD_NAME}"
|
139
144
|
uinput.create_from_device(name: VIRTUAL_TOUCHPAD_NAME, device: @source_touchpad)
|
140
145
|
end
|
141
146
|
|
147
|
+
def set_trap
|
148
|
+
@destroy = lambda do
|
149
|
+
begin
|
150
|
+
uinput.destroy
|
151
|
+
rescue IOError
|
152
|
+
# already destroyed
|
153
|
+
end
|
154
|
+
exit 0
|
155
|
+
end
|
156
|
+
|
157
|
+
Signal.trap(:INT) { @destroy.call }
|
158
|
+
Signal.trap(:TERM) { @destroy.call }
|
159
|
+
end
|
160
|
+
|
142
161
|
# Detect palm touch
|
143
162
|
class PalmDetection
|
144
163
|
def initialize(touchpad)
|
@@ -109,10 +109,10 @@ class UinputTouchpad < Ruinput::UinputDevice
|
|
109
109
|
@file.ioctl UI_SET_EVBIT, Revdev::EV_ABS
|
110
110
|
Revdev::ABS_CNT.times do |i|
|
111
111
|
if touchpad_abs.include?(i)
|
112
|
-
puts "setting #{i} (#{Revdev::REVERSE_MAPS[:ABS][i]})"
|
112
|
+
# puts "setting #{i} (#{Revdev::REVERSE_MAPS[:ABS][i]})"
|
113
113
|
@file.ioctl UI_SET_ABSBIT, i
|
114
114
|
else
|
115
|
-
puts "skipping #{i} (#{Revdev::REVERSE_MAPS[:ABS][i]})"
|
115
|
+
# puts "skipping #{i} (#{Revdev::REVERSE_MAPS[:ABS][i]})"
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -126,10 +126,10 @@ class UinputTouchpad < Ruinput::UinputDevice
|
|
126
126
|
@file.ioctl UI_SET_EVBIT, Revdev::EV_REL
|
127
127
|
Revdev::REL_CNT.times do |i|
|
128
128
|
if touchpad_rels.include?(i)
|
129
|
-
puts "setting #{i} (#{Revdev::REVERSE_MAPS[:REL][i]})"
|
129
|
+
# puts "setting #{i} (#{Revdev::REVERSE_MAPS[:REL][i]})"
|
130
130
|
@file.ioctl UI_SET_RELBIT, i
|
131
131
|
else
|
132
|
-
puts "skipping #{i} (#{Revdev::REVERSE_MAPS[:REL][i]})"
|
132
|
+
# puts "skipping #{i} (#{Revdev::REVERSE_MAPS[:REL][i]})"
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fusuma-plugin-remap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iberianpig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fusuma
|