procon_bypass_man 0.1.9 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +2 -0
  4. data/CHANGELOG.md +14 -0
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +13 -12
  7. data/README.md +14 -16
  8. data/bin/console +4 -0
  9. data/bin/{report_receive_server.rb → dev_api_server.rb} +8 -1
  10. data/lib/procon_bypass_man/background/has_server_pool.rb +54 -0
  11. data/lib/procon_bypass_man/background/http_client.rb +67 -0
  12. data/lib/procon_bypass_man/background/job_performer.rb +16 -0
  13. data/lib/procon_bypass_man/background/job_runnable.rb +16 -0
  14. data/lib/procon_bypass_man/background/job_runner.rb +45 -0
  15. data/lib/procon_bypass_man/background/jobs/base_job.rb +12 -0
  16. data/lib/procon_bypass_man/background/jobs/report_boot_job.rb +10 -0
  17. data/lib/procon_bypass_man/background/jobs/report_error_job.rb +10 -0
  18. data/lib/procon_bypass_man/background/jobs/report_heartbeat_job.rb +10 -0
  19. data/lib/procon_bypass_man/background/jobs/report_load_config_job.rb +10 -0
  20. data/lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb +18 -0
  21. data/lib/procon_bypass_man/background/jobs/report_reload_config_job.rb +10 -0
  22. data/lib/procon_bypass_man/background.rb +12 -0
  23. data/lib/procon_bypass_man/boot_message.rb +13 -9
  24. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/layer.rb +51 -30
  25. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/loader.rb +12 -11
  26. data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/validator.rb +1 -1
  27. data/lib/procon_bypass_man/buttons_setting_configuration.rb +101 -0
  28. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +42 -0
  29. data/lib/procon_bypass_man/bypass.rb +57 -38
  30. data/lib/procon_bypass_man/commands/bypass_command.rb +86 -0
  31. data/lib/procon_bypass_man/commands/connect_device_command.rb +11 -0
  32. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +9 -0
  33. data/lib/procon_bypass_man/commands/send_error_command.rb +19 -0
  34. data/lib/procon_bypass_man/commands/send_reload_config_event_command.rb +11 -0
  35. data/lib/procon_bypass_man/commands/write_device_id_command.rb +12 -0
  36. data/lib/procon_bypass_man/commands/write_session_id_command.rb +13 -0
  37. data/lib/procon_bypass_man/commands.rb +7 -0
  38. data/lib/procon_bypass_man/configuration.rb +92 -78
  39. data/lib/procon_bypass_man/device_connector.rb +31 -25
  40. data/lib/procon_bypass_man/io_monitor.rb +9 -4
  41. data/lib/procon_bypass_man/procon/analog_stick.rb +31 -0
  42. data/lib/procon_bypass_man/procon/analog_stick_cap.rb +9 -32
  43. data/lib/procon_bypass_man/procon/button_collection.rb +1 -0
  44. data/lib/procon_bypass_man/procon/{data.rb → consts.rb} +1 -1
  45. data/lib/procon_bypass_man/procon/layer_changer.rb +40 -0
  46. data/lib/procon_bypass_man/procon/macro_registry.rb +2 -2
  47. data/lib/procon_bypass_man/procon/mode_registry.rb +2 -2
  48. data/lib/procon_bypass_man/procon/user_operation.rb +15 -17
  49. data/lib/procon_bypass_man/procon.rb +15 -15
  50. data/lib/procon_bypass_man/procon_reader.rb +31 -0
  51. data/lib/procon_bypass_man/runner.rb +15 -113
  52. data/lib/procon_bypass_man/splatoon2/macro/fast_return.rb +15 -0
  53. data/lib/procon_bypass_man/splatoon2/macro/jump_to_left_key.rb +15 -0
  54. data/lib/procon_bypass_man/splatoon2/macro/jump_to_right_key.rb +15 -0
  55. data/lib/procon_bypass_man/splatoon2/macro/jump_to_up_key.rb +15 -0
  56. data/lib/procon_bypass_man/splatoon2/mode/guruguru.rb +57 -0
  57. data/lib/procon_bypass_man/splatoon2/version.rb +7 -0
  58. data/lib/procon_bypass_man/splatoon2.rb +11 -0
  59. data/lib/procon_bypass_man/support/callbacks.rb +70 -0
  60. data/lib/procon_bypass_man/support/compress_array.rb +56 -0
  61. data/lib/procon_bypass_man/{on_memory_cache.rb → support/on_memory_cache.rb} +0 -0
  62. data/lib/procon_bypass_man/{timer.rb → support/safe_timeout.rb} +1 -1
  63. data/lib/procon_bypass_man/support/signal_handler.rb +11 -0
  64. data/lib/procon_bypass_man/support/uptime.rb +25 -0
  65. data/lib/procon_bypass_man/version.rb +1 -1
  66. data/lib/procon_bypass_man.rb +41 -82
  67. data/procon_bypass_man.gemspec +2 -2
  68. data/project_template/README.md +19 -12
  69. data/project_template/app.rb +7 -8
  70. data/project_template/systemd_units/pbm_web.service +11 -0
  71. data/project_template/web.rb +16 -0
  72. data/sig/{README.rb → README.md} +0 -0
  73. data/sig/main.rbs +54 -16
  74. metadata +53 -22
  75. data/examples/practical/app.rb +0 -21
  76. data/examples/practical/setting.yml +0 -24
  77. data/lib/procon_bypass_man/analog_stick_position.rb +0 -14
  78. data/lib/procon_bypass_man/error_reporter.rb +0 -44
  79. data/lib/procon_bypass_man/procon/debug_dumper.rb +0 -17
  80. data/lib/procon_bypass_man/procon/layer_changeable.rb +0 -28
  81. data/lib/procon_bypass_man/procon/pressed_button_helper.rb +0 -15
  82. data/lib/procon_bypass_man/reporter.rb +0 -42
  83. data/lib/procon_bypass_man/uptime.rb +0 -13
