procon_bypass_man 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +24 -8
  3. data/.github/workflows/ruby.yml +1 -1
  4. data/.rspec +1 -0
  5. data/CHANGELOG.md +24 -1
  6. data/Gemfile.lock +3 -3
  7. data/docs/getting_started.md +38 -5
  8. data/docs/setting/splatoon2_macro_dasei_cancel.md +73 -0
  9. data/lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb +10 -0
  10. data/lib/procon_bypass_man/background.rb +1 -0
  11. data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +28 -5
  12. data/lib/procon_bypass_man/buttons_setting_configuration.rb +1 -1
  13. data/lib/procon_bypass_man/commands/bypass_command.rb +21 -2
  14. data/lib/procon_bypass_man/commands/connect_device_command.rb +11 -21
  15. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +6 -0
  16. data/lib/procon_bypass_man/configuration.rb +15 -0
  17. data/lib/procon_bypass_man/device_connector.rb +6 -9
  18. data/lib/procon_bypass_man/device_procon_finder.rb +0 -20
  19. data/lib/procon_bypass_man/domains/binary/processing_procon_binary.rb +1 -1
  20. data/lib/procon_bypass_man/domains/bypass_mode.rb +29 -0
  21. data/lib/procon_bypass_man/domains.rb +1 -0
  22. data/lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb +21 -0
  23. data/lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb +4 -0
  24. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb +4 -0
  25. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb +4 -0
  26. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_up_key.rb +4 -0
  27. data/lib/procon_bypass_man/plugin/splatoon2/macro/sokuwari_for_splash_bomb.rb +4 -0
  28. data/lib/procon_bypass_man/plugin/splatoon2/mode/guruguru.rb +4 -0
  29. data/lib/procon_bypass_man/plugins.rb +1 -0
  30. data/lib/procon_bypass_man/procon/button_collection.rb +0 -8
  31. data/lib/procon_bypass_man/procon/macro.rb +48 -23
  32. data/lib/procon_bypass_man/procon/macro_builder.rb +31 -21
  33. data/lib/procon_bypass_man/procon/macro_registry.rb +7 -2
  34. data/lib/procon_bypass_man/procon/user_operation.rb +1 -1
  35. data/lib/procon_bypass_man/procon/value_objects/analog_stick.rb +9 -5
  36. data/lib/procon_bypass_man/procon.rb +32 -12
  37. data/lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb +4 -1
  38. data/lib/procon_bypass_man/scheduler.rb +1 -1
  39. data/lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb +59 -0
  40. data/lib/procon_bypass_man/{never_exit_accidentally.rb → support/never_exit_accidentally.rb} +0 -0
  41. data/lib/procon_bypass_man/usb_device_controller.rb +53 -0
  42. data/lib/procon_bypass_man/version.rb +1 -1
  43. data/lib/procon_bypass_man/websocket/forever.rb +47 -0
  44. data/lib/procon_bypass_man/websocket/pbm_job_client.rb +14 -7
  45. data/lib/procon_bypass_man/websocket/watchdog.rb +19 -0
  46. data/lib/procon_bypass_man.rb +8 -7
  47. data/procon_bypass_man.gemspec +1 -1
  48. data/project_template/app.rb +11 -1
  49. data/project_template/systemd_units/pbm.service +1 -1
  50. data/sig/main.rbs +20 -0
  51. metadata +13 -5
@@ -0,0 +1,19 @@
1
+ module ProconBypassMan
2
+ module Websocket
3
+ class Watchdog
4
+ def self.outdated?
5
+ @@time < Time.now
6
+ end
7
+
8
+ def self.time
9
+ @@time
10
+ end
11
+
12
+ def self.active!
13
+ @@time = Time.now + 100
14
+ end
15
+
16
+ active!
17
+ end
18
+ end
19
+ end
@@ -8,6 +8,8 @@ require 'em/pure_ruby'
8
8
  require "action_cable_client"
9
9
  require "ext/em_pure_ruby"
10
10
  require "ext/module"
11
+ require "resolv-replace"
12
+ require "pbmenv"
11
13
 
12
14
  require_relative "procon_bypass_man/version"
13
15
  require_relative "procon_bypass_man/remote_pbm_action"
@@ -23,14 +25,16 @@ require_relative "procon_bypass_man/support/report_http_client"
23
25
  require_relative "procon_bypass_man/support/update_remote_pbm_action_status_http_client"
24
26
  require_relative "procon_bypass_man/support/send_device_stats_http_client"
25
27
  require_relative "procon_bypass_man/support/server_pool"
28
+ require_relative "procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler"
29
+ require_relative "procon_bypass_man/support/never_exit_accidentally"
26
30
  require_relative "procon_bypass_man/background"
27
31
  require_relative "procon_bypass_man/commands"
28
32
  require_relative "procon_bypass_man/bypass"
29
33
  require_relative "procon_bypass_man/domains"
30
- require_relative "procon_bypass_man/never_exit_accidentally"
31
34
  require_relative "procon_bypass_man/device_connector"
32
35
  require_relative "procon_bypass_man/device_procon_finder"
33
36
  require_relative "procon_bypass_man/device_status"
37
+ require_relative "procon_bypass_man/usb_device_controller"
34
38
  require_relative "procon_bypass_man/runner"
35
39
  require_relative "procon_bypass_man/processor"
36
40
  require_relative "procon_bypass_man/configuration"
@@ -44,6 +48,8 @@ require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_a
44
48
  require_relative "procon_bypass_man/scheduler"
45
49
  require_relative "procon_bypass_man/plugins"
46
50
  require_relative "procon_bypass_man/websocket/pbm_job_client"
51
+ require_relative "procon_bypass_man/websocket/watchdog"
52
+ require_relative "procon_bypass_man/websocket/forever"
47
53
 
48
54
  STDOUT.sync = true
49
55
  Thread.abort_on_exception = true
@@ -54,7 +60,6 @@ module ProconBypassMan
54
60
 
55
61
  class CouldNotLoadConfigError < StandardError; end
56
62
  class ConnectionError < StandardError; end
57
- class NotFoundRequiredFilesError < StandardError; end
58
63
  class FirstConnectionError < ConnectionError; end
59
64
  class EternalConnectionError < ConnectionError; end
60
65
 
@@ -71,11 +76,6 @@ module ProconBypassMan
71
76
  Runner.new(gadget: gadget, procon: procon).run # ここでblockingする
72
77
  FileUtils.rm_rf(ProconBypassMan.pid_path)
73
78
  FileUtils.rm_rf(ProconBypassMan.digest_path)
74
- rescue ProconBypassMan::NotFoundRequiredFilesError
75
- ProconBypassMan::SendErrorCommand.execute(error: "/sys/kernel/config/usb_gadget/proconディレクトリがありませんでした。処理を終了します。")
76
- FileUtils.rm_rf(ProconBypassMan.pid_path)
77
- FileUtils.rm_rf(ProconBypassMan.digest_path)
78
- exit 1 # 前提条件を満たしていないので絶対に落とす
79
79
  rescue ProconBypassMan::CouldNotLoadConfigError
80
80
  ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。設定ファイルの読み込みに失敗しました")
81
81
  ProconBypassMan::DeviceStatus.change_to_setting_syntax_error_and_shutdown!
@@ -127,6 +127,7 @@ module ProconBypassMan
127
127
  def self.initialize_pbm
128
128
  ProconBypassMan::WriteDeviceIdCommand.execute
129
129
  ProconBypassMan::WriteSessionIdCommand.execute
130
+ system("renice -n -20 -p #{$$}")
130
131
  File.write(pid_path, $$)
131
132
  ProconBypassMan::DeviceStatus.change_to_running!
132
133
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  # Uncomment to register a new dependency of your gem
31
- spec.add_dependency "pbmenv"
31
+ spec.add_dependency "pbmenv", ">= 0.1.9" # Pbmenv.installでのenable_pbm_cloudに依存している
32
32
  spec.add_dependency "action_cable_client"
33
33
  spec.add_dependency "sorted_set"
34
34
 
@@ -5,18 +5,28 @@ require 'bundler/inline'
5
5
  gemfile do
6
6
  source 'https://rubygems.org'
7
7
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
8
- gem 'procon_bypass_man', '0.1.20'
8
+ gem 'procon_bypass_man', '0.1.21'
9
9
  end
10
10
 
11
11
  ProconBypassMan.configure do |config|
12
12
  config.root = File.expand_path(__dir__)
13
13
  config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
14
14
  config.logger.level = :debug
15
+
16
+ # バイパスするログを全部app.logに流すか
17
+ config.verbose_bypass_log = false
18
+
15
19
  # webからProconBypassManを操作できるwebサービス
16
20
  # config.api_servers = ['https://pbm-cloud.herokuapp.com']
21
+
22
+ # エラーが起きたらerror.logに書き込みます
17
23
  config.enable_critical_error_logging = true
24
+
18
25
  # pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
19
26
  config.never_exit_accidentally = true
27
+
28
+ # 操作が高頻度で固まるときは、 gadget_to_procon_interval の数値は大きくしてください
29
+ config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 5 }
20
30
  end
21
31
 
22
32
  ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
@@ -7,7 +7,7 @@ Type=simple
7
7
  WorkingDirectory=/usr/share/pbm/current
8
8
  ExecStart=/bin/bash -c "/home/pi/.rbenv/versions/3.0.1/bin/ruby /usr/share/pbm/current/app.rb"
9
9
  Restart=always
10
- Nice=-19
10
+ Nice=-20
11
11
 
12
12
  [Install]
13
13
  WantedBy=multi-user.target
data/sig/main.rbs CHANGED
@@ -531,6 +531,26 @@ module ProconBypassMan
531
531
  end
532
532
  end
533
533
 
534
+ class ProconBypassMan::BypassMode
535
+ TYPE_NORMAL: ::Symbol
536
+
537
+ TYPE_AGGRESSIVE: ::Symbol
538
+
539
+ TYPES: ::Array[::Symbol]
540
+
541
+ DEFAULT_GADGET_TO_PROCON_INTERVAL: ::Float
542
+
543
+ attr_accessor mode: ::Symbol
544
+
545
+ attr_accessor gadget_to_procon_interval: ::Float
546
+
547
+ def self.default_value: () -> ::ProconBypassMan::BypassMode
548
+
549
+ def initialize: (mode: ::Symbol mode, gadget_to_procon_interval: ::Float gadget_to_procon_interval) -> void
550
+
551
+ def to_s: () -> ::String
552
+ end
553
+
534
554
  class ProconBypassMan::Domains::Binary::Base
535
555
  # @param [String] binary
536
556
  def initialize: (binary: untyped binary) -> void
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.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-13 00:00:00.000000000 Z
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pbmenv
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.1.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.1.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: action_cable_client
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -79,6 +79,7 @@ files:
79
79
  - docs/getting_started.md
80
80
  - docs/how_to_connect_procon.md
81
81
  - docs/setting/left-analogstick-cap.md
82
+ - docs/setting/splatoon2_macro_dasei_cancel.md
82
83
  - docs/setting/splatoon2_macro_sokuwari_bubble.md
83
84
  - docs/setting/splatoon2_recommended_setting.md
84
85
  - docs/setup_raspi.md
@@ -96,6 +97,7 @@ files:
96
97
  - lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb
97
98
  - lib/procon_bypass_man/background/jobs/concerns/job_runnable.rb
98
99
  - lib/procon_bypass_man/background/jobs/report_boot_job.rb
100
+ - lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb
99
101
  - lib/procon_bypass_man/background/jobs/report_error_job.rb
100
102
  - lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb
101
103
  - lib/procon_bypass_man/background/jobs/report_event_base_job.rb
@@ -130,8 +132,9 @@ files:
130
132
  - lib/procon_bypass_man/domains/binary/has_mutable_binary.rb
131
133
  - lib/procon_bypass_man/domains/binary/inbound_procon_binary.rb
132
134
  - lib/procon_bypass_man/domains/binary/processing_procon_binary.rb
135
+ - lib/procon_bypass_man/domains/bypass_mode.rb
133
136
  - lib/procon_bypass_man/io_monitor.rb
134
- - lib/procon_bypass_man/never_exit_accidentally.rb
137
+ - lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb
135
138
  - lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb
136
139
  - lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb
137
140
  - lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb
@@ -166,9 +169,11 @@ files:
166
169
  - lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
167
170
  - lib/procon_bypass_man/runner.rb
168
171
  - lib/procon_bypass_man/scheduler.rb
172
+ - lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb
169
173
  - lib/procon_bypass_man/support/callbacks.rb
170
174
  - lib/procon_bypass_man/support/compress_array.rb
171
175
  - lib/procon_bypass_man/support/http_client.rb
176
+ - lib/procon_bypass_man/support/never_exit_accidentally.rb
172
177
  - lib/procon_bypass_man/support/on_memory_cache.rb
173
178
  - lib/procon_bypass_man/support/report_http_client.rb
174
179
  - lib/procon_bypass_man/support/safe_timeout.rb
@@ -178,8 +183,11 @@ files:
178
183
  - lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb
179
184
  - lib/procon_bypass_man/support/uptime.rb
180
185
  - lib/procon_bypass_man/support/yaml_writer.rb
186
+ - lib/procon_bypass_man/usb_device_controller.rb
181
187
  - lib/procon_bypass_man/version.rb
188
+ - lib/procon_bypass_man/websocket/forever.rb
182
189
  - lib/procon_bypass_man/websocket/pbm_job_client.rb
190
+ - lib/procon_bypass_man/websocket/watchdog.rb
183
191
  - procon_bypass_man.gemspec
184
192
  - project_template/README.md
185
193
  - project_template/app.rb