procon_bypass_man 0.1.21 → 0.1.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +9 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +7 -0
  5. data/Gemfile.lock +1 -1
  6. data/README.md +4 -1
  7. data/docs/getting_started.md +68 -4
  8. data/docs/setting/left-analogstick-cap.md +1 -1
  9. data/docs/setting/splatoon2_macro_dasei_cancel.md +4 -0
  10. data/docs/setting/splatoon2_macro_sokuwari_bubble.md +4 -0
  11. data/docs/setting/splatoon2_shake_tansan.md +47 -0
  12. data/lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb +17 -0
  13. data/lib/procon_bypass_man/background.rb +1 -0
  14. data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +142 -80
  15. data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +2 -0
  16. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button.rb +28 -0
  17. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button_list.rb +31 -0
  18. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/disable_macro_if_pressed.rb +28 -0
  19. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/flip_if_pressed.rb +31 -0
  20. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/force_neutral.rb +28 -0
  21. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed.rb +26 -0
  22. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil.rb +28 -0
  23. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/open_macro_steps.rb +26 -0
  24. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer.rb +17 -0
  25. data/lib/procon_bypass_man/buttons_setting_configuration.rb +5 -4
  26. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +4 -0
  27. data/lib/procon_bypass_man/configuration.rb +8 -1
  28. data/lib/procon_bypass_man/device_connector.rb +1 -4
  29. data/lib/procon_bypass_man/device_procon_finder.rb +0 -2
  30. data/lib/procon_bypass_man/domains/analog_stick_position.rb +18 -0
  31. data/lib/procon_bypass_man/domains/binary/processing_procon_binary.rb +6 -1
  32. data/lib/procon_bypass_man/domains.rb +1 -0
  33. data/lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb +21 -0
  34. data/lib/procon_bypass_man/plugin/splatoon2/version.rb +1 -1
  35. data/lib/procon_bypass_man/plugins.rb +1 -0
  36. data/lib/procon_bypass_man/procon/analog_stick_cap.rb +4 -23
  37. data/lib/procon_bypass_man/procon/analog_stick_manipulator.rb +36 -0
  38. data/lib/procon_bypass_man/procon/layer_changer.rb +4 -1
  39. data/lib/procon_bypass_man/procon/macro.rb +5 -2
  40. data/lib/procon_bypass_man/procon/macro_builder.rb +15 -17
  41. data/lib/procon_bypass_man/procon/macro_plugin_map.rb +23 -0
  42. data/lib/procon_bypass_man/procon/macro_registry.rb +21 -10
  43. data/lib/procon_bypass_man/procon/user_operation.rb +29 -15
  44. data/lib/procon_bypass_man/procon.rb +19 -5
  45. data/lib/procon_bypass_man/remote_macro/queue_over_process.rb +62 -0
  46. data/lib/procon_bypass_man/remote_macro/remote_macro_object.rb +30 -0
  47. data/lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb +37 -0
  48. data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +8 -0
  49. data/lib/procon_bypass_man/remote_macro/task.rb +6 -0
  50. data/lib/procon_bypass_man/remote_macro/task_queue.rb +13 -0
  51. data/lib/procon_bypass_man/remote_macro.rb +14 -0
  52. data/lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb +1 -1
  53. data/lib/procon_bypass_man/remote_pbm_action.rb +1 -0
  54. data/lib/procon_bypass_man/runner.rb +5 -1
  55. data/lib/procon_bypass_man/support/remote_macro_http_client.rb +9 -0
  56. data/lib/procon_bypass_man/usb_device_controller.rb +0 -2
  57. data/lib/procon_bypass_man/version.rb +1 -1
  58. data/lib/procon_bypass_man/websocket/{pbm_job_client.rb → client.rb} +31 -6
  59. data/lib/procon_bypass_man.rb +11 -2
  60. data/procon_bypass_man.gemspec +1 -1
  61. data/project_template/app.rb +1 -1
  62. metadata +27 -4
@@ -33,22 +33,22 @@ class ProconBypassMan::Procon::UserOperation
33
33
  binary.write_as_press_button(button)