@@ -1,140 +1,99 @@
1
1
  require "logger"
2
2
  require 'yaml'
3
+ require "json"
4
+ require "net/http"
3
5
  require "fileutils"
6
+ require "securerandom"
4
7
 
5
8
  require_relative "procon_bypass_man/version"
6
- require_relative "procon_bypass_man/analog_stick_position"
7
- require_relative "procon_bypass_man/timer"
9
+ require_relative "procon_bypass_man/support/signal_handler"
10
+ require_relative "procon_bypass_man/support/callbacks"
11
+ require_relative "procon_bypass_man/support/safe_timeout"
12
+ require_relative "procon_bypass_man/support/compress_array"
13
+ require_relative "procon_bypass_man/support/uptime"
14
+ require_relative "procon_bypass_man/support/on_memory_cache"
15
+ require_relative "procon_bypass_man/background"
16
+ require_relative "procon_bypass_man/commands"
8
17
  require_relative "procon_bypass_man/bypass"
9
18
  require_relative "procon_bypass_man/device_connector"
10
19
  require_relative "procon_bypass_man/runner"
11
20
  require_relative "procon_bypass_man/processor"
12
21
  require_relative "procon_bypass_man/configuration"
22
+ require_relative "procon_bypass_man/buttons_setting_configuration"
13
23
  require_relative "procon_bypass_man/procon"
14
- require_relative "procon_bypass_man/procon/debug_dumper"
24
+ require_relative "procon_bypass_man/procon_reader"
25
+ require_relative "procon_bypass_man/procon/analog_stick"
15
26
  require_relative "procon_bypass_man/procon/analog_stick_cap"
16
- require_relative "procon_bypass_man/reporter"
17
- require_relative "procon_bypass_man/error_reporter"
18
- require_relative "procon_bypass_man/on_memory_cache"
27
+ require_relative "procon_bypass_man/splatoon2"
19
28
 
20
29
  STDOUT.sync = true
21
30
  Thread.abort_on_exception = true
22
31
 
23
- # new feature from ruby3.0
24
- if GC.respond_to?(:auto_compact)
25
- GC.auto_compact = true
26
- end
27
-
28
32
  module ProconBypassMan
29
- class ProConRejected < StandardError; end
33
+ extend ProconBypassMan::Configuration::ClassMethods
34
+
30
35
  class CouldNotLoadConfigError < StandardError; end
31
36
  class FirstConnectionError < StandardError; end
32
37
  class EternalConnectionError < StandardError; end
33
38
 
34
- def self.configure(setting_path: nil, &block)
39
+ def self.buttons_setting_configure(setting_path: nil, &block)
35
40
  unless setting_path
36
41
  logger.warn "setting_pathが未設定です。設定ファイルのライブリロードが使えません。"
37
42
  end
38
43
 
39
44
  if block_given?
40
- ProconBypassMan::Configuration.instance.instance_eval(&block)
45
+ ProconBypassMan::ButtonsSettingConfiguration.instance.instance_eval(&block)
41
46
  else
