procon_bypass_man 0.1.10 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +13 -1
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +15 -12
  6. data/README.md +13 -9
  7. data/bin/console +4 -0
  8. data/bin/{report_receive_server.rb → dev_api_server.rb} +8 -1
  9. data/lib/procon_bypass_man/background/job_performer.rb +16 -0
  10. data/lib/procon_bypass_man/background/job_runner.rb +45 -0
  11. data/lib/procon_bypass_man/background/jobs/base_job.rb +7 -0
  12. data/lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb +5 -0
  13. data/lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb +5 -0
  14. data/lib/procon_bypass_man/background/jobs/concerns/job_runnable.rb +16 -0
  15. data/lib/procon_bypass_man/background/jobs/fetch_and_run_remote_pbm_action_job.rb +29 -0
  16. data/lib/procon_bypass_man/background/jobs/report_boot_job.rb +12 -0
  17. data/lib/procon_bypass_man/background/jobs/report_error_job.rb +11 -0
  18. data/lib/procon_bypass_man/background/jobs/report_event_base_job.rb +5 -0
  19. data/lib/procon_bypass_man/background/jobs/report_load_config_job.rb +11 -0
  20. data/lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb +15 -0
  21. data/lib/procon_bypass_man/background/jobs/report_reload_config_job.rb +11 -0
  22. data/lib/procon_bypass_man/background/jobs/sync_device_stats_job.rb +16 -0
  23. data/lib/procon_bypass_man/background.rb +14 -0
  24. data/lib/procon_bypass_man/boot_message.rb +16 -8
  25. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/layer.rb +34 -29
  26. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/loader.rb +5 -4
  27. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/validator.rb +0 -0
  28. data/lib/procon_bypass_man/buttons_setting_configuration.rb +8 -7
  29. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +20 -2
  30. data/lib/procon_bypass_man/bypass.rb +15 -15
  31. data/lib/procon_bypass_man/commands/bypass_command.rb +86 -0
  32. data/lib/procon_bypass_man/commands/connect_device_command.rb +16 -0
  33. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +9 -0
  34. data/lib/procon_bypass_man/commands/run_local_shell_command.rb +6 -0
  35. data/lib/procon_bypass_man/commands/run_remote_pbm_action_dispatch_command.rb +19 -0
  36. data/lib/procon_bypass_man/commands/send_error_command.rb +19 -0
  37. data/lib/procon_bypass_man/commands/send_reload_config_event_command.rb +11 -0
  38. data/lib/procon_bypass_man/commands/write_device_id_command.rb +12 -0
  39. data/lib/procon_bypass_man/commands/write_session_id_command.rb +7 -0
  40. data/lib/procon_bypass_man/commands.rb +8 -0
  41. data/lib/procon_bypass_man/configuration.rb +48 -8
  42. data/lib/procon_bypass_man/device_connector.rb +33 -26
  43. data/lib/procon_bypass_man/device_status.rb +44 -0
  44. data/lib/procon_bypass_man/io_monitor.rb +9 -4
  45. data/lib/procon_bypass_man/procon/analog_stick.rb +31 -0
  46. data/lib/procon_bypass_man/procon/analog_stick_cap.rb +9 -32
  47. data/lib/procon_bypass_man/procon/button_collection.rb +1 -0
  48. data/lib/procon_bypass_man/procon/{data.rb → consts.rb} +1 -1
  49. data/lib/procon_bypass_man/procon/layer_changer.rb +40 -0
  50. data/lib/procon_bypass_man/procon/user_operation.rb +11 -17
  51. data/lib/procon_bypass_man/procon.rb +6 -10
  52. data/lib/procon_bypass_man/procon_reader.rb +31 -0
  53. data/lib/procon_bypass_man/remote_pbm_action/base_action.rb +53 -0
  54. data/lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb +21 -0
  55. data/lib/procon_bypass_man/remote_pbm_action/lib/update_remote_pbm_action_status_command.rb +24 -0
  56. data/lib/procon_bypass_man/remote_pbm_action/reboot_os_action.rb +17 -0
  57. data/lib/procon_bypass_man/remote_pbm_action/stop_pbm_action.rb +17 -0
  58. data/lib/procon_bypass_man/remote_pbm_action.rb +31 -0
  59. data/lib/procon_bypass_man/runner.rb +14 -112
  60. data/lib/procon_bypass_man/scheduler.rb +92 -0
  61. data/lib/procon_bypass_man/splatoon2/macro/fast_return.rb +15 -0
  62. data/lib/procon_bypass_man/splatoon2/macro/jump_to_left_key.rb +15 -0
  63. data/lib/procon_bypass_man/splatoon2/macro/jump_to_right_key.rb +15 -0
  64. data/lib/procon_bypass_man/splatoon2/macro/jump_to_up_key.rb +15 -0
  65. data/lib/procon_bypass_man/splatoon2/mode/guruguru.rb +57 -0
  66. data/lib/procon_bypass_man/splatoon2/version.rb +7 -0
  67. data/lib/procon_bypass_man/splatoon2.rb +11 -0
  68. data/lib/procon_bypass_man/{callbacks.rb → support/callbacks.rb} +0 -0
  69. data/lib/procon_bypass_man/support/compress_array.rb +56 -0
  70. data/lib/procon_bypass_man/support/http_client.rb +102 -0
  71. data/lib/procon_bypass_man/{on_memory_cache.rb → support/on_memory_cache.rb} +0 -0
  72. data/lib/procon_bypass_man/support/report_http_client.rb +19 -0
  73. data/lib/procon_bypass_man/{timer.rb → support/safe_timeout.rb} +1 -1
  74. data/lib/procon_bypass_man/support/send_device_stats_http_client.rb +9 -0
  75. data/lib/procon_bypass_man/support/server_pool.rb +42 -0
  76. data/lib/procon_bypass_man/support/signal_handler.rb +11 -0
  77. data/lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb +9 -0
  78. data/lib/procon_bypass_man/support/uptime.rb +25 -0
  79. data/lib/procon_bypass_man/value_objects/remote_pbm_action_object.rb +38 -0
  80. data/lib/procon_bypass_man/version.rb +1 -1
  81. data/lib/procon_bypass_man.rb +57 -20
  82. data/procon_bypass_man.gemspec +3 -3
  83. data/project_template/README.md +18 -11
  84. data/project_template/app.rb +3 -4
  85. data/project_template/web.rb +1 -1
  86. data/sig/{README.rb → README.md} +0 -0
  87. data/sig/main.rbs +12 -13
  88. metadata +82 -26
  89. data/examples/practical/app.rb +0 -21
  90. data/examples/practical/setting.yml +0 -24
  91. data/lib/procon_bypass_man/analog_stick_position.rb +0 -8
  92. data/lib/procon_bypass_man/outbound/base.rb +0 -40
  93. data/lib/procon_bypass_man/outbound/error_reporter.rb +0 -13
  94. data/lib/procon_bypass_man/outbound/reporter.rb +0 -12
  95. data/lib/procon_bypass_man/outbound/usb_hid_data_reporter.rb +0 -13
  96. data/lib/procon_bypass_man/procon/debug_dumper.rb +0 -17
  97. data/lib/procon_bypass_man/procon/layer_changeable.rb +0 -28
  98. data/lib/procon_bypass_man/procon/pressed_button_helper.rb +0 -15
  99. data/lib/procon_bypass_man/uptime.rb +0 -15
