procon_bypass_man 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile.lock +24 -6
  4. data/README.md +8 -0
  5. data/lib/ext/em_pure_ruby.rb +25 -0
  6. data/lib/procon_bypass_man/background.rb +0 -1
  7. data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +2 -6
  8. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +1 -1
  9. data/lib/procon_bypass_man/bypass.rb +13 -6
  10. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +50 -1
  11. data/lib/procon_bypass_man/commands/print_message_command.rb +8 -0
  12. data/lib/procon_bypass_man/commands/run_remote_pbm_action_dispatch_command.rb +1 -1
  13. data/lib/procon_bypass_man/commands/send_reload_config_event_command.rb +1 -2
  14. data/lib/procon_bypass_man/commands.rb +1 -0
  15. data/lib/procon_bypass_man/configuration.rb +27 -0
  16. data/lib/procon_bypass_man/domains/binary/base.rb +11 -0
  17. data/lib/procon_bypass_man/domains/binary/has_immutable_binary.rb +5 -0
  18. data/lib/procon_bypass_man/domains/binary/has_mutable_binary.rb +5 -0
  19. data/lib/procon_bypass_man/domains/binary/inbound_procon_binary.rb +23 -0
  20. data/lib/procon_bypass_man/domains/binary/processing_procon_binary.rb +80 -0
  21. data/lib/procon_bypass_man/domains.rb +11 -0
  22. data/lib/procon_bypass_man/{plugin.rb → plugins.rb} +0 -0
  23. data/lib/procon_bypass_man/processor.rb +4 -5
  24. data/lib/procon_bypass_man/procon/button.rb +11 -0
  25. data/lib/procon_bypass_man/procon/button_collection.rb +2 -12
  26. data/lib/procon_bypass_man/procon/layer_changer.rb +3 -2
  27. data/lib/procon_bypass_man/procon/press_button_aware.rb +5 -4
  28. data/lib/procon_bypass_man/procon/user_operation.rb +46 -63
  29. data/lib/procon_bypass_man/procon/{analog_stick.rb → value_objects/analog_stick.rb} +3 -4
  30. data/lib/procon_bypass_man/procon/value_objects/procon_reader.rb +34 -0
  31. data/lib/procon_bypass_man/procon.rb +16 -14
  32. data/lib/procon_bypass_man/remote_pbm_action/{lib → commands}/update_remote_pbm_action_status_command.rb +0 -0
  33. data/lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb +1 -1
  34. data/lib/procon_bypass_man/{value_objects → remote_pbm_action/value_objects}/remote_pbm_action_object.rb +0 -0
  35. data/lib/procon_bypass_man/remote_pbm_action.rb +1 -1
  36. data/lib/procon_bypass_man/runner.rb +3 -3
  37. data/lib/procon_bypass_man/scheduler.rb +0 -7
  38. data/lib/procon_bypass_man/version.rb +1 -1
  39. data/lib/procon_bypass_man/websocket/pbm_job_client.rb +79 -0
  40. data/lib/procon_bypass_man.rb +12 -6
  41. data/procon_bypass_man.gemspec +2 -0
  42. data/project_template/app.rb +1 -1
  43. data/sig/main.rbs +15 -1
  44. metadata +45 -10
  45. data/lib/procon_bypass_man/background/jobs/fetch_and_run_remote_pbm_action_job.rb +0 -29
  46. data/lib/procon_bypass_man/boot_message.rb +0 -48
  47. data/lib/procon_bypass_man/commands/run_local_shell_command.rb +0 -6
  48. data/lib/procon_bypass_man/procon_reader.rb +0 -31
@@ -1,29 +0,0 @@
1
- class ProconBypassMan::FetchAndRunRemotePbmActionJob < ProconBypassMan::BaseJob
2
- extend ProconBypassMan::HasExternalApiSetting
3
-
4
- def self.perform
5
- pbm_jobs = ProconBypassMan::HttpClient.new(path: path, server_pool: server_pool).get
6
- if pbm_jobs.nil? || pbm_jobs.size.zero?
7
- # ProconBypassMan.logger.debug "remote pbm_jobsはありませんでした"
8
- return
9
- else
10
- pbm_job_hash = pbm_jobs.first
11
- begin
12
- pbm_job_object = ProconBypassMan::RemotePbmActionObject.new(action: pbm_job_hash["action"],
13
- status: pbm_job_hash["status"],
14
- uuid: pbm_job_hash["uuid"],
15
- created_at: pbm_job_hash["created_at"],
16
- job_args: pbm_job_hash["args"])
17
- pbm_job_object.validate!
18
- ProconBypassMan::RunRemotePbmActionDispatchCommand.execute(action: pbm_job_object.action, uuid: pbm_job_object.uuid, job_args: pbm_job_object.job_args)
19
- rescue ProconBypassMan::RemotePbmActionObject::ValidationError => e
20
- ProconBypassMan::SendErrorCommand.execute(error: e)
21
- end
22
- end
23
- end
24
-
25
- def self.path
26
- device_id = ProconBypassMan.device_id
27
- "/api/devices/#{device_id}/pbm_jobs"
28
- end
29
- end
@@ -1,48 +0,0 @@
1
- class ProconBypassMan::BootMessage
2
- def initialize
3
- @table = {}
4
- @table[:ruby_version] = RUBY_VERSION
5
- @table[:pbm_version] = ProconBypassMan::VERSION
6
- @table[:pid] = $$
7
- @table[:root_path] = ProconBypassMan.root
8
- @table[:pid_path] = ProconBypassMan.pid_path
9
- @table[:setting_path] = ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path
10
- @table[:uptime_from_boot] = ProconBypassMan::Uptime.from_boot
11
- @table[:use_pbmenv] = !(!!`which pbmenv`.empty?)
12
- @table[:session_id] = ProconBypassMan.session_id
13
- @table[:device_id] = ProconBypassMan.device_id
14
-
15
- # 開発中のHEADを取りたかったけど、Gem::Specification経由から取得する必要がありそう
16
- # build_version = `git rev-parse --short HEAD`.chomp
17
- # if build_version.empty?
18
- # @table[:build_version] = 'release version'
19
- # else
20
- # @table[:build_version] = build_version
21
- # end
22
-
23
- # build version: #{@table[:build_version]}
24
- end
25
-
26
- # @return [String]
27
- def to_s
28
- booted_message = <<~EOF
29
- ----
30
- RUBY_VERSION: #{@table[:ruby_version]}
31
- ProconBypassMan::VERSION: #{@table[:pbm_version]}
32
- pid: #{@table[:pid]}
33
- root: #{@table[:root_path]}
34
- pid_path: #{@table[:pid_path]}
35
- setting_path: #{@table[:setting_path]}
36
- uptime from boot: #{@table[:uptime_from_boot]} sec
37
- use_pbmenv: #{@table[:use_pbmenv]}
38
- session_id: #{ProconBypassMan.session_id}
39
- device_id: #{ProconBypassMan.device_id}
40
- ----
41
- EOF
42
- end
43
-
44
- # @return [Hash]
45
- def to_hash
46
- @table
47
- end
48
- end
@@ -1,6 +0,0 @@
1
- class ProconBypassMan::RunLocalShellCommand
2
- class LocalCommandError < StandardError; end
3
-
4
- def self.execute(action: , uuid: )
5
- end
6
- end
@@ -1,31 +0,0 @@
1
- class ProconBypassMan::ProconReader
2
- def initialize(binary: )
3
- @binary = binary
4
- @analog_stick = ProconBypassMan::Procon::AnalogStick.new(binary: binary)
5
- end
6
-
7
- # @return [Array<Symbol>]
8
- def pressed
9
- aware = ProconBypassMan::PpressButtonAware.new(@binary)
10
- pressed_table = ::ProconBypassMan::Procon::ButtonCollection::BUTTONS.reduce({}) do |acc, button|
11
- acc[button] = aware.pressed_button?(button)
12
- acc
13
- end
14
- pressed_table.select { |_key, value| value }.keys
15
- end
16
-
17
- def left_analog_stick
18
- { x: @analog_stick.relative_x, y: @analog_stick.relative_y }
19
- end
20
-
21
- def left_analog_stick_by_abs
22
- { x: @analog_stick.abs_x, y: @analog_stick.abs_y }
23
- end
24
-
25
- def to_hash
26
- { left_analog_stick: left_analog_stick,
27
- left_analog_stick_by_abs: left_analog_stick_by_abs,
28
- buttons: pressed,
29
- }
30
- end
31
- end