fusuma-plugin-remap 0.5.0 → 0.6.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb8fcbe6eb272ae081100e9faa67846308cc7a9adb4cfbff7af5b693ffbcbd3e
|
4
|
+
data.tar.gz: 310ff2f96642be97fda21211d8ca7ed87aa2b8682a2cf70797882c9168e4df0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97b927263c174f2ffc7edf3648510a77c34433523b58373aa4e533a21fe2c2198c181922352c1044717fabdc02d3a093b0a8e091ab0b3e6ba003970151395d67
|
7
|
+
data.tar.gz: 8adf8cb9f59083639f0439a5107a0c8afd7f386aaef572db8f6bb85589585aad8aa939f12613120ced49f100a67646379227b728bed9ee80ad12d171039cd460
|
data/README.md
CHANGED
@@ -65,12 +65,26 @@ remap:
|
|
65
65
|
SPACE: BTN_LEFT
|
66
66
|
```
|
67
67
|
|
68
|
-
## Emergency
|
68
|
+
## Emergency Stop Keybind for Virtual Keyboard
|
69
69
|
|
70
|
-
This
|
71
|
-
If you press following keybind, physical keyboard will be ungrabbed and Fusuma process will be terminated.
|
70
|
+
This plugin includes a special keybind for emergency stop. Pressing this key combination will ungrab the physical keyboard and terminate the Fusuma process. This feature is particularly useful in situations where the plugin or system becomes unresponsive.
|
72
71
|
|
73
|
-
|
72
|
+
### How to Use
|
73
|
+
To execute the emergency stop, press the following key combination(default):
|
74
|
+
- <kbd>RIGHTCTRL</kbd> → <kbd>LEFTCTRL</kbd>
|
75
|
+
|
76
|
+
### Configuration Example
|
77
|
+
You can configure the emergency stop key in your Fusuma configuration file (`~/.config/fusuma/config.yml`) as follows:
|
78
|
+
|
79
|
+
```yaml
|
80
|
+
plugin:
|
81
|
+
inputs:
|
82
|
+
remap_keyboard_input:
|
83
|
+
emergency_ungrab_keys: RIGHTCTRL+LEFTCTRL # keybind
|
84
|
+
```
|
85
|
+
|
86
|
+
This configuration allows you to specify which keys will trigger the emergency stop functionality.
|
87
|
+
It is important to verify this keybind to ensure a swift response during unexpected situations.
|
74
88
|
|
75
89
|
## Contributing
|
76
90
|
|
@@ -13,6 +13,7 @@ module Fusuma
|
|
13
13
|
|
14
14
|
def config_param_types
|
15
15
|
{
|
16
|
+
emergency_ungrab_keys: [String],
|
16
17
|
keyboard_name_patterns: [Array, String],
|
17
18
|
touchpad_name_patterns: [Array, String]
|
18
19
|
}
|
@@ -47,7 +48,7 @@ module Fusuma
|
|
47
48
|
|
48
49
|
def setup_remapper
|
49
50
|
config = {
|
50
|
-
|
51
|
+
emergency_ungrab_keys: config_params(:emergency_ungrab_keys),
|
51
52
|
keyboard_name_patterns: config_params(:keyboard_name_patterns),
|
52
53
|
touchpad_name_patterns: config_params(:touchpad_name_patterns)
|
53
54
|
}
|
@@ -103,9 +103,7 @@ module Fusuma
|
|
103
103
|
MultiLogger.info("Reload keyboards: #{source_keyboards.map(&:device_name)}")
|
104
104
|
|
105
105
|
set_trap(source_keyboards)
|
106
|
-
|
107
|
-
# it should stop other remappers
|
108
|
-
set_emergency_ungrab_keybinds("RIGHTCTRL", "LEFTCTRL")
|
106
|
+
set_emergency_ungrab_keys(@config[:emergency_ungrab_keys])
|
109
107
|
grab_keyboards(source_keyboards)
|
110
108
|
rescue => e
|
111
109
|
MultiLogger.error "Failed to reload keyboards: #{e.message}"
|
@@ -174,9 +172,9 @@ module Fusuma
|
|
174
172
|
wait_release_all_keys(keyboard)
|
175
173
|
begin
|
176
174
|
keyboard.grab
|
177
|
-
MultiLogger.info "Grabbed #{keyboard.device_name}"
|
175
|
+
MultiLogger.info "Grabbed keyboard: #{keyboard.device_name}"
|
178
176
|
rescue Errno::EBUSY
|
179
|
-
MultiLogger.error "Failed to grab #{keyboard.device_name}"
|
177
|
+
MultiLogger.error "Failed to grab keyboard: #{keyboard.device_name}"
|
180
178
|
end
|
181
179
|
end
|
182
180
|
end
|
@@ -205,14 +203,31 @@ module Fusuma
|
|
205
203
|
end
|
206
204
|
|
207
205
|
# Emergency stop keybind for virtual keyboard
|
208
|
-
def
|
209
|
-
|
210
|
-
|
211
|
-
|
206
|
+
def set_emergency_ungrab_keys(keybind_string)
|
207
|
+
keybinds = keybind_string&.split("+")
|
208
|
+
# TODO: Extract to a configuration file or make it optional
|
209
|
+
# it should stop other remappers
|
210
|
+
if keybinds&.size != 2
|
211
|
+
MultiLogger.error "Invalid emergency ungrab keybinds: #{keybinds}"
|
212
|
+
MultiLogger.error "Please set two keys separated by '+'"
|
213
|
+
MultiLogger.error <<~YAML
|
214
|
+
plugin:
|
215
|
+
inputs:
|
216
|
+
remap_keyboard_input:
|
217
|
+
emergency_ungrab_keys: RIGHTCTRL+LEFTCTRL
|
218
|
+
YAML
|
219
|
+
|
220
|
+
exit 1
|
221
|
+
end
|
222
|
+
|
223
|
+
MultiLogger.info "Emergency ungrab keybind: #{keybinds[0]}+#{keybinds[1]}"
|
224
|
+
|
225
|
+
first_keycode = find_code_from_key(keybinds[0])
|
226
|
+
second_keycode = find_code_from_key(keybinds[1])
|
212
227
|
|
213
228
|
@emergency_stop = lambda do |prev, current|
|
214
229
|
if (prev&.code == first_keycode && prev.value != 0) && (current.code == second_keycode && current.value != 0)
|
215
|
-
MultiLogger.info "Emergency ungrab keybind: #{
|
230
|
+
MultiLogger.info "Emergency ungrab keybind is pressed: #{keybinds[0]}+#{keybinds[1]}"
|
216
231
|
@destroy.call
|
217
232
|
end
|
218
233
|
end
|
@@ -278,7 +293,7 @@ module Fusuma
|
|
278
293
|
def released_all_keys?(device)
|
279
294
|
# key status if all bytes are 0, the key is not pressed
|
280
295
|
bytes = device.read_ioctl_with(Revdev::EVIOCGKEY)
|
281
|
-
bytes.unpack("C*").all?
|
296
|
+
bytes.unpack("C*").all?(0)
|
282
297
|
end
|
283
298
|
|
284
299
|
def wait_release_all_keys(device, &block)
|
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.6.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-09-
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fusuma
|