@@ -0,0 +1,9 @@
1
+ module ProconBypassMan
2
+ class SendDeviceStatsHttpClient < HttpClient
3
+ def post(status: , pbm_session_id: )
4
+ super(request_body: {
5
+ body: { status: status, pbm_session_id: pbm_session_id },
6
+ })
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,42 @@
1
+ module ProconBypassMan
2
+ class ServerPool
3
+ def initialize(servers: )
4
+ if servers.nil? || servers.empty?
5
+ return
6
+ end
7
+
8
+ @servers = servers
9
+ if @servers.size >= 1
10
+ @index = 0
11
+ else
12
+ @index = nil
13
+ end
14
+ end
15
+
16
+ def pick
17
+ if @index.nil?
18
+ return @servers&.first
19
+ end
20
+ @servers[@index] or raise "bug!!!"
21
+ end
22
+ def server; pick; end
23
+
24
+ def next!
25
+ inc_index
26
+ if @servers[@index].nil?
27
+ reset
28
+ return
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def reset
35
+ @index = 0
36
+ end
37
+
38
+ def inc_index
39
+ @index = @index + 1
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,11 @@
1
+ module ProconBypassMan::SignalHandler
2
+ def handle_signal(sig)
3
+ ProconBypassMan.logger.info "#{$$}で#{sig}を受け取りました"
4
+ case sig
5
+ when 'USR2'
6
+ raise ProconBypassMan::Runner::InterruptForRestart
7
+ when 'INT', 'TERM'
8
+ raise Interrupt
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module ProconBypassMan
2
+ class UpdateRemotePbmActionStatusHttpClient < HttpClient
3
+ def put(to_status: )
4
+ super(request_body: {
5
+ body: { status: to_status },
6
+ })
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ require "time"
2
+
3
+ module ProconBypassMan
4
+ class Uptime
5
+ # @return [Integer]
6
+ def self.from_boot
7
+ new(uptime_cmd_result: `uptime -s`.chomp).from_boot
8
+ end
9
+
10
+ # @param [String] uptime_cmd_result
11
+ def initialize(uptime_cmd_result: )
12
+ @result = uptime_cmd_result
13
+ end
14
+
15
+ # @return [Integer]
16
+ def from_boot
17
+ return -1 if @result == '' # darwin系だとsオプションが使えない
18
+ boot_time = Time.parse(@result).to_i
19
+ return Time.now.to_i - boot_time.to_i
20
+ rescue => e
21
+ ProconBypassMan.logger.error(e)
22
+ return -1
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,38 @@
1
+ module ProconBypassMan
2
+ class RemotePbmActionObject
3
+ # valueobjectがvalidatorの責務も持っている. 今度分離する
4
+ class ValidationError < StandardError; end
5
+ class MustBeNotNilError < ValidationError; end
6
+ class NonSupportAction < ValidationError; end
7
+
8
+ attr_accessor :action, :status, :uuid, :created_at, :job_args
9
+
10
+ # @param [String] action
11
+ # @param [String] status
12
+ # @param [String] #uuid
13
+ # @param [Time] created_at
14
+ # @return [Hash] job_args
15
+ def initialize(action: , status:, uuid:, created_at:, job_args: )
16
+ self.action = action
17
+ self.status = status
18
+ self.uuid = uuid
19
+ self.created_at = created_at
20
+ self.job_args = job_args
21
+
22
+ freeze
23
+ end
24
+
25
+ # @raise [MustBeNotNilError]
26
+ # @raise [NonSupportAction]
27
+ # @return [void]
28
+ def validate!
29
+ self.action or raise MustBeNotNilError, "actionは値が必須です"
30
+ self.status or raise MustBeNotNilError, "statusは値が必須です"
31
+ self.uuid or raise MustBeNotNilError, "uuidは値が必須です"
32
+
33
+ unless ProconBypassMan::RemotePbmAction::ACTIONS.include?(action)
34
+ raise NonSupportAction, "知らないアクションです"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProconBypassMan
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.14"
5
5
  end