42
- ProconBypassMan::Configuration::Loader.load(setting_path: setting_path)
47
+ ProconBypassMan::ButtonsSettingConfiguration::Loader.load(setting_path: setting_path)
43
48
  end
44
49
  end
45
50
 
51
+ # @return [void]
46
52
  def self.run(setting_path: nil, &block)
47
53
  ProconBypassMan.logger.info "PBMを起動しています"
48
54
  puts "PBMを起動しています"
49
- configure(setting_path: setting_path, &block)
55
+ buttons_setting_configure(setting_path: setting_path, &block)
56
+ initialize_pbm
50
57
  File.write(pid_path, $$)
51
- Runner.new.run
58
+ ProconBypassMan::WriteSessionIdCommand.execute
59
+ ProconBypassMan::Background::JobRunner.start!
60
+ gadget, procon = ProconBypassMan::ConnectDeviceCommand.execute!
61
+ Runner.new(gadget: gadget, procon: procon).run
52
62
  rescue CouldNotLoadConfigError
53
- ProconBypassMan.logger.error "設定ファイルが不正です。設定ファイルの読み込みに失敗しました"
54
- puts "設定ファイルが不正です。設定ファイルの読み込みに失敗しました"
63
+ ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。設定ファイルの読み込みに失敗しました")
55
64
  FileUtils.rm_rf(ProconBypassMan.pid_path)
56
65
  FileUtils.rm_rf(ProconBypassMan.digest_path)
57
66
  exit 1
58
67
  rescue EternalConnectionError
59
- ProconBypassMan.logger.error "接続の見込みがないのでsleepしまくります"
60
- puts "接続の見込みがないのでsleepしまくります"
68
+ ProconBypassMan::SendErrorCommand.execute(error: "接続の見込みがないのでsleepしまくります")
61
69
  FileUtils.rm_rf(ProconBypassMan.pid_path)
62
70
  sleep(999999999)
63
71
  rescue FirstConnectionError
64
- puts "接続を確立できませんでした。やりなおします。"
72
+ ProconBypassMan::SendErrorCommand.execute(error: "接続を確立できませんでした。やりなおします。")
65
73
  retry
66
74
  end
67
75
 
68
- def self.logger=(logger)
69
- @@logger = logger
70
- end
71
-
72
- # @return [Logger]
73
- def self.logger
74
- if ENV["PBM_ENV"] == 'test'
75
- return Logger.new($stdout)
76
- end
77
-
78
- if defined?(@@logger) && @@logger.is_a?(Logger)
79
- @@logger
80
- else
81
- Logger.new(nil)
82
- end
83
- end
84
-
85
- def self.enable_critical_error_logging!
86
- @@enable_critical_error_logging = true
87
- end
88
-
89
- def self.error_logger
90
- if defined?(@@enable_critical_error_logging)
91
- @@error_logger ||= Logger.new("#{ProconBypassMan.root}/error.log", 5, 1024 * 1024 * 10)
92
- else
93
- Logger.new(nil)
94
- end
76
+ def self.configure(&block)
77
+ @@configuration = ProconBypassMan::Configuration.new
78
+ @@configuration.instance_eval(&block)
79
+ @@configuration
95
80
  end
96
81
 
97
- def self.pid_path
98
- @@pid_path ||= File.expand_path("#{root}/pbm_pid", __dir__).freeze
82
+ # @return [ProconBypassMan::Configuration]
83
+ def self.config
84
+ @@configuration ||= ProconBypassMan::Configuration.new
99
85
  end
100
86
 
87
+ # @return [void]
101
88
  def self.reset!
102
89
  ProconBypassMan::Procon::MacroRegistry.reset!
103
90
  ProconBypassMan::Procon::ModeRegistry.reset!
104
91
  ProconBypassMan::Procon.reset!
105
- ProconBypassMan::Configuration.instance.reset!
92
+ ProconBypassMan::ButtonsSettingConfiguration.instance.reset!
106
93
  ProconBypassMan::IOMonitor.reset!
107
94
  end
108
95
 
109
- def self.root
110
- if defined?(@@root)
111
- @@root
112
- else
113
- File.expand_path('..', __dir__).freeze
114
- end
115
- end
116
-
117
- def self.root=(path)
118
- @@root = path
119
- end
120
-
121
- def self.api_server=(api_server)
122
- @@api_server = api_server
123
- end
124
-
125
- def self.api_server
126
- if defined?(@@api_server)
127
- @@api_server
128
- else
129
- nil
130
- end
131
- end
132
-
133
- def self.cache
134
- @@cache_table ||= ProconBypassMan::OnMemoryCache.new
135
- end
136
-
137
- def self.digest_path
138
- "#{root}/.setting_yaml_digest"
96
+ def self.initialize_pbm
97
+ ProconBypassMan::WriteDeviceIdCommand.execute
139
98
  end
