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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +9 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -1
- data/docs/getting_started.md +68 -4
- data/docs/setting/left-analogstick-cap.md +1 -1
- data/docs/setting/splatoon2_macro_dasei_cancel.md +4 -0
- data/docs/setting/splatoon2_macro_sokuwari_bubble.md +4 -0
- data/docs/setting/splatoon2_shake_tansan.md +47 -0
- data/lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb +17 -0
- data/lib/procon_bypass_man/background.rb +1 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +142 -80
- data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +2 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button.rb +28 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button_list.rb +31 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/disable_macro_if_pressed.rb +28 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/flip_if_pressed.rb +31 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/force_neutral.rb +28 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed.rb +26 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil.rb +28 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/open_macro_steps.rb +26 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer.rb +17 -0
- data/lib/procon_bypass_man/buttons_setting_configuration.rb +5 -4
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +4 -0
- data/lib/procon_bypass_man/configuration.rb +8 -1
- data/lib/procon_bypass_man/device_connector.rb +1 -4
- data/lib/procon_bypass_man/device_procon_finder.rb +0 -2
- data/lib/procon_bypass_man/domains/analog_stick_position.rb +18 -0
- data/lib/procon_bypass_man/domains/binary/processing_procon_binary.rb +6 -1
- data/lib/procon_bypass_man/domains.rb +1 -0
- data/lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb +21 -0
- data/lib/procon_bypass_man/plugin/splatoon2/version.rb +1 -1
- data/lib/procon_bypass_man/plugins.rb +1 -0
- data/lib/procon_bypass_man/procon/analog_stick_cap.rb +4 -23
- data/lib/procon_bypass_man/procon/analog_stick_manipulator.rb +36 -0
- data/lib/procon_bypass_man/procon/layer_changer.rb +4 -1
- data/lib/procon_bypass_man/procon/macro.rb +5 -2
- data/lib/procon_bypass_man/procon/macro_builder.rb +15 -17
- data/lib/procon_bypass_man/procon/macro_plugin_map.rb +23 -0
- data/lib/procon_bypass_man/procon/macro_registry.rb +21 -10
- data/lib/procon_bypass_man/procon/user_operation.rb +29 -15
- data/lib/procon_bypass_man/procon.rb +19 -5
- data/lib/procon_bypass_man/remote_macro/queue_over_process.rb +62 -0
- data/lib/procon_bypass_man/remote_macro/remote_macro_object.rb +30 -0
- data/lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb +37 -0
- data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +8 -0
- data/lib/procon_bypass_man/remote_macro/task.rb +6 -0
- data/lib/procon_bypass_man/remote_macro/task_queue.rb +13 -0
- data/lib/procon_bypass_man/remote_macro.rb +14 -0
- data/lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb +1 -1
- data/lib/procon_bypass_man/remote_pbm_action.rb +1 -0
- data/lib/procon_bypass_man/runner.rb +5 -1
- data/lib/procon_bypass_man/support/remote_macro_http_client.rb +9 -0
- data/lib/procon_bypass_man/usb_device_controller.rb +0 -2
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/{pbm_job_client.rb → client.rb} +31 -6
- data/lib/procon_bypass_man.rb +11 -2
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/app.rb +1 -1
- metadata +27 -4
@@ -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
|
data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil.rb
ADDED
@@ -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
|
6
|
+
class Position < Struct.new(:x, :y); end
|
7
7
|
|
8
8
|
class ButtonsSettingConfiguration
|
9
9
|
attr_accessor :layers,
|
@@ -90,7 +90,7 @@ module ProconBypassMan
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def set_neutral_position(x, y)
|
93
|
-
self.neutral_position =
|
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
|
-
|
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 =
|
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
|
@@ -156,7 +156,14 @@ class ProconBypassMan::Configuration
|
|
156
156
|
end
|
157
157
|
|
158
158
|
# @return [Boolean]
|
159
|
-
def enable_ws
|
159
|
+
def enable_ws?
|
160
|
+
!!current_server
|
161
|
+
end
|
162
|
+
|
163
|
+
# @return [Boolean]
|
164
|
+
def enable_remote_macro?
|
165
|
+
enable_ws?
|
166
|
+
end
|
160
167
|
|
161
168
|
# @return [Array<String>]
|
162
169
|
def api_servers
|
@@ -10,16 +10,13 @@ class ProconBypassMan::DeviceConnector
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
PROCON_PATH = "/dev/hidraw0"
|
14
|
-
PROCON2_PATH = "/dev/hidraw1"
|
15
|
-
|
16
13
|
def self.connect
|
17
14
|
s = new(throw_error_if_timeout: true, enable_at_exit: false)
|
18
15
|
s.add([
|
19
16
|
["0000"],
|
20
17
|
["0000"],
|
21
18
|
["8005"],
|
22
|
-
["
|
19
|
+
["0000"],
|
23
20
|
], read_from: :switch)
|
24
21
|
# 1. Sends current connection status, and if the Joy-Con are connected,
|
25
22
|
s.add([["8001"]], read_from: :switch)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ProconBypassMan::AnalogStickPosition
|
2
|
+
attr_accessor :x, :y
|
3
|
+
|
4
|
+
def initialize(x:, y:)
|
5
|
+
@x = x.to_i
|
6
|
+
@y = y.to_i
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_binary
|
10
|
+
analog_stick_data = [
|
11
|
+
(@x & "0xff".to_i(16)),
|
12
|
+
((@y << 4) & "0xf0".to_i(16)) | ((@x >> 8) & "0x0f".to_i(16)),
|
13
|
+
(@y >> 4) & "0xff".to_i(16),
|
14
|
+
]
|
15
|
+
hex = analog_stick_data.map{ |x| x.to_s(16).rjust(2, "0") }.join
|
16
|
+
[hex].pack("H*")
|
17
|
+
end
|
18
|
+
end
|
@@ -36,13 +36,18 @@ class ProconBypassMan::Domains::ProcessingProconBinary < ProconBypassMan::Domain
|
|
36
36
|
|
37
37
|
# @param [Symbol] button
|
38
38
|
def write_as_press_button(button)
|
39
|
-
|
39
|
+
return if ProconBypassMan::PressButtonAware.new(binary).pressing_button?(button)
|
40
40
|
|
41
41
|
button_obj = ProconBypassMan::Procon::Button.new(button)
|
42
42
|
value = binary[button_obj.byte_position].unpack("C").first + (2**button_obj.bit_position)
|
43
43
|
binary[button_obj.byte_position] = ["%02X" % value.to_s].pack("H*")
|
44
44
|
end
|
45
45
|
|
46
|
+
# @param [Symbol] stick method
|
47
|
+
def write_as_tilt_left_stick(step)
|
48
|
+
binary[6..8] = ProconBypassMan::Procon::AnalogStickManipulator.new(binary, method: step).to_binary
|
49
|
+
end
|
50
|
+
|
46
51
|
# @param [Symbol] button
|
47
52
|
def write_as_unpress_button(button)
|
48
53
|
raise "do not press button(#{button}) yet" if not ProconBypassMan::PressButtonAware.new(binary).pressing_button?(button)
|
@@ -5,6 +5,7 @@ module ProconBypassMan
|
|
5
5
|
end
|
6
6
|
|
7
7
|
require_relative "domains/bypass_mode"
|
8
|
+
require_relative "domains/analog_stick_position"
|
8
9
|
require_relative "domains/binary/base"
|
9
10
|
require_relative "domains/binary/has_mutable_binary"
|
10
11
|
require_relative "domains/binary/has_immutable_binary"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module Plugin
|
3
|
+
module Splatoon2
|
4
|
+
module Macro
|
5
|
+
module ChargeTansanBomb
|
6
|
+
def self.display_name
|
7
|
+
:charge_tansan_bomb
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.steps
|
11
|
+
[:shake_left_stick_and_toggle_b_for_0_1sec].freeze
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.description
|
15
|
+
'タンサンボムのチャージ'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -5,6 +5,7 @@ require_relative "plugin/splatoon2/macro/jump_to_up_key"
|
|
5
5
|
require_relative "plugin/splatoon2/macro/jump_to_left_key"
|
6
6
|
require_relative "plugin/splatoon2/macro/sokuwari_for_splash_bomb"
|
7
7
|
require_relative "plugin/splatoon2/macro/dasei_cancel"
|
8
|
+
require_relative "plugin/splatoon2/macro/charge_tansan_bomb"
|
8
9
|
require_relative "plugin/splatoon2/mode/guruguru"
|
9
10
|
|
10
11
|
module ProconBypassMan
|
@@ -1,36 +1,17 @@
|
|
1
1
|
class ProconBypassMan::Procon::AnalogStickCap
|
2
|
-
class Position
|
3
|
-
attr_accessor :x, :y
|
4
|
-
|
5
|
-
def initialize(x:, y:)
|
6
|
-
@x = x.to_i
|
7
|
-
@y = y.to_i
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_binary
|
11
|
-
analog_stick_data = [
|
12
|
-
(@x & "0xff".to_i(16)),
|
13
|
-
((@y << 4) & "0xf0".to_i(16)) | ((@x >> 8) & "0x0f".to_i(16)),
|
14
|
-
(@y >> 4) & "0xff".to_i(16),
|
15
|
-
]
|
16
|
-
hex = analog_stick_data.map{ |x| x.to_s(16).rjust(2, "0") }.join
|
17
|
-
[hex].pack("H*")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
2
|
def initialize(binary)
|
22
3
|
@binary = binary
|
23
4
|
@analog_stick = ProconBypassMan::Procon::AnalogStick.new(binary: binary)
|
24
5
|
end
|
25
6
|
|
26
|
-
# @return [ProconBypassMan::
|
7
|
+
# @return [ProconBypassMan::AnalogStickPosition]
|
27
8
|
def capped_position(cap_hypotenuse: )
|
28
9
|
if hypotenuse > cap_hypotenuse
|
29
10
|
relative_capped_x = cap_hypotenuse * Math.cos(rad * Math::PI / 180).abs
|
30
11
|
relative_capped_y = cap_hypotenuse * Math.sin(rad * Math::PI / 180).abs
|
31
12
|
relative_capped_x = -(relative_capped_x.abs) if relative_x.negative?
|
32
13
|
relative_capped_y = -(relative_capped_y.abs) if relative_y.negative?
|
33
|
-
return
|
14
|
+
return ProconBypassMan::AnalogStickPosition.new(
|
34
15
|
x: relative_capped_x + @analog_stick.neutral_position.x,
|
35
16
|
y: relative_capped_y + @analog_stick.neutral_position.y,
|
36
17
|
)
|
@@ -39,9 +20,9 @@ class ProconBypassMan::Procon::AnalogStickCap
|
|
39
20
|
end
|
40
21
|
end
|
41
22
|
|
42
|
-
# @return [ProconBypassMan::
|
23
|
+
# @return [ProconBypassMan::AnalogStickPosition]
|
43
24
|
def position
|
44
|
-
|
25
|
+
ProconBypassMan::AnalogStickPosition.new(x: abs_x, y: abs_y)
|
45
26
|
end
|
46
27
|
|
47
28
|
def abs_x; @analog_stick.abs_x; end # 0, 0からのx
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class ProconBypassMan::Procon::AnalogStickManipulator
|
2
|
+
attr_accessor :manipulated_abs_x, :manipulated_abs_y
|
3
|
+
|
4
|
+
def initialize(binary, method: )
|
5
|
+
analog_stick = ProconBypassMan::Procon::AnalogStick.new(binary: binary)
|
6
|
+
|
7
|
+
if method =~ /tilt_left_stick_(completely)_to_(left|right)/
|
8
|
+
power_level = $1
|
9
|
+
direction = $2
|
10
|
+
|
11
|
+
case direction
|
12
|
+
when 'left'
|
13
|
+
self.manipulated_abs_x = 400
|
14
|
+
# yを引き継ぐとタンサンボムの溜まりが悪くなったので固定値を入れる
|
15
|
+
self.manipulated_abs_y = analog_stick.abs_y
|
16
|
+
# self.manipulated_abs_y = 1808
|
17
|
+
when 'right'
|
18
|
+
self.manipulated_abs_x = 3400
|
19
|
+
self.manipulated_abs_y = 1808
|
20
|
+
end
|
21
|
+
else
|
22
|
+
warn "error stick manipulator"
|
23
|
+
self.manipulated_abs_x = analog_stick.abs_x
|
24
|
+
self.manipulated_abs_y = analog_stick.abs_y
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# @return [String]
|
30
|
+
def to_binary
|
31
|
+
ProconBypassMan::AnalogStickPosition.new(
|
32
|
+
x: self.manipulated_abs_x,
|
33
|
+
y: self.manipulated_abs_y,
|
34
|
+
).to_binary
|
35
|
+
end
|
36
|
+
end
|
@@ -24,7 +24,10 @@ class ProconBypassMan::Procon::LayerChanger
|
|
24
24
|
# @return [Boolean]
|
25
25
|
def change_layer?
|
26
26
|
if ProconBypassMan::ButtonsSettingConfiguration.instance.prefix_keys.empty?
|
27
|
-
|
27
|
+
ProconBypassMan.cache.fetch key: 'unknown prefix_keys', expires_in: 60 do
|
28
|
+
warn "prefix_keysが未設定です"
|
29
|
+
end
|
30
|
+
return false
|
28
31
|
end
|
29
32
|
ProconBypassMan::ButtonsSettingConfiguration.instance.prefix_keys.map { |b| pressed?(button: b) }.all?
|
30
33
|
end
|
@@ -74,11 +74,13 @@ class ProconBypassMan::Procon::Macro
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
attr_accessor :name, :steps
|
77
|
+
attr_accessor :name, :steps, :after_callback_block, :force_neutral_buttons
|
78
78
|
|
79
|
-
def initialize(name: , steps: )
|
79
|
+
def initialize(name: , steps: , force_neutral_buttons: [], &after_callback_block)
|
80
80
|
self.name = name
|
81
81
|
self.steps = steps
|
82
|
+
self.after_callback_block = after_callback_block
|
83
|
+
self.force_neutral_buttons = force_neutral_buttons # 外部から呼ばれるだけ
|
82
84
|
end
|
83
85
|
|
84
86
|
def next_step
|
@@ -97,6 +99,7 @@ class ProconBypassMan::Procon::Macro
|
|
97
99
|
|
98
100
|
if nested_step.over?
|
99
101
|
steps.shift # NestedStepを破棄する
|
102
|
+
self.after_callback_block.call if self.after_callback_block
|
100
103
|
return next_step
|
101
104
|
else
|
102
105
|
return nested_step.next_step
|
@@ -13,34 +13,32 @@ class ProconBypassMan::Procon::MacroBuilder
|
|
13
13
|
|
14
14
|
class Subject
|
15
15
|
def initialize(value)
|
16
|
-
|
17
|
-
|
18
|
-
match
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
if not /^shake_/ =~ value
|
17
|
+
@button =
|
18
|
+
if match = value.match(/_(\w+)\z/)
|
19
|
+
match[1]
|
20
|
+
else
|
21
|
+
:unknown
|
22
|
+
end
|
23
|
+
end
|
22
24
|
@type =
|
23
25
|
if value.start_with?("toggle_")
|
24
26
|
:toggle
|
27
|
+
elsif value.start_with?("shake_left_stick")
|
28
|
+
:shake_left_stick
|
25
29
|
else
|
26
30
|
:pressing
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
30
|
-
def toggle?
|
31
|
-
@type == :toggle
|
32
|
-
end
|
33
|
-
|
34
|
-
def pressing?
|
35
|
-
not toggle?
|
36
|
-
end
|
37
|
-
|
38
34
|
def to_steps
|
39
35
|
case @type
|
40
36
|
when :toggle
|
41
37
|
[@button.to_sym, :none]
|
42
38
|
when :pressing
|
43
39
|
[@button.to_sym, @button.to_sym]
|
40
|
+
when :shake_left_stick
|
41
|
+
[:tilt_left_stick_completely_to_left, :tilt_left_stick_completely_to_right]
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
@@ -92,7 +90,7 @@ class ProconBypassMan::Procon::MacroBuilder
|
|
92
90
|
]
|
93
91
|
end
|
94
92
|
|
95
|
-
if %r!^(pressing_|toggle_)! =~ step && (subjects = step.scan(%r!pressing_[^_]+|toggle_[^_]+!)) && (match = step.match(%r!_for_([\d_]+)(sec)?\z!))
|
93
|
+
if %r!^(pressing_|toggle_|shake_left_stick_)! =~ step && (subjects = step.scan(%r!pressing_[^_]+|shake_left_stick|toggle_[^_]+!)) && (match = step.match(%r!_for_([\d_]+)(sec)?\z!))
|
96
94
|
if sec = match[1]
|
97
95
|
return {
|
98
96
|
continue_for: to_f(sec),
|
@@ -100,14 +98,14 @@ class ProconBypassMan::Procon::MacroBuilder
|
|
100
98
|
if x.is_a?(Array)
|
101
99
|
x.select { |y| is_button(y) || RESERVED_WORD_NONE == y }
|
102
100
|
else
|
103
|
-
is_button(x) || RESERVED_WORD_NONE == x
|
101
|
+
is_button(x) || RESERVED_WORD_NONE == x || :tilt_left_stick_completely_to_left == x || :tilt_left_stick_completely_to_right == x
|
104
102
|
end
|
105
103
|
},
|
106
104
|
}
|
107
105
|
end
|
108
106
|
end
|
109
107
|
|
110
|
-
if %r!^(pressing_|toggle_)! =~ step && (subjects = step.scan(%r!pressing_[^_]+|toggle_[^_]+!))
|
108
|
+
if %r!^(pressing_|toggle_|shake_left_stick_)! =~ step && (subjects = step.scan(%r!pressing_[^_]+|shake_left_stick|toggle_[^_]+!))
|
111
109
|
return SubjectMerger.merge(subjects.map { |x| Subject.new(x) }).select { |x|
|
112
110
|
if x.is_a?(Array)
|
113
111
|
x.select { |y| is_button(y) || RESERVED_WORD_NONE == y }
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
class Procon
|
3
|
+
# macroキーにメタデータを埋め込んでいる. 通常の処理ではメタデータを露出したくないので露出しないためのクラス
|
4
|
+
class MacroPluginMap < ::Hash
|
5
|
+
def [](value)
|
6
|
+
self.fetch([value, :normal], nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
def each
|
10
|
+
transform_keys(&:first).each { |x| yield(x[0], x[1]) }
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :original_keys, :keys
|
14
|
+
def keys
|
15
|
+
super.map(&:first)
|
16
|
+
end
|
17
|
+
|
18
|
+
def raw_keys
|
19
|
+
self.original_keys
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -3,20 +3,23 @@ class ProconBypassMan::Procon::MacroRegistry
|
|
3
3
|
null: [],
|
4
4
|
}
|
5
5
|
|
6
|
-
def self.install_plugin(klass, steps: nil)
|
7
|
-
if plugins[klass.to_s.to_sym]
|
8
|
-
|
6
|
+
def self.install_plugin(klass, steps: nil, macro_type: :normal)
|
7
|
+
if plugins.fetch([klass.to_s.to_sym, macro_type], nil)
|
8
|
+
Kernel.warn "#{klass} macro is already registered"
|
9
|
+
return
|
9
10
|
end
|
10
11
|
|
11
|
-
plugins
|
12
|
-
|
13
|
-
|
12
|
+
plugins.store(
|
13
|
+
[klass.to_s.to_sym, macro_type], ->{
|
14
|
+
ProconBypassMan::Procon::MacroBuilder.new(steps || klass.steps).build
|
15
|
+
}
|
16
|
+
)
|
14
17
|
end
|
15
18
|
|
16
19
|
# @return [ProconBypassMan::Procon::Macro]
|
17
|
-
def self.load(name)
|
18
|
-
if(steps = PRESETS[name] || plugins[name]&.call)
|
19
|
-
return ProconBypassMan::Procon::Macro.new(name: name, steps: steps.dup)
|
20
|
+
def self.load(name, macro_type: :normal, force_neutral_buttons: [], &after_callback_block)
|
21
|
+
if(steps = PRESETS[name] || plugins.fetch([name.to_s.to_sym, macro_type], nil)&.call)
|
22
|
+
return ProconBypassMan::Procon::Macro.new(name: name, steps: steps.dup, force_neutral_buttons: force_neutral_buttons, &after_callback_block)
|
20
23
|
else
|
21
24
|
warn "installされていないマクロ(#{name})を使うことはできません"
|
22
25
|
return self.load(:null)
|
@@ -24,12 +27,20 @@ class ProconBypassMan::Procon::MacroRegistry
|
|
24
27
|
end
|
25
28
|
|
26
29
|
def self.reset!
|
27
|
-
ProconBypassMan::ButtonsSettingConfiguration.instance.macro_plugins =
|
30
|
+
ProconBypassMan::ButtonsSettingConfiguration.instance.macro_plugins = ProconBypassMan::Procon::MacroPluginMap.new
|
28
31
|
end
|
29
32
|
|
30
33
|
def self.plugins
|
31
34
|
ProconBypassMan::ButtonsSettingConfiguration.instance.macro_plugins
|
32
35
|
end
|
33
36
|
|
37
|
+
def self.cleanup_remote_macros!
|
38
|
+
remote_keys = ProconBypassMan::Procon::MacroRegistry.plugins.original_keys.select { |_, y| y == :remote }
|
39
|
+
remote_keys.each do |remote_key|
|
40
|
+
ProconBypassMan::Procon::MacroRegistry.plugins.delete(remote_key)
|
41
|
+
end
|
42
|
+
ProconBypassMan::Procon::MacroRegistry.plugins
|
43
|
+
end
|
44
|
+
|
34
45
|
reset!
|
35
46
|
end
|