@@ -3,34 +3,47 @@ require 'yaml'
3
3
  require "json"
4
4
  require "net/http"
5
5
  require "fileutils"
6
+ require "securerandom"
6
7
 
7
8
  require_relative "procon_bypass_man/version"
8
- require_relative "procon_bypass_man/callbacks"
9
- require_relative "procon_bypass_man/analog_stick_position"
10
- require_relative "procon_bypass_man/timer"
9
+ require_relative "procon_bypass_man/remote_pbm_action"
10
+ require_relative "procon_bypass_man/support/signal_handler"
11
+ require_relative "procon_bypass_man/support/callbacks"
12
+ require_relative "procon_bypass_man/support/safe_timeout"
13
+ require_relative "procon_bypass_man/support/compress_array"
14
+ require_relative "procon_bypass_man/support/uptime"
15
+ require_relative "procon_bypass_man/support/on_memory_cache"
16
+ require_relative "procon_bypass_man/support/http_client"
17
+ require_relative "procon_bypass_man/support/report_http_client"
18
+ require_relative "procon_bypass_man/support/update_remote_pbm_action_status_http_client"
19
+ require_relative "procon_bypass_man/support/send_device_stats_http_client"
20
+ require_relative "procon_bypass_man/support/server_pool"
21
+ require_relative "procon_bypass_man/background"
22
+ require_relative "procon_bypass_man/commands"
11
23
  require_relative "procon_bypass_man/bypass"