140
99
  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.
@@ -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
- * commands
7
- * systemctl daemon-reload
8
- * systemctl enable pbm.service
9
- * systemctl disable pbm.service
10
- * systemctl start pbm.service
11
- * systemctl status pbm.service
12
- * systemctl restart pbm.service
13
- * systemctl list-unit-files --type=service
6
+ * sudo ln -s /usr/share/pbm/current/systemd_units/pbm_web.service /etc/systemd/system/pbm_web.service
7
+ * sudo systemctl enable pbm.service
8
+ * sudo systemctl enable pbm_web.service
14
9
 
15
- ### ログ
16
- * journalctl -xe -f
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
17
22
 
23
+ ### デバッグ
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.13'
10
9
  end
11
10
 
12
- ProconBypassMan.tap do |pbm|
13
- pbm.root = File.expand_path(__dir__)
14
- pbm.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
15
- pbm.logger.level = :debug
16
- # pbm.api_server = 'https://...'
17
- pbm.enable_critical_error_logging!
11
+ ProconBypassMan.configure do |config|
12
+ config.root = File.expand_path(__dir__)
13
+ config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
14
+ config.logger.level = :debug
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")
@@ -0,0 +1,11 @@
1
+ [Unit]
2
+ Description=PBM WEB
3
+
4
+ [Service]
5
+ Type=simple
6
+ WorkingDirectory=/home/pi/src/procon_bypass_man_sample
7
+ ExecStart=/bin/bash -c "/home/pi/.rbenv/versions/3.0.1/bin/ruby /usr/share/pbm/current/web.rb"
8
+ Restart=always
9
+
10
+ [Install]
11
+ WantedBy=multi-user.target
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/inline'
4
+
5
+ gemfile do
6
+ source 'https://rubygems.org'
7
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
8
+ gem 'procon_bypass_man-web', '0.1.3'
9
+ end
10
+
11
+ ProconBypassMan::Web.configure do |config|
12
+ config.root = File.expand_path(__dir__)
13
+ config.logger = Logger.new("#{ProconBypassMan::Web.root}/web.log", 1, 1024 * 1024 * 10)
14
+ end
15
+
16
+ ProconBypassMan::Web::Server.start
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
 
@@ -63,7 +60,7 @@ class AnalogStickPosition
63
60
  end
64
61
 
65
62
  module ProconBypassMan
66
- class Configuration
63
+ class ButtonsSettingConfiguration
67
64
  attr_accessor layers: untyped
68
65
 
69
66
  attr_accessor setting_path: untyped
@@ -101,7 +98,7 @@ module ProconBypassMan
101
98
  end
102
99
 
103
100
  module ProconBypassMan
104
- class Configuration
101
+ class ButtonsSettingConfiguration
105
102
  class Layer
106
103
  attr_accessor mode: untyped
107
104
 
@@ -131,7 +128,7 @@ module ProconBypassMan
131
128
  end
132
129
 
133
130
  module ProconBypassMan
134
- class Configuration
131
+ class ButtonsSettingConfiguration
135
132
  module Loader
136
133
  def self.load: (setting_path: untyped setting_path) -> untyped
137
134
 
@@ -141,7 +138,7 @@ module ProconBypassMan
141
138
  end
142
139
 
143
140
  module ProconBypassMan
144
- class Configuration
141
+ class ButtonsSettingConfiguration
145
142
  class Validator
146
143
  def initialize: (untyped config) -> untyped
147
144
 
@@ -167,6 +164,46 @@ module ProconBypassMan
167
164
  end
168
165
  end
169
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
+
170
207
  class ProconBypassMan::DeviceConnector
171
208
  class BytesMismatchError < StandardError
172
209
  end
@@ -383,23 +420,17 @@ class ProconBypassMan::Procon::ModeRegistry
383
420
  def self.plugins: () -> untyped
384
421
  end
385
422
 
386
- module ProconBypassMan::Procon::PushedButtonHelper
423
+ module ProconBypassMan::Procon::PressedButtonHelper
387
424
  module Static
388
425
  def pressed_button?: (untyped button) -> untyped
389
426
  end
