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
@@ -1,8 +0,0 @@
1
- class AnalogStickPosition
2
- attr_accessor :x, :y
3
-
4
- def initialize(x: , y: )
5
- @x = x
6
- @y = y
7
- end
8
- end
@@ -1,40 +0,0 @@
1
- module ProconBypassMan
2
- module Outbound
3
- class Base
4
- class Client
5
- def initialize(path: , server: )
6
- @path = path
7
- if server.is_a?(Array)
8
- @server = server.first
9
- else
10
- @server = server
11
- end
12
- @hostname = `hostname`.chomp
13
- end
14
-
15
- def post(body: )
16
- # TODO ここでvalidationする
17
- if @server.nil?
18
- ProconBypassMan.logger.info('送信先が未設定なのでスキップしました')
19
- return
20
- end
21
-
22
- uri = URI.parse("#{@server}#{@path}")
23
- http = Net::HTTP.new(uri.host, uri.port)
24
- http.use_ssl = uri.scheme === "https"
25
- response = http.post(
26
- uri.path,
27
- { report: body.to_json, hostname: @hostname }.to_json,
28
- { "Content-Type" => "application/json" },
29
- )
30
- unless response.code == /^20/
31
- ProconBypassMan.logger.error(response.body)
32
- end
33
- rescue => e
34
- puts e
35
- ProconBypassMan.logger.error(e)
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,13 +0,0 @@
1
- require "procon_bypass_man/outbound/base"
2
-
3
- class ProconBypassMan::ErrorReporter < ProconBypassMan::Outbound::Base
4
- PATH = "/api/error_reports"
5
-
6
- def self.report(body: )
7
- Client.new(
8
- path: PATH,
9
- server: ProconBypassMan.config.api_server,
10
- ).post(body: body.full_message.to_json)
11
- end
12
- end
13
-
@@ -1,12 +0,0 @@
1
- require "procon_bypass_man/outbound/base"
2
-
3
- class ProconBypassMan::Reporter < ProconBypassMan::Outbound::Base
4
- PATH = "/api/reports"
5
-
6
- def self.report(body: )
7
- Client.new(
8
- path: PATH,
9
- server: ProconBypassMan.config.api_server,
10
- ).post(body: body.to_json)
11
- end
12
- end
@@ -1,13 +0,0 @@
1
- require "procon_bypass_man/outbound/base"
2
-
3
- class ProconBypassMan::UsbHidDataReporter < ProconBypassMan::Outbound::Base
4
- PATH = "/api/usb_hid_chunks"
5
-
6
- def self.report(body: )
7
- Client.new(
8
- path: PATH,
9
- server: ProconBypassMan.config.internal_api_servers,
10
- ).post(body: body.to_json)
11
- end
12
- end
13
-
@@ -1,17 +0,0 @@
1
- class ProconBypassMan::Procon::DebugDumper
2
- def initialize(binary: )
3
- @binary = binary
4
- # ProconBypassMan.logger.debug { "<<< patched #{@binary.unpack("H*")}" }
5
- end
6
-
7
- def dump_analog_sticks
8
- byte6 = @binary[6].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
9
- byte7 = @binary[7].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
10
- byte8 = @binary[8].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
11
-
12
- x = "#{byte7[4..7]}#{byte6}"
13
- y = "#{byte8}#{byte7[0..3]}"
14
- ProconBypassMan.logger.debug "x: #{x}, val: #{x.to_i(2)}"
15
- ProconBypassMan.logger.debug "y: #{y}, val: #{y.to_i(2)}"
16
- end
17
- 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::ButtonsSettingConfiguration.instance.prefix_keys.empty?
20
- raise "prefix_keysが未設定です"
21
- end
22
- ProconBypassMan::ButtonsSettingConfiguration.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,15 +0,0 @@
1
- module ProconBypassMan::Procon::PushedButtonHelper
2
- module Dynamic
3
- @@compiled = false
4
- def compile_if_not_compile_yet!
5
- unless @@compiled
6
- ::ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP.each do |button, _value|
7
- define_method "pressed_#{button}?" do
8
- pressed_button?(button)
9
- end
10
- end
11
- end
12
- @@compiled = true
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require "time"
2
-
3
- module ProconBypassMan
4
- class Uptime
5
- def self.from_boot
6
- result = `uptime -s`.chomp
7
- return -1 if result == '' # darwin系だとsオプションが使えない
8
- boot_time = result.to_i
9
- return Time.now.to_i - boot_time.to_i
10
- rescue => e
11
- ProconBypassMan.logger.error(e)
12
- return -1
13
- end
14
- end
15
- end