34
34
  end
35
35
 
36
- # @param [Symbol, Array<Symbol>] button
37
- def press_button_only(button)
38
- if button.is_a?(Array)
39
- binary.set_no_action!
40
- button.uniq.each do |b|
41
- unless ProconBypassMan::Procon::MacroBuilder::RESERVED_WORD_NONE == b
42
- binary.write_as_press_button(b)
43
- end
44
- end
45
- return
46
- end
36
+ # @param [Symbol, Array<Symbol>] macro_step
37
+ def press_button_only_or_tilt_sticks(macro_step)
38
+ macro_step = [macro_step] if not macro_step.is_a?(Array)
39
+ # スティック操作の時はボタン入力を通す
40
+ binary.set_no_action! if is_button?(macro_step)
41
+
42
+ macro_step.uniq.each do |ms|
43
+ next if ProconBypassMan::Procon::MacroBuilder::RESERVED_WORD_NONE == ms
47
44
 
48
- if ProconBypassMan::Procon::MacroBuilder::RESERVED_WORD_NONE == button
49
- binary.set_no_action!
50
- else
51
- binary.write_as_press_button_only(button)
45
+ if is_button?(ms)
46
+ binary.write_as_press_button(ms)
47
+ elsif is_stick?(ms)
48
+ binary.write_as_tilt_left_stick(ms)
49
+ else
50
+ warn "知らないmacro stepです"
51
+ end
52
52
  end
53
53
  end
54
54
 
@@ -71,4 +71,18 @@ class ProconBypassMan::Procon::UserOperation
71
71
  aware = ProconBypassMan::PressButtonAware.new(@binary.raw)
72
72
  buttons.all? { |b| aware.pressing_button?(b) }
73
73
  end
74
+
75
+ # @return [Boolean]
76
+ def is_button?(button)
77
+ button = [button] if not button.is_a?(Array)
78
+
79
+ button.all? do |b|
80
+ !!ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP[b.to_sym] || b.to_sym == ProconBypassMan::Procon::MacroBuilder::RESERVED_WORD_NONE
81
+ end
82
+ end
83
+
84
+ # @return [Boolean]
85
+ def is_stick?(step)
86
+ !!(step =~ /\Atilt_/)
87
+ end
74
88
  end
@@ -1,3 +1,5 @@
1
+ require "procon_bypass_man/procon/macro_plugin_map"
2
+
1
3
  class ProconBypassMan::Procon
2
4
  require "procon_bypass_man/procon/consts"
3
5
  require "procon_bypass_man/procon/mode_registry"
@@ -78,12 +80,22 @@ class ProconBypassMan::Procon
78
80
  end
79
81
 
80
82
  if user_operation.pressing_all_buttons?(options[:if_pressed])
81
- @@status[:ongoing_macro] = MacroRegistry.load(macro_name)
83
+ @@status[:ongoing_macro] = MacroRegistry.load(macro_name, force_neutral_buttons: options[:force_neutral])
82
84
  break
83
85
  end
84
86
  end
85
87
  end
86
88
 
89
+ # remote macro
90
+ if task = ProconBypassMan::RemoteMacro::TaskQueueInProcess.non_blocking_shift
91
+ ProconBypassMan::Procon::MacroRegistry.cleanup_remote_macros!
92
+ macro_name = task.name || "RemoteMacro-#{task.steps.join}".to_sym
93
+ ProconBypassMan::Procon::MacroRegistry.install_plugin(macro_name, steps: task.steps, macro_type: :remote)
94
+ @@status[:ongoing_macro] = MacroRegistry.load(macro_name, macro_type: :remote) do
95
+ ProconBypassMan::PostCompletedRemoteMacroJob.perform_async(task.uuid)
96
+ end
97
+ end
98
+
87
99
  case current_layer.mode
88
100
  when :manual
89
101
  @@status[:ongoing_mode] = ModeRegistry.load(:manual)
@@ -124,9 +136,11 @@ class ProconBypassMan::Procon
124
136
  return user_operation.binary.raw
125
137
  end
126
138
 