390
-
391
- module Dynamic
392
- def compile_if_not_compile_yet!: () -> untyped
393
- end
394
427
  end
395
428
 
396
429
  class ProconBypassMan::Procon
397
430
  class UserOperation
398
431
  include LayerChangeable
399
432
 
400
- include PushedButtonHelper::Static
401
-
402
- extend PushedButtonHelper::Dynamic
433
+ include PressedButtonHelper::Static
403
434
 
404
435
  attr_reader binary: untyped
405
436
 
@@ -458,7 +489,14 @@ end
458
489
 
459
490
  module ProconBypassMan
460
491
  class Uptime
461
- def self.from_boot: () -> untyped
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
462
500
  end
463
501
  end
464
502
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procon_bypass_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.13
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-19 00:00:00.000000000 Z
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: extension for Nintendo Switch Pro Controller
13
+ description: An extension for Nintendo Switch Pro Controller
14
14
  email:
15
15
  - n905i.1214@gmail.com
16
16
  executables: []
@@ -31,50 +31,80 @@ files:
31
31
  - Rakefile
32
32
  - Steepfile
33
33
  - bin/console
34
- - bin/report_receive_server.rb
34
+ - bin/dev_api_server.rb
35
35
  - bin/setup
36
36
  - docs/how_to_connect_procon.md
37
37
  - docs/setup_raspi.md
38
38
  - docs/setup_raspi.mitamae.rb
39
39
  - docs/setup_raspi_by_mitamae.md
40
- - examples/practical/app.rb
41
- - examples/practical/setting.yml
42
40
  - lib/procon_bypass_man.rb
43
- - lib/procon_bypass_man/analog_stick_position.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_load_config_job.rb
52
+ - lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb
53
+ - lib/procon_bypass_man/background/jobs/report_reload_config_job.rb
44
54
  - lib/procon_bypass_man/boot_message.rb
55
+ - lib/procon_bypass_man/buttons_setting_configuration.rb
56
+ - lib/procon_bypass_man/buttons_setting_configuration/layer.rb
57
+ - lib/procon_bypass_man/buttons_setting_configuration/loader.rb
58
+ - lib/procon_bypass_man/buttons_setting_configuration/validator.rb
45
59
  - lib/procon_bypass_man/bypass.rb
60
+ - lib/procon_bypass_man/bypass/usb_hid_logger.rb
61
+ - lib/procon_bypass_man/commands.rb
62
+ - lib/procon_bypass_man/commands/bypass_command.rb
63
+ - lib/procon_bypass_man/commands/connect_device_command.rb
64
+ - lib/procon_bypass_man/commands/print_boot_message_command.rb
65
+ - lib/procon_bypass_man/commands/send_error_command.rb
66
+ - lib/procon_bypass_man/commands/send_reload_config_event_command.rb
67
+ - lib/procon_bypass_man/commands/write_device_id_command.rb
68
+ - lib/procon_bypass_man/commands/write_session_id_command.rb
46
69
  - lib/procon_bypass_man/configuration.rb
47
- - lib/procon_bypass_man/configuration/layer.rb
48
- - lib/procon_bypass_man/configuration/loader.rb
49
- - lib/procon_bypass_man/configuration/validator.rb
50
70
  - lib/procon_bypass_man/device_connector.rb
51
- - lib/procon_bypass_man/error_reporter.rb
52
71
  - lib/procon_bypass_man/io_monitor.rb
53
- - lib/procon_bypass_man/on_memory_cache.rb
54
72
  - lib/procon_bypass_man/processor.rb
55
73
  - lib/procon_bypass_man/procon.rb
74
+ - lib/procon_bypass_man/procon/analog_stick.rb
56
75
  - lib/procon_bypass_man/procon/analog_stick_cap.rb
57
76
  - lib/procon_bypass_man/procon/button_collection.rb
58
- - lib/procon_bypass_man/procon/data.rb
59
- - lib/procon_bypass_man/procon/debug_dumper.rb
77
+ - lib/procon_bypass_man/procon/consts.rb
60
78
  - lib/procon_bypass_man/procon/flip_cache.rb
61
- - lib/procon_bypass_man/procon/layer_changeable.rb
79
+ - lib/procon_bypass_man/procon/layer_changer.rb
62
80
  - lib/procon_bypass_man/procon/macro_registry.rb
63
81
  - lib/procon_bypass_man/procon/mode_registry.rb
64
82
  - lib/procon_bypass_man/procon/press_button_aware.rb
65
- - lib/procon_bypass_man/procon/pressed_button_helper.rb
66
83
  - lib/procon_bypass_man/procon/user_operation.rb
