procon_bypass_man 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -5
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +7 -13
- data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +4 -3
- data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +29 -39
- data/lib/procon_bypass_man/buttons_setting_configuration/validator.rb +5 -5
- data/lib/procon_bypass_man/buttons_setting_configuration.rb +28 -47
- data/lib/procon_bypass_man/commands/print_boot_message_command.rb +1 -1
- data/lib/procon_bypass_man/device_connection/command.rb +1 -1
- data/lib/procon_bypass_man/device_connection/executor.rb +9 -1
- data/lib/procon_bypass_man/device_connection/pre_bypass.rb +10 -1
- data/lib/procon_bypass_man/device_connection/procon_color.rb +37 -0
- data/lib/procon_bypass_man/device_connection/procon_setting_overrider.rb +1 -1
- data/lib/procon_bypass_man/device_connection.rb +2 -0
- data/lib/procon_bypass_man/ephemeral_configuration.rb +9 -3
- data/lib/procon_bypass_man/procon/analog_stick_manipulator.rb +1 -1
- data/lib/procon_bypass_man/procon/layer_changer.rb +2 -2
- data/lib/procon_bypass_man/procon/{macro_registry.rb → macro_registry2.rb} +13 -16
- data/lib/procon_bypass_man/procon/{mode_registry.rb → mode_registry2.rb} +11 -11
- data/lib/procon_bypass_man/procon/value_objects/analog_stick.rb +1 -1
- data/lib/procon_bypass_man/procon.rb +13 -13
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb +2 -2
- data/lib/procon_bypass_man/support/renice_command.rb +1 -1
- data/lib/procon_bypass_man/support/shell_runner.rb +11 -0
- data/lib/procon_bypass_man/support/sudo_need_password_checker.rb +6 -0
- data/lib/procon_bypass_man/support/usb_device_controller.rb +2 -2
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/client.rb +2 -2
- data/lib/procon_bypass_man.rb +19 -7
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/app.rb +1 -1
- data/project_template/app.rb.erb +1 -1
- data/project_template/setting.yml +4 -1
- metadata +13 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0517ee4fdd17910ba59e27c6775d9c6ed84b061458ab6aa65e0c184baa90773d
|
|
4
|
+
data.tar.gz: bbe27048f71e5b0fecaf79a775252d36b804baebbf42d4664a48a4be77d958ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1c12516bc8ff8950e26d29207eef77691482373dedf493a6c65675b2c19d3959146d03ac2febd446580f97eeb63001028d53290747cf1b89ab98cd71f0ed0a6f
|
|
7
|
+
data.tar.gz: abcf11a50b53783f7f9c2698a45d849ebe3c30fae2fa1141f1252df6791b5e1eb3a7b41f907ccfd8ce0e69c5792bd7599e0699a33476551542b1d3b76212a23d
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -16,18 +16,15 @@ jobs:
|
|
|
16
16
|
timeout-minutes: 5
|
|
17
17
|
strategy:
|
|
18
18
|
matrix:
|
|
19
|
-
ruby-version: ['3.0', '3.1', '3.2']
|
|
19
|
+
ruby-version: ['3.0', '3.1', '3.2', '3.3.0']
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
22
|
- uses: actions/checkout@v3
|
|
23
23
|
- name: Set up Ruby
|
|
24
|
-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
|
25
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
|
26
|
-
# uses: ruby/setup-ruby@v1
|
|
27
24
|
uses: ruby/setup-ruby@v1
|
|
28
25
|
with:
|
|
29
26
|
ruby-version: ${{ matrix.ruby-version }}
|
|
30
|
-
bundler-cache: true
|
|
27
|
+
bundler-cache: true
|
|
31
28
|
- name: Run tests
|
|
32
29
|
run: |-
|
|
33
30
|
bundle exec rake
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
##
|
|
1
|
+
## [0.3.12] 2024-1-8
|
|
2
|
+
* sudoをつけずにPBMを起動できるようになりました。(なお周辺ファイルは未対応)
|
|
3
|
+
* setting.ymlからコントローラーアイコンの色を変更できるようになりました
|
|
4
|
+
* https://github.com/splaplapla/procon_bypass_man/pull/287
|
|
5
|
+
|
|
6
|
+
## [0.3.11] 2023-12-13
|
|
2
7
|
* 起動時の安定性向上
|
|
3
|
-
* systemd unit pbm.service
|
|
8
|
+
* systemd unit pbm.serviceをRestart=noにしました
|
|
4
9
|
|
|
5
10
|
## [0.3.10] 2023-11-30
|
|
6
11
|
* マクロを実行するとメモリ使用率が増え続ける不具合を修正しました
|
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
procon_bypass_man (0.3.
|
|
4
|
+
procon_bypass_man (0.3.12)
|
|
5
5
|
action_cable_client
|
|
6
|
-
blue_green_process (= 0.1.4.
|
|
6
|
+
blue_green_process (= 0.1.4.3)
|
|
7
7
|
pbmenv (>= 0.1.11)
|
|
8
8
|
sorted_set
|
|
9
9
|
|
|
@@ -21,7 +21,7 @@ GEM
|
|
|
21
21
|
ast (2.4.2)
|
|
22
22
|
backport (1.2.0)
|
|
23
23
|
benchmark (0.2.1)
|
|
24
|
-
blue_green_process (0.1.4.
|
|
24
|
+
blue_green_process (0.1.4.3)
|
|
25
25
|
coderay (1.1.3)
|
|
26
26
|
concurrent-ruby (1.1.9)
|
|
27
27
|
diff-lcs (1.4.4)
|
|
@@ -40,19 +40,13 @@ GEM
|
|
|
40
40
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
41
41
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
42
42
|
method_source (1.0.0)
|
|
43
|
-
mini_portile2 (2.8.
|
|
43
|
+
mini_portile2 (2.8.5)
|
|
44
44
|
minitest (5.14.4)
|
|
45
45
|
mustermann (1.1.1)
|
|
46
46
|
ruby2_keywords (~> 0.0.1)
|
|
47
|
-
nokogiri (1.15.
|
|
47
|
+
nokogiri (1.15.5)
|
|
48
48
|
mini_portile2 (~> 2.8.2)
|
|
49
49
|
racc (~> 1.4)
|
|
50
|
-
nokogiri (1.15.2-arm-linux)
|
|
51
|
-
racc (~> 1.4)
|
|
52
|
-
nokogiri (1.15.2-arm64-darwin)
|
|
53
|
-
racc (~> 1.4)
|
|
54
|
-
nokogiri (1.15.2-x86_64-linux)
|
|
55
|
-
racc (~> 1.4)
|
|
56
50
|
parallel (1.21.0)
|
|
57
51
|
parser (3.0.3.2)
|
|
58
52
|
ast (~> 2.4.1)
|
|
@@ -60,7 +54,7 @@ GEM
|
|
|
60
54
|
pry (0.14.1)
|
|
61
55
|
coderay (~> 1.1)
|
|
62
56
|
method_source (~> 1.0)
|
|
63
|
-
racc (1.7.
|
|
57
|
+
racc (1.7.3)
|
|
64
58
|
rack (2.2.3.1)
|
|
65
59
|
rack-protection (2.2.0)
|
|
66
60
|
rack
|
|
@@ -102,7 +96,7 @@ GEM
|
|
|
102
96
|
ruby-progressbar (1.11.0)
|
|
103
97
|
ruby2_keywords (0.0.5)
|
|
104
98
|
serialport (1.3.2)
|
|
105
|
-
set (1.0
|
|
99
|
+
set (1.1.0)
|
|
106
100
|
sinatra (2.2.0)
|
|
107
101
|
mustermann (~> 1.0)
|
|
108
102
|
rack (~> 2.2)
|
|
@@ -3,7 +3,8 @@ module ProconBypassMan
|
|
|
3
3
|
class Layer
|
|
4
4
|
attr_accessor :mode, :flips, :macros, :disable_macros, :remaps, :left_analog_stick_caps, :disables
|
|
5
5
|
|
|
6
|
-
def initialize(mode: :manual)
|
|
6
|
+
def initialize(context, mode: :manual)
|
|
7
|
+
@context = context
|
|
7
8
|
self.mode = mode
|
|
8
9
|
self.flips = {}
|
|
9
10
|
self.macros = {}
|
|
@@ -83,7 +84,7 @@ module ProconBypassMan
|
|
|
83
84
|
end
|
|
84
85
|
|
|
85
86
|
macro_name = name.to_s.to_sym
|
|
86
|
-
if
|
|
87
|
+
if @context.macro_registry.plugins[macro_name]
|
|
87
88
|
self.macros[macro_name] = { if_pressed: if_pressed, if_tilted_left_stick: if_tilted_left_stick, force_neutral: force_neutral }.compact
|
|
88
89
|
else
|
|
89
90
|
warn "#{macro_name}マクロがinstallされていません"
|
|
@@ -133,7 +134,7 @@ module ProconBypassMan
|
|
|
133
134
|
end
|
|
134
135
|
|
|
135
136
|
macro_name = name || "OpenMacro-#{steps.join}".to_sym
|
|
136
|
-
|
|
137
|
+
@context.macro_registry.install_plugin(macro_name, steps: steps)
|
|
137
138
|
self.macros[macro_name] = { if_pressed: if_pressed, if_tilted_left_stick: if_tilted_left_stick, force_neutral: force_neutral }.compact
|
|
138
139
|
end
|
|
139
140
|
|
|
@@ -8,58 +8,48 @@ module ProconBypassMan
|
|
|
8
8
|
|
|
9
9
|
# @return [ProconBypassMan::ButtonsSettingConfiguration]
|
|
10
10
|
def self.load(setting_path: )
|
|
11
|
-
ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path = setting_path
|
|
12
|
-
|
|
13
11
|
metadata_loader = ProconBypassMan::ButtonsSettingConfiguration::MetadataLoader.load(setting_path: setting_path)
|
|
14
12
|
if(Gem::Version.new(metadata_loader.required_pbm_version) >= Gem::Version.new(ProconBypassMan::VERSION))
|
|
15
13
|
ProconBypassMan::SendErrorCommand.execute(error: '起動中のPBMが設定ファイルのバージョンを満たしていません。設定ファイルが意図した通り動かない可能性があります。PBMのバージョンをあげてください。')
|
|
16
14
|
end
|
|
17
15
|
|
|
18
|
-
ProconBypassMan::
|
|
19
|
-
yaml = YAML.load_file(setting_path) or raise "読み込みに失敗しました"
|
|
20
|
-
new_instance.instance_eval(yaml["setting"])
|
|
21
|
-
validator = Validator.new(new_instance)
|
|
22
|
-
if validator.valid?
|
|
23
|
-
next
|
|
24
|
-
else
|
|
25
|
-
raise ProconBypassMan::CouldNotLoadConfigError, validator.errors_to_s
|
|
26
|
-
end
|
|
27
|
-
rescue SyntaxError
|
|
28
|
-
fallback_setting_if_has_backup(current_setting_path: setting_path)
|
|
29
|
-
raise ProconBypassMan::CouldNotLoadConfigError, "Rubyスクリプトのシンタックスエラーです"
|
|
30
|
-
rescue NameError
|
|
31
|
-
fallback_setting_if_has_backup(current_setting_path: setting_path)
|
|
32
|
-
raise ProconBypassMan::CouldNotLoadConfigError, "Rubyスクリプトに未定義の定数・変数があります"
|
|
33
|
-
rescue Psych::SyntaxError
|
|
34
|
-
fallback_setting_if_has_backup(current_setting_path: setting_path)
|
|
35
|
-
raise ProconBypassMan::CouldNotLoadConfigError, "yamlのシンタックスエラーです"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
ProconBypassMan::ButtonsSettingConfiguration.instance.reset!
|
|
39
|
-
ProconBypassMan.reset!
|
|
16
|
+
ProconBypassMan::Procon.reset! # TODO: ここでresetするのは微妙な気がする
|
|
40
17
|
|
|
41
|
-
yaml =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
18
|
+
new_instance, yaml =
|
|
19
|
+
begin
|
|
20
|
+
new_instance = ProconBypassMan::ButtonsSettingConfiguration.new
|
|
21
|
+
new_instance.setting_path = setting_path
|
|
22
|
+
yaml = ProconBypassMan::YamlLoader.load(path: setting_path)
|
|
23
|
+
new_instance.instance_eval(yaml["setting"])
|
|
24
|
+
validator = Validator.new(new_instance)
|
|
25
|
+
if validator.valid?
|
|
26
|
+
[new_instance, yaml]
|
|
27
|
+
else
|
|
28
|
+
fallback_setting_if_has_backup(current_setting_path: setting_path)
|
|
29
|
+
raise ProconBypassMan::CouldNotLoadConfigError, validator.errors_to_s
|
|
30
|
+
end
|
|
31
|
+
rescue SyntaxError
|
|
32
|
+
fallback_setting_if_has_backup(current_setting_path: setting_path)
|
|
33
|
+
raise ProconBypassMan::CouldNotLoadConfigError, "Rubyスクリプトのシンタックスエラーです"
|
|
34
|
+
rescue NameError
|
|
35
|
+
fallback_setting_if_has_backup(current_setting_path: setting_path)
|
|
36
|
+
raise ProconBypassMan::CouldNotLoadConfigError, "Rubyスクリプトに未定義の定数・変数があります"
|
|
37
|
+
rescue Psych::SyntaxError
|
|
38
|
+
fallback_setting_if_has_backup(current_setting_path: setting_path)
|
|
39
|
+
raise ProconBypassMan::CouldNotLoadConfigError, "yamlのシンタックスエラーです"
|
|
40
|
+
end
|
|
50
41
|
|
|
42
|
+
ProconBypassMan.config.raw_setting = yaml
|
|
43
|
+
ProconBypassMan.buttons_setting_configuration = new_instance
|
|
51
44
|
File.write(ProconBypassMan.digest_path, Digest::MD5.hexdigest(yaml["setting"]))
|
|
45
|
+
FileUtils.rm_rf(ProconBypassMan.fallback_setting_path) # NOTE: 設定ファイルの読み込みに成功したら、バックアップを削除する
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
FileUtils.rm_rf(ProconBypassMan.fallback_setting_path)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
ProconBypassMan::ButtonsSettingConfiguration.instance
|
|
47
|
+
ProconBypassMan.buttons_setting_configuration
|
|
58
48
|
end
|
|
59
49
|
|
|
60
50
|
def self.reload_setting
|
|
61
51
|
ProconBypassMan.ephemeral_config.reset!
|
|
62
|
-
self.load(setting_path: ProconBypassMan
|
|
52
|
+
self.load(setting_path: ProconBypassMan.buttons_setting_configuration.setting_path)
|
|
63
53
|
end
|
|
64
54
|
|
|
65
55
|
def self.fallback_setting_if_has_backup(current_setting_path: )
|
|
@@ -2,8 +2,8 @@ module ProconBypassMan
|
|
|
2
2
|
class ButtonsSettingConfiguration
|
|
3
3
|
class Validator
|
|
4
4
|
def initialize(config)
|
|
5
|
-
@macro_plugins = config.
|
|
6
|
-
@mode_plugins = config.
|
|
5
|
+
@macro_plugins = config.macro_registry.plugins
|
|
6
|
+
@mode_plugins = config.mode_registry.plugins
|
|
7
7
|
@layers = config.layers
|
|
8
8
|
@prefix_keys = config.prefix_keys
|
|
9
9
|
end
|
|
@@ -46,7 +46,7 @@ module ProconBypassMan
|
|
|
46
46
|
|
|
47
47
|
def validate_config_of_button_lonely
|
|
48
48
|
@layers.each do |layer_key, value|
|
|
49
|
-
if ProconBypassMan
|
|
49
|
+
if ProconBypassMan.buttons_setting_configuration.mode_registry.presets.key?(value.mode)
|
|
50
50
|
next
|
|
51
51
|
else
|
|
52
52
|
if !value.flips.empty? || !value.macros.empty?
|
|
@@ -83,8 +83,8 @@ module ProconBypassMan
|
|
|
83
83
|
flip_option_target_button
|
|
84
84
|
}
|
|
85
85
|
}.compact.each { |b| unverified_buttons << b }
|
|
86
|
-
unless(
|
|
87
|
-
@errors[:layers] << "#{layer_key}で存在しないボタン#{
|
|
86
|
+
unless(unsupported_buttons = (unverified_buttons - ProconBypassMan::Procon::ButtonCollection::BUTTONS)).length.zero?
|
|
87
|
+
@errors[:layers] << "#{layer_key}で存在しないボタン#{unsupported_buttons.join(", ")}があります"
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
end
|
|
@@ -3,51 +3,21 @@ 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 Position < Struct.new(:x, :y); end
|
|
7
|
-
|
|
8
6
|
class ButtonsSettingConfiguration
|
|
7
|
+
class Position < Struct.new(:x, :y); end
|
|
8
|
+
|
|
9
|
+
module ManualMode; def self.name; :manual; end; end
|
|
10
|
+
|
|
9
11
|
attr_accessor :layers,
|
|
10
12
|
:setting_path,
|
|
11
|
-
:
|
|
12
|
-
:
|
|
13
|
+
:macro_registry,
|
|
14
|
+
:mode_registry,
|
|
13
15
|
:neutral_position
|
|
14
16
|
|
|
15
|
-
def self.instance
|
|
16
|
-
@@context ||= {}
|
|
17
|
-
@@context[current_context_key] ||= new
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.current_context_key
|
|
21
|
-
@@current_context_key ||= :main
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def self.instance=(val)
|
|
25
|
-
@@context[current_context_key] = val
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def self.switch_new_context(new_context_key)
|
|
29
|
-
@@context[new_context_key] = new
|
|
30
|
-
previous_key = current_context_key
|
|
31
|
-
if block_given?
|
|
32
|
-
@@current_context_key = new_context_key
|
|
33
|
-
value = yield(@@context[new_context_key])
|
|
34
|
-
return value
|
|
35
|
-
else
|
|
36
|
-
@@current_context_key = new_context_key
|
|
37
|
-
end
|
|
38
|
-
ensure
|
|
39
|
-
@@current_context_key = previous_key
|
|
40
|
-
end
|
|
41
|
-
|
|
42
17
|
def initialize
|
|
43
18
|
reset!
|
|
44
19
|
end
|
|
45
20
|
|
|
46
|
-
module ManualMode
|
|
47
|
-
def self.name
|
|
48
|
-
:manual
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
21
|
def layer(direction, mode: ManualMode, &block)
|
|
52
22
|
if ProconBypassMan::ButtonsSettingConfiguration::ManualMode == mode
|
|
53
23
|
mode_name = mode.name
|
|
@@ -64,23 +34,24 @@ module ProconBypassMan
|
|
|
64
34
|
end
|
|
65
35
|
end
|
|
66
36
|
|
|
67
|
-
unless ([ManualMode.name] +
|
|
37
|
+
unless ([ManualMode.name] + mode_registry.plugins.keys).include?(mode_name)
|
|
38
|
+
# TODO: strict modeが有効なときはエラーにする
|
|
68
39
|
warn "#{mode_name}モードがinstallされていません"
|
|
69
40
|
end
|
|
70
41
|
|
|
71
|
-
layer = Layer.new(mode: mode_name)
|
|
42
|
+
layer = Layer.new(self, mode: mode_name)
|
|
72
43
|
layer.instance_eval(&block) if block_given?
|
|
73
44
|
self.layers[direction] = layer
|
|
74
45
|
self
|
|
75
46
|
end
|
|
76
47
|
|
|
77
48
|
def install_mode_plugin(klass)
|
|
78
|
-
|
|
49
|
+
mode_registry.install_plugin(klass)
|
|
79
50
|
self
|
|
80
51
|
end
|
|
81
52
|
|
|
82
53
|
def install_macro_plugin(klass)
|
|
83
|
-
|
|
54
|
+
macro_registry.install_plugin(klass)
|
|
84
55
|
self
|
|
85
56
|
end
|
|
86
57
|
|
|
@@ -99,11 +70,21 @@ module ProconBypassMan
|
|
|
99
70
|
end
|
|
100
71
|
|
|
101
72
|
# @param [Symbol, String] setting_name
|
|
73
|
+
# @param [Array<any>] args
|
|
102
74
|
# @return [void]
|
|
103
|
-
def enable(setting_name)
|
|
75
|
+
def enable(setting_name, *args)
|
|
104
76
|
case setting_name.to_sym
|
|
105
77
|
when :rumble_on_layer_change
|
|
106
78
|
ProconBypassMan.ephemeral_config.enable_rumble_on_layer_change = true
|
|
79
|
+
when :procon_color
|
|
80
|
+
color_name = args.first
|
|
81
|
+
return if color_name.nil? || color_name == :default || color_name == 'default'
|
|
82
|
+
color = ProconBypassMan::DeviceConnection::ProconColor.new(color_name)
|
|
83
|
+
if color.valid?
|
|
84
|
+
ProconBypassMan.ephemeral_config.recognized_procon_color = ProconBypassMan::DeviceConnection::ProconColor.new(color_name)
|
|
85
|
+
else
|
|
86
|
+
warn "recognized_procon_colorに存在しないcolor(#{color_name})が呼び出されました。"
|
|
87
|
+
end
|
|
107
88
|
else
|
|
108
89
|
warn "存在しないenable(#{setting_name.to_sym})が呼び出されました。"
|
|
109
90
|
end
|
|
@@ -111,17 +92,17 @@ module ProconBypassMan
|
|
|
111
92
|
|
|
112
93
|
def reset!
|
|
113
94
|
@prefix_keys_for_changing_layer = []
|
|
114
|
-
self.mode_plugins = {}
|
|
115
95
|
# プロセスを一度起動するとsetting_pathは変わらない、という想定なので適当に扱う. resetでは初期化しない
|
|
116
96
|
# self.setting_path = nil
|
|
117
97
|
# どこかで初期化している気がするのでコメントアウト
|
|
118
|
-
self.macro_plugins = ProconBypassMan::Procon::MacroPluginMap.new # ProconBypassMan::Procon::MacroRegistry.reset!と重複している
|
|
119
98
|
self.layers = {
|
|
120
|
-
up: Layer.new,
|
|
121
|
-
down: Layer.new,
|
|
122
|
-
left: Layer.new,
|
|
123
|
-
right: Layer.new,
|
|
99
|
+
up: Layer.new(self),
|
|
100
|
+
down: Layer.new(self),
|
|
101
|
+
left: Layer.new(self),
|
|
102
|
+
right: Layer.new(self),
|
|
124
103
|
}
|
|
104
|
+
@macro_registry = ProconBypassMan::Procon::MacroRegistry2.new
|
|
105
|
+
@mode_registry = ProconBypassMan::Procon::ModeRegistry2.new
|
|
125
106
|
@neutral_position = Position.new(2124, 1808).freeze
|
|
126
107
|
end
|
|
127
108
|
end
|
|
@@ -8,7 +8,7 @@ class ProconBypassMan::PrintBootMessageCommand
|
|
|
8
8
|
@table[:pid] = $$
|
|
9
9
|
@table[:root_path] = ProconBypassMan.root
|
|
10
10
|
@table[:pid_path] = ProconBypassMan.pid_path
|
|
11
|
-
@table[:setting_path] = ProconBypassMan
|
|
11
|
+
@table[:setting_path] = ProconBypassMan.buttons_setting_configuration.setting_path
|
|
12
12
|
@table[:uptime_from_boot] = ProconBypassMan::Uptime.from_boot
|
|
13
13
|
@table[:use_pbmenv] = ProconBypassMan.root.start_with?(Pbmenv::PBM_DIR)
|
|
14
14
|
@table[:session_id] = ProconBypassMan.session_id
|
|
@@ -15,7 +15,7 @@ class ProconBypassMan::DeviceConnection::Command
|
|
|
15
15
|
|
|
16
16
|
retry_count = retry_count + 1
|
|
17
17
|
retry
|
|
18
|
-
rescue ProconBypassMan::DeviceConnection::NotFoundProconError => e
|
|
18
|
+
rescue ProconBypassMan::DeviceConnection::NotFoundProconError, ProconBypassMan::DeviceConnection::SetupIncompleteError => e
|
|
19
19
|
raise
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -150,14 +150,21 @@ class ProconBypassMan::DeviceConnection::Executer
|
|
|
150
150
|
@procon
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
+
GADGET_PATH = '/dev/hidg0'
|
|
153
154
|
def init_devices
|
|
155
|
+
unless SudoNeedPasswordChecker.execute!
|
|
156
|
+
raise ProconBypassMan::DeviceConnection::SetupIncompleteError
|
|
157
|
+
end
|
|
158
|
+
|
|
154
159
|
if @initialized_devices
|
|
155
160
|
return
|
|
156
161
|
end
|
|
162
|
+
|
|
157
163
|
ProconBypassMan::UsbDeviceController.init
|
|
158
164
|
ProconBypassMan::UsbDeviceController.reset
|
|
159
165
|
|
|
160
166
|
if path = ProconBypassMan::DeviceProconFinder.find
|
|
167
|
+
ShellRunner.execute("sudo chmod 777 #{path}")
|
|
161
168
|
@procon = File.open(path, "w+b")
|
|
162
169
|
ProconBypassMan.logger.info "proconのデバイスファイルは#{path}を使います"
|
|
163
170
|
else
|
|
@@ -165,7 +172,8 @@ class ProconBypassMan::DeviceConnection::Executer
|
|
|
165
172
|
end
|
|
166
173
|
|
|
167
174
|
begin
|
|
168
|
-
|
|
175
|
+
ShellRunner.execute("sudo chmod 777 #{GADGET_PATH}")
|
|
176
|
+
@gadget = File.open(GADGET_PATH, "w+b")
|
|
169
177
|
rescue Errno::ENXIO => e
|
|
170
178
|
# /dev/hidg0 をopenできないときがある
|
|
171
179
|
ProconBypassMan::SendErrorCommand.execute(error: "Errno::ENXIOが起きたのでresetします.\n #{e.full_message}", stdout: false)
|
|
@@ -33,7 +33,16 @@ class ProconBypassMan::DeviceConnection::PreBypass
|
|
|
33
33
|
begin
|
|
34
34
|
raw_data = non_blocking_read_procon
|
|
35
35
|
output_report_watcher.mark_as_receive(raw_data)
|
|
36
|
-
ProconBypassMan.logger.info "[pre_bypass] <<< #{raw_data.
|
|
36
|
+
ProconBypassMan.logger.info "[pre_bypass] <<< #{raw_data.unpack1("H*")}"
|
|
37
|
+
|
|
38
|
+
if(recognized_procon_color = ProconBypassMan.ephemeral_config.recognized_procon_color)
|
|
39
|
+
first_data_part = raw_data[0].unpack1("H*")
|
|
40
|
+
sub_command = raw_data[15..16].unpack1("H*")
|
|
41
|
+
if first_data_part == '21' && sub_command == "5060"
|
|
42
|
+
raw_data[recognized_procon_color.byte_position] = recognized_procon_color.to_bytes
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
37
46
|
send_switch(raw_data)
|
|
38
47
|
rescue IO::EAGAINWaitReadable
|
|
39
48
|
# no-op
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
class ProconBypassMan::DeviceConnection::ProconColor
|
|
2
|
+
# NOTE: [Body, Buttons, Left Grip, Right Grip] RGB
|
|
3
|
+
COLOR_TABLE = {
|
|
4
|
+
red: ['ff 00 00', 'ff ff ff', 'ff 00 00', 'ff 00 00'],
|
|
5
|
+
blue: ['00 00 ff', 'ff ff ff', '00 00 ff', '00 00 ff'],
|
|
6
|
+
yellow: ['ff ff 00', 'ff ff ff', 'ff ff 00', 'ff ff 00'],
|
|
7
|
+
green: ['00 ff 00', 'ff ff ff', '00 ff 00', '00 ff 00'],
|
|
8
|
+
pink: ['ff 00 ff', 'ff ff ff', 'ff 00 ff', 'ff 00 ff'],
|
|
9
|
+
cyan: ['00 ff ff', 'ff ff ff', '00 ff ff', '00 ff ff'],
|
|
10
|
+
white: ['ff ff ff', '00 00 00', 'ff ff ff', 'ff ff ff'],
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
BYTE_POSITION = 20...(20+(3*4))
|
|
14
|
+
|
|
15
|
+
attr_accessor :name
|
|
16
|
+
|
|
17
|
+
# @param [Symbol] color_name
|
|
18
|
+
# @return [void]
|
|
19
|
+
def initialize(color_name)
|
|
20
|
+
self.name = color_name.to_sym
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @return [String]
|
|
24
|
+
def to_bytes
|
|
25
|
+
[COLOR_TABLE[self.name].join.gsub(/[,\s]/, '')].pack('H*')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @return [Range]
|
|
29
|
+
def byte_position
|
|
30
|
+
BYTE_POSITION
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @return [Boolean]
|
|
34
|
+
def valid?
|
|
35
|
+
!!COLOR_TABLE[self.name]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -17,7 +17,7 @@ class ProconBypassMan::DeviceConnection::ProconSettingOverrider
|
|
|
17
17
|
def initialize(procon: )
|
|
18
18
|
use_steps = {}
|
|
19
19
|
if ProconBypassMan.config.enable_home_led_on_connect
|
|
20
|
-
use_steps.merge!(ALL_SETTINGS)
|
|
20
|
+
use_steps.merge!(home_led_on: ALL_SETTINGS[:home_led_on])
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
@setting_steps = use_steps.keys
|
|
@@ -3,6 +3,7 @@ module ProconBypassMan::DeviceConnection
|
|
|
3
3
|
class NotFoundProconError < StandardError; end
|
|
4
4
|
class TimeoutErrorInConditionalRoute < StandardError; end
|
|
5
5
|
class TimeoutError < StandardError; end
|
|
6
|
+
class SetupIncompleteError < StandardError; end
|
|
6
7
|
end
|
|
7
8
|
|
|
8
9
|
require_relative "device_connection/executor"
|
|
@@ -14,3 +15,4 @@ require_relative "device_connection/output_report_generator"
|
|
|
14
15
|
require_relative "device_connection/output_report_sub_command_table"
|
|
15
16
|
require_relative "device_connection/spoofing_output_report_watcher"
|
|
16
17
|
require_relative "device_connection/output_report_watcher"
|
|
18
|
+
require_relative "device_connection/procon_color"
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
1
|
# setting.yamlから設定される値。設定ファイルを再読み込みするとすべて消える
|
|
3
2
|
class ProconBypassMan::EphemeralConfiguration
|
|
4
|
-
|
|
3
|
+
KEYS = [
|
|
4
|
+
:enable_rumble_on_layer_change,
|
|
5
|
+
:recognized_procon_color,
|
|
6
|
+
].freeze
|
|
7
|
+
|
|
8
|
+
attr_accessor(*KEYS)
|
|
5
9
|
|
|
6
10
|
def reset!
|
|
7
|
-
|
|
11
|
+
KEYS.each do |key|
|
|
12
|
+
self.send("#{key}=", nil)
|
|
13
|
+
end
|
|
8
14
|
end
|
|
9
15
|
end
|
|
@@ -28,7 +28,7 @@ class ProconBypassMan::Procon::AnalogStickManipulator
|
|
|
28
28
|
power_level = $1
|
|
29
29
|
arc_degree = $2.to_i
|
|
30
30
|
syahen = 1800 # 最大まで傾けた状態
|
|
31
|
-
neutral_position = ProconBypassMan
|
|
31
|
+
neutral_position = ProconBypassMan.buttons_setting_configuration.neutral_position
|
|
32
32
|
self.manipulated_abs_x = (syahen * Math.cos(arc_degree * Math::PI / 180)).to_i - neutral_position.x
|
|
33
33
|
self.manipulated_abs_y = (syahen * Math.sin(arc_degree * Math::PI / 180)).to_i - neutral_position.y
|
|
34
34
|
return
|
|
@@ -25,13 +25,13 @@ class ProconBypassMan::Procon::LayerChanger
|
|
|
25
25
|
|
|
26
26
|
# @return [Boolean]
|
|
27
27
|
def change_layer?
|
|
28
|
-
if ProconBypassMan
|
|
28
|
+
if ProconBypassMan.buttons_setting_configuration.prefix_keys.empty?
|
|
29
29
|
ProconBypassMan.cache.fetch key: 'unknown prefix_keys', expires_in: 60 do
|
|
30
30
|
warn "prefix_keysが未設定です"
|
|
31
31
|
end
|
|
32
32
|
return false
|
|
33
33
|
end
|
|
34
|
-
ProconBypassMan
|
|
34
|
+
ProconBypassMan.buttons_setting_configuration.prefix_keys.map { |b| pressed?(button: b) }.all?
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# @return [Boolean]
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
class ProconBypassMan::Procon::
|
|
3
|
+
class ProconBypassMan::Procon::MacroRegistry2
|
|
4
|
+
attr_accessor :plugins
|
|
5
|
+
|
|
4
6
|
PRESETS = {
|
|
5
7
|
null: [],
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
def
|
|
10
|
+
def initialize
|
|
11
|
+
self.plugins = ProconBypassMan::Procon::MacroPluginMap.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def install_plugin(klass, steps: nil, macro_type: :normal)
|
|
9
15
|
if plugins.fetch([klass.to_s.to_sym, macro_type], nil)
|
|
10
16
|
Kernel.warn "#{klass} macro is already registered"
|
|
11
17
|
return
|
|
@@ -19,7 +25,7 @@ class ProconBypassMan::Procon::MacroRegistry
|
|
|
19
25
|
end
|
|
20
26
|
|
|
21
27
|
# @return [ProconBypassMan::Procon::Macro]
|
|
22
|
-
def
|
|
28
|
+
def load(name, macro_type: :normal, force_neutral_buttons: [], &after_callback_block)
|
|
23
29
|
if(steps = PRESETS[name] || plugins.fetch([name.to_s.to_sym, macro_type], nil)&.call)
|
|
24
30
|
return ProconBypassMan::Procon::Macro.new(name: name, steps: steps.dup, force_neutral_buttons: force_neutral_buttons, &after_callback_block)
|
|
25
31
|
else
|
|
@@ -28,21 +34,12 @@ class ProconBypassMan::Procon::MacroRegistry
|
|
|
28
34
|
end
|
|
29
35
|
end
|
|
30
36
|
|
|
31
|
-
def self.reset!
|
|
32
|
-
ProconBypassMan::ButtonsSettingConfiguration.instance.macro_plugins = ProconBypassMan::Procon::MacroPluginMap.new
|
|
33
|
-
end
|
|
34
37
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def self.cleanup_remote_macros!
|
|
40
|
-
remote_keys = ProconBypassMan::Procon::MacroRegistry.plugins.original_keys.select { |_, y| y == :remote }
|
|
38
|
+
def cleanup_remote_macros!
|
|
39
|
+
remote_keys = plugins.original_keys.select { |_, y| y == :remote }
|
|
41
40
|
remote_keys.each do |remote_key|
|
|
42
|
-
|
|
41
|
+
plugins.delete(remote_key)
|
|
43
42
|
end
|
|
44
|
-
|
|
43
|
+
plugins
|
|
45
44
|
end
|
|
46
|
-
|
|
47
|
-
reset!
|
|
48
45
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class ProconBypassMan::Procon::
|
|
1
|
+
class ProconBypassMan::Procon::ModeRegistry2
|
|
2
2
|
class Mode
|
|
3
3
|
attr_accessor :name, :binaries, :source_binaries
|
|
4
4
|
|
|
@@ -18,29 +18,29 @@ class ProconBypassMan::Procon::ModeRegistry
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
attr_accessor :plugins
|
|
22
|
+
|
|
21
23
|
PRESETS = {
|
|
22
24
|
manual: [],
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
def
|
|
27
|
+
def initialize
|
|
28
|
+
self.plugins = {}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def install_plugin(klass)
|
|
26
32
|
if plugins[klass.to_s.to_sym]
|
|
27
33
|
raise "#{klass} mode is already registered"
|
|
28
34
|
end
|
|
29
35
|
plugins[klass.to_s.to_sym] = ->{ klass.binaries }
|
|
30
36
|
end
|
|
31
37
|
|
|
32
|
-
def
|
|
38
|
+
def load(name)
|
|
33
39
|
b = PRESETS[name] || plugins[name]&.call || raise("#{name} is unknown mode")
|
|
34
40
|
Mode.new(name: name, binaries: b.dup)
|
|
35
41
|
end
|
|
36
42
|
|
|
37
|
-
def
|
|
38
|
-
|
|
43
|
+
def presets
|
|
44
|
+
PRESETS
|
|
39
45
|
end
|
|
40
|
-
|
|
41
|
-
def self.plugins
|
|
42
|
-
ProconBypassMan::ButtonsSettingConfiguration.instance.mode_plugins
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
reset!
|
|
46
46
|
end
|
|
@@ -5,7 +5,7 @@ class ProconBypassMan::Procon::AnalogStick
|
|
|
5
5
|
attr_writer :bin_x, :bin_y
|
|
6
6
|
|
|
7
7
|
def initialize(binary: )
|
|
8
|
-
@neutral_position = ProconBypassMan
|
|
8
|
+
@neutral_position = ProconBypassMan.buttons_setting_configuration.neutral_position
|
|
9
9
|
bytes = binary[ProconBypassMan::Procon::ButtonCollection::LEFT_ANALOG_STICK.fetch(:byte_position)]
|
|
10
10
|
byte6, byte7, byte8 = bytes.each_char.map { |x| x.unpack("C").first.to_s(2).rjust(8, "0") }
|
|
11
11
|
|
|
@@ -11,9 +11,9 @@ class ProconBypassMan::Procon
|
|
|
11
11
|
require "procon_bypass_man/procon/value_objects/bypass_mode"
|
|
12
12
|
require "procon_bypass_man/procon/performance_measurement"
|
|
13
13
|
require "procon_bypass_man/procon/performance_measurement/queue_over_process"
|
|
14
|
-
require "procon_bypass_man/procon/
|
|
14
|
+
require "procon_bypass_man/procon/mode_registry2"
|
|
15
15
|
require "procon_bypass_man/procon/macro"
|
|
16
|
-
require "procon_bypass_man/procon/
|
|
16
|
+
require "procon_bypass_man/procon/macro_registry2"
|
|
17
17
|
require "procon_bypass_man/procon/macro_builder"
|
|
18
18
|
require "procon_bypass_man/procon/layer_changer"
|
|
19
19
|
require "procon_bypass_man/procon/button_collection"
|
|
@@ -27,14 +27,13 @@ class ProconBypassMan::Procon
|
|
|
27
27
|
|
|
28
28
|
def self.reset!
|
|
29
29
|
@@status = {
|
|
30
|
-
ongoing_macro:
|
|
31
|
-
ongoing_mode:
|
|
30
|
+
ongoing_macro: ProconBypassMan.buttons_setting_configuration.macro_registry.load(:null),
|
|
31
|
+
ongoing_mode: ProconBypassMan.buttons_setting_configuration.mode_registry.load(:manual), # 削除予定
|
|
32
32
|
}
|
|
33
33
|
BlueGreenProcess::SharedVariable.instance.data["buttons"] = {}
|
|
34
34
|
BlueGreenProcess::SharedVariable.instance.data["current_layer_key"] = :up
|
|
35
35
|
BlueGreenProcess::SharedVariable.instance.data["recent_left_stick_hypotenuses"] = []
|
|
36
36
|
end
|
|
37
|
-
reset!
|
|
38
37
|
|
|
39
38
|
# @param [string] binary
|
|
40
39
|
def initialize(binary)
|
|
@@ -74,7 +73,7 @@ class ProconBypassMan::Procon
|
|
|
74
73
|
def ongoing_mode; @@status[:ongoing_mode]; end
|
|
75
74
|
|
|
76
75
|
def current_layer
|
|
77
|
-
ProconBypassMan
|
|
76
|
+
ProconBypassMan.buttons_setting_configuration.layers[current_layer_key]
|
|
78
77
|
end
|
|
79
78
|
|
|
80
79
|
# 内部ステータスを書き換えるフェーズ
|
|
@@ -112,7 +111,7 @@ class ProconBypassMan::Procon
|
|
|
112
111
|
if(if_tilted_left_stick_value = options[:if_tilted_left_stick])
|
|
113
112
|
threshold = (if_tilted_left_stick_value.is_a?(Hash) && if_tilted_left_stick_value[:threshold]) || ProconBypassMan::AnalogStickTiltingPowerScaler::DEFAULT_THRESHOLD
|
|
114
113
|
if dumped_tilting_power.tilting?(threshold: threshold, current_position_x: analog_stick.relative_x, current_position_y: analog_stick.relative_y) && user_operation.pressing_all_buttons?(options[:if_pressed])
|
|
115
|
-
@@status[:ongoing_macro] =
|
|
114
|
+
@@status[:ongoing_macro] = ProconBypassMan.buttons_setting_configuration.macro_registry.load(macro_name)
|
|
116
115
|
break
|
|
117
116
|
end
|
|
118
117
|
|
|
@@ -120,7 +119,8 @@ class ProconBypassMan::Procon
|
|
|
120
119
|
end
|
|
121
120
|
|
|
122
121
|
if user_operation.pressing_all_buttons?(options[:if_pressed])
|
|
123
|
-
@@status[:ongoing_macro] =
|
|
122
|
+
@@status[:ongoing_macro] = ProconBypassMan.buttons_setting_configuration.macro_registry.load(macro_name, force_neutral_buttons: options[:force_neutral])
|
|
123
|
+
|
|
124
124
|
break
|
|
125
125
|
end
|
|
126
126
|
end
|
|
@@ -132,11 +132,11 @@ class ProconBypassMan::Procon
|
|
|
132
132
|
when ProconBypassMan::RemoteAction::Task::TYPE_MACRO
|
|
133
133
|
no_op_step = :wait_for_0_3 # マクロの最後に固まって最後の入力をし続けるので、無の状態を最後に注入する
|
|
134
134
|
BlueGreenProcess::SharedVariable.extend_run_on_this_process = true
|
|
135
|
-
ProconBypassMan
|
|
135
|
+
ProconBypassMan.buttons_setting_configuration.macro_registry.cleanup_remote_macros!
|
|
136
136
|
macro_name = task.name || "RemoteMacro-#{task.steps.join}".to_sym
|
|
137
137
|
task.steps << no_op_step
|
|
138
|
-
ProconBypassMan
|
|
139
|
-
@@status[:ongoing_macro] =
|
|
138
|
+
ProconBypassMan.buttons_setting_configuration.macro_registry.install_plugin(macro_name, steps: task.steps, macro_type: :remote)
|
|
139
|
+
@@status[:ongoing_macro] = ProconBypassMan.buttons_setting_configuration.macro_registry.load(macro_name, macro_type: :remote) do
|
|
140
140
|
GC.start # NOTE: extend_run_on_this_process = true するとGCされなくなるので手動で呼び出す
|
|
141
141
|
ProconBypassMan::PostCompletedRemoteMacroJob.perform_async(task.uuid)
|
|
142
142
|
end
|
|
@@ -153,7 +153,7 @@ class ProconBypassMan::Procon
|
|
|
153
153
|
|
|
154
154
|
case current_layer.mode
|
|
155
155
|
when :manual
|
|
156
|
-
@@status[:ongoing_mode] =
|
|
156
|
+
@@status[:ongoing_mode] = ProconBypassMan.buttons_setting_configuration.mode_registry.load(:manual)
|
|
157
157
|
current_layer.flip_buttons.each do |button, options|
|
|
158
158
|
if !options[:if_pressed]
|
|
159
159
|
# FIXME マルチプロセス化したので、クラス変数に状態を保持するFlipCacheは意図した挙動にならない. BlueGreenProcess.shared_variables を使って状態をプロセス間で共有すれば動く
|
|
@@ -175,7 +175,7 @@ class ProconBypassMan::Procon
|
|
|
175
175
|
end
|
|
176
176
|
else
|
|
177
177
|
unless ongoing_mode.name == current_layer.mode
|
|
178
|
-
@@status[:ongoing_mode] = ProconBypassMan
|
|
178
|
+
@@status[:ongoing_mode] = ProconBypassMan.buttons_setting_configuration.mode_registry.load(current_layer.mode)
|
|
179
179
|
end
|
|
180
180
|
if(binary = ongoing_mode.next_binary)
|
|
181
181
|
self.user_operation.merge([binary].pack("H*"))
|
|
@@ -10,12 +10,12 @@ module ProconBypassMan
|
|
|
10
10
|
|
|
11
11
|
# 復元に失敗したら戻せるように退避する
|
|
12
12
|
FileUtils.copy(
|
|
13
|
-
ProconBypassMan
|
|
13
|
+
ProconBypassMan.buttons_setting_configuration.setting_path,
|
|
14
14
|
ProconBypassMan.fallback_setting_path,
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
ProconBypassMan::YamlWriter.write(
|
|
18
|
-
path: ProconBypassMan
|
|
18
|
+
path: ProconBypassMan.buttons_setting_configuration.setting_path,
|
|
19
19
|
content: setting,
|
|
20
20
|
)
|
|
21
21
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class ShellRunner
|
|
2
|
+
# @param [String] command
|
|
3
|
+
# @param [Boolean] stdout
|
|
4
|
+
# @return [void]
|
|
5
|
+
def self.execute(command, stdout: true)
|
|
6
|
+
system(command) # TODO: ここでエラーが起きたときに、エラーをログに出力する
|
|
7
|
+
if stdout
|
|
8
|
+
ProconBypassMan.logger.info("[SHELL]: #{command}")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -52,8 +52,8 @@ module ProconBypassMan
|
|
|
52
52
|
watchdog.active!
|
|
53
53
|
|
|
54
54
|
ProconBypassMan.cache.fetch key: 'ws_pinged', expires_in: 10 do
|
|
55
|
-
ProconBypassMan.logger.
|
|
56
|
-
ProconBypassMan.logger.
|
|
55
|
+
ProconBypassMan.logger.debug('[WebsocketClient] pinged!!')
|
|
56
|
+
ProconBypassMan.logger.debug(msg)
|
|
57
57
|
end
|
|
58
58
|
}
|
|
59
59
|
end
|
data/lib/procon_bypass_man.rb
CHANGED
|
@@ -47,6 +47,8 @@ require_relative "procon_bypass_man/support/forever"
|
|
|
47
47
|
require_relative "procon_bypass_man/support/simple_tcp_server"
|
|
48
48
|
require_relative "procon_bypass_man/support/proccess_cheacker"
|
|
49
49
|
require_relative "procon_bypass_man/support/output_report_generator"
|
|
50
|
+
require_relative "procon_bypass_man/support/sudo_need_password_checker"
|
|
51
|
+
require_relative "procon_bypass_man/support/shell_runner"
|
|
50
52
|
require_relative "procon_bypass_man/procon_display"
|
|
51
53
|
require_relative "procon_bypass_man/background"
|
|
52
54
|
require_relative "procon_bypass_man/commands"
|
|
@@ -57,8 +59,8 @@ require_relative "procon_bypass_man/processor"
|
|
|
57
59
|
require_relative "procon_bypass_man/configuration"
|
|
58
60
|
require_relative "procon_bypass_man/ephemeral_configuration"
|
|
59
61
|
require_relative "procon_bypass_man/buttons_setting_configuration"
|
|
60
|
-
require_relative "procon_bypass_man/procon"
|
|
61
62
|
require_relative "procon_bypass_man/device_model"
|
|
63
|
+
require_relative "procon_bypass_man/procon"
|
|
62
64
|
require_relative "procon_bypass_man/procon/button"
|
|
63
65
|
require_relative "procon_bypass_man/procon/analog_stick_cap"
|
|
64
66
|
require_relative "procon_bypass_man/procon/analog_stick_manipulator"
|
|
@@ -105,6 +107,13 @@ module ProconBypassMan
|
|
|
105
107
|
# デバイスの接続フェーズ
|
|
106
108
|
begin
|
|
107
109
|
gadget, procon = ProconBypassMan::DeviceConnection::Command.execute!
|
|
110
|
+
rescue ProconBypassMan::DeviceConnection::SetupIncompleteError
|
|
111
|
+
ProconBypassMan::SendErrorCommand.execute(error: "The program is terminating because it encountered a request for the sudo password. Please review your sudo settings.", stdout: true)
|
|
112
|
+
ProconBypassMan::DeviceStatus.change_to_procon_not_found_error! # NOTE: procon_not_found_errorではないけど、めんどいのでこのステータスにする
|
|
113
|
+
ProconBypassMan::NeverExitAccidentally.exit_if_allow_at_config do
|
|
114
|
+
terminate_pbm
|
|
115
|
+
end
|
|
116
|
+
return
|
|
108
117
|
rescue ProconBypassMan::DeviceConnection::NotFoundProconError
|
|
109
118
|
ProconBypassMan::SendErrorCommand.execute(error: "プロコンが見つかりませんでした。")
|
|
110
119
|
ProconBypassMan::DeviceStatus.change_to_procon_not_found_error!
|
|
@@ -143,22 +152,25 @@ module ProconBypassMan
|
|
|
143
152
|
nil
|
|
144
153
|
end
|
|
145
154
|
|
|
155
|
+
# NOTE: app.rbみたいな実行ファイルに書き込まれている設定を管理する
|
|
146
156
|
# @return [ProconBypassMan::Configuration]
|
|
147
157
|
def self.config
|
|
148
158
|
@@configuration ||= ProconBypassMan::Configuration.new
|
|
149
159
|
end
|
|
150
160
|
|
|
161
|
+
# NOTE: setting.ymlから読み込んだ一部の値を管理する
|
|
151
162
|
# @return [ProconBypassMan::EphemeralConfiguration]
|
|
152
163
|
def self.ephemeral_config
|
|
153
164
|
@@ephemeral_configuration ||= ProconBypassMan::EphemeralConfiguration.new
|
|
154
165
|
end
|
|
155
166
|
|
|
156
|
-
#
|
|
157
|
-
def self.
|
|
158
|
-
ProconBypassMan::
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
167
|
+
# NOTE: setting.ymlから読み込んだボタンに関する値を管理する
|
|
168
|
+
def self.buttons_setting_configuration
|
|
169
|
+
@@buttons_setting_configuration ||= ProconBypassMan::ButtonsSettingConfiguration.new
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def self.buttons_setting_configuration=(instance)
|
|
173
|
+
@@buttons_setting_configuration = instance
|
|
162
174
|
end
|
|
163
175
|
|
|
164
176
|
# @return [void]
|
data/procon_bypass_man.gemspec
CHANGED
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
|
|
30
30
|
# Uncomment to register a new dependency of your gem
|
|
31
31
|
spec.add_dependency "action_cable_client"
|
|
32
|
-
spec.add_dependency "blue_green_process", '0.1.4.
|
|
32
|
+
spec.add_dependency "blue_green_process", '0.1.4.3'
|
|
33
33
|
spec.add_dependency "pbmenv", ">= 0.1.11" # enable_pbm_cloud連携機能でPbmenv.install, .cleanを使っている.
|
|
34
34
|
spec.add_dependency "sorted_set"
|
|
35
35
|
|
data/project_template/app.rb
CHANGED
|
@@ -12,7 +12,7 @@ begin
|
|
|
12
12
|
gemfile do
|
|
13
13
|
source 'https://rubygems.org'
|
|
14
14
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
15
|
-
gem 'procon_bypass_man', '0.3.
|
|
15
|
+
gem 'procon_bypass_man', '0.3.12'
|
|
16
16
|
# uncomment if you want to use master branch
|
|
17
17
|
# gem 'procon_bypass_man', github: 'splaplapla/procon_bypass_man', branch: 'master'
|
|
18
18
|
# uncomment if you want to use serial communication feature
|
data/project_template/app.rb.erb
CHANGED
|
@@ -12,7 +12,7 @@ begin
|
|
|
12
12
|
gemfile do
|
|
13
13
|
source 'https://rubygems.org'
|
|
14
14
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
15
|
-
gem 'procon_bypass_man', '0.3.
|
|
15
|
+
gem 'procon_bypass_man', '0.3.12'
|
|
16
16
|
# uncomment if you want to use master branch
|
|
17
17
|
# gem 'procon_bypass_man', github: 'splaplapla/procon_bypass_man', branch: 'master'
|
|
18
18
|
# uncomment if you want to use serial communication feature
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
version: 1.0
|
|
2
2
|
setting: |-
|
|
3
|
-
#
|
|
3
|
+
# 1) レイヤー変更時にコントローラーが振動する。※有効にすると稀に、コントローラーが数秒間固まることがあります。
|
|
4
4
|
# enable(:rumble_on_layer_change)
|
|
5
|
+
#
|
|
6
|
+
# 2) available colors: :default, :red, :blue, :yellow, :green, :pink, :cyan, :white
|
|
7
|
+
enable(:procon_color, :red)
|
|
5
8
|
|
|
6
9
|
prefix_keys_for_changing_layer [:zr, :zl, :l]
|
|
7
10
|
|
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.3.
|
|
4
|
+
version: 0.3.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jiikko
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: action_cable_client
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.1.4.
|
|
33
|
+
version: 0.1.4.3
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.1.4.
|
|
40
|
+
version: 0.1.4.3
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: pbmenv
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -176,6 +176,7 @@ files:
|
|
|
176
176
|
- lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb
|
|
177
177
|
- lib/procon_bypass_man/device_connection/output_report_watcher.rb
|
|
178
178
|
- lib/procon_bypass_man/device_connection/pre_bypass.rb
|
|
179
|
+
- lib/procon_bypass_man/device_connection/procon_color.rb
|
|
179
180
|
- lib/procon_bypass_man/device_connection/procon_setting_overrider.rb
|
|
180
181
|
- lib/procon_bypass_man/device_connection/spoofing_output_report_watcher.rb
|
|
181
182
|
- lib/procon_bypass_man/device_model.rb
|
|
@@ -221,8 +222,8 @@ files:
|
|
|
221
222
|
- lib/procon_bypass_man/procon/macro.rb
|
|
222
223
|
- lib/procon_bypass_man/procon/macro_builder.rb
|
|
223
224
|
- lib/procon_bypass_man/procon/macro_plugin_map.rb
|
|
224
|
-
- lib/procon_bypass_man/procon/
|
|
225
|
-
- lib/procon_bypass_man/procon/
|
|
225
|
+
- lib/procon_bypass_man/procon/macro_registry2.rb
|
|
226
|
+
- lib/procon_bypass_man/procon/mode_registry2.rb
|
|
226
227
|
- lib/procon_bypass_man/procon/performance_measurement.rb
|
|
227
228
|
- lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb
|
|
228
229
|
- lib/procon_bypass_man/procon/performance_measurement/measurement_collection.rb
|
|
@@ -292,7 +293,9 @@ files:
|
|
|
292
293
|
- lib/procon_bypass_man/support/retryable.rb
|
|
293
294
|
- lib/procon_bypass_man/support/safe_timeout.rb
|
|
294
295
|
- lib/procon_bypass_man/support/send_device_stats_http_client.rb
|
|
296
|
+
- lib/procon_bypass_man/support/shell_runner.rb
|
|
295
297
|
- lib/procon_bypass_man/support/simple_tcp_server.rb
|
|
298
|
+
- lib/procon_bypass_man/support/sudo_need_password_checker.rb
|
|
296
299
|
- lib/procon_bypass_man/support/update_remote_pbm_job_status_http_client.rb
|
|
297
300
|
- lib/procon_bypass_man/support/uptime.rb
|
|
298
301
|
- lib/procon_bypass_man/support/usb_device_controller.rb
|
|
@@ -323,7 +326,7 @@ metadata:
|
|
|
323
326
|
homepage_uri: https://github.com/splaplapla/procon_bypass_man
|
|
324
327
|
source_code_uri: https://github.com/splaplapla/procon_bypass_man
|
|
325
328
|
changelog_uri: https://github.com/splaplapla/procon_bypass_man/blob/master/CHANGELOG.md
|
|
326
|
-
post_install_message:
|
|
329
|
+
post_install_message:
|
|
327
330
|
rdoc_options: []
|
|
328
331
|
require_paths:
|
|
329
332
|
- lib
|
|
@@ -338,8 +341,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
338
341
|
- !ruby/object:Gem::Version
|
|
339
342
|
version: '0'
|
|
340
343
|
requirements: []
|
|
341
|
-
rubygems_version: 3.
|
|
342
|
-
signing_key:
|
|
344
|
+
rubygems_version: 3.2.15
|
|
345
|
+
signing_key:
|
|
343
346
|
specification_version: 4
|
|
344
347
|
summary: A programmable converter for Nintendo Switch Pro Controller
|
|
345
348
|
test_files: []
|