procon_bypass_man 0.1.5 → 0.1.9

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +41 -13
  3. data/.github/workflows/ruby.yml +34 -0
  4. data/.rubocop.yml +24 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +15 -0
  7. data/Gemfile +5 -0
  8. data/Gemfile.lock +75 -3
  9. data/README.md +22 -8
  10. data/Rakefile +10 -1
  11. data/Steepfile +39 -0
  12. data/bin/report_receive_server.rb +11 -0
  13. data/docs/setup_raspi.md +12 -7
  14. data/docs/setup_raspi.mitamae.rb +60 -0
  15. data/docs/setup_raspi_by_mitamae.md +14 -0
  16. data/examples/practical/app.rb +2 -2
  17. data/lib/procon_bypass_man/analog_stick_position.rb +14 -0
  18. data/lib/procon_bypass_man/boot_message.rb +40 -0
  19. data/lib/procon_bypass_man/bypass.rb +20 -7
  20. data/lib/procon_bypass_man/configuration/layer.rb +33 -3
  21. data/lib/procon_bypass_man/configuration/loader.rb +17 -16
  22. data/lib/procon_bypass_man/configuration/validator.rb +20 -19
  23. data/lib/procon_bypass_man/configuration.rb +24 -12
  24. data/lib/procon_bypass_man/device_connector.rb +14 -31
  25. data/lib/procon_bypass_man/error_reporter.rb +44 -0
  26. data/lib/procon_bypass_man/io_monitor.rb +7 -4
  27. data/lib/procon_bypass_man/on_memory_cache.rb +34 -0
  28. data/lib/procon_bypass_man/procon/analog_stick_cap.rb +88 -0
  29. data/lib/procon_bypass_man/procon/button_collection.rb +14 -6
  30. data/lib/procon_bypass_man/procon/debug_dumper.rb +17 -0
  31. data/lib/procon_bypass_man/procon/mode_registry.rb +2 -2
  32. data/lib/procon_bypass_man/procon/press_button_aware.rb +13 -0
  33. data/lib/procon_bypass_man/procon/pressed_button_helper.rb +1 -11
  34. data/lib/procon_bypass_man/procon/user_operation.rb +10 -3
  35. data/lib/procon_bypass_man/procon.rb +15 -1
  36. data/lib/procon_bypass_man/reporter.rb +42 -0
  37. data/lib/procon_bypass_man/runner.rb +39 -50
  38. data/lib/procon_bypass_man/uptime.rb +13 -0
  39. data/lib/procon_bypass_man/version.rb +1 -1
  40. data/lib/procon_bypass_man.rb +53 -2
  41. data/procon_bypass_man.gemspec +1 -1
  42. data/project_template/README.md +17 -0
  43. data/project_template/app.rb +20 -0
  44. data/project_template/setting.yml +35 -0
  45. data/project_template/systemd_units/pbm.service +13 -0
  46. data/sig/README.rb +4 -0
  47. data/sig/main.rbs +467 -0
  48. metadata +27 -8
  49. data/examples/pbm.service +0 -27
  50. data/examples/simple.rb +0 -13