67
- - lib/procon_bypass_man/reporter.rb
84
+ - lib/procon_bypass_man/procon_reader.rb
68
85
  - lib/procon_bypass_man/runner.rb
69
- - lib/procon_bypass_man/timer.rb
70
- - lib/procon_bypass_man/uptime.rb
86
+ - lib/procon_bypass_man/splatoon2.rb
87
+ - lib/procon_bypass_man/splatoon2/macro/fast_return.rb
88
+ - lib/procon_bypass_man/splatoon2/macro/jump_to_left_key.rb
89
+ - lib/procon_bypass_man/splatoon2/macro/jump_to_right_key.rb
90
+ - lib/procon_bypass_man/splatoon2/macro/jump_to_up_key.rb
91
+ - lib/procon_bypass_man/splatoon2/mode/guruguru.rb
92
+ - lib/procon_bypass_man/splatoon2/version.rb
93
+ - lib/procon_bypass_man/support/callbacks.rb
94
+ - lib/procon_bypass_man/support/compress_array.rb
95
+ - lib/procon_bypass_man/support/on_memory_cache.rb
96
+ - lib/procon_bypass_man/support/safe_timeout.rb
97
+ - lib/procon_bypass_man/support/signal_handler.rb
98
+ - lib/procon_bypass_man/support/uptime.rb
71
99
  - lib/procon_bypass_man/version.rb
72
100
  - procon_bypass_man.gemspec
73
101
  - project_template/README.md
74
102
  - project_template/app.rb
75
103
  - project_template/setting.yml
76
104
  - project_template/systemd_units/pbm.service
77
- - sig/README.rb
105
+ - project_template/systemd_units/pbm_web.service
106
+ - project_template/web.rb
107
+ - sig/README.md
78
108
  - sig/main.rbs
79
109
  homepage: https://github.com/splaplapla/procon_bypass_man
80
110
  licenses:
@@ -82,6 +112,7 @@ licenses:
82
112
  metadata:
83
113
  homepage_uri: https://github.com/splaplapla/procon_bypass_man
84
114
  source_code_uri: https://github.com/splaplapla/procon_bypass_man
115
+ changelog_uri: https://github.com/splaplapla/procon_bypass_man/blob/master/CHANGELOG.md
85
116
  post_install_message:
86
117
  rdoc_options: []
87
118
  require_paths:
@@ -97,8 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
128
  - !ruby/object:Gem::Version
98
129
  version: '0'
99
130
  requirements: []
100
- rubygems_version: 3.2.22
131
+ rubygems_version: 3.2.30
101
132
  signing_key:
102
133
  specification_version: 4
103
- summary: extension for Nintendo Switch Pro Controller
134
+ summary: An extension for Nintendo Switch Pro Controller
104
135
  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
@@ -1,14 +0,0 @@
1
- class AnalogStickPosition
2
- def initialize(x: , y: )
3
- @x = x
4
- @y = y
5
- end
6
-
7
- def y
8
- @y
9
- end
10
-
11
- def x
12
- @x
13
- end
14
- end
@@ -1,44 +0,0 @@
1
- require "net/http"
2
- require "json"
3
-
4
- class ProconBypassMan::ErrorReporter
5
- PATH = "/api/error_reports" # POST
6
-
7
- class Client
8
- def initialize
9
- @server = ProconBypassMan.api_server
10
- @hostname = `hostname`.chomp
11
- end
12
-
13
- def post(body: )
14
- # TODO ここでvalidationする
15
- if @server.nil?
16
- ProconBypassMan.logger.info('送信先が未設定なのでスキップしました')
17
- return
18
- end
19
-
20
- uri = URI.parse("#{@server}#{PATH}")
21
- http = Net::HTTP.new(uri.host, uri.port)
22
- http.use_ssl = uri.scheme === "https"
23
- response = http.post(
24
- uri.path,
25
- { report: body.full_message.to_json, hostname: @hostname }.to_json,
26
- { "Content-Type" => "application/json" },
27
- )
28
- unless response.code == /^20/
29
- ProconBypassMan.logger.error(response.body)
30
- end
31
- rescue => e
32
- puts e
33
- ProconBypassMan.logger.error(e)
34
- end
35
- end
36
-
37
- def self.report(body: )
38
- ProconBypassMan.logger.error(body)
39
- Client.new.post(body: body)
40
- rescue => e
41
- ProconBypassMan.logger.error(e)
42
- end
43
- end
44
-