procon_bypass_man 0.1.20.1 → 0.1.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +33 -8
  3. data/.github/workflows/ruby.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rspec +1 -0
  6. data/CHANGELOG.md +29 -2
  7. data/Gemfile.lock +3 -3
  8. data/README.md +4 -1
  9. data/docs/getting_started.md +104 -7
  10. data/docs/setting/left-analogstick-cap.md +1 -1
  11. data/docs/setting/splatoon2_macro_dasei_cancel.md +77 -0
  12. data/docs/setting/splatoon2_macro_sokuwari_bubble.md +4 -0
  13. data/docs/setting/splatoon2_shake_tansan.md +47 -0
  14. data/lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb +17 -0
  15. data/lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb +10 -0
  16. data/lib/procon_bypass_man/background.rb +2 -0
  17. data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +155 -70
  18. data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +2 -0
  19. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button.rb +28 -0
  20. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button_list.rb +31 -0
  21. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/disable_macro_if_pressed.rb +28 -0
  22. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/flip_if_pressed.rb +31 -0
  23. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/force_neutral.rb +28 -0
  24. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed.rb +26 -0
  25. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil.rb +28 -0
  26. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/open_macro_steps.rb +26 -0
  27. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer.rb +17 -0
  28. data/lib/procon_bypass_man/buttons_setting_configuration.rb +6 -5
  29. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +4 -0
  30. data/lib/procon_bypass_man/bypass.rb +0 -1
  31. data/lib/procon_bypass_man/commands/connect_device_command.rb +11 -21
  32. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +6 -0
  33. data/lib/procon_bypass_man/configuration.rb +8 -1
  34. data/lib/procon_bypass_man/device_connector.rb +7 -13
  35. data/lib/procon_bypass_man/device_procon_finder.rb +0 -22
  36. data/lib/procon_bypass_man/domains/analog_stick_position.rb +18 -0
  37. data/lib/procon_bypass_man/domains/binary/processing_procon_binary.rb +7 -2
  38. data/lib/procon_bypass_man/{bypass → domains}/bypass_mode.rb +8 -0
  39. data/lib/procon_bypass_man/domains.rb +2 -0
  40. data/lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb +21 -0
  41. data/lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb +21 -0
  42. data/lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb +4 -0
  43. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb +4 -0
  44. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb +4 -0
  45. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_up_key.rb +4 -0
  46. data/lib/procon_bypass_man/plugin/splatoon2/macro/sokuwari_for_splash_bomb.rb +4 -0
  47. data/lib/procon_bypass_man/plugin/splatoon2/mode/guruguru.rb +4 -0
  48. data/lib/procon_bypass_man/plugin/splatoon2/version.rb +1 -1
  49. data/lib/procon_bypass_man/plugins.rb +2 -0
  50. data/lib/procon_bypass_man/procon/analog_stick_cap.rb +4 -23
  51. data/lib/procon_bypass_man/procon/analog_stick_manipulator.rb +36 -0
  52. data/lib/procon_bypass_man/procon/button_collection.rb +0 -8
  53. data/lib/procon_bypass_man/procon/layer_changer.rb +4 -1
  54. data/lib/procon_bypass_man/procon/macro.rb +53 -25
  55. data/lib/procon_bypass_man/procon/macro_builder.rb +43 -35
  56. data/lib/procon_bypass_man/procon/macro_plugin_map.rb +23 -0
  57. data/lib/procon_bypass_man/procon/macro_registry.rb +26 -10
  58. data/lib/procon_bypass_man/procon/user_operation.rb +30 -16
  59. data/lib/procon_bypass_man/procon/value_objects/analog_stick.rb +9 -5
  60. data/lib/procon_bypass_man/procon.rb +51 -17
  61. data/lib/procon_bypass_man/remote_macro/queue_over_process.rb +62 -0
  62. data/lib/procon_bypass_man/remote_macro/remote_macro_object.rb +30 -0
  63. data/lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb +37 -0
  64. data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +8 -0
  65. data/lib/procon_bypass_man/remote_macro/task.rb +6 -0
  66. data/lib/procon_bypass_man/remote_macro/task_queue.rb +13 -0
  67. data/lib/procon_bypass_man/remote_macro.rb +14 -0
  68. data/lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb +4 -1
  69. data/lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb +1 -1
  70. data/lib/procon_bypass_man/remote_pbm_action.rb +1 -0
  71. data/lib/procon_bypass_man/runner.rb +5 -1
  72. data/lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb +59 -0
  73. data/lib/procon_bypass_man/{never_exit_accidentally.rb → support/never_exit_accidentally.rb} +0 -0
  74. data/lib/procon_bypass_man/support/remote_macro_http_client.rb +9 -0
  75. data/lib/procon_bypass_man/usb_device_controller.rb +51 -0
  76. data/lib/procon_bypass_man/version.rb +1 -1
  77. data/lib/procon_bypass_man/websocket/{pbm_job_client.rb → client.rb} +44 -12
  78. data/lib/procon_bypass_man/websocket/forever.rb +47 -0
  79. data/lib/procon_bypass_man/websocket/watchdog.rb +19 -0
  80. data/lib/procon_bypass_man.rb +19 -9
  81. data/procon_bypass_man.gemspec +2 -2
  82. data/project_template/app.rb +10 -2
  83. data/project_template/systemd_units/pbm.service +1 -1
  84. data/sig/main.rbs +20 -0
  85. metadata +38 -8