data/sig/main.rbs ADDED
@@ -0,0 +1,467 @@
1
+ interface _Symolize
2
+ def to_sym: () -> ::Symbol
3
+ end
4
+
5
+ interface _Pluginable
6
+ def name: () -> _Symolize
7
+ def respond_to?: (::Symbol) -> bool
8
+ end
9
+
10
+ module ProconBypassMan
11
+ class ProConRejected < StandardError
12
+ end
13
+
14
+ class CouldNotLoadConfigError < StandardError
15
+ end
16
+
17
+ class FirstConnectionError < StandardError
18
+ end
19
+
20
+ class EternalConnectionError < StandardError
21
+ end
22
+
23
+ def self.configure: (?setting_path: untyped? setting_path) { () -> untyped } -> untyped
24
+
25
+ def self.run: (?setting_path: untyped? setting_path) { () -> untyped } -> untyped
26
+
27
+ def self.logger=: (untyped logger) -> untyped
28
+
29
+ # @return [Logger]
30
+ def self.logger: () -> untyped
31
+
32
+ def self.pid_path: () -> untyped
33
+
34
+ def self.reset!: () -> untyped
35
+
36
+ def self.root: () -> untyped
37
+
38
+ def self.root=: (untyped path) -> untyped
39
+
40
+ def self.digest_path: () -> ::String
41
+ end
42
+
43
+ class ProconBypassMan::Bypass
44
+ attr_accessor gadget: untyped
45
+
46
+ attr_accessor procon: untyped
47
+
48
+ attr_accessor monitor: untyped
49
+
50
+ def initialize: (gadget: untyped gadget, procon: untyped procon, monitor: untyped monitor) -> untyped
51
+
52
+ # ゆっくりでいい
53
+ def send_gadget_to_procon!: () -> (nil | untyped)
54
+
55
+ def send_procon_to_gadget!: () -> (nil | untyped)
56
+ end
57
+
58
+ class AnalogStickPosition
59
+ attr_accessor x: Integer
60
+ attr_accessor y: Integer
61
+
62
+ def initialize: (x: Integer, y: Integer) -> untyped
63
+ end
64
+
65
+ module ProconBypassMan
66
+ class Configuration
67
+ attr_accessor layers: untyped
68
+
69
+ attr_accessor setting_path: untyped
70
+
71
+ attr_accessor mode_plugins: untyped
72
+
73
+ attr_accessor macro_plugins: untyped
74
+
75
+ attr_accessor context: untyped
76
+
77
+ attr_accessor current_context_key: untyped
78
+
79
+ attr_accessor neutral_position: AnalogStickPosition
80
+
81
+ def self.instance: () -> untyped
82
+
83
+ def self.switch_new_context: (untyped key) { (untyped) -> untyped } -> untyped
84
+
85
+ def initialize: () -> untyped
86
+
87
+ MODES: ::Array[untyped]
88
+
89
+ def layer: (untyped direction, ?mode: (_Pluginable) mode) { () -> untyped } -> untyped
90
+
91
+ def install_mode_plugin: (untyped klass) -> untyped
92
+
93
+ def install_macro_plugin: (untyped klass) -> untyped
94
+
95
+ def prefix_keys_for_changing_layer: (untyped buttons) -> untyped
96
+
97
+ def prefix_keys: () -> untyped
98
+
99
+ def reset!: () -> untyped
100
+ end
101
+ end
102
+
103
+ module ProconBypassMan
104
+ class Configuration
105
+ class Layer
106
+ attr_accessor mode: untyped
107
+
108
+ attr_accessor flips: untyped
109
+
110
+ attr_accessor macros: untyped
111
+
112
+ attr_accessor remaps: untyped
113
+
114
+ def initialize: (?mode: ::Symbol mode) -> untyped
115
+
116
+ # @param [Symbol] button
117
+ def flip: (untyped button, ?if_pressed: bool if_pressed, ?force_neutral: untyped? force_neutral, ?flip_interval: untyped? flip_interval) -> untyped
118
+
119
+ PRESET_MACROS: ::Array[untyped]
120
+
121
+ def macro: (untyped name, if_pressed: untyped if_pressed) -> untyped
122
+
123
+ def remap: (untyped button, to: untyped to) -> untyped
124
+
125
+ # @return [Array]
126
+ def flip_buttons: () -> untyped
127
+
128
+ def instance_eval: ()?{ () -> nil } -> untyped
129
+ end
130
+ end
131
+ end
132
+
133
+ module ProconBypassMan
134
+ class Configuration
135
+ module Loader
136
+ def self.load: (setting_path: untyped setting_path) -> untyped
137
+
138
+ def self.reload_setting: () -> untyped
139
+ end
140
+ end
141
+ end
142
+
143
+ module ProconBypassMan
144
+ class Configuration
145
+ class Validator
146
+ def initialize: (untyped config) -> untyped
147
+
148
+ # @return [Boolean]
149
+ def valid?: () -> untyped
150
+
151
+ # @return [Boolean]
152
+ def invalid?: () -> untyped
153
+
154
+ # @return [Hash]
155
+ def errors: () -> untyped
156
+
157
+ private
158
+
159
+ def validate_config_of_button_lonely: () -> untyped
160
+
161
+ def validate_require_prefix_keys: () -> untyped
162
+
163
+ def validate_verify_button_existence: () -> untyped
164
+
165
+ def validate_flip_and_remap_are_hate_each_other: () -> untyped
166
+ end
167
+ end
168
+ end
169
+
170
+ class ProconBypassMan::DeviceConnector
171
+ class BytesMismatchError < StandardError
172
+ end
173
+
174
+ class Value
175
+ attr_accessor read_from: untyped
176
+
177
+ attr_accessor values: untyped
178
+
179
+ def initialize: (values: untyped values, read_from: untyped read_from) -> untyped
180
+ end
181
+
182
+ PROCON_PATH: ::String
183
+
184
+ PROCON2_PATH: ::String
185
+
186
+ # 画面で再接続ができたが状況は変わらない
187
+ def self.reset_connection!: () -> untyped
188
+
189
+ def self.connect: () -> ::Array[untyped]
190
+
191
+ def initialize: (?throw_error_if_timeout: bool throw_error_if_timeout, ?throw_error_if_mismatch: bool throw_error_if_mismatch, ?enable_at_exit: bool enable_at_exit) -> untyped
192
+
193
+ def add: (untyped values, read_from: untyped read_from) -> untyped
194
+
195
+ def drain_all: () -> untyped
196
+
197
+ # switchに任意の命令を入力して、switchから読み取る
198
+ def write_switch: (untyped data, ?only_write: bool only_write) -> untyped
199
+
200
+ def write_procon: (untyped data, ?only_write: bool only_write) -> untyped
201
+
202
+ def read_procon: (?only_read: bool only_read) -> untyped
203
+
204
+ def read_switch: (?only_read: bool only_read) -> untyped
205
+
206
+ def from_device: (untyped item) -> untyped
207
+
208
+ # fromの対になる
209
+ def to_device: (untyped item) -> untyped
210
+
211
+ def switch: () -> untyped
212
+
213
+ def procon: () -> untyped
214
+
215
+ def is_available_device?: (untyped path) -> (::FalseClass | ::TrueClass | untyped)
216
+
217
+ def to_bin: (untyped string) -> untyped
218
+
219
+ def init_devices: () -> untyped
220
+ end
221
+
222
+ module ProconBypassMan
223
+ class Counter
224
+ attr_accessor label: untyped
225
+
226
+ attr_accessor table: untyped
227
+
228
+ attr_accessor previous_table: untyped
229
+
230
+ def initialize: (label: untyped label) -> untyped
231
+
232
+ # アクティブなバケットは1つだけ
233
+ def record: (untyped event_name) -> untyped
234
+
235
+ def formated_previous_table: () -> ::String
236
+ end
237
+
238
+ module IOMonitor
239
+ def self.new: (label: untyped label) -> untyped
240
+
241
+ # @return [Array<Counter>]
242
+ def self.targets: () -> untyped
243
+
244
+ # ここで集計する
245
+ def self.start!: () -> untyped
246
+
247
+ def self.reset!: () -> untyped
248
+ end
249
+ end
250
+
251
+ class ProconBypassMan::Processor
252
+ # @return [String] binary
253
+ def initialize: (untyped binary) -> untyped
254
+
255
+ # @return [String] 加工後の入力データ
256
+ def process: () -> untyped
257
+ end
258
+
259
+ class ProconBypassMan::Procon
260
+ attr_accessor user_operation: untyped
261
+
262
+ def self.reset!: () -> untyped
263
+
264
+ def initialize: (untyped binary) -> untyped
265
+
266
+ def status: () -> untyped
267
+
268
+ def ongoing_macro: () -> untyped
269
+
270
+ def ongoing_mode: () -> untyped
271
+
272
+ def current_layer_key: () -> untyped
273
+
274
+ def current_layer: () -> untyped
275
+
276
+ def apply!: () -> (nil | untyped)
277
+
278
+ # @return [String<binary>]
279
+ def to_binary: () -> untyped
280
+
281
+ private
282
+
283
+ def method_missing: (untyped name) -> untyped
284
+ end
285
+
286
+ class ProconBypassMan::Procon::ButtonCollection
287
+ class Button
288
+ attr_accessor byte_position: untyped
289
+
290
+ attr_accessor bit_position: untyped
291
+
292
+ def initialize: (untyped key) -> untyped
293
+ end
294
+
295
+ # ) ZR R SR(right) SL(right) A B X Y
296
+ # ) Grip (none) Cap Home ThumbL ThumbR + -
297
+ # ) ZL L SL(left) SR(left) Left Right Up Down
298
+ # ) analog[0]
299
+ # ) analog[1]
300
+ # ) analog[2]
301
+ # ) analog[3]
302
+ # ) analog[4]
303
+ # ) analog[5]
304
+ BYTES_MAP: untyped
305
+
306
+ BUTTONS_MAP: untyped
307
+
308
+ BUTTONS: untyped
309
+
310
+ def self.load: (untyped button_key) -> untyped
311
+ end
312
+
313
+ class ProconBypassMan::Procon
314
+ module Data
315
+ NO_ACTION: untyped
316
+ end
317
+ end
318
+
319
+ class ProconBypassMan::Procon
320
+ class FlipCache
321
+ def self.fetch: (key: untyped key, expires_in: untyped expires_in) { () -> untyped } -> untyped
322
+
323
+ # for testing
324
+ def self.reset!: () -> untyped
325
+ end
326
+ end
327
+
328
+ module ProconBypassMan::Procon::LayerChangeable
329
+ def next_layer_key: () -> untyped
330
+
331
+ def change_layer?: () -> untyped
332
+
333
+ def pressed_next_layer?: () -> untyped
334
+ end
335
+
336
+ class ProconBypassMan::Procon::MacroRegistry
337
+ class Macro
338
+ attr_accessor name: untyped
339
+
340
+ attr_accessor steps: untyped
341
+
342
+ def initialize: (name: untyped name, steps: untyped steps) -> untyped
343
+
344
+ def next_step: () -> untyped
345
+
346
+ def finished?: () -> untyped
347
+
348
+ def ongoing?: () -> untyped
349
+ end
350
+
351
+ PRESETS: ::Hash[untyped, untyped]
352
+
353
+ def self.install_plugin: (untyped klass) -> untyped
354
+
355
+ def self.load: (untyped name) -> untyped
356
+
357
+ def self.reset!: () -> untyped
358
+
359
+ def self.plugins: () -> untyped
360
+ end
361
+
362
+ class ProconBypassMan::Procon::ModeRegistry
363
+ class Mode
364
+ attr_accessor name: untyped
365
+
366
+ attr_accessor binaries: untyped
367
+
368
+ attr_accessor source_binaries: untyped
369
+
370
+ def initialize: (name: untyped name, binaries: untyped binaries) -> untyped
371
+
372
+ def next_binary: () -> untyped
373
+ end
374
+
375
+ PRESETS: ::Hash[untyped, untyped]
376
+
377
+ def self.install_plugin: (untyped klass) -> untyped
378
+
379
+ def self.load: (untyped name) -> untyped
380
+
381
+ def self.reset!: () -> untyped
382
+
383
+ def self.plugins: () -> untyped
384
+ end
385
+
386
+ module ProconBypassMan::Procon::PushedButtonHelper
387
+ module Static
388
+ def pressed_button?: (untyped button) -> untyped
389
+ end
390
+
391
+ module Dynamic
392
+ def compile_if_not_compile_yet!: () -> untyped
393
+ end
394
+ end
395
+
396
+ class ProconBypassMan::Procon
397
+ class UserOperation
398
+ include LayerChangeable
399
+
400
+ include PushedButtonHelper::Static
401
+
402
+ extend PushedButtonHelper::Dynamic
403
+
404
+ attr_reader binary: untyped
405
+
406
+ def initialize: (untyped binary) -> untyped
407
+
408
+ ZERO_BIT: untyped
409
+
410
+ ASCII_ENCODING: ::String
411
+
412
+ # @depilicate
413
+ def binary=: (untyped binary) -> untyped
414
+
415
+ def set_no_action!: () -> untyped
416
+
417
+ def unpress_button: (untyped button) -> untyped
418
+
419
+ def press_button: (untyped button) -> untyped
420
+
421
+ def press_button_only: (untyped button) -> untyped
422
+
423
+ def merge: (target_binary: untyped target_binary) -> untyped
424
+ end
425
+ end
426
+
427
+ class ProconBypassMan::Runner
428
+ class InterruptForRestart < StandardError
429
+ end
430
+
431
+ def initialize: () -> untyped
432
+
433
+ def run: () -> untyped
434
+
435
+ private
436
+
437
+ def main_loop: () -> untyped
438
+
439
+ def first_negotiation: () -> untyped
440
+
441
+ def handle_signal: (untyped sig) -> untyped
442
+
443
+ # @return [void]
444
+ def print_booted_message: () -> untyped
445
+ end
446
+
447
+ module ProconBypassMan
448
+ class Timer
449
+ class Timeout < StandardError
450
+ end
451
+
452
+ # 5秒後がタイムアウト
453
+ def initialize: (?timeout: untyped timeout) -> untyped
454
+
455
+ def throw_if_timeout!: () -> untyped
456
+ end
457
+ end
458
+
459
+ module ProconBypassMan
460
+ class Uptime
461
+ def self.from_boot: () -> untyped
462
+ end
463
+ end
464
+
465
+ module ProconBypassMan
466
+ VERSION: ::String
467
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procon_bypass_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-29 00:00:00.000000000 Z
11
+ date: 2021-10-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: extension for Nintendo Switch Pro Controller
14
14
  email:
@@ -18,8 +18,10 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - ".circleci/config.yml"
21
+ - ".github/workflows/ruby.yml"
21
22
  - ".gitignore"
22
23
  - ".rspec"
24
+ - ".rubocop.yml"
23
25
  - ".ruby-version"
24
26
  - CHANGELOG.md
25
27
  - Gemfile
@@ -27,42 +29,59 @@ files:
27
29
  - LICENSE.txt
28
30
  - README.md
29
31
  - Rakefile
32
+ - Steepfile
30
33
  - bin/console
34
+ - bin/report_receive_server.rb
31
35
  - bin/setup
32
36
  - docs/how_to_connect_procon.md
33
37
  - docs/setup_raspi.md
34
- - examples/pbm.service
38
+ - docs/setup_raspi.mitamae.rb
39
+ - docs/setup_raspi_by_mitamae.md
35
40
  - examples/practical/app.rb
36
41
  - examples/practical/setting.yml
37
- - examples/simple.rb
38
42
  - lib/procon_bypass_man.rb
43
+ - lib/procon_bypass_man/analog_stick_position.rb
44
+ - lib/procon_bypass_man/boot_message.rb
39
45
  - lib/procon_bypass_man/bypass.rb
40
46
  - lib/procon_bypass_man/configuration.rb
41
47
  - lib/procon_bypass_man/configuration/layer.rb
42
48
  - lib/procon_bypass_man/configuration/loader.rb
43
49
  - lib/procon_bypass_man/configuration/validator.rb
44
50
  - lib/procon_bypass_man/device_connector.rb
51
+ - lib/procon_bypass_man/error_reporter.rb
45
52
  - lib/procon_bypass_man/io_monitor.rb
53
+ - lib/procon_bypass_man/on_memory_cache.rb
46
54
  - lib/procon_bypass_man/processor.rb
47
55
  - lib/procon_bypass_man/procon.rb
56
+ - lib/procon_bypass_man/procon/analog_stick_cap.rb
48
57
  - lib/procon_bypass_man/procon/button_collection.rb
49
58
  - lib/procon_bypass_man/procon/data.rb
59
+ - lib/procon_bypass_man/procon/debug_dumper.rb
50
60
  - lib/procon_bypass_man/procon/flip_cache.rb
51
61
  - lib/procon_bypass_man/procon/layer_changeable.rb
52
62
  - lib/procon_bypass_man/procon/macro_registry.rb
53
63
  - lib/procon_bypass_man/procon/mode_registry.rb
64
+ - lib/procon_bypass_man/procon/press_button_aware.rb
54
65
  - lib/procon_bypass_man/procon/pressed_button_helper.rb
55
66
  - lib/procon_bypass_man/procon/user_operation.rb
67
+ - lib/procon_bypass_man/reporter.rb
56
68
  - lib/procon_bypass_man/runner.rb
57
69
  - lib/procon_bypass_man/timer.rb
70
+ - lib/procon_bypass_man/uptime.rb
58
71
  - lib/procon_bypass_man/version.rb
59
72
  - procon_bypass_man.gemspec
60
- homepage: https://github.com/splaspla-hacker/procon_bypass_man
73
+ - project_template/README.md
74
+ - project_template/app.rb
75
+ - project_template/setting.yml
76
+ - project_template/systemd_units/pbm.service
77
+ - sig/README.rb
78
+ - sig/main.rbs
79
+ homepage: https://github.com/splaplapla/procon_bypass_man
61
80
  licenses:
62
81
  - MIT
63
82
  metadata:
64
- homepage_uri: https://github.com/splaspla-hacker/procon_bypass_man
65
- source_code_uri: https://github.com/splaspla-hacker/procon_bypass_man
83
+ homepage_uri: https://github.com/splaplapla/procon_bypass_man
84
+ source_code_uri: https://github.com/splaplapla/procon_bypass_man
66
85
  post_install_message:
67
86
  rdoc_options: []
68
87
  require_paths:
@@ -78,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
97
  - !ruby/object:Gem::Version
79
98
  version: '0'
80
99
  requirements: []
81
- rubygems_version: 3.2.15
100
+ rubygems_version: 3.2.22
82
101
  signing_key:
83
102
  specification_version: 4
84
103
  summary: extension for Nintendo Switch Pro Controller
data/examples/pbm.service DELETED
@@ -1,27 +0,0 @@
1
- # sudo ln -s /home/pi/src/procon_bypass_man/examples/pbm.service /etc/systemd/system/pbm.service
2
- # Usage:
3
- # systemctl daemon-reload
4
- # systemctl enable pbm.service
5
- # systemctl start pbm.service
6
- # systemctl status pbm.service
7
- # systemctl restart pbm.service
8
- # Debug:
9
- # journalctl -xe -f
10
- # TODO:
11
- # do not make PIDFILE
12
-
13
- [Unit]
14
- Description=PBM
15
- # After=network-online.target
16
- After=network.target
17
-
18
- [Service]
19
- Type=simple
20
- # PIDFile=/home/pi/src/procon_bypass_man/pbm_pid
21
- # WatchdogSec=60
22
- WorkingDirectory=/home/pi/src/procon_bypass_man
23
- ExecStart=/home/pi/.rbenv/versions/3.0.1/bin/ruby examples/practical/app.rb
24
- Restart=always
25
-
26
- [Install]
27
- WantedBy=multi-user.target
data/examples/simple.rb DELETED
@@ -1,13 +0,0 @@
1
- ProconBypassMan.run do
2
- prefix_keys_for_changing_layer [:zr, :r, :zl, :l]
3
-
4
- layer :up, mode: :manual do
5
- flip :zr, if_pressed: :zr
6
- end
7
- layer :right
8
- layer :left
9
- layer :down do
10
- flip :zl
11
- end
12
- end
13
-