procon_bypass_man 0.1.20.2 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +9 -5
  3. data/.github/workflows/ruby.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rspec +1 -0
  6. data/CHANGELOG.md +30 -1
  7. data/Gemfile.lock +4 -4
  8. data/README.md +4 -1
  9. data/docs/getting_started.md +81 -11
  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.rb +1 -0
  16. data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +155 -70
  17. data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +2 -0
  18. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button.rb +28 -0
  19. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button_list.rb +31 -0
  20. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/disable_macro_if_pressed.rb +28 -0
  21. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/flip_if_pressed.rb +31 -0
  22. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/force_neutral.rb +28 -0
  23. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed.rb +26 -0
  24. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil.rb +28 -0
  25. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/open_macro_steps.rb +26 -0
  26. data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer.rb +17 -0
  27. data/lib/procon_bypass_man/buttons_setting_configuration.rb +6 -5
  28. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +4 -0
  29. data/lib/procon_bypass_man/bypass.rb +45 -23
  30. data/lib/procon_bypass_man/commands/bypass_command.rb +30 -10
  31. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +1 -1
  32. data/lib/procon_bypass_man/configuration.rb +8 -1
  33. data/lib/procon_bypass_man/device_connector.rb +55 -174
  34. data/lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb +21 -0
  35. data/lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb +21 -0
  36. data/lib/procon_bypass_man/plugin/splatoon2/version.rb +1 -1
  37. data/lib/procon_bypass_man/plugins.rb +2 -0
  38. data/lib/procon_bypass_man/procon/analog_stick_cap.rb +4 -23
  39. data/lib/procon_bypass_man/procon/analog_stick_manipulator.rb +36 -0
  40. data/lib/procon_bypass_man/procon/button_collection.rb +0 -8
  41. data/lib/procon_bypass_man/procon/layer_changer.rb +4 -1
  42. data/lib/procon_bypass_man/procon/macro.rb +53 -25
  43. data/lib/procon_bypass_man/procon/macro_builder.rb +43 -35
  44. data/lib/procon_bypass_man/procon/macro_plugin_map.rb +23 -0
  45. data/lib/procon_bypass_man/procon/macro_registry.rb +26 -10
  46. data/lib/procon_bypass_man/procon/suppress_rumble.rb +13 -0
  47. data/lib/procon_bypass_man/procon/user_operation.rb +30 -16
  48. data/lib/procon_bypass_man/procon/value_objects/analog_stick.rb +9 -5
  49. data/lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb +18 -0
  50. data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/base.rb +0 -0
  51. data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/has_immutable_binary.rb +0 -0
  52. data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/has_mutable_binary.rb +0 -0
  53. data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/inbound_procon_binary.rb +5 -0
  54. data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/processing_procon_binary.rb +7 -2
  55. data/lib/procon_bypass_man/procon/value_objects/binary.rb +11 -0
  56. data/lib/procon_bypass_man/{bypass → procon/value_objects}/bypass_mode.rb +0 -0
  57. data/lib/procon_bypass_man/procon/value_objects/rumble_binary.rb +18 -0
  58. data/lib/procon_bypass_man/procon.rb +59 -17
  59. data/lib/procon_bypass_man/remote_macro/queue_over_process.rb +62 -0
  60. data/lib/procon_bypass_man/remote_macro/remote_macro_object.rb +30 -0
  61. data/lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb +37 -0
  62. data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +8 -0
  63. data/lib/procon_bypass_man/remote_macro/task.rb +6 -0
  64. data/lib/procon_bypass_man/remote_macro/task_queue.rb +13 -0
  65. data/lib/procon_bypass_man/remote_macro.rb +14 -0
  66. data/lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb +1 -1
  67. data/lib/procon_bypass_man/remote_pbm_action.rb +1 -0
  68. data/lib/procon_bypass_man/runner.rb +11 -7
  69. data/lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb +59 -0
  70. data/lib/procon_bypass_man/support/cycle_sleep.rb +22 -0
  71. data/lib/procon_bypass_man/support/device_mouse_finder.rb +60 -0
  72. data/lib/procon_bypass_man/{device_procon_finder.rb → support/device_procon_finder.rb} +0 -2
  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/support/safe_timeout.rb +7 -1
  76. data/lib/procon_bypass_man/{usb_device_controller.rb → support/usb_device_controller.rb} +7 -4
  77. data/lib/procon_bypass_man/version.rb +1 -1
  78. data/lib/procon_bypass_man/websocket/{pbm_job_client.rb → client.rb} +34 -12
  79. data/lib/procon_bypass_man/websocket/forever.rb +47 -0
  80. data/lib/procon_bypass_man/websocket/watchdog.rb +19 -0
  81. data/lib/procon_bypass_man.rb +25 -23
  82. data/procon_bypass_man.gemspec +1 -1
  83. data/project_template/app.rb +13 -4
  84. data/sig/main.rbs +21 -13
  85. metadata +46 -14
  86. data/lib/procon_bypass_man/domains.rb +0 -11