@@ -0,0 +1,59 @@
1
+ class ProconBypassMan::AnalogStickTiltingPowerScaler
2
+ DEFAULT_THRESHOLD = 500
3
+
4
+ class PowerChunk
5
+ def initialize(list)
6
+ @list = list
7
+ end
8
+
9
+ def moving_power
10
+ max = @list.max
11
+ min = @list.min
12
+ moving_power = (max - min).abs
13
+ end
14
+
15
+ def tilting?(threshold: DEFAULT_THRESHOLD, current_position_x: , current_position_y: )
16
+ # スティックがニュートラルな時
17
+ if (-200..200).include?(current_position_x) && (-200..200).include?(current_position_y)
18
+ return false
19
+ end
20
+
21
+ moving_power >= threshold
22
+ end
23
+ end
24
+
25
+ def initialize
26
+ @map = {}
27
+ end
28
+
29
+ # @return [NilClass, Chunk] ローテトしたらvalueを返す
30
+ def add_sample(value)
31
+ rotated = nil
32
+ current_key = key
33
+ if @map[current_key].nil?
34
+ rotated = rotate
35
+ @map = { current_key => [] } # renew or initialize
36
+ end
37
+
38
+ @map[current_key] << value
39
+ rotated
40
+ end
41
+
42
+ private
43
+
44
+ # 0.1sec刻みで進行する
45
+ def key
46
+ time = Time.now
47
+ m1 = time.strftime('%L')[0]
48
+ [time.to_i, m1].join.to_i
49
+ end
50
+
51
+ def rotate
52
+ list = @map.values.first
53
+ if list
54
+ return PowerChunk.new(list)
55
+ else
56
+ return nil
57
+ end
58
+ end
59
+ end
@@ -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
@@ -0,0 +1,51 @@
1
+ class ProconBypassMan::UsbDeviceController
2
+ class << self
3
+ def reset
4
+ system('echo > /sys/kernel/config/usb_gadget/procon/UDC')
5
+ system('ls /sys/class/udc > /sys/kernel/config/usb_gadget/procon/UDC')
6
+ sleep 0.5
7
+ end
8
+
9
+ def init
10
+ return if initialized?
11
+
12
+ shell = <<~EOH
13
+ cd /sys/kernel/config/usb_gadget/
14
+ mkdir -p procon
15
+ cd procon
16
+ echo 0x057e > idVendor
17
+ echo 0x2009 > idProduct
18
+ echo 0x0200 > bcdDevice
19
+ echo 0x0200 > bcdUSB
20
+ echo 0x00 > bDeviceClass
21
+ echo 0x00 > bDeviceSubClass
22
+ echo 0x00 > bDeviceProtocol
23
+
24
+ mkdir -p strings/0x409
25
+ echo "000000000001" > strings/0x409/serialnumber
26
+ echo "Nintendo Co., Ltd." > strings/0x409/manufacturer
27
+ echo "Pro Controller" > strings/0x409/product
28
+
29
+ mkdir -p configs/c.1/strings/0x409
30
+ echo "Nintendo Switch Pro Controller" > configs/c.1/strings/0x409/configuration
31
+ echo 500 > configs/c.1/MaxPower
32
+ echo 0xa0 > configs/c.1/bmAttributes
33
+
34
+ mkdir -p functions/hid.usb0
35
+ echo 0 > functions/hid.usb0/protocol
36
+ echo 0 > functions/hid.usb0/subclass
37
+ echo 64 > functions/hid.usb0/report_length
38
+ echo 050115000904A1018530050105091901290A150025017501950A5500650081020509190B290E150025017501950481027501950281030B01000100A1000B300001000B310001000B320001000B35000100150027FFFF0000751095048102C00B39000100150025073500463B0165147504950181020509190F2912150025017501950481027508953481030600FF852109017508953F8103858109027508953F8103850109037508953F9183851009047508953F9183858009057508953F9183858209067508953F9183C0 | xxd -r -ps > functions/hid.usb0/report_desc
39
+
40
+ ln -s functions/hid.usb0 configs/c.1/
41
+ ls /sys/class/udc > UDC
42
+ EOH
43
+
44
+ `bash -c '#{shell}'`
45
+ end
46
+
47
+ def initialized?
48
+ Dir.exist?("/sys/kernel/config/usb_gadget/procon")
49
+ end
50
+ end
51
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProconBypassMan
4
- VERSION = "0.1.20.1"
4
+ VERSION = "0.1.22"
5
5
  end
@@ -1,17 +1,13 @@
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!
7
7
  return unless ProconBypassMan.config.enable_ws?
8
8
 
9
9
  Thread.start do
10
- loop do
11
- run
12
- rescue
13
- retry
14
- end
10
+ Forever.run { run }
15
11
  end
16
12
  end
17
13
 
@@ -24,14 +20,16 @@ module ProconBypassMan
24
20
  )
25
21
 
26
22
  client.connected {
27
- ProconBypassMan.logger.info('successfully connected in ProconBypassMan::Websocket::PbmJobClient')
23
+ ProconBypassMan.logger.info('websocket client: successfully connected in ProconBypassMan::Websocket::Client')
28
24
  }
29
25
  client.subscribed { |msg|
26
+ ProconBypassMan.logger.info('websocket client: subscribed')
30
27
  puts({ event: :subscribed, msg: msg })
31
28
  ProconBypassMan::SyncDeviceStatsJob.perform(ProconBypassMan::DeviceStatus.current)
32
29
  }
33
30
 
34
31
  client.received do |data|
32
+ ProconBypassMan.logger.info('websocket client: received!!')
35
33
  ProconBypassMan.logger.info(data)
36
34
 
37
35
  dispatch(data: data, client: client)
@@ -40,13 +38,22 @@ module ProconBypassMan
40
38
  end
41
39
 
42
40
  client.disconnected {
41
+ ProconBypassMan.logger.info('websocket client: disconnected!!')
43
42
  puts :disconnected
44
43
  client.reconnect!
45
44
  sleep 2
46
45
  }
47
- client.errored { |msg| puts :errored; puts msg }
46
+ client.errored { |msg|
47
+ ProconBypassMan.logger.error("websocket client: errored!!, #{msg}")
48
+ puts :errored
49
+ client.reconnect!
50
+ sleep 2
51
+ }
48
52
  client.pinged { |msg|
53
+ Watchdog.active!
54
+
49
55
  ProconBypassMan.cache.fetch key: 'ws_pinged', expires_in: 10 do
56
+ ProconBypassMan.logger.info('websocket client: pinged!!')
50
57
  ProconBypassMan.logger.info(msg)
51
58
  end
52
59
  }
@@ -56,17 +63,22 @@ module ProconBypassMan
56
63
  # @param [Hash] data
57
64
  def self.dispatch(data: , client: )
58
65
  pbm_job_hash = data.dig("message")
59
- if pbm_job_hash['action'] == "ping"
66
+ case pbm_job_hash['action']
67
+ when "ping"
60
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)
61
73
  else
62
- validate_and_run(data: data)
74
+ ProconBypassMan.logger.error "unknown action"
63
75
  end
64
76
  end
65
77
 
66
78
  # @raise [ProconBypassMan::RemotePbmActionObject::ValidationError]
67
79
  # @param [Hash] data
68
80
  # @return [Void]
69
- def self.validate_and_run(data: )
81
+ def self.validate_and_run_remote_pbm_action(data: )
70
82
  pbm_job_hash = data.dig("message")
71
83
  begin
72
84
  pbm_job_object = ProconBypassMan::RemotePbmActionObject.new(action: pbm_job_hash["action"],
@@ -76,7 +88,8 @@ module ProconBypassMan
76
88
  job_args: pbm_job_hash["args"])
77
89
  pbm_job_object.validate!
78
90
  rescue ProconBypassMan::RemotePbmActionObject::ValidationError => e
79
- raise
91
+ ProconBypassMan::SendErrorCommand.execute(error: e)
92
+ return
80
93
  end
81
94
 
82
95
  ProconBypassMan::RunRemotePbmActionDispatchCommand.execute(
@@ -85,6 +98,25 @@ module ProconBypassMan
85
98
  job_args: pbm_job_object.job_args
86
99
  )
87
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
88
120
  end
89
121
  end
90
122
  end
@@ -0,0 +1,47 @@
1
+ module ProconBypassMan
2
+ module Websocket
3
+ class Forever
4
+ # 動作確認方法
5
+ # - 10秒ごとにrefreshするのでタイムアウトは起きない
6
+ # - ProconBypassMan::Websocket::Forever.run { loop { puts(:hi); sleep(10); ProconBypassMan::Websocket::Watchdog.active! } }
7
+ # - タイムアウトが起きること
8
+ # - ProconBypassMan::Websocket::Forever.run { puts(:hi); sleep(3000); }
9
+ # - ブロックを1回評価するとThreadが死ぬので100秒後にタイムアウトが起きること
10
+ # - ProconBypassMan::Websocket::Forever.run { puts(:hi); sleep(10); ProconBypassMan::Websocket::Watchdog.active! }
11
+ def self.run(&block)
12
+ loop do
13
+ new.run(&block)
14
+ end
15
+ end
16
+
17
+ def run(&block)
18
+ raise("need a block") unless block_given?
19
+
20
+ ws_thread = work_one(callable: block)
21
+ wait_and_kill_if_outdated(ws_thread)
22
+ end
23
+
24
+ # @return [Thread]
25
+ def work_one(callable: )
26
+ Thread.start do
27
+ callable.call
28
+ rescue => e
29
+ ProconBypassMan.logger.error("websocket client with forever: #{e.full_message}")
30
+ end
31
+ end
32
+
33
+ def wait_and_kill_if_outdated(thread)
34
+ loop do
35
+ if Watchdog.outdated?
36
+ Watchdog.active!
37
+ ProconBypassMan.logger.error("watchdog timeout!!")
38
+ thread.kill
39
+ return
40
+ end
41
+
42
+ sleep(10)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,19 @@
1
+ module ProconBypassMan
2
+ module Websocket
3
+ class Watchdog
4
+ def self.outdated?
5
+ @@time < Time.now
6
+ end
7
+
8
+ def self.time
9
+ @@time
10
+ end
11
+
12
+ def self.active!
13
+ @@time = Time.now + 100
14
+ end
15
+
16
+ active!
17
+ end
18
+ end
19
+ end
@@ -8,9 +8,12 @@ require 'em/pure_ruby'
8
8
  require "action_cable_client"
9
9
  require "ext/em_pure_ruby"
10
10
  require "ext/module"
11
+ require "resolv-replace"
12
+ require "pbmenv"
11
13
 
12
14
  require_relative "procon_bypass_man/version"
13
15
  require_relative "procon_bypass_man/remote_pbm_action"
16
+ require_relative "procon_bypass_man/remote_macro"
14
17
  require_relative "procon_bypass_man/support/signal_handler"
15
18
  require_relative "procon_bypass_man/support/callbacks"
16
19
  require_relative "procon_bypass_man/support/yaml_writer"
@@ -20,17 +23,20 @@ require_relative "procon_bypass_man/support/uptime"
20
23
  require_relative "procon_bypass_man/support/on_memory_cache"
21
24
  require_relative "procon_bypass_man/support/http_client"
22
25
  require_relative "procon_bypass_man/support/report_http_client"
26
+ require_relative "procon_bypass_man/support/remote_macro_http_client"
23
27
  require_relative "procon_bypass_man/support/update_remote_pbm_action_status_http_client"
24
28
  require_relative "procon_bypass_man/support/send_device_stats_http_client"
25
29
  require_relative "procon_bypass_man/support/server_pool"
30
+ require_relative "procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler"
31
+ require_relative "procon_bypass_man/support/never_exit_accidentally"
26
32
  require_relative "procon_bypass_man/background"
27
33
  require_relative "procon_bypass_man/commands"
28
34
  require_relative "procon_bypass_man/bypass"
29
35
  require_relative "procon_bypass_man/domains"
30
- require_relative "procon_bypass_man/never_exit_accidentally"
31
36
  require_relative "procon_bypass_man/device_connector"
32
37
  require_relative "procon_bypass_man/device_procon_finder"
33
38
  require_relative "procon_bypass_man/device_status"
39
+ require_relative "procon_bypass_man/usb_device_controller"
34
40
  require_relative "procon_bypass_man/runner"
35
41
  require_relative "procon_bypass_man/processor"
36
42
  require_relative "procon_bypass_man/configuration"
@@ -40,10 +46,13 @@ require_relative "procon_bypass_man/procon/button"
40
46
  require_relative "procon_bypass_man/procon/value_objects/analog_stick"
41
47
  require_relative "procon_bypass_man/procon/value_objects/procon_reader"
42
48
  require_relative "procon_bypass_man/procon/analog_stick_cap"
49
+ require_relative "procon_bypass_man/procon/analog_stick_manipulator"
43
50
  require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
44
51
  require_relative "procon_bypass_man/scheduler"
45
52
  require_relative "procon_bypass_man/plugins"
46
- require_relative "procon_bypass_man/websocket/pbm_job_client"
53
+ require_relative "procon_bypass_man/websocket/client"
54
+ require_relative "procon_bypass_man/websocket/watchdog"
55
+ require_relative "procon_bypass_man/websocket/forever"
47
56
 
48
57
  STDOUT.sync = true
49
58
  Thread.abort_on_exception = true
@@ -54,7 +63,6 @@ module ProconBypassMan
54
63
 
55
64
  class CouldNotLoadConfigError < StandardError; end
56
65
  class ConnectionError < StandardError; end
57
- class NotFoundRequiredFilesError < StandardError; end
58
66
  class FirstConnectionError < ConnectionError; end
59
67
  class EternalConnectionError < ConnectionError; end
60
68
 
@@ -62,7 +70,8 @@ module ProconBypassMan
62
70
  def self.run(setting_path: nil)
63
71
  ProconBypassMan::Scheduler.start!
64
72
  ProconBypassMan::Background::JobRunner.start!
65
- ProconBypassMan::Websocket::PbmJobClient.start!
73
+ ProconBypassMan::Websocket::Client.start!
74
+ ProconBypassMan::QueueOverProcess.start!
66
75
 
67
76
  ProconBypassMan::PrintMessageCommand.execute(text: "PBMを起動しています")
68
77
  initialize_pbm
@@ -71,24 +80,24 @@ module ProconBypassMan
71
80
  Runner.new(gadget: gadget, procon: procon).run # ここでblockingする
72
81
  FileUtils.rm_rf(ProconBypassMan.pid_path)
73
82
  FileUtils.rm_rf(ProconBypassMan.digest_path)
74
- rescue ProconBypassMan::NotFoundRequiredFilesError
75
- ProconBypassMan::SendErrorCommand.execute(error: "/sys/kernel/config/usb_gadget/proconディレクトリがありませんでした。処理を終了します。")
76
- FileUtils.rm_rf(ProconBypassMan.pid_path)
77
- FileUtils.rm_rf(ProconBypassMan.digest_path)
78
- exit 1 # 前提条件を満たしていないので絶対に落とす
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
@@ -127,6 +136,7 @@ module ProconBypassMan
127
136
  def self.initialize_pbm
128
137
  ProconBypassMan::WriteDeviceIdCommand.execute
129
138
  ProconBypassMan::WriteSessionIdCommand.execute
139
+ system("renice -n -20 -p #{$$}")
130
140
  File.write(pid_path, $$)
131
141
  ProconBypassMan::DeviceStatus.change_to_running!
132
142
  end
@@ -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
@@ -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 "pbmenv"
31
+ spec.add_dependency "pbmenv", ">= 0.1.9" # Pbmenv.installでのenable_pbm_cloudに依存している
32
32
  spec.add_dependency "action_cable_client"
33
33
  spec.add_dependency "sorted_set"
34
34
 
@@ -5,20 +5,28 @@ 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.20.1'
8
+ gem 'procon_bypass_man', '0.1.22'
9
9
  end
10
10
 
11
11
  ProconBypassMan.configure do |config|
12
12
  config.root = File.expand_path(__dir__)
13
13
  config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
14
14
  config.logger.level = :debug
15
+
16
+ # バイパスするログを全部app.logに流すか
17
+ config.verbose_bypass_log = false
18
+
15
19
  # webからProconBypassManを操作できるwebサービス
16
20
  # config.api_servers = ['https://pbm-cloud.herokuapp.com']
21
+
22
+ # エラーが起きたらerror.logに書き込みます
17
23
  config.enable_critical_error_logging = true
24
+
18
25
  # pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
19
26
  config.never_exit_accidentally = true
27
+
20
28
  # 操作が高頻度で固まるときは、 gadget_to_procon_interval の数値は大きくしてください
21
- config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 0.5 }
29
+ config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 5 }
22
30
  end
23
31
 
24
32
  ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
@@ -7,7 +7,7 @@ Type=simple
7
7
  WorkingDirectory=/usr/share/pbm/current
8
8
  ExecStart=/bin/bash -c "/home/pi/.rbenv/versions/3.0.1/bin/ruby /usr/share/pbm/current/app.rb"
9
9
  Restart=always
10
- Nice=-19
10
+ Nice=-20
11
11
 
12
12
  [Install]
13
13
  WantedBy=multi-user.target
data/sig/main.rbs CHANGED
@@ -531,6 +531,26 @@ module ProconBypassMan
531
531
  end
532
532
  end
533
533
 
534
+ class ProconBypassMan::BypassMode
535
+ TYPE_NORMAL: ::Symbol
536
+
537
+ TYPE_AGGRESSIVE: ::Symbol
538
+
539
+ TYPES: ::Array[::Symbol]
540
+
541
+ DEFAULT_GADGET_TO_PROCON_INTERVAL: ::Float
542
+
543
+ attr_accessor mode: ::Symbol
544
+
545
+ attr_accessor gadget_to_procon_interval: ::Float
546
+
547
+ def self.default_value: () -> ::ProconBypassMan::BypassMode
548
+
549
+ def initialize: (mode: ::Symbol mode, gadget_to_procon_interval: ::Float gadget_to_procon_interval) -> void
550
+
551
+ def to_s: () -> ::String
552
+ end
553
+
534
554
  class ProconBypassMan::Domains::Binary::Base
535
555
  # @param [String] binary
536
556
  def initialize: (binary: untyped binary) -> void
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.20.1
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-02-13 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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.1.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.1.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: action_cable_client
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -79,8 +79,10 @@ files:
79
79
  - docs/getting_started.md
80
80
  - docs/how_to_connect_procon.md
81
81
  - docs/setting/left-analogstick-cap.md
82
+ - docs/setting/splatoon2_macro_dasei_cancel.md
82
83
  - docs/setting/splatoon2_macro_sokuwari_bubble.md
83
84
  - docs/setting/splatoon2_recommended_setting.md
85
+ - docs/setting/splatoon2_shake_tansan.md
84
86
  - docs/setup_raspi.md
85
87
  - docs/setup_raspi.mitamae.rb
86
88
  - docs/setup_raspi_by_mitamae.md
@@ -95,7 +97,9 @@ files:
95
97
  - lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb
96
98
  - lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb
97
99
  - lib/procon_bypass_man/background/jobs/concerns/job_runnable.rb
100
+ - lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb
98
101
  - lib/procon_bypass_man/background/jobs/report_boot_job.rb
102
+ - lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb
99
103
  - lib/procon_bypass_man/background/jobs/report_error_job.rb
100
104
  - lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb
101
105
  - lib/procon_bypass_man/background/jobs/report_event_base_job.rb
@@ -107,9 +111,17 @@ files:
107
111
  - lib/procon_bypass_man/buttons_setting_configuration.rb
108
112
  - lib/procon_bypass_man/buttons_setting_configuration/layer.rb
109
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
110
123
  - lib/procon_bypass_man/buttons_setting_configuration/validator.rb
111
124
  - lib/procon_bypass_man/bypass.rb
112
- - lib/procon_bypass_man/bypass/bypass_mode.rb
113
125
  - lib/procon_bypass_man/bypass/usb_hid_logger.rb
114
126
  - lib/procon_bypass_man/commands.rb
115
127
  - lib/procon_bypass_man/commands/bypass_command.rb
@@ -126,13 +138,16 @@ files:
126
138
  - lib/procon_bypass_man/device_procon_finder.rb
127
139
  - lib/procon_bypass_man/device_status.rb
128
140
  - lib/procon_bypass_man/domains.rb
141
+ - lib/procon_bypass_man/domains/analog_stick_position.rb
129
142
  - lib/procon_bypass_man/domains/binary/base.rb
130
143
  - lib/procon_bypass_man/domains/binary/has_immutable_binary.rb
131
144
  - lib/procon_bypass_man/domains/binary/has_mutable_binary.rb
132
145
  - lib/procon_bypass_man/domains/binary/inbound_procon_binary.rb
133
146
  - lib/procon_bypass_man/domains/binary/processing_procon_binary.rb
147
+ - lib/procon_bypass_man/domains/bypass_mode.rb
134
148
  - lib/procon_bypass_man/io_monitor.rb
135
- - lib/procon_bypass_man/never_exit_accidentally.rb
149
+ - lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb
150
+ - lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb
136
151
  - lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb
137
152
  - lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb
138
153
  - lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb
@@ -144,6 +159,7 @@ files:
144
159
  - lib/procon_bypass_man/processor.rb
145
160
  - lib/procon_bypass_man/procon.rb
146
161
  - lib/procon_bypass_man/procon/analog_stick_cap.rb
162
+ - lib/procon_bypass_man/procon/analog_stick_manipulator.rb
147
163
  - lib/procon_bypass_man/procon/button.rb
148
164
  - lib/procon_bypass_man/procon/button_collection.rb
149
165
  - lib/procon_bypass_man/procon/consts.rb
@@ -151,12 +167,20 @@ files:
151
167
  - lib/procon_bypass_man/procon/layer_changer.rb
152
168
  - lib/procon_bypass_man/procon/macro.rb
153
169
  - lib/procon_bypass_man/procon/macro_builder.rb
170
+ - lib/procon_bypass_man/procon/macro_plugin_map.rb
154
171
  - lib/procon_bypass_man/procon/macro_registry.rb
155
172
  - lib/procon_bypass_man/procon/mode_registry.rb
156
173
  - lib/procon_bypass_man/procon/press_button_aware.rb
157
174
  - lib/procon_bypass_man/procon/user_operation.rb
158
175
  - lib/procon_bypass_man/procon/value_objects/analog_stick.rb
159
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
160
184
  - lib/procon_bypass_man/remote_pbm_action.rb
161
185
  - lib/procon_bypass_man/remote_pbm_action/base_action.rb
162
186
  - lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb
@@ -167,10 +191,13 @@ files:
167
191
  - lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
168
192
  - lib/procon_bypass_man/runner.rb
169
193
  - lib/procon_bypass_man/scheduler.rb
194
+ - lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb
170
195
  - lib/procon_bypass_man/support/callbacks.rb
171
196
  - lib/procon_bypass_man/support/compress_array.rb
172
197
  - lib/procon_bypass_man/support/http_client.rb
198
+ - lib/procon_bypass_man/support/never_exit_accidentally.rb
173
199
  - lib/procon_bypass_man/support/on_memory_cache.rb
200
+ - lib/procon_bypass_man/support/remote_macro_http_client.rb
174
201
  - lib/procon_bypass_man/support/report_http_client.rb
175
202
  - lib/procon_bypass_man/support/safe_timeout.rb
176
203
  - lib/procon_bypass_man/support/send_device_stats_http_client.rb
@@ -179,8 +206,11 @@ files:
179
206
  - lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb
180
207
  - lib/procon_bypass_man/support/uptime.rb
181
208
  - lib/procon_bypass_man/support/yaml_writer.rb
209
+ - lib/procon_bypass_man/usb_device_controller.rb
182
210
  - lib/procon_bypass_man/version.rb
183
- - lib/procon_bypass_man/websocket/pbm_job_client.rb
211
+ - lib/procon_bypass_man/websocket/client.rb
212
+ - lib/procon_bypass_man/websocket/forever.rb
213
+ - lib/procon_bypass_man/websocket/watchdog.rb
184
214
  - procon_bypass_man.gemspec
185
215
  - project_template/README.md
186
216
  - project_template/app.rb
@@ -206,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
236
  requirements:
207
237
  - - ">="
208
238
  - !ruby/object:Gem::Version
209
- version: 2.4.0
239
+ version: 3.0.0
210
240
  required_rubygems_version: !ruby/object:Gem::Requirement
211
241
  requirements:
212
242
  - - ">="