12
24
  require_relative "procon_bypass_man/device_connector"
25
+ require_relative "procon_bypass_man/device_status"
13
26
  require_relative "procon_bypass_man/runner"
14
27
  require_relative "procon_bypass_man/processor"
15
28
  require_relative "procon_bypass_man/configuration"
16
29
  require_relative "procon_bypass_man/buttons_setting_configuration"
17
30
  require_relative "procon_bypass_man/procon"
18
- require_relative "procon_bypass_man/procon/debug_dumper"
31
+ require_relative "procon_bypass_man/procon_reader"
32
+ require_relative "procon_bypass_man/procon/analog_stick"
19
33
  require_relative "procon_bypass_man/procon/analog_stick_cap"
20
- require_relative "procon_bypass_man/outbound/reporter"
21
- require_relative "procon_bypass_man/outbound/error_reporter"
22
- require_relative "procon_bypass_man/outbound/usb_hid_data_reporter"
23
- require_relative "procon_bypass_man/on_memory_cache"
34
+ require_relative "procon_bypass_man/value_objects/remote_pbm_action_object"
35
+ require_relative "procon_bypass_man/scheduler"
36
+ require_relative "procon_bypass_man/splatoon2"
24
37
 
25
38
  STDOUT.sync = true
26
39
  Thread.abort_on_exception = true
27
40
 
28
41
  module ProconBypassMan
29
- extend ProconBypassMan::Configuration::ClassAttributes
42
+ extend ProconBypassMan::Configuration::ClassMethods
30
43
 
31
- class ProConRejected < StandardError; end
32
44
  class CouldNotLoadConfigError < StandardError; end
33
45
  class FirstConnectionError < StandardError; end
46
+ class NotFoundProconError < StandardError; end
34
47
  class EternalConnectionError < StandardError; end
35
48
 
36
49
  def self.buttons_setting_configure(setting_path: nil, &block)
@@ -45,25 +58,39 @@ module ProconBypassMan
45
58
  end
46
59
  end
47
60
 
61
+ # @return [void]
48
62
  def self.run(setting_path: nil, &block)
63
+ ProconBypassMan::Scheduler.start!
64
+ ProconBypassMan::Background::JobRunner.start!
65
+
49
66
  ProconBypassMan.logger.info "PBMを起動しています"
50
67
  puts "PBMを起動しています"
51
68
  buttons_setting_configure(setting_path: setting_path, &block)
69
+ initialize_pbm
52
70
  File.write(pid_path, $$)
53
- Runner.new.run
54
- rescue CouldNotLoadConfigError
55
- ProconBypassMan.logger.error "設定ファイルが不正です。設定ファイルの読み込みに失敗しました"
56
- puts "設定ファイルが不正です。設定ファイルの読み込みに失敗しました"
71
+ ProconBypassMan::WriteSessionIdCommand.execute
72
+ gadget, procon = ProconBypassMan::ConnectDeviceCommand.execute!
73
+ ProconBypassMan::DeviceStatus.change_to_running!
74
+ Runner.new(gadget: gadget, procon: procon).run
75
+ rescue ProconBypassMan::CouldNotLoadConfigError
76
+ ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。設定ファイルの読み込みに失敗しました")
77
+ ProconBypassMan::DeviceStatus.change_to_setting_syntax_error_and_shutdown!
57
78
  FileUtils.rm_rf(ProconBypassMan.pid_path)
58
79
  FileUtils.rm_rf(ProconBypassMan.digest_path)
59
80
  exit 1
60
- rescue EternalConnectionError
61
- ProconBypassMan.logger.error "接続の見込みがないのでsleepしまくります"
62
- puts "接続の見込みがないのでsleepしまくります"
81
+ rescue ProconBypassMan::NotFoundProconError
82
+ ProconBypassMan::SendErrorCommand.execute(error: "プロコンが見つかりませんでした。終了します。")
83
+ ProconBypassMan::DeviceStatus.change_to_procon_not_found_error!
63
84
  FileUtils.rm_rf(ProconBypassMan.pid_path)
64
- sleep(999999999)
65
- rescue FirstConnectionError
66
- puts "接続を確立できませんでした。やりなおします。"
85
+ FileUtils.rm_rf(ProconBypassMan.digest_path)
86
+ exit 1
87
+ rescue ProconBypassMan::EternalConnectionError
88
+ ProconBypassMan::SendErrorCommand.execute(error: "接続の見込みがないのでsleepしまくります")
89
+ ProconBypassMan::DeviceStatus.change_to_connected_but_sleeping!
90
+ FileUtils.rm_rf(ProconBypassMan.pid_path)
91
+ eternal_sleep
92
+ rescue ProconBypassMan::FirstConnectionError
93
+ ProconBypassMan::SendErrorCommand.execute(error: "接続を確立できませんでした。やりなおします。")
67
94
  retry
68
95
  end
69
96
 
@@ -73,10 +100,12 @@ module ProconBypassMan
73
100
  @@configuration
74
101
  end
75
102
 
103
+ # @return [ProconBypassMan::Configuration]
76
104
  def self.config
77
105
  @@configuration ||= ProconBypassMan::Configuration.new
78
106
  end
79
107
 
108
+ # @return [void]
80
109
  def self.reset!
81
110
  ProconBypassMan::Procon::MacroRegistry.reset!
82
111
  ProconBypassMan::Procon::ModeRegistry.reset!
@@ -84,4 +113,12 @@ module ProconBypassMan
84
113
  ProconBypassMan::ButtonsSettingConfiguration.instance.reset!
85
114
  ProconBypassMan::IOMonitor.reset!
86
115
  end
116
+
117
+ def self.initialize_pbm
118
+ ProconBypassMan::WriteDeviceIdCommand.execute
119
+ end
120
+
121
+ def self.eternal_sleep
122
+ sleep(999999999)
123
+ end
87
124
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["jiikko"]
9
9
  spec.email = ["n905i.1214@gmail.com"]
10
10
 
11
- spec.summary = "extension for Nintendo Switch Pro Controller"
11
+ spec.summary = "An extension for Nintendo Switch Pro Controller"
12
12
  spec.description = spec.summary
13
13
  spec.homepage = "https://github.com/splaplapla/procon_bypass_man"
14
14
  spec.license = "MIT"
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
19
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
+ spec.metadata["changelog_uri"] = "https://github.com/splaplapla/procon_bypass_man/blob/master/CHANGELOG.md"
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -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 "example-gem", "~> 1.0"
31
+ spec.add_dependency "pbmenv"
32
32
 
33
33
  # For more information and examples about making a new gem, checkout our
34
34
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -1,17 +1,24 @@
1
1
  # Project Template
2
- https://github.com/splaplapla/pbmenv で使っているファイルです
2
+ これらは https://github.com/splaplapla/pbmenv がinstallするときに配備するファイルです
3
3
 
4
- ## systemd
4
+ ## systemdを使ってサービスに登録する方法
5
5
  * sudo ln -s /usr/share/pbm/current/systemd_units/pbm.service /etc/systemd/system/pbm.service
6
6
  * sudo ln -s /usr/share/pbm/current/systemd_units/pbm_web.service /etc/systemd/system/pbm_web.service
7
- * commands
8
- * systemctl daemon-reload
9
- * systemctl enable pbm.service
10
- * systemctl disable pbm.service
11
- * systemctl start pbm.service
12
- * systemctl status pbm.service
13
- * systemctl restart pbm.service
14
- * systemctl list-unit-files --type=service
7
+ * sudo systemctl enable pbm.service
8
+ * sudo systemctl enable pbm_web.service
15
9
 
16
- ### ログ
10
+ ## systemdを使ってサービスから解除する方法
11
+ * sudo systemctl disable pbm.service
12
+ * sudo systemctl disable pbm_web.service
13
+
14
+ ### CheatSheet
15
+ * systemctl daemon-reload
16
+ * systemctl enable pbm.service
17
+ * systemctl disable pbm.service
18
+ * systemctl start pbm.service
19
+ * systemctl status pbm.service
20
+ * systemctl restart pbm.service
21
+ * systemctl list-unit-files --type=service
22
+
23
+ ### デバッグ
17
24
  * journalctl -xe -f
@@ -5,16 +5,15 @@ 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.9'
9
- gem 'procon_bypass_man-splatoon2', github: 'splaplapla/procon_bypass_man-splatoon2', tag: "0.1.1"
8
+ gem 'procon_bypass_man', '0.1.14'
10
9
  end
11
10
 
12
11
  ProconBypassMan.configure do |config|
13
12
  config.root = File.expand_path(__dir__)
14
13
  config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
15
14
  config.logger.level = :debug
16
- # pbm.api_server = 'https://...'
17
- config.enable_critical_error_logging!
15
+ # config.api_servers = ['https://...']
16
+ config.enable_critical_error_logging = true
18
17
  end
19
18
 
20
19
  ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
@@ -5,7 +5,7 @@ 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-web', '0.1.2'
8
+ gem 'procon_bypass_man-web', '0.1.3'
9
9
  end
10
10
 
11
11
  ProconBypassMan::Web.configure do |config|
File without changes
data/sig/main.rbs CHANGED
@@ -8,9 +8,6 @@ interface _Pluginable
8
8
  end
9
9
 
10
10
  module ProconBypassMan
11
- class ProConRejected < StandardError
12
- end
13
-
14
11
  class CouldNotLoadConfigError < StandardError
15
12
  end
16
13
 
@@ -168,7 +165,7 @@ module ProconBypassMan
168
165
  end
169
166
 
170
167
  class ProconBypassMan::Configuration
171
- module ClassAttributes
168
+ module ClassMethods
172
169
  def root: () -> untyped
173
170
 
174
171
  def logger: () -> untyped
@@ -185,6 +182,7 @@ class ProconBypassMan::Configuration
185
182
  end
186
183
 
187
184
  attr_reader api_server: untyped
185
+ attr_reader api_servers: untyped
188
186
 
189
187
  attr_accessor enable_critical_error_logging: untyped
190
188
 
@@ -423,23 +421,17 @@ class ProconBypassMan::Procon::ModeRegistry
423
421
  def self.plugins: () -> untyped
424
422
  end
425
423
 
426
- module ProconBypassMan::Procon::PushedButtonHelper
424
+ module ProconBypassMan::Procon::PressedButtonHelper
427
425
  module Static
428
426
  def pressed_button?: (untyped button) -> untyped
429
427
  end
430
-
431
- module Dynamic
432
- def compile_if_not_compile_yet!: () -> untyped
433
- end
434
428
  end
435
429
 
436
430
  class ProconBypassMan::Procon
437
431
  class UserOperation
438
432
  include LayerChangeable
439
433
 
440
- include PushedButtonHelper::Static
441
-
442
- extend PushedButtonHelper::Dynamic
434
+ include PressedButtonHelper::Static
443
435
 
444
436
  attr_reader binary: untyped
445
437
 
@@ -498,7 +490,14 @@ end
498
490
 
499
491
  module ProconBypassMan
500
492
  class Uptime
501
- def self.from_boot: () -> untyped
493
+ # @return [Integer]
494
+ def self.from_boot: () -> Integer
495
+
496
+ # @param [String] uptime_cmd_result
497
+ def initialize: (uptime_cmd_result: String uptime_cmd_result) -> void
498
+
499
+ # @return [Integer]
500
+ def from_boot: () -> Integer
502
501
  end
503
502
  end
504
503
 
metadata CHANGED
@@ -1,16 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procon_bypass_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
12
- dependencies: []
13
- description: extension for Nintendo Switch Pro Controller
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pbmenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: An extension for Nintendo Switch Pro Controller
14
28
  email:
15
29
  - n905i.1214@gmail.com
16
30
  executables: []
@@ -31,48 +45,89 @@ files:
31
45
  - Rakefile
32
46
  - Steepfile
33
47
  - bin/console
34
- - bin/report_receive_server.rb
48
+ - bin/dev_api_server.rb
35
49
  - bin/setup
36
50
  - docs/how_to_connect_procon.md
37
51
  - docs/setup_raspi.md
38
52
  - docs/setup_raspi.mitamae.rb
39
53
  - docs/setup_raspi_by_mitamae.md
40
- - examples/practical/app.rb
41
- - examples/practical/setting.yml
42
54
  - lib/procon_bypass_man.rb
43
- - lib/procon_bypass_man/analog_stick_position.rb
55
+ - lib/procon_bypass_man/background.rb
56
+ - lib/procon_bypass_man/background/job_performer.rb
57
+ - lib/procon_bypass_man/background/job_runner.rb
58
+ - lib/procon_bypass_man/background/jobs/base_job.rb
59
+ - lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb
60
+ - lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb
61
+ - lib/procon_bypass_man/background/jobs/concerns/job_runnable.rb
62
+ - lib/procon_bypass_man/background/jobs/fetch_and_run_remote_pbm_action_job.rb
63
+ - lib/procon_bypass_man/background/jobs/report_boot_job.rb
64
+ - lib/procon_bypass_man/background/jobs/report_error_job.rb
65
+ - lib/procon_bypass_man/background/jobs/report_event_base_job.rb
66
+ - lib/procon_bypass_man/background/jobs/report_load_config_job.rb
67
+ - lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb
68
+ - lib/procon_bypass_man/background/jobs/report_reload_config_job.rb
69
+ - lib/procon_bypass_man/background/jobs/sync_device_stats_job.rb
44
70
  - lib/procon_bypass_man/boot_message.rb
45
71
  - lib/procon_bypass_man/buttons_setting_configuration.rb
72
+ - lib/procon_bypass_man/buttons_setting_configuration/layer.rb
73
+ - lib/procon_bypass_man/buttons_setting_configuration/loader.rb
74
+ - lib/procon_bypass_man/buttons_setting_configuration/validator.rb
46
75
  - lib/procon_bypass_man/bypass.rb
47
76
  - lib/procon_bypass_man/bypass/usb_hid_logger.rb
48
- - lib/procon_bypass_man/callbacks.rb
77
+ - lib/procon_bypass_man/commands.rb
78
+ - lib/procon_bypass_man/commands/bypass_command.rb
79
+ - lib/procon_bypass_man/commands/connect_device_command.rb
80
+ - lib/procon_bypass_man/commands/print_boot_message_command.rb
81
+ - lib/procon_bypass_man/commands/run_local_shell_command.rb
82
+ - lib/procon_bypass_man/commands/run_remote_pbm_action_dispatch_command.rb
83
+ - lib/procon_bypass_man/commands/send_error_command.rb
84
+ - lib/procon_bypass_man/commands/send_reload_config_event_command.rb
85
+ - lib/procon_bypass_man/commands/write_device_id_command.rb
86
+ - lib/procon_bypass_man/commands/write_session_id_command.rb
49
87
  - lib/procon_bypass_man/configuration.rb
50
- - lib/procon_bypass_man/configuration/layer.rb
51
- - lib/procon_bypass_man/configuration/loader.rb
52
- - lib/procon_bypass_man/configuration/validator.rb
53
88
  - lib/procon_bypass_man/device_connector.rb
89
+ - lib/procon_bypass_man/device_status.rb
54
90
  - lib/procon_bypass_man/io_monitor.rb
55
- - lib/procon_bypass_man/on_memory_cache.rb
56
- - lib/procon_bypass_man/outbound/base.rb
57
- - lib/procon_bypass_man/outbound/error_reporter.rb
58
- - lib/procon_bypass_man/outbound/reporter.rb
59
- - lib/procon_bypass_man/outbound/usb_hid_data_reporter.rb
60
91
  - lib/procon_bypass_man/processor.rb
61
92
  - lib/procon_bypass_man/procon.rb
93
+ - lib/procon_bypass_man/procon/analog_stick.rb
62
94
  - lib/procon_bypass_man/procon/analog_stick_cap.rb
63
95
  - lib/procon_bypass_man/procon/button_collection.rb
64
- - lib/procon_bypass_man/procon/data.rb
65
- - lib/procon_bypass_man/procon/debug_dumper.rb
96
+ - lib/procon_bypass_man/procon/consts.rb
66
97
  - lib/procon_bypass_man/procon/flip_cache.rb
67
- - lib/procon_bypass_man/procon/layer_changeable.rb
98
+ - lib/procon_bypass_man/procon/layer_changer.rb
68
99
  - lib/procon_bypass_man/procon/macro_registry.rb
69
100
  - lib/procon_bypass_man/procon/mode_registry.rb
70
101
  - lib/procon_bypass_man/procon/press_button_aware.rb
71
- - lib/procon_bypass_man/procon/pressed_button_helper.rb
72
102
  - lib/procon_bypass_man/procon/user_operation.rb
103
+ - lib/procon_bypass_man/procon_reader.rb
104
+ - lib/procon_bypass_man/remote_pbm_action.rb
105
+ - lib/procon_bypass_man/remote_pbm_action/base_action.rb
106
+ - lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb
107
+ - lib/procon_bypass_man/remote_pbm_action/lib/update_remote_pbm_action_status_command.rb
108
+ - lib/procon_bypass_man/remote_pbm_action/reboot_os_action.rb
109
+ - lib/procon_bypass_man/remote_pbm_action/stop_pbm_action.rb
73
110
  - lib/procon_bypass_man/runner.rb
74
- - lib/procon_bypass_man/timer.rb
75
- - lib/procon_bypass_man/uptime.rb
111
+ - lib/procon_bypass_man/scheduler.rb
112
+ - lib/procon_bypass_man/splatoon2.rb
113
+ - lib/procon_bypass_man/splatoon2/macro/fast_return.rb
114
+ - lib/procon_bypass_man/splatoon2/macro/jump_to_left_key.rb
115
+ - lib/procon_bypass_man/splatoon2/macro/jump_to_right_key.rb
116
+ - lib/procon_bypass_man/splatoon2/macro/jump_to_up_key.rb
117
+ - lib/procon_bypass_man/splatoon2/mode/guruguru.rb
118
+ - lib/procon_bypass_man/splatoon2/version.rb
119
+ - lib/procon_bypass_man/support/callbacks.rb
120
+ - lib/procon_bypass_man/support/compress_array.rb
121
+ - lib/procon_bypass_man/support/http_client.rb
122
+ - lib/procon_bypass_man/support/on_memory_cache.rb
123
+ - lib/procon_bypass_man/support/report_http_client.rb
124
+ - lib/procon_bypass_man/support/safe_timeout.rb
125
+ - lib/procon_bypass_man/support/send_device_stats_http_client.rb
126
+ - lib/procon_bypass_man/support/server_pool.rb
127
+ - lib/procon_bypass_man/support/signal_handler.rb
128
+ - lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb
129
+ - lib/procon_bypass_man/support/uptime.rb
130
+ - lib/procon_bypass_man/value_objects/remote_pbm_action_object.rb
76
131
  - lib/procon_bypass_man/version.rb
77
132
  - procon_bypass_man.gemspec
78
133
  - project_template/README.md
@@ -81,7 +136,7 @@ files:
81
136
  - project_template/systemd_units/pbm.service
82
137
  - project_template/systemd_units/pbm_web.service
83
138
  - project_template/web.rb
84
- - sig/README.rb
139
+ - sig/README.md
85
140
  - sig/main.rbs
86
141
  homepage: https://github.com/splaplapla/procon_bypass_man
87
142
  licenses:
@@ -89,6 +144,7 @@ licenses:
89
144
  metadata:
90
145
  homepage_uri: https://github.com/splaplapla/procon_bypass_man
91
146
  source_code_uri: https://github.com/splaplapla/procon_bypass_man
147
+ changelog_uri: https://github.com/splaplapla/procon_bypass_man/blob/master/CHANGELOG.md
92
148
  post_install_message:
93
149
  rdoc_options: []
94
150
  require_paths:
@@ -104,8 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
160
  - !ruby/object:Gem::Version
105
161
  version: '0'
106
162
  requirements: []
107
- rubygems_version: 3.2.22
163
+ rubygems_version: 3.2.30
108
164
  signing_key:
109
165
  specification_version: 4
110
- summary: extension for Nintendo Switch Pro Controller
166
+ summary: An extension for Nintendo Switch Pro Controller
111
167
  test_files: []
@@ -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