@@ -1,12 +1,13 @@
1
1
  module ProconBypassMan
2
2
  class ButtonsSettingConfiguration
3
3
  class Layer
4
- attr_accessor :mode, :flips, :macros, :remaps, :left_analog_stick_caps, :disables
4
+ attr_accessor :mode, :flips, :macros, :disable_macros, :remaps, :left_analog_stick_caps, :disables
5
5
 
6
6
  def initialize(mode: :manual)
7
7
  self.mode = mode
8
8
  self.flips = {}
9
9
  self.macros = {}
10
+ self.disable_macros = []
10
11
  self.remaps = {}
11
12
  self.left_analog_stick_caps = []
12
13
  self.disables = []
@@ -14,31 +15,29 @@ module ProconBypassMan
14
15
 
15
16
  # @param [Symbol] button
16
17
  def flip(button, if_pressed: false, force_neutral: nil, flip_interval: nil)
17
- case if_pressed
18
- when TrueClass
19
- if_pressed = [button]
20
- when Symbol, String
21
- if_pressed = [if_pressed]
22
- when Array
23
- # if_pressed = if_pressed
24
- when FalseClass, NilClass
25
- # no-op
26
- else
27
- raise "not support class"
18
+ begin
19
+ button = ParamNormalizer::Button.new(button).to_value!
20
+ rescue ParamNormalizer::UnSupportValueError
21
+ Kernel.warn "設定ファイルに記述ミスがあります. flipの第一引数にはボタンを渡してください."
22
+ return
23
+ end
24
+
25
+ begin
26
+ if_pressed = ParamNormalizer::FlipIfPressed.new(if_pressed, button: button).to_value!
27
+ rescue ParamNormalizer::UnSupportValueError
28
+ Kernel.warn "設定ファイルに記述ミスがあります. flipのif_pressedにはボタンを渡してください."
29
+ return
28
30
  end
29
31
 
30
32
  hash = { if_pressed: if_pressed }
31
- case force_neutral
32
- when TrueClass
33
- raise "ボタンを渡してください"
34
- when Symbol, String
35
- hash[:force_neutral] = [force_neutral]
36
- when Array
37
- hash[:force_neutral] = force_neutral
38
- when FalseClass, NilClass
39
- # no-op
40
- else
41
- raise "not support value"
33
+
34
+ begin
35
+ if(force_neutral = ParamNormalizer::ForceNeutral.new(force_neutral).to_value!)
36
+ hash[:force_neutral] = force_neutral
37
+ end
38
+ rescue ParamNormalizer::UnSupportValueError
39
+ Kernel.warn "設定ファイルに記述ミスがあります. flipのforce_neutralにはボタンを渡してください."
40
+ return
42
41
  end
43
42
 
44
43
  if flip_interval
@@ -54,79 +53,165 @@ module ProconBypassMan
54
53
  end
55
54
 
56
55
  # @param [String, Class] プラグインのclass
57
- def macro(name, if_pressed: )
56
+ def macro(name, if_pressed: nil, if_tilted_left_stick: nil, force_neutral: nil)
57
+ case if_tilted_left_stick
58
+ when Integer, String, Symbol, Array
59
+ warn "macro #{name}のif_tilted_left_stickで想定外の値です"
60
+ if_tilted_left_stick = nil
61
+ when TrueClass, NilClass, FalseClass
62
+ # OK
63
+ else
64
+ Kernel.warn "設定ファイルに記述ミスがあります. 未対応の値を受け取りました."
65
+ return
66
+ end
67
+
68
+ begin
69
+ if(fn = ParamNormalizer::ForceNeutral.new(force_neutral).to_value!)
70
+ force_neutral = fn
71
+ end
72
+ rescue ParamNormalizer::UnSupportValueError
73
+ Kernel.warn "設定ファイルに記述ミスがあります. macroのforce_neutralにはボタンを渡してください."
74
+ return
75
+ end
76
+
77
+ begin
78
+ if_pressed = ParamNormalizer::IfPressed.new(if_pressed).to_value!
79
+ rescue ParamNormalizer::UnSupportValueError
80
+ Kernel.warn "設定ファイルに記述ミスがあります. macroのif_pressedにはボタンを渡してください."
81
+ return
82
+ end
83
+
58
84
  macro_name = name.to_s.to_sym
59
- self.macros[macro_name] = { if_pressed: if_pressed }
85
+ if ProconBypassMan::ButtonsSettingConfiguration.instance.macro_plugins[macro_name]
86
+ self.macros[macro_name] = { if_pressed: if_pressed, if_tilted_left_stick: if_tilted_left_stick, force_neutral: force_neutral }.compact
87
+ else
88
+ warn "#{macro_name}マクロがinstallされていません"
89
+ end
60
90
  end
61
91
 
62
92
  # 設定ファイルに直接マクロを打ち込める
63
93
  # @param [String, Class] macroの識別子
64
94
  # @paramh[Array<Symbol>] macroの本体. ボタンの配列
65
- def open_macro(name, steps: , if_pressed: )
95
+ def open_macro(name, steps: [], if_pressed: nil, if_tilted_left_stick: nil, force_neutral: nil)
96
+ if name.nil?
97
+ Kernel.warn "設定ファイルに記述ミスがあります. open_macroのnameには一意になる名前を渡してください."
98
+ return
99
+ end
100
+
101
+ begin
102
+ steps = ParamNormalizer::OpenMacroSteps.new(steps).to_value!
103
+ rescue ParamNormalizer::UnSupportValueError
104
+ Kernel.warn "設定ファイルに記述ミスがあります. open_macroのstepsには文字列の配列を渡してください."
105
+ return
106
+ end
107
+
108
+ case if_tilted_left_stick
109
+ when Integer, String, Symbol, Array
110
+ warn "open_macro #{name}のif_tilted_left_stickで想定外の値です"
111
+ if_tilted_left_stick = nil
112
+ when TrueClass, NilClass, FalseClass, Hash
113
+ # OK
114
+ else
115
+ Kernel.warn "設定ファイルに記述ミスがあります. 未対応の値を受け取りました."
116
+ return
117
+ end
118
+
119
+ begin
120
+ force_neutral = ParamNormalizer::ForceNeutral.new(force_neutral).to_value!
121
+ rescue ParamNormalizer::UnSupportValueError
122
+ Kernel.warn "設定ファイルに記述ミスがあります. open_macroのforce_neutralにはボタンを渡してください."
123
+ return
124
+ end
125
+
126
+ begin
127
+ if_pressed = ParamNormalizer::IfPressed.new(if_pressed).to_value!
128
+ rescue ParamNormalizer::UnSupportValueError
129
+ Kernel.warn "設定ファイルに記述ミスがあります. open_macroのif_pressedにはボタンを渡してください."
130
+ return
131
+ end
132
+
66
133
  macro_name = name || "OpenMacro-#{steps.join}".to_sym
67
134
  ProconBypassMan::Procon::MacroRegistry.install_plugin(macro_name, steps: steps)
68
- self.macros[macro_name] = { if_pressed: if_pressed }
135
+ self.macros[macro_name] = { if_pressed: if_pressed, if_tilted_left_stick: if_tilted_left_stick, force_neutral: force_neutral }.compact
69
136
  end
70
137
 
71
- def remap(button, to: )
72
- case to
73
- when TrueClass, FalseClass, NilClass
74
- raise "ボタンを渡してください"
75
- when Symbol, String
76
- self.remaps[button] = { to: [to] }
77
- when Array
78
- raise "ボタンを渡してください" if to.size.zero?
79
- self.remaps[button] = { to: to }
138
+ def disable_macro(name, if_pressed: nil)
139
+ if name.nil?
140
+ Kernel.warn "設定ファイルに記述ミスがあります. disable_macroのnameにはmacro nameかクラス名の名前を渡してください."
141
+ return
80
142
  end
143
+
144
+ hash = { name: name.to_s.to_sym, if_pressed: [] }
145
+ begin
146
+ if(if_pressed = ParamNormalizer::DisableMacroIfPressed.new(if_pressed).to_value!)
147
+ hash[:if_pressed] = if_pressed
148
+ end
149
+ rescue ParamNormalizer::UnSupportValueError
150
+ Kernel.warn "設定ファイルに記述ミスがあります. disable_macroのif_pressedにはボタンを渡してください."
151
+ return
152
+ end
153
+
154
+ disable_macros << hash
81
155
  end
82
156
 
83
- def left_analog_stick_cap(cap: , if_pressed: nil, force_neutral: nil)
84
- hash = { cap: cap }
157
+ def remap(button, to: )
158
+ begin
159
+ button = ParamNormalizer::Button.new(button).to_value!
160
+ rescue ParamNormalizer::UnSupportValueError
161
+ Kernel.warn "設定ファイルに記述ミスがあります. remapにはボタンを渡してください."
162
+ return
163
+ end
164
+
165
+ begin
166
+ self.remaps[button] = { to: ParamNormalizer::ButtonList.new(to).to_value! }
167
+ rescue ParamNormalizer::UnSupportValueError
168
+ Kernel.warn "設定ファイルに記述ミスがあります. remapのtoにはボタンを渡してください."
169
+ return
170
+ end
171
+ end
85
172
 
86
- case if_pressed
87
- when TrueClass, FalseClass
88
- raise "ボタンを渡してください"
89
- when Symbol, String
90
- if_pressed = [if_pressed]
91
- when Array, NilClass
92
- # no-op
173
+ def left_analog_stick_cap(cap: nil, if_pressed: nil, force_neutral: nil)
174
+ case cap
175
+ when Integer
176
+ # OK
177
+ when Float
178
+ cap = cap.to_i
93
179
  else
94
- raise "not support value"
180
+ Kernel.warn "設定ファイルに記述ミスがあります. left_analog_stick_capのcapで未対応の値を受け取りました."
181
+ return
95
182
  end
96
183
 
97
- if if_pressed
98
- hash[:if_pressed] = if_pressed
184
+ hash = { cap: cap }
185
+
186
+ begin
187
+ if(if_pressed = ParamNormalizer::IfPressedAllowsFalsy.new(if_pressed).to_value!)
188
+ hash[:if_pressed] = if_pressed
189
+ end
190
+ rescue ParamNormalizer::UnSupportValueError
191
+ Kernel.warn "設定ファイルに記述ミスがあります. left_analog_stick_capのif_pressedにはボタンを渡してください."
192
+ return
99
193
  end
100
194
 
101
- case force_neutral
102
- when TrueClass
103
- raise "ボタンを渡してください"
104
- when Symbol, String
105
- hash[:force_neutral] = [force_neutral]
106
- when Array
107
- hash[:force_neutral] = force_neutral
108
- when FalseClass, NilClass
109
- # no-op
110
- else
111
- raise "not support value"
195
+ begin
196
+ if(force_neutral = ParamNormalizer::ForceNeutral.new(force_neutral).to_value!)
197
+ hash[:force_neutral] = force_neutral
198
+ end
199
+ rescue ParamNormalizer::UnSupportValueError
200
+ Kernel.warn "設定ファイルに記述ミスがあります. left_analog_stick_capのforce_neutralにはボタンを渡してください."
201
+ return
112
202
  end
113
203
 
114
204
  left_analog_stick_caps << hash
115
205
  end
116
206
 
117
207
  def disable(button)
118
- case button
119
- when TrueClass, FalseClass, NilClass
120
- raise "not support class"
121
- when Symbol
122
- disables << button
123
- when String
124
- disables << button.to_sym
125
- when Array
126
- button.each { |b| disables << b }
127
- else
128
- raise "not support value"
208
+ ParamNormalizer::ButtonList.new(button).to_value!.each do |disable|
209
+ disables << disable
129
210
  end
211
+ disables.uniq!
212
+ rescue ParamNormalizer::UnSupportValueError
213
+ Kernel.warn "設定ファイルに記述ミスがあります. disableにはボタンを渡してください."
214
+ return
130
215
  end
131
216
 
132
217
  # @return [Array]
@@ -1,3 +1,5 @@
1
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer"
2
+
1
3
  module ProconBypassMan
2
4
  class ButtonsSettingConfiguration
3
5
  module Loader
@@ -0,0 +1,28 @@
1
+ module ProconBypassMan
2
+ class ButtonsSettingConfiguration
3
+ module ParamNormalizer
4
+ class Button
5
+ attr_reader :button
6
+
7
+ def initialize(button)
8
+ @button = button
9
+ end
10
+
11
+ def to_value!
12
+ case button
13
+ when TrueClass, FalseClass, NilClass, Array, Integer
14
+ raise UnSupportValueError
15
+ when Symbol, String
16
+ unless !!ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP[button.to_sym]
17
+ raise UnexpectedValueError
18
+ end
19
+
20
+ return button.to_sym
21
+ else
22
+ raise UnexpectedValueError
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ module ProconBypassMan
2
+ class ButtonsSettingConfiguration
3
+ module ParamNormalizer
4
+ class ButtonList
5
+ attr_reader :button
6
+
7
+ def initialize(button)
8
+ @button = button
9
+ end
10
+
11
+ # @return [Array]
12
+ # @raise [UnSupportValueError]
13
+ # @raise [UnexpectedValueError]
14
+ def to_value!
15
+ case button
16
+ when Integer, TrueClass, FalseClass, NilClass
17
+ raise UnSupportValueError
18
+ when Symbol
19
+ return [button]
20
+ when String
21
+ return [button.to_sym]
22
+ when Array
23
+ return button.map(&:to_sym).uniq
24
+ else
25
+ raise UnexpectedValueError
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ module ProconBypassMan
2
+ class ButtonsSettingConfiguration
3
+ module ParamNormalizer
4
+ class DisableMacroIfPressed
5
+ attr_reader :value
6
+
7
+ def initialize(value)
8
+ @value = value
9
+ end
10
+
11
+ def to_value!
12
+ case value
13
+ when FalseClass, Integer, TrueClass
14
+ raise UnSupportValueError
15
+ when Symbol, String
16
+ return [value.to_sym]
17
+ when Array
18
+ return value.map(&:to_sym).uniq
19
+ when NilClass # 常に対象のmacroをdisableにする
20
+ return [true]
21
+ else
22
+ raise UnexpectedValueError
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ module ProconBypassMan
2
+ class ButtonsSettingConfiguration
3
+ module ParamNormalizer
4
+ class FlipIfPressed
5
+ attr_reader :value
6
+
7
+ def initialize(value, button: )
8
+ @value = value
9
+ @button = button
10
+ end
11
+
12
+ def to_value!
13
+ case value
14
+ when Integer
15
+ raise UnSupportValueError
16
+ when TrueClass
17
+ return [@button]
18
+ when Symbol, String
19
+ return [value.to_sym]
20
+ when Array
21
+ return value.map(&:to_sym).uniq
22
+ when FalseClass, NilClass
23
+ return false
24
+ else
25
+ raise UnexpectedValueError
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ module ProconBypassMan
2
+ class ButtonsSettingConfiguration
3
+ module ParamNormalizer
4
+ class ForceNeutral
5
+ attr_reader :force_neutral
6
+
7
+ def initialize(force_neutral)
8
+ @force_neutral = force_neutral
9
+ end
10
+
11
+ def to_value!
12
+ case force_neutral
13
+ when Integer, TrueClass
14
+ raise UnSupportValueError
15
+ when Symbol, String
16
+ return [force_neutral.to_sym]
17
+ when Array
18
+ return force_neutral.map(&:to_sym).uniq
19
+ when FalseClass, NilClass
20
+ return nil
21
+ else
22
+ raise UnexpectedValueError
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ module ProconBypassMan
2
+ class ButtonsSettingConfiguration
3
+ module ParamNormalizer
4
+ class IfPressed
5
+ attr_reader :value
6
+
7
+ def initialize(value)
8
+ @value = value
9
+ end
10
+
11
+ def to_value!
12
+ case value
13
+ when Integer, TrueClass, FalseClass, NilClass
14
+ raise UnSupportValueError
15
+ when Symbol, String
16
+ return [value.to_sym]
17
+ when Array
18
+ return value.map(&:to_sym).uniq
19
+ else
20
+ raise UnexpectedValueError
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ module ProconBypassMan
2
+ class ButtonsSettingConfiguration
3
+ module ParamNormalizer
4
+ class IfPressedAllowsFalsy
5
+ attr_reader :value
6
+
7
+ def initialize(value)
8
+ @value = value
9
+ end
10
+
11
+ def to_value!
12
+ case value
13
+ when Integer, TrueClass
14
+ raise UnSupportValueError
15
+ when Symbol, String
16
+ return [value.to_sym]
17
+ when Array
18
+ return value.map(&:to_sym).uniq
19
+ when FalseClass, NilClass
20
+ # OK
21
+ else
22
+ raise UnexpectedValueError
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ module ProconBypassMan
2
+ class ButtonsSettingConfiguration
3
+ module ParamNormalizer
4
+ class OpenMacroSteps
5
+ attr_reader :steps
6
+
7
+ def initialize(steps)
8
+ @steps = steps
9
+ end
10
+
11
+ def to_value!
12
+ case steps
13
+ when Integer, TrueClass, FalseClass, NilClass
14
+ raise UnSupportValueError
15
+ when String, Symbol
16
+ return [steps.to_sym]
17
+ when Array
18
+ return steps.map(&:to_sym)
19
+ else
20
+ raise UnexpectedValueError
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer/button_list"
2
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer/button"
3
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer/force_neutral"
4
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil"
5
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer/flip_if_pressed"
6
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer/disable_macro_if_pressed"
7
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed"
8
+ require "procon_bypass_man/buttons_setting_configuration/param_normalizer/open_macro_steps"
9
+
10
+ module ProconBypassMan
11
+ class ButtonsSettingConfiguration
12
+ module ParamNormalizer
13
+ class UnSupportValueError < StandardError; end
14
+ class UnexpectedValueError < UnSupportValueError; end
15
+ end
16
+ end
17
+ end
@@ -3,7 +3,7 @@ require "procon_bypass_man/buttons_setting_configuration/loader"
3
3
  require "procon_bypass_man/buttons_setting_configuration/layer"
4
4
 
5
5
  module ProconBypassMan
6
- class AnalogStickPosition < Struct.new(:x, :y); end
6
+ class Position < Struct.new(:x, :y); end
7
7
 
8
8
  class ButtonsSettingConfiguration
9
9
  attr_accessor :layers,
@@ -65,7 +65,7 @@ module ProconBypassMan
65
65
  end
66
66
 
67
67
  unless ([ManualMode.name] + ProconBypassMan::Procon::ModeRegistry.plugins.keys).include?(mode_name)
68
- raise("#{mode_name} mode is unknown")
68
+ warn "#{mode_name}モードがinstallされていません"
69
69
  end
70
70
 
71
71
  layer = Layer.new(mode: mode_name)
@@ -90,7 +90,7 @@ module ProconBypassMan
90
90
  end
91
91
 
92
92
  def set_neutral_position(x, y)
93
- self.neutral_position = AnalogStickPosition.new(x, y).freeze
93
+ self.neutral_position = Position.new(x, y).freeze
94
94
  self
95
95
  end
96
96
 
@@ -103,14 +103,15 @@ module ProconBypassMan
103
103
  self.mode_plugins = {}
104
104
  # プロセスを一度起動するとsetting_pathは変わらない、という想定なので適当に扱う. resetでは初期化しない
105
105
  # self.setting_path = nil
106
- self.macro_plugins = {}
106
+ # どこかで初期化している気がするのでコメントアウト
107
+ self.macro_plugins = ProconBypassMan::Procon::MacroPluginMap.new # ProconBypassMan::Procon::MacroRegistry.reset!と重複している
107
108
  self.layers = {
108
109
  up: Layer.new,
109
110
  down: Layer.new,
110
111
  left: Layer.new,
111
112
  right: Layer.new,
112
113
  }
113
- @neutral_position = AnalogStickPosition.new(2124, 1808).freeze
114
+ @neutral_position = Position.new(2124, 1808).freeze
114
115
  end
115
116
  end
116
117
  end
@@ -10,6 +10,8 @@ class ProconBypassMan::Bypass
10
10
  set_callback :send_procon_to_gadget, :after, :log_procon_to_gadget
11
11
 
12
12
  def log_send_gadget_to_procon
13
+ return unless bypass_value.to_text
14
+
13
15
  if ProconBypassMan.config.verbose_bypass_log
14
16
  ProconBypassMan.logger.debug { ">>> #{bypass_value.to_text}" }
15
17
  else
@@ -20,6 +22,8 @@ class ProconBypassMan::Bypass
20
22
  end
21
23
 
22
24
  def log_procon_to_gadget
25
+ return unless bypass_value.to_text
26
+
23
27
  if ProconBypassMan.config.verbose_bypass_log
24
28
  ProconBypassMan.logger.debug { "<<< #{bypass_value.to_text}" }
25
29
  else