127
- if ongoing_macro.ongoing?
128
- step = ongoing_macro.next_step or return(user_operation.binary.raw)
129
- user_operation.press_button_only(step)
139
+ if ongoing_macro.ongoing? && (step = ongoing_macro.next_step)
140
+ ongoing_macro.force_neutral_buttons&.each do |force_neutral_button|
141
+ user_operation.unpress_button(force_neutral_button)
142
+ end
143
+ user_operation.press_button_only_or_tilt_sticks(step)
130
144
  return user_operation.binary.raw
131
145
  end
132
146
 
@@ -135,7 +149,7 @@ class ProconBypassMan::Procon
135
149
  end
136
150
 
137
151
  current_layer.left_analog_stick_caps.each do |config|
138
- if config[:if_pressed].nil? || user_operation.pressing_all_buttons?(config[:if_pressed])
152
+ if !config[:if_pressed] || user_operation.pressing_all_buttons?(config[:if_pressed])
139
153
  config[:force_neutral]&.each do |force_neutral_button|
140
154
  user_operation.unpress_button(force_neutral_button)
141
155
  end
@@ -0,0 +1,62 @@
1
+ class ProconBypassMan::QueueOverProcess
2
+ attr_reader :drb
3
+
4
+ @@drb_server = nil
5
+ @@drb_server_thread = nil
6
+
7
+ def self.start!
8
+ return unless ProconBypassMan.config.enable_remote_macro?
9
+ require 'drb/drb'
10
+
11
+ FileUtils.rm_rf(file_path) if File.exist?(file_path)
12
+ begin
13
+ @@drb_server = DRb.start_service(url, Queue.new, safe_level: 1)
14
+ rescue Errno::EADDRINUSE => e
15
+ ProconBypassMan.logger.error e
16
+ raise
17
+ end
18
+
19
+ @@drb_server_thread =
20
+ Thread.new do
21
+ DRb.thread.join
22
+ end
23
+ end
24
+
25
+ def self.shutdown
26
+ if @@drb_server
27
+ @@drb_server_thread.kill
28
+ @@drb_server.stop_service
29
+ end
30
+ end
31
+
32
+ def self.push(value)
33
+ return unless ProconBypassMan.config.enable_remote_macro?
34
+
35
+ drb.push(value)
36
+ end
37
+
38
+ def self.pop
39
+ return unless ProconBypassMan.config.enable_remote_macro?
40
+
41
+ drb.pop
42
+ end
43
+
44
+ def self.drb
45
+ return unless ProconBypassMan.config.enable_remote_macro?
46
+
47
+ @@drb ||= new.drb
48
+ end
49
+
50
+ PROTOCOL = "drbunix"
51
+ def self.url
52
+ "#{PROTOCOL}:/tmp/procon_bypass_man_queue"
53
+ end
54
+
55
+ def self.file_path
56
+ url.gsub("#{PROTOCOL}:", "")
57
+ end
58
+
59
+ def initialize
60
+ @drb = DRbObject.new_with_uri(self.class.url)
61
+ end
62
+ end
@@ -0,0 +1,30 @@
1
+ module ProconBypassMan
2
+ class RemoteMacroObject
3
+ # valueobjectがvalidatorの責務も持っている. 今度分離する
4
+ class ValidationError < StandardError; end
5
+ class MustBeNotNilError < ValidationError; end
6
+ class NonSupportAction < ValidationError; end
7
+
8
+ attr_accessor :name, :uuid, :steps
9
+
10
+ # @param [String] name
11
+ # @param [String] uuid
12
+ # @param [Array] steps
13
+ def initialize(name: , uuid:, steps: )
14
+ @name = name
15
+ @uuid = uuid
16
+ @steps = steps
17
+ freeze
18
+ end
19
+
20
+ # @raise [MustBeNotNilError]
21
+ # @raise [NonSupportAction]
22
+ # @return [void]
23
+ def validate!
24
+ self.uuid or raise MustBeNotNilError, "uuidは値が必須です"
25
+ unless self.steps.is_a?(Array)
26
+ raise ValidationError, "stepsは配列です"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ class ProconBypassMan::RemoteMacroReceiver
2
+ # forkしたプロセスで動かすクラス。sock経由で命令を受け取ってmacoのキューに積んでいく
3
+ def self.start_with_foreground!
4
+ return unless ProconBypassMan.config.enable_remote_macro?
5
+
6
+ run
7
+ end
8
+
9
+ def self.start!
10
+ return unless ProconBypassMan.config.enable_remote_macro?
11
+
12
+ Thread.start do
13
+ start_with_foreground!
14
+ end
15
+ end
16
+
17
+ def self.run
18
+ while(task = ProconBypassMan::QueueOverProcess.pop)
19
+ receive(task)
20
+ end
21
+ shutdown
22
+ rescue Errno::ENOENT, Errno::ECONNRESET, Errno::ECONNREFUSED => e
23
+ ProconBypassMan.logger.debug(e)
24
+ end
25
+
26
+
27
+ # @param [ProconBypassMan::RemoteMacro::Task] task
28
+ def self.receive(task)
29
+ ProconBypassMan.logger.info "[remote macro][receiver] name: #{task.name}, uuid: #{task.uuid}, steps: #{task.steps}"
30
+ ProconBypassMan::RemoteMacro::TaskQueueInProcess.push(task)
31
+ true
32
+ end
33
+
34
+ def self.shutdown
35
+ ProconBypassMan.logger.info("ProconBypassMan::RemoteMacroReceiverを終了します。")
36
+ end
37
+ end
@@ -0,0 +1,8 @@
1
+ class ProconBypassMan::RemoteMacroSender
2
+ def self.execute(name: , uuid: , steps: )
3
+ ProconBypassMan.logger.info "[remote macro][sender] name: #{name}, uuid: #{uuid}, steps: #{steps}"
4
+ ProconBypassMan::QueueOverProcess.push(
5
+ ProconBypassMan::RemoteMacro::Task.new(name, uuid, steps)
6
+ )
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module ProconBypassMan
2
+ module RemoteMacro
3
+ class Task < Struct.new(:name, :uuid, :steps)
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ module ProconBypassMan
2
+ module RemoteMacro
3
+ class TaskQueue < ::Queue
4
+ def present?
5
+ not empty?
6
+ end
7
+
8
+ def non_blocking_shift
9
+ present? && shift
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module ProconBypassMan
2
+ module RemoteMacro
3
+ require "procon_bypass_man/remote_macro/remote_macro_object"
4
+ require "procon_bypass_man/remote_macro/remote_macro_receiver"
5
+ require "procon_bypass_man/remote_macro/remote_macro_sender"
6
+ require "procon_bypass_man/remote_macro/queue_over_process"
7
+ require "procon_bypass_man/remote_macro/task"
8
+ require "procon_bypass_man/remote_macro/task_queue"
9
+
10
+ ACTION_KEY = "remote_macro"
11
+
12
+ TaskQueueInProcess = ProconBypassMan::RemoteMacro::TaskQueue.new
13
+ end
14
+ end
@@ -11,7 +11,7 @@ module ProconBypassMan
11
11
  # @param [String] status
12
12
  # @param [String] #uuid
13
13
  # @param [Time] created_at
14
- # @return [Hash] job_args
14
+ # @param [Hash] job_args
15
15
  def initialize(action: , status:, uuid:, created_at:, job_args: )
16
16
  self.action = action
17
17
  self.status = status
@@ -6,6 +6,7 @@ module ProconBypassMan
6
6
  require "procon_bypass_man/remote_pbm_action/stop_pbm_action"
7
7
  require "procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb"
8
8
  require "procon_bypass_man/remote_pbm_action/commands/update_remote_pbm_action_status_command"
9
+ require "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
9
10
 
10
11
  ACTION_CHANGE_PBM_VERSION = "change_pbm_version"
11
12
  ACTION_REBOOT_OS = "reboot_os"
@@ -27,7 +27,11 @@ class ProconBypassMan::Runner
27
27
  loop do
28
28
  $will_terminate_token = false
29
29
  # NOTE メインプロセスではThreadをいくつか起動しているので念のためパフォーマンスを優先するためにforkしていく
30
- child_pid = Kernel.fork { ProconBypassMan::BypassCommand.new(gadget: @gadget, procon: @procon).execute }
30
+ child_pid = Kernel.fork {
31
+ DRb.start_service if defined?(DRb)
32
+ ProconBypassMan::RemoteMacroReceiver.start!
33
+ ProconBypassMan::BypassCommand.new(gadget: @gadget, procon: @procon).execute
34
+ }
31
35
 
32
36
  begin
33
37
  # TODO 小プロセスが消滅した時に、メインプロセスは生き続けてしまい、何もできなくなる問題がある
@@ -0,0 +1,9 @@
1
+ module ProconBypassMan
2
+ class RemoteMacroHttpClient < HttpClient
3
+ def post(job_id: )
4
+ super(request_body: {
5
+ job_id: job_id,
6
+ })
7
+ end
8
+ end
9
+ end
@@ -10,8 +10,6 @@ class ProconBypassMan::UsbDeviceController
10
10
  return if initialized?
11
11
 
12
12
  shell = <<~EOH
13
- #!/bin/bash
14
-
15
13
  cd /sys/kernel/config/usb_gadget/
16
14
  mkdir -p procon
17
15
  cd procon
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProconBypassMan
4
- VERSION = "0.1.21"
4
+ VERSION = "0.1.22"
5
5
  end
@@ -1,6 +1,6 @@
1
1
  module ProconBypassMan
2
2
  module Websocket
3
- module PbmJobClient
3
+ module Client
4
4
  CHANNEL = 'PbmJobChannel'
5
5
 
6
6
  def self.start!
@@ -20,7 +20,7 @@ module ProconBypassMan
20
20
  )
21
21
 
22
22
  client.connected {
23
- ProconBypassMan.logger.info('websocket client: successfully connected in ProconBypassMan::Websocket::PbmJobClient')
23
+ ProconBypassMan.logger.info('websocket client: successfully connected in ProconBypassMan::Websocket::Client')
24
24
  }
25
25
  client.subscribed { |msg|
26
26
  ProconBypassMan.logger.info('websocket client: subscribed')
@@ -63,17 +63,22 @@ module ProconBypassMan
63
63
  # @param [Hash] data
64
64
  def self.dispatch(data: , client: )
65
65
  pbm_job_hash = data.dig("message")
66
- if pbm_job_hash['action'] == "ping"
66
+ case pbm_job_hash['action']
67
+ when "ping"
67
68
  client.perform('pong', { device_id: ProconBypassMan.device_id, message: 'hello from pbm' })
69
+ when ProconBypassMan::RemoteMacro::ACTION_KEY
70
+ validate_and_run_remote_macro(data: data)
71
+ when *ProconBypassMan::RemotePbmAction::ACTIONS
72
+ validate_and_run_remote_pbm_action(data: data)
68
73
  else
69
- validate_and_run(data: data)
74
+ ProconBypassMan.logger.error "unknown action"
70
75
  end
71
76
  end
72
77
 
73
78
  # @raise [ProconBypassMan::RemotePbmActionObject::ValidationError]
74
79
  # @param [Hash] data
75
80
  # @return [Void]
76
- def self.validate_and_run(data: )
81
+ def self.validate_and_run_remote_pbm_action(data: )
77
82
  pbm_job_hash = data.dig("message")
78
83
  begin
79
84
  pbm_job_object = ProconBypassMan::RemotePbmActionObject.new(action: pbm_job_hash["action"],
@@ -83,7 +88,8 @@ module ProconBypassMan
83
88
  job_args: pbm_job_hash["args"])
84
89
  pbm_job_object.validate!
85
90
  rescue ProconBypassMan::RemotePbmActionObject::ValidationError => e
86
- raise
91
+ ProconBypassMan::SendErrorCommand.execute(error: e)
92
+ return
87
93
  end
88
94
 
89
95
  ProconBypassMan::RunRemotePbmActionDispatchCommand.execute(
@@ -92,6 +98,25 @@ module ProconBypassMan
92
98
  job_args: pbm_job_object.job_args
93
99
  )
94
100
  end
101
+
102
+ def self.validate_and_run_remote_macro(data: )
103
+ pbm_job_hash = data.dig("message")
104
+ begin
105
+ remote_macro_object = ProconBypassMan::RemoteMacroObject.new(name: pbm_job_hash["name"],
106
+ uuid: pbm_job_hash["uuid"],
107
+ steps: pbm_job_hash["steps"])
108
+ remote_macro_object.validate!
109
+ rescue ProconBypassMan::RemoteMacroObject::ValidationError => e
110
+ ProconBypassMan::SendErrorCommand.execute(error: e)
111
+ return
112
+ end
113
+
114
+ ProconBypassMan::RemoteMacroSender.execute(
115
+ name: remote_macro_object.name,
116
+ uuid: remote_macro_object.uuid,
117
+ steps: remote_macro_object.steps,
118
+ )
119
+ end
95
120
  end
96
121
  end
97
122
  end
@@ -13,6 +13,7 @@ require "pbmenv"
13
13
 
14
14
  require_relative "procon_bypass_man/version"
15
15
  require_relative "procon_bypass_man/remote_pbm_action"
16
+ require_relative "procon_bypass_man/remote_macro"
16
17
  require_relative "procon_bypass_man/support/signal_handler"
17
18
  require_relative "procon_bypass_man/support/callbacks"
18
19
  require_relative "procon_bypass_man/support/yaml_writer"
@@ -22,6 +23,7 @@ require_relative "procon_bypass_man/support/uptime"
22
23
  require_relative "procon_bypass_man/support/on_memory_cache"
23
24
  require_relative "procon_bypass_man/support/http_client"
24
25
  require_relative "procon_bypass_man/support/report_http_client"
26
+ require_relative "procon_bypass_man/support/remote_macro_http_client"
25
27
  require_relative "procon_bypass_man/support/update_remote_pbm_action_status_http_client"
26
28
  require_relative "procon_bypass_man/support/send_device_stats_http_client"
27
29
  require_relative "procon_bypass_man/support/server_pool"
@@ -44,10 +46,11 @@ require_relative "procon_bypass_man/procon/button"
44
46
  require_relative "procon_bypass_man/procon/value_objects/analog_stick"
45
47
  require_relative "procon_bypass_man/procon/value_objects/procon_reader"
46
48
  require_relative "procon_bypass_man/procon/analog_stick_cap"
49
+ require_relative "procon_bypass_man/procon/analog_stick_manipulator"
47
50
  require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
48
51
  require_relative "procon_bypass_man/scheduler"
49
52
  require_relative "procon_bypass_man/plugins"
50
- require_relative "procon_bypass_man/websocket/pbm_job_client"
53
+ require_relative "procon_bypass_man/websocket/client"
51
54
  require_relative "procon_bypass_man/websocket/watchdog"
52
55
  require_relative "procon_bypass_man/websocket/forever"
53
56
 
@@ -67,7 +70,8 @@ module ProconBypassMan
67
70
  def self.run(setting_path: nil)
68
71
  ProconBypassMan::Scheduler.start!
69
72
  ProconBypassMan::Background::JobRunner.start!
70
- ProconBypassMan::Websocket::PbmJobClient.start!
73
+ ProconBypassMan::Websocket::Client.start!
74
+ ProconBypassMan::QueueOverProcess.start!
71
75
 
72
76
  ProconBypassMan::PrintMessageCommand.execute(text: "PBMを起動しています")
73
77
  initialize_pbm
@@ -76,19 +80,24 @@ module ProconBypassMan
76
80
  Runner.new(gadget: gadget, procon: procon).run # ここでblockingする
77
81
  FileUtils.rm_rf(ProconBypassMan.pid_path)
78
82
  FileUtils.rm_rf(ProconBypassMan.digest_path)
83
+ ProconBypassMan::QueueOverProcess.shutdown
79
84
  rescue ProconBypassMan::CouldNotLoadConfigError
80
85
  ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。設定ファイルの読み込みに失敗しました")
81
86
  ProconBypassMan::DeviceStatus.change_to_setting_syntax_error_and_shutdown!
87
+ # TODO シグナルトラップをしていないのでUSR2を送ったときにプロセスが停止している. 明示的にハンドリングするべき.
82
88
  ProconBypassMan.exit_if_allow(1) do
83
89
  FileUtils.rm_rf(ProconBypassMan.pid_path)
84
90
  FileUtils.rm_rf(ProconBypassMan.digest_path)
91
+ ProconBypassMan::QueueOverProcess.shutdown
85
92
  end
86
93
  rescue ProconBypassMan::ConnectDeviceCommand::NotFoundProconError
87
94
  ProconBypassMan::SendErrorCommand.execute(error: "プロコンが見つかりませんでした。")
88
95
  ProconBypassMan::DeviceStatus.change_to_procon_not_found_error!
96
+ # TODO シグナルトラップをしていないのでUSR2を送ったときにプロセスが停止している. 明示的にハンドリングするべき.
89
97
  ProconBypassMan.exit_if_allow(1) do
90
98
  FileUtils.rm_rf(ProconBypassMan.pid_path)
91
99
  FileUtils.rm_rf(ProconBypassMan.digest_path)
100
+ ProconBypassMan::QueueOverProcess.shutdown
92
101
  end
93
102
  rescue ProconBypassMan::ConnectionError
94
103
  begin
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = spec.summary
13
13
  spec.homepage = "https://github.com/splaplapla/procon_bypass_man"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
@@ -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', '0.1.21'
8
+ gem 'procon_bypass_man', '0.1.22'
9
9
  end
10
10
 
11
11
  ProconBypassMan.configure do |config|
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.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-03 00:00:00.000000000 Z
11
+ date: 2022-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pbmenv
@@ -82,6 +82,7 @@ files:
82
82
  - docs/setting/splatoon2_macro_dasei_cancel.md
83
83
  - docs/setting/splatoon2_macro_sokuwari_bubble.md
84
84
  - docs/setting/splatoon2_recommended_setting.md
85
+ - docs/setting/splatoon2_shake_tansan.md
85
86
  - docs/setup_raspi.md
86
87
  - docs/setup_raspi.mitamae.rb
87
88
  - docs/setup_raspi_by_mitamae.md
@@ -96,6 +97,7 @@ files:
96
97
  - lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb
97
98
  - lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb
98
99
  - lib/procon_bypass_man/background/jobs/concerns/job_runnable.rb
100
+ - lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb
99
101
  - lib/procon_bypass_man/background/jobs/report_boot_job.rb
100
102
  - lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb
101
103
  - lib/procon_bypass_man/background/jobs/report_error_job.rb
@@ -109,6 +111,15 @@ files:
109
111
  - lib/procon_bypass_man/buttons_setting_configuration.rb
110
112
  - lib/procon_bypass_man/buttons_setting_configuration/layer.rb
111
113
  - lib/procon_bypass_man/buttons_setting_configuration/loader.rb
114
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer.rb
115
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button.rb
116
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button_list.rb
117
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/disable_macro_if_pressed.rb
118
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/flip_if_pressed.rb
119
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/force_neutral.rb
120
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed.rb
121
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil.rb
122
+ - lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/open_macro_steps.rb
112
123
  - lib/procon_bypass_man/buttons_setting_configuration/validator.rb
113
124
  - lib/procon_bypass_man/bypass.rb
114
125
  - lib/procon_bypass_man/bypass/usb_hid_logger.rb
@@ -127,6 +138,7 @@ files:
127
138
  - lib/procon_bypass_man/device_procon_finder.rb
128
139
  - lib/procon_bypass_man/device_status.rb
129
140
  - lib/procon_bypass_man/domains.rb
141
+ - lib/procon_bypass_man/domains/analog_stick_position.rb
130
142
  - lib/procon_bypass_man/domains/binary/base.rb
131
143
  - lib/procon_bypass_man/domains/binary/has_immutable_binary.rb
132
144
  - lib/procon_bypass_man/domains/binary/has_mutable_binary.rb
@@ -134,6 +146,7 @@ files:
134
146
  - lib/procon_bypass_man/domains/binary/processing_procon_binary.rb
135
147
  - lib/procon_bypass_man/domains/bypass_mode.rb
136
148
  - lib/procon_bypass_man/io_monitor.rb
149
+ - lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb
137
150
  - lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb
138
151
  - lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb
139
152
  - lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb
@@ -146,6 +159,7 @@ files:
146
159
  - lib/procon_bypass_man/processor.rb
147
160
  - lib/procon_bypass_man/procon.rb
148
161
  - lib/procon_bypass_man/procon/analog_stick_cap.rb
162
+ - lib/procon_bypass_man/procon/analog_stick_manipulator.rb
149
163
  - lib/procon_bypass_man/procon/button.rb
150
164
  - lib/procon_bypass_man/procon/button_collection.rb
151
165
  - lib/procon_bypass_man/procon/consts.rb
@@ -153,12 +167,20 @@ files:
153
167
  - lib/procon_bypass_man/procon/layer_changer.rb
154
168
  - lib/procon_bypass_man/procon/macro.rb
155
169
  - lib/procon_bypass_man/procon/macro_builder.rb
170
+ - lib/procon_bypass_man/procon/macro_plugin_map.rb
156
171
  - lib/procon_bypass_man/procon/macro_registry.rb
157
172
  - lib/procon_bypass_man/procon/mode_registry.rb
158
173
  - lib/procon_bypass_man/procon/press_button_aware.rb
159
174
  - lib/procon_bypass_man/procon/user_operation.rb
160
175
  - lib/procon_bypass_man/procon/value_objects/analog_stick.rb
161
176
  - lib/procon_bypass_man/procon/value_objects/procon_reader.rb
177
+ - lib/procon_bypass_man/remote_macro.rb
178
+ - lib/procon_bypass_man/remote_macro/queue_over_process.rb
179
+ - lib/procon_bypass_man/remote_macro/remote_macro_object.rb
180
+ - lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb
181
+ - lib/procon_bypass_man/remote_macro/remote_macro_sender.rb
182
+ - lib/procon_bypass_man/remote_macro/task.rb
183
+ - lib/procon_bypass_man/remote_macro/task_queue.rb
162
184
  - lib/procon_bypass_man/remote_pbm_action.rb
163
185
  - lib/procon_bypass_man/remote_pbm_action/base_action.rb
164
186
  - lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb
@@ -175,6 +197,7 @@ files:
175
197
  - lib/procon_bypass_man/support/http_client.rb
176
198
  - lib/procon_bypass_man/support/never_exit_accidentally.rb
177
199
  - lib/procon_bypass_man/support/on_memory_cache.rb
200
+ - lib/procon_bypass_man/support/remote_macro_http_client.rb
178
201
  - lib/procon_bypass_man/support/report_http_client.rb
179
202
  - lib/procon_bypass_man/support/safe_timeout.rb
180
203
  - lib/procon_bypass_man/support/send_device_stats_http_client.rb
@@ -185,8 +208,8 @@ files:
185
208
  - lib/procon_bypass_man/support/yaml_writer.rb
186
209
  - lib/procon_bypass_man/usb_device_controller.rb
187
210
  - lib/procon_bypass_man/version.rb
211
+ - lib/procon_bypass_man/websocket/client.rb
188
212
  - lib/procon_bypass_man/websocket/forever.rb
189
- - lib/procon_bypass_man/websocket/pbm_job_client.rb
190
213
  - lib/procon_bypass_man/websocket/watchdog.rb
191
214
  - procon_bypass_man.gemspec
192
215
  - project_template/README.md
@@ -213,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
236
  requirements:
214
237
  - - ">="
215
238
  - !ruby/object:Gem::Version
216
- version: 2.4.0
239
+ version: 3.0.0
217
240
  required_rubygems_version: !ruby/object:Gem::Requirement
218
241
  requirements:
219
242
  - - ">="