procon_bypass_man 0.1.8 → 0.1.12

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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +3 -2
  3. data/.github/workflows/ruby.yml +5 -4
  4. data/.gitignore +5 -0
  5. data/.rubocop.yml +2 -0
  6. data/.ruby-version +1 -1
  7. data/CHANGELOG.md +18 -1
  8. data/Gemfile +4 -0
  9. data/Gemfile.lock +53 -2
  10. data/README.md +14 -8
  11. data/Steepfile +39 -0
  12. data/bin/console +4 -0
  13. data/bin/dev_api_server.rb +18 -0
  14. data/docs/setup_raspi.mitamae.rb +12 -0
  15. data/lib/procon_bypass_man/background/has_server_pool.rb +54 -0
  16. data/lib/procon_bypass_man/background/http_client.rb +70 -0
  17. data/lib/procon_bypass_man/background/job_performer.rb +16 -0
  18. data/lib/procon_bypass_man/background/job_runnable.rb +16 -0
  19. data/lib/procon_bypass_man/background/job_runner.rb +44 -0
  20. data/lib/procon_bypass_man/background/jobs/base_job.rb +12 -0
  21. data/lib/procon_bypass_man/background/jobs/report_boot_job.rb +10 -0
  22. data/lib/procon_bypass_man/background/jobs/report_error_job.rb +10 -0
  23. data/lib/procon_bypass_man/background/jobs/report_heartbeat_job.rb +10 -0
  24. data/lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb +18 -0
  25. data/lib/procon_bypass_man/background/jobs/report_reload_config_job.rb +10 -0
  26. data/lib/procon_bypass_man/background.rb +10 -0
  27. data/lib/procon_bypass_man/boot_message.rb +42 -0
  28. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/layer.rb +50 -4
  29. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/loader.rb +12 -11
  30. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/validator.rb +1 -1
  31. data/lib/procon_bypass_man/buttons_setting_configuration.rb +101 -0
  32. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +36 -0
  33. data/lib/procon_bypass_man/bypass.rb +61 -29
  34. data/lib/procon_bypass_man/callbacks.rb +70 -0
  35. data/lib/procon_bypass_man/commands/connect_device_command.rb +11 -0
  36. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +9 -0
  37. data/lib/procon_bypass_man/commands/send_error_command.rb +18 -0
  38. data/lib/procon_bypass_man/commands/send_reload_config_event_command.rb +10 -0
  39. data/lib/procon_bypass_man/commands/write_device_id_command.rb +11 -0
  40. data/lib/procon_bypass_man/commands/write_session_id_command.rb +13 -0
  41. data/lib/procon_bypass_man/commands.rb +6 -0
  42. data/lib/procon_bypass_man/configuration.rb +92 -67
  43. data/lib/procon_bypass_man/device_connector.rb +11 -29
  44. data/lib/procon_bypass_man/io_monitor.rb +16 -8
  45. data/lib/procon_bypass_man/on_memory_cache.rb +34 -0
  46. data/lib/procon_bypass_man/procon/analog_stick.rb +31 -0
  47. data/lib/procon_bypass_man/procon/analog_stick_cap.rb +65 -0
  48. data/lib/procon_bypass_man/procon/button_collection.rb +15 -6
  49. data/lib/procon_bypass_man/procon/{data.rb → consts.rb} +1 -1
  50. data/lib/procon_bypass_man/procon/layer_changer.rb +40 -0
  51. data/lib/procon_bypass_man/procon/macro_registry.rb +2 -2
  52. data/lib/procon_bypass_man/procon/mode_registry.rb +4 -4
  53. data/lib/procon_bypass_man/procon/press_button_aware.rb +13 -0
  54. data/lib/procon_bypass_man/procon/user_operation.rb +21 -16
  55. data/lib/procon_bypass_man/procon.rb +23 -9
  56. data/lib/procon_bypass_man/procon_reader.rb +31 -0
  57. data/lib/procon_bypass_man/runner.rb +43 -64
  58. data/lib/procon_bypass_man/uptime.rb +14 -2
  59. data/lib/procon_bypass_man/version.rb +1 -1
  60. data/lib/procon_bypass_man.rb +38 -43
  61. data/project_template/README.md +1 -1
  62. data/project_template/app.rb +7 -5
  63. data/project_template/systemd_units/pbm_web.service +11 -0
  64. data/project_template/web.rb +16 -0
  65. data/sig/README.rb +4 -0
  66. data/sig/main.rbs +505 -0
  67. metadata +42 -11
  68. data/examples/practical/app.rb +0 -21
  69. data/examples/practical/setting.yml +0 -24
  70. data/lib/procon_bypass_man/procon/layer_changeable.rb +0 -28
  71. data/lib/procon_bypass_man/procon/pressed_button_helper.rb +0 -25
data/sig/main.rbs ADDED
@@ -0,0 +1,505 @@
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 CouldNotLoadConfigError < StandardError
12
+ end
13
+
14
+ class FirstConnectionError < StandardError
15
+ end
16
+
17
+ class EternalConnectionError < StandardError
18
+ end
19
+
20
+ def self.configure: (?setting_path: untyped? setting_path) { () -> untyped } -> untyped
21
+
22
+ def self.run: (?setting_path: untyped? setting_path) { () -> untyped } -> untyped
23
+
24
+ def self.logger=: (untyped logger) -> untyped
25
+
26
+ # @return [Logger]
27
+ def self.logger: () -> untyped
28
+
29
+ def self.pid_path: () -> untyped
30
+
31
+ def self.reset!: () -> untyped
32
+
33
+ def self.root: () -> untyped
34
+
35
+ def self.root=: (untyped path) -> untyped
36
+
37
+ def self.digest_path: () -> ::String
38
+ end
39
+
40
+ class ProconBypassMan::Bypass
41
+ attr_accessor gadget: untyped
42
+
43
+ attr_accessor procon: untyped
44
+
45
+ attr_accessor monitor: untyped
46
+
47
+ def initialize: (gadget: untyped gadget, procon: untyped procon, monitor: untyped monitor) -> untyped
48
+
49
+ # ゆっくりでいい
50
+ def send_gadget_to_procon!: () -> (nil | untyped)
51
+
52
+ def send_procon_to_gadget!: () -> (nil | untyped)
53
+ end
54
+
55
+ class AnalogStickPosition
56
+ attr_accessor x: Integer
57
+ attr_accessor y: Integer
58
+
59
+ def initialize: (x: Integer, y: Integer) -> untyped
60
+ end
61
+
62
+ module ProconBypassMan
63
+ class ButtonsSettingConfiguration
64
+ attr_accessor layers: untyped
65
+
66
+ attr_accessor setting_path: untyped
67
+
68
+ attr_accessor mode_plugins: untyped
69
+
70
+ attr_accessor macro_plugins: untyped
71
+
72
+ attr_accessor context: untyped
73
+
74
+ attr_accessor current_context_key: untyped
75
+
76
+ attr_accessor neutral_position: AnalogStickPosition
77
+
78
+ def self.instance: () -> untyped
79
+
80
+ def self.switch_new_context: (untyped key) { (untyped) -> untyped } -> untyped
81
+
82
+ def initialize: () -> untyped
83
+
84
+ MODES: ::Array[untyped]
85
+
86
+ def layer: (untyped direction, ?mode: (_Pluginable) mode) { () -> untyped } -> untyped
87
+
88
+ def install_mode_plugin: (untyped klass) -> untyped
89
+
90
+ def install_macro_plugin: (untyped klass) -> untyped
91
+
92
+ def prefix_keys_for_changing_layer: (untyped buttons) -> untyped
93
+
94
+ def prefix_keys: () -> untyped
95
+
96
+ def reset!: () -> untyped
97
+ end
98
+ end
99
+
100
+ module ProconBypassMan
101
+ class ButtonsSettingConfiguration
102
+ class Layer
103
+ attr_accessor mode: untyped
104
+
105
+ attr_accessor flips: untyped
106
+
107
+ attr_accessor macros: untyped
108
+
109
+ attr_accessor remaps: untyped
110
+
111
+ def initialize: (?mode: ::Symbol mode) -> untyped
112
+
113
+ # @param [Symbol] button
114
+ def flip: (untyped button, ?if_pressed: bool if_pressed, ?force_neutral: untyped? force_neutral, ?flip_interval: untyped? flip_interval) -> untyped
115
+
116
+ PRESET_MACROS: ::Array[untyped]
117
+
118
+ def macro: (untyped name, if_pressed: untyped if_pressed) -> untyped
119
+
120
+ def remap: (untyped button, to: untyped to) -> untyped
121
+
122
+ # @return [Array]
123
+ def flip_buttons: () -> untyped
124
+
125
+ def instance_eval: ()?{ () -> nil } -> untyped
126
+ end
127
+ end
128
+ end
129
+
130
+ module ProconBypassMan
131
+ class ButtonsSettingConfiguration
132
+ module Loader
133
+ def self.load: (setting_path: untyped setting_path) -> untyped
134
+
135
+ def self.reload_setting: () -> untyped
136
+ end
137
+ end
138
+ end
139
+
140
+ module ProconBypassMan
141
+ class ButtonsSettingConfiguration
142
+ class Validator
143
+ def initialize: (untyped config) -> untyped
144
+
145
+ # @return [Boolean]
146
+ def valid?: () -> untyped
147
+
148
+ # @return [Boolean]
149
+ def invalid?: () -> untyped
150
+
151
+ # @return [Hash]
152
+ def errors: () -> untyped
153
+
154
+ private
155
+
156
+ def validate_config_of_button_lonely: () -> untyped
157
+
158
+ def validate_require_prefix_keys: () -> untyped
159
+
160
+ def validate_verify_button_existence: () -> untyped
161
+
162
+ def validate_flip_and_remap_are_hate_each_other: () -> untyped
163
+ end
164
+ end
165
+ end
166
+
167
+ class ProconBypassMan::Configuration
168
+ module ClassMethods
169
+ def root: () -> untyped
170
+
171
+ def logger: () -> untyped
172
+
173
+ def error_logger: () -> untyped
174
+
175
+ def pid_path: () -> untyped
176
+
177
+ def digest_path: () -> untyped
178
+
179
+ def cache: () -> untyped
180
+
181
+ def config: () -> untyped
182
+ end
183
+
184
+ attr_reader api_server: untyped
185
+
186
+ attr_accessor enable_critical_error_logging: untyped
187
+
188
+ def root=: (untyped path) -> untyped
189
+
190
+ def root: () -> untyped
191
+
192
+ def api_server=: (untyped api_server) -> untyped
193
+
194
+ def logger=: (untyped logger) -> untyped
195
+
196
+ def logger: () -> untyped
197
+
198
+ def error_logger: () -> untyped
199
+
200
+ def digest_path: () -> ::String
201
+
202
+ # @return [String] pbm-webの接続先
203
+ def internal_api_servers: () -> untyped
204
+ end
205
+
206
+
207
+ class ProconBypassMan::DeviceConnector
208
+ class BytesMismatchError < StandardError
209
+ end
210
+
211
+ class Value
212
+ attr_accessor read_from: untyped
213
+
214
+ attr_accessor values: untyped
215
+
216
+ def initialize: (values: untyped values, read_from: untyped read_from) -> untyped
217
+ end
218
+
219
+ PROCON_PATH: ::String
220
+
221
+ PROCON2_PATH: ::String
222
+
223
+ # 画面で再接続ができたが状況は変わらない
224
+ def self.reset_connection!: () -> untyped
225
+
226
+ def self.connect: () -> ::Array[untyped]
227
+
228
+ 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
229
+
230
+ def add: (untyped values, read_from: untyped read_from) -> untyped
231
+
232
+ def drain_all: () -> untyped
233
+
234
+ # switchに任意の命令を入力して、switchから読み取る
235
+ def write_switch: (untyped data, ?only_write: bool only_write) -> untyped
236
+
237
+ def write_procon: (untyped data, ?only_write: bool only_write) -> untyped
238
+
239
+ def read_procon: (?only_read: bool only_read) -> untyped
240
+
241
+ def read_switch: (?only_read: bool only_read) -> untyped
242
+
243
+ def from_device: (untyped item) -> untyped
244
+
245
+ # fromの対になる
246
+ def to_device: (untyped item) -> untyped
247
+
248
+ def switch: () -> untyped
249
+
250
+ def procon: () -> untyped
251
+
252
+ def is_available_device?: (untyped path) -> (::FalseClass | ::TrueClass | untyped)
253
+
254
+ def to_bin: (untyped string) -> untyped
255
+
256
+ def init_devices: () -> untyped
257
+ end
258
+
259
+ module ProconBypassMan
260
+ class Counter
261
+ attr_accessor label: untyped
262
+
263
+ attr_accessor table: untyped
264
+
265
+ attr_accessor previous_table: untyped
266
+
267
+ def initialize: (label: untyped label) -> untyped
268
+
269
+ # アクティブなバケットは1つだけ
270
+ def record: (untyped event_name) -> untyped
271
+
272
+ def formated_previous_table: () -> ::String
273
+ end
274
+
275
+ module IOMonitor
276
+ def self.new: (label: untyped label) -> untyped
277
+
278
+ # @return [Array<Counter>]
279
+ def self.targets: () -> untyped
280
+
281
+ # ここで集計する
282
+ def self.start!: () -> untyped
283
+
284
+ def self.reset!: () -> untyped
285
+ end
286
+ end
287
+
288
+ class ProconBypassMan::Processor
289
+ # @return [String] binary
290
+ def initialize: (untyped binary) -> untyped
291
+
292
+ # @return [String] 加工後の入力データ
293
+ def process: () -> untyped
294
+ end
295
+
296
+ class ProconBypassMan::Procon
297
+ attr_accessor user_operation: untyped
298
+
299
+ def self.reset!: () -> untyped
300
+
301
+ def initialize: (untyped binary) -> untyped
302
+
303
+ def status: () -> untyped
304
+
305
+ def ongoing_macro: () -> untyped
306
+
307
+ def ongoing_mode: () -> untyped
308
+
309
+ def current_layer_key: () -> untyped
310
+
311
+ def current_layer: () -> untyped
312
+
313
+ def apply!: () -> (nil | untyped)
314
+
315
+ # @return [String<binary>]
316
+ def to_binary: () -> untyped
317
+
318
+ private
319
+
320
+ def method_missing: (untyped name) -> untyped
321
+ end
322
+
323
+ class ProconBypassMan::Procon::ButtonCollection
324
+ class Button
325
+ attr_accessor byte_position: untyped
326
+
327
+ attr_accessor bit_position: untyped
328
+
329
+ def initialize: (untyped key) -> untyped
330
+ end
331
+
332
+ # ) ZR R SR(right) SL(right) A B X Y
333
+ # ) Grip (none) Cap Home ThumbL ThumbR + -
334
+ # ) ZL L SL(left) SR(left) Left Right Up Down
335
+ # ) analog[0]
336
+ # ) analog[1]
337
+ # ) analog[2]
338
+ # ) analog[3]
339
+ # ) analog[4]
340
+ # ) analog[5]
341
+ BYTES_MAP: untyped
342
+
343
+ BUTTONS_MAP: untyped
344
+
345
+ BUTTONS: untyped
346
+
347
+ def self.load: (untyped button_key) -> untyped
348
+ end
349
+
350
+ class ProconBypassMan::Procon
351
+ module Data
352
+ NO_ACTION: untyped
353
+ end
354
+ end
355
+
356
+ class ProconBypassMan::Procon
357
+ class FlipCache
358
+ def self.fetch: (key: untyped key, expires_in: untyped expires_in) { () -> untyped } -> untyped
359
+
360
+ # for testing
361
+ def self.reset!: () -> untyped
362
+ end
363
+ end
364
+
365
+ module ProconBypassMan::Procon::LayerChangeable
366
+ def next_layer_key: () -> untyped
367
+
368
+ def change_layer?: () -> untyped
369
+
370
+ def pressed_next_layer?: () -> untyped
371
+ end
372
+
373
+ class ProconBypassMan::Procon::MacroRegistry
374
+ class Macro
375
+ attr_accessor name: untyped
376
+
377
+ attr_accessor steps: untyped
378
+
379
+ def initialize: (name: untyped name, steps: untyped steps) -> untyped
380
+
381
+ def next_step: () -> untyped
382
+
383
+ def finished?: () -> untyped
384
+
385
+ def ongoing?: () -> untyped
386
+ end
387
+
388
+ PRESETS: ::Hash[untyped, untyped]
389
+
390
+ def self.install_plugin: (untyped klass) -> untyped
391
+
392
+ def self.load: (untyped name) -> untyped
393
+
394
+ def self.reset!: () -> untyped
395
+
396
+ def self.plugins: () -> untyped
397
+ end
398
+
399
+ class ProconBypassMan::Procon::ModeRegistry
400
+ class Mode
401
+ attr_accessor name: untyped
402
+
403
+ attr_accessor binaries: untyped
404
+
405
+ attr_accessor source_binaries: untyped
406
+
407
+ def initialize: (name: untyped name, binaries: untyped binaries) -> untyped
408
+
409
+ def next_binary: () -> untyped
410
+ end
411
+
412
+ PRESETS: ::Hash[untyped, untyped]
413
+
414
+ def self.install_plugin: (untyped klass) -> untyped
415
+
416
+ def self.load: (untyped name) -> untyped
417
+
418
+ def self.reset!: () -> untyped
419
+
420
+ def self.plugins: () -> untyped
421
+ end
422
+
423
+ module ProconBypassMan::Procon::PressedButtonHelper
424
+ module Static
425
+ def pressed_button?: (untyped button) -> untyped
426
+ end
427
+ end
428
+
429
+ class ProconBypassMan::Procon
430
+ class UserOperation
431
+ include LayerChangeable
432
+
433
+ include PressedButtonHelper::Static
434
+
435
+ attr_reader binary: untyped
436
+
437
+ def initialize: (untyped binary) -> untyped
438
+
439
+ ZERO_BIT: untyped
440
+
441
+ ASCII_ENCODING: ::String
442
+
443
+ # @depilicate
444
+ def binary=: (untyped binary) -> untyped
445
+
446
+ def set_no_action!: () -> untyped
447
+
448
+ def unpress_button: (untyped button) -> untyped
449
+
450
+ def press_button: (untyped button) -> untyped
451
+
452
+ def press_button_only: (untyped button) -> untyped
453
+
454
+ def merge: (target_binary: untyped target_binary) -> untyped
455
+ end
456
+ end
457
+
458
+ class ProconBypassMan::Runner
459
+ class InterruptForRestart < StandardError
460
+ end
461
+
462
+ def initialize: () -> untyped
463
+
464
+ def run: () -> untyped
465
+
466
+ private
467
+
468
+ def main_loop: () -> untyped
469
+
470
+ def first_negotiation: () -> untyped
471
+
472
+ def handle_signal: (untyped sig) -> untyped
473
+
474
+ # @return [void]
475
+ def print_booted_message: () -> untyped
476
+ end
477
+
478
+ module ProconBypassMan
479
+ class Timer
480
+ class Timeout < StandardError
481
+ end
482
+
483
+ # 5秒後がタイムアウト
484
+ def initialize: (?timeout: untyped timeout) -> untyped
485
+
486
+ def throw_if_timeout!: () -> untyped
487
+ end
488
+ end
489
+
490
+ module ProconBypassMan
491
+ class Uptime
492
+ # @return [Integer]
493
+ def self.from_boot: () -> Integer
494
+
495
+ # @param [String] uptime_cmd_result
496
+ def initialize: (uptime_cmd_result: String uptime_cmd_result) -> void
497
+
498
+ # @return [Integer]
499
+ def from_boot: () -> Integer
500
+ end
501
+ end
502
+
503
+ module ProconBypassMan
504
+ VERSION: ::String
505
+ 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.8
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-19 00:00:00.000000000 Z
11
+ date: 2021-11-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: extension for Nintendo Switch Pro Controller
14
14
  email:
@@ -29,32 +29,59 @@ files:
29
29
  - LICENSE.txt
30
30
  - README.md
31
31
  - Rakefile
32
+ - Steepfile
32
33
  - bin/console
34
+ - bin/dev_api_server.rb
33
35
  - bin/setup
34
36
  - docs/how_to_connect_procon.md
35
37
  - docs/setup_raspi.md
36
38
  - docs/setup_raspi.mitamae.rb
37
39
  - docs/setup_raspi_by_mitamae.md
38
- - examples/practical/app.rb
39
- - examples/practical/setting.yml
40
40
  - lib/procon_bypass_man.rb
41
+ - lib/procon_bypass_man/background.rb
42
+ - lib/procon_bypass_man/background/has_server_pool.rb
43
+ - lib/procon_bypass_man/background/http_client.rb
44
+ - lib/procon_bypass_man/background/job_performer.rb
45
+ - lib/procon_bypass_man/background/job_runnable.rb
46
+ - lib/procon_bypass_man/background/job_runner.rb
47
+ - lib/procon_bypass_man/background/jobs/base_job.rb
48
+ - lib/procon_bypass_man/background/jobs/report_boot_job.rb
49
+ - lib/procon_bypass_man/background/jobs/report_error_job.rb
50
+ - lib/procon_bypass_man/background/jobs/report_heartbeat_job.rb
51
+ - lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb
52
+ - lib/procon_bypass_man/background/jobs/report_reload_config_job.rb
53
+ - lib/procon_bypass_man/boot_message.rb
54
+ - lib/procon_bypass_man/buttons_setting_configuration.rb
55
+ - lib/procon_bypass_man/buttons_setting_configuration/layer.rb
56
+ - lib/procon_bypass_man/buttons_setting_configuration/loader.rb
57
+ - lib/procon_bypass_man/buttons_setting_configuration/validator.rb
41
58
  - lib/procon_bypass_man/bypass.rb
59
+ - lib/procon_bypass_man/bypass/usb_hid_logger.rb
60
+ - lib/procon_bypass_man/callbacks.rb
61
+ - lib/procon_bypass_man/commands.rb
62
+ - lib/procon_bypass_man/commands/connect_device_command.rb
63
+ - lib/procon_bypass_man/commands/print_boot_message_command.rb
64
+ - lib/procon_bypass_man/commands/send_error_command.rb
65
+ - lib/procon_bypass_man/commands/send_reload_config_event_command.rb
66
+ - lib/procon_bypass_man/commands/write_device_id_command.rb
67
+ - lib/procon_bypass_man/commands/write_session_id_command.rb
42
68
  - lib/procon_bypass_man/configuration.rb
43
- - lib/procon_bypass_man/configuration/layer.rb
44
- - lib/procon_bypass_man/configuration/loader.rb
45
- - lib/procon_bypass_man/configuration/validator.rb
46
69
  - lib/procon_bypass_man/device_connector.rb
47
70
  - lib/procon_bypass_man/io_monitor.rb
71
+ - lib/procon_bypass_man/on_memory_cache.rb
48
72
  - lib/procon_bypass_man/processor.rb
49
73
  - lib/procon_bypass_man/procon.rb
74
+ - lib/procon_bypass_man/procon/analog_stick.rb
75
+ - lib/procon_bypass_man/procon/analog_stick_cap.rb
50
76
  - lib/procon_bypass_man/procon/button_collection.rb
51
- - lib/procon_bypass_man/procon/data.rb
77
+ - lib/procon_bypass_man/procon/consts.rb
52
78
  - lib/procon_bypass_man/procon/flip_cache.rb
53
- - lib/procon_bypass_man/procon/layer_changeable.rb
79
+ - lib/procon_bypass_man/procon/layer_changer.rb
54
80
  - lib/procon_bypass_man/procon/macro_registry.rb
55
81
  - lib/procon_bypass_man/procon/mode_registry.rb
56
- - lib/procon_bypass_man/procon/pressed_button_helper.rb
82
+ - lib/procon_bypass_man/procon/press_button_aware.rb
57
83
  - lib/procon_bypass_man/procon/user_operation.rb
84
+ - lib/procon_bypass_man/procon_reader.rb
58
85
  - lib/procon_bypass_man/runner.rb
59
86
  - lib/procon_bypass_man/timer.rb
60
87
  - lib/procon_bypass_man/uptime.rb
@@ -64,6 +91,10 @@ files:
64
91
  - project_template/app.rb
65
92
  - project_template/setting.yml
66
93
  - project_template/systemd_units/pbm.service
94
+ - project_template/systemd_units/pbm_web.service
95
+ - project_template/web.rb
96
+ - sig/README.rb
97
+ - sig/main.rbs
67
98
  homepage: https://github.com/splaplapla/procon_bypass_man
68
99
  licenses:
69
100
  - MIT
@@ -85,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
116
  - !ruby/object:Gem::Version
86
117
  version: '0'
87
118
  requirements: []
88
- rubygems_version: 3.2.15
119
+ rubygems_version: 3.2.30
89
120
  signing_key:
90
121
  specification_version: 4
91
122
  summary: extension for Nintendo Switch Pro Controller
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # sudo ln -s /home/pi/src/procon_bypass_man/examples/practical/setting.yml /home/pi/src/procon_bypass_man/setting.yml
4
- # cd src/procon_bypass_man
5
- # sudo ruby examples/practical/app.rb
6
-
7
- require 'bundler/inline'
8
-
9
- gemfile do
10
- source 'https://rubygems.org'
11
- gem 'procon_bypass_man', github: 'splaplapla/procon_bypass_man', branch: "edge"
12
- gem 'procon_bypass_man-splatoon2', github: 'splaplapla/procon_bypass_man-splatoon2', branch: "0.1.0"
13
- end
14
-
15
- ProconBypassMan.tap do |pbm|
16
- pbm.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10) # 5世代まで残して, 10MBでローテーション
17
- pbm.logger.level = :debug
18
- pbm.root = File.expand_path(__dir__)
19
- end
20
-
21
- ProconBypassMan.run(setting_path: "./setting.yml")
@@ -1,24 +0,0 @@
1
- version: 1.0
2
- setting: |-
3
- fast_return = ProconBypassMan::Splatoon2::Macro::FastReturn
4
- guruguru = ProconBypassMan::Splatoon2::Mode::Guruguru
5
-
6
- install_macro_plugin fast_return
7
- install_mode_plugin guruguru
8
-
9
- prefix_keys_for_changing_layer [:zr, :r, :zl, :l]
10
-
11
- layer :up, mode: :manual do
12
- flip :zr, if_pressed: :zr, force_neutral: :zl, flip_interval: "8F"
13
- flip :zl, if_pressed: [:y, :b, :zl]
14
- flip :down, if_pressed: :down
15
- macro fast_return.name, if_pressed: [:y, :b, :down]
16
- remap :l, to: :zr
17
- end
18
- layer :right, mode: guruguru.name
19
- layer :left do
20
- # no-op
21
- end
22
- layer :down do
23
- flip :zl
24
- end
@@ -1,28 +0,0 @@
1
- module ProconBypassMan::Procon::LayerChangeable
2
- def next_layer_key
3
- case
4
- when pressed_up?
5
- :up
6
- when pressed_right?
7
- :right
8
- when pressed_left?
9
- :left
10
- when pressed_down?
11
- :down
12
- else
13
- ProconBypassMan.logger.warn("next_layer_key is unknown")
14
- :up
15
- end
16
- end
17
-
18
- def change_layer?
19
- if ProconBypassMan::Configuration.instance.prefix_keys.empty?
20
- raise "prefix_keysが未設定です"
21
- end
22
- ProconBypassMan::Configuration.instance.prefix_keys.map { |b| pressed_button?(b) }.all?
23
- end
24
-
25
- def pressed_next_layer?
26
- change_layer? && (pressed_up? || pressed_right? || pressed_left? || pressed_down?)
27
- end
28
- end
@@ -1,25 +0,0 @@
1
- module ProconBypassMan::Procon::PushedButtonHelper
2
- module Static
3
- def pressed_button?(button)
4
- binary[
5
- ::ProconBypassMan::Procon::ButtonCollection.load(button).byte_position
6
- ].unpack("H*").first.to_i(16).to_s(2).reverse[
7
- ::ProconBypassMan::Procon::ButtonCollection.load(button).bit_position
8
- ] == '1'
9
- end
10
- end
11
-
12
- module Dynamic
13
- @@compiled = false
14
- def compile_if_not_compile_yet!
15
- unless @@compiled
16
- ::ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP.each do |button, _value|
17
- define_method "pressed_#{button}?" do
18
- pressed_button?(button)
19
- end
20
- end
21
- end
22
- @@compiled = true
23
- end
24
- end
25
- end