procon_bypass_man 0.1.16 → 0.1.19
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/.circleci/config.yml +86 -11
- data/.github/workflows/release.yml +2 -2
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +19 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +7 -3
- data/README.md +39 -15
- data/Steepfile +31 -17
- data/docs/getting_started.md +60 -0
- data/docs/setting/left-analogstick-cap.md +60 -0
- data/docs/setting/splatoon2_macro_sokuwari_bubble.md +52 -0
- data/docs/setup_raspi.md +2 -0
- data/docs/setup_raspi.mitamae.rb +7 -8
- data/docs/setup_raspi_by_mitamae.md +37 -1
- data/docs/upgrade_pbm.md +56 -0
- data/lib/ext/module.rb +16 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +33 -7
- data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +4 -1
- data/lib/procon_bypass_man/buttons_setting_configuration/validator.rb +36 -0
- data/lib/procon_bypass_man/buttons_setting_configuration.rb +34 -21
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +6 -4
- data/lib/procon_bypass_man/commands/bypass_command.rb +2 -2
- data/lib/procon_bypass_man/configuration.rb +5 -1
- data/lib/procon_bypass_man/domains/binary/base.rb +14 -0
- data/lib/procon_bypass_man/domains/binary/inbound_procon_binary.rb +0 -14
- data/lib/procon_bypass_man/domains/binary/processing_procon_binary.rb +2 -16
- data/lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb +1 -1
- data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb +1 -1
- data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb +1 -1
- data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_up_key.rb +1 -1
- data/lib/procon_bypass_man/plugin/splatoon2/macro/sokuwari_for_splash_bomb.rb +22 -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/button.rb +1 -1
- data/lib/procon_bypass_man/procon/button_collection.rb +8 -0
- data/lib/procon_bypass_man/procon/macro.rb +89 -0
- data/lib/procon_bypass_man/procon/macro_builder.rb +123 -0
- data/lib/procon_bypass_man/procon/macro_registry.rb +9 -27
- data/lib/procon_bypass_man/procon/mode_registry.rb +4 -4
- data/lib/procon_bypass_man/procon/press_button_aware.rb +6 -5
- data/lib/procon_bypass_man/procon/user_operation.rb +16 -2
- data/lib/procon_bypass_man/procon/value_objects/analog_stick.rb +1 -1
- data/lib/procon_bypass_man/procon.rb +6 -4
- data/lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb +3 -3
- data/lib/procon_bypass_man/support/compress_array.rb +5 -0
- data/lib/procon_bypass_man/support/http_client.rb +4 -0
- data/lib/procon_bypass_man/support/on_memory_cache.rb +3 -1
- data/lib/procon_bypass_man/support/server_pool.rb +4 -0
- data/lib/procon_bypass_man/support/yaml_writer.rb +9 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/pbm_job_client.rb +13 -2
- data/lib/procon_bypass_man.rb +2 -0
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/README.md +10 -5
- data/project_template/app.rb +3 -2
- data/sig/main.rbs +213 -42
- data/sig/on_memory_cache.rbs +16 -0
- metadata +15 -5
@@ -1,9 +1,11 @@
|
|
1
|
+
セットアップ手順を半自動化にしました
|
2
|
+
|
1
3
|
# Raspberry Pi4のセットアップ手順 With mitamae
|
2
4
|
* SDカードにRaspberry Pi OS lite (32-bit)を焼く
|
3
5
|
* sshをできる状態で焼いておく
|
4
6
|
* SDカードをRaspberry Pi4本体に挿して起動する
|
5
7
|
* sshする
|
6
|
-
*
|
8
|
+
* wget -O - "https://github.com/itamae-kitchen/mitamae/releases/latest/download/mitamae-armhf-linux.tar.gz" | tar xvz
|
7
9
|
* wget https://raw.githubusercontent.com/splaplapla/procon_bypass_man/master/docs/setup_raspi.mitamae.rb -O setup_raspi.mitamae.rb
|
8
10
|
* sudo ./mitamae-armhf-linux local setup_raspi.mitamae.rb -l debug
|
9
11
|
* sudo reboot
|
@@ -12,3 +14,37 @@
|
|
12
14
|
* PCとRaspberry Pi4を接続し、プロコンとして認識していることを確認する
|
13
15
|
* sudo gem i pbmenv
|
14
16
|
* sudo pbmenv install latest
|
17
|
+
|
18
|
+
## 上記手順の動作確認方法
|
19
|
+
* 使えそうなイメージ
|
20
|
+
* navikey/raspbian-bullseye
|
21
|
+
* balenalib/raspberry-pi
|
22
|
+
|
23
|
+
```shell
|
24
|
+
docker run -it --rm --name my-running-app2 navikey/raspbian-bullseye bash
|
25
|
+
```
|
26
|
+
|
27
|
+
### 準備
|
28
|
+
* docker runするとrootなのでpiでログインする
|
29
|
+
|
30
|
+
```shell
|
31
|
+
useradd -m --uid 1000 --groups sudo pi
|
32
|
+
echo pi:pi | chpasswd
|
33
|
+
su pi
|
34
|
+
cd ~ && sudo ls
|
35
|
+
```
|
36
|
+
|
37
|
+
### mitamaeスクリプトを実行する
|
38
|
+
|
39
|
+
```
|
40
|
+
wget -O - "https://github.com/itamae-kitchen/mitamae/releases/latest/download/mitamae-armhf-linux.tar.gz" | tar xvz
|
41
|
+
wget https://raw.githubusercontent.com/splaplapla/procon_bypass_man/master/docs/setup_raspi.mitamae.rb -O setup_raspi.mitamae.rb
|
42
|
+
sudo ./mitamae-armhf-linux local setup_raspi.mitamae.rb -l debug
|
43
|
+
```
|
44
|
+
|
45
|
+
実行に成功したら以下を確認する
|
46
|
+
|
47
|
+
* /home/pi/.rbenv/verions に ruby3.0.1がインストールしていること
|
48
|
+
* /etc/modules に指定の文字列があること
|
49
|
+
* /boot/config.txt に指定の文字列があること
|
50
|
+
* /usr/share/pbm/shared/add_procon_gadget.sh が存在していること
|
data/docs/upgrade_pbm.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# procon_bypass_man のアップグレード方法
|
2
|
+
* pbm-cloudを使う方法、pbmenvを使う方法、pbmenvを使わない方法があります
|
3
|
+
|
4
|
+
## pbm-cloudを使う方法
|
5
|
+
* https://pbm-cloud.herokuapp.com からデバイス詳細画面を開いてください
|
6
|
+
* `デバイスの設定` => `PBMのバージョンアップ`を選択して、表示されるモーダルからインストールしたいバージョンを選択し、 `このバージョンでバージョンアップする` をクリックしてください
|
7
|
+
* クリックするとRaspberry Piが再起動するのでしばらく待ってください
|
8
|
+
* 設定ファイルが初期状態に戻っているので適宜復元してください
|
9
|
+
* デバイス詳細画面からバージョンが上がっていることを確認してください
|
10
|
+
|
11
|
+
## pbmenvを使う方法
|
12
|
+
* sshをして、以下の3行を実行してください
|
13
|
+
|
14
|
+
```
|
15
|
+
sudo gem i pbmenv
|
16
|
+
sudo pbmenv install latest
|
17
|
+
sudo pbmenv use latest
|
18
|
+
```
|
19
|
+
|
20
|
+
* `sudo pbmenv use latest` を実行すると、 `/usr/share/pbm/current/` に新しいバージョンのprocon_bypass_manを配備します
|
21
|
+
* `/usr/share/pbm/current/setting.yml` が初期状態になっているので適宜変更してください
|
22
|
+
* 前バージョンのsetting.ymlは消していないので残っています
|
23
|
+
* 変更後は、プログラムを起動し直してください
|
24
|
+
|
25
|
+
## pbmenvを使わない方法
|
26
|
+
* rbファイル内にある `gem 'procon_bypass_man', ` の後ろの番号を変更することで、procon_bypass_manのバージョンを変更できます
|
27
|
+
* 最新バージョンは https://rubygems.org/gems/procon_bypass_man を参照してください
|
28
|
+
* 変更後は、プログラムを起動し直してください
|
29
|
+
* バージョンを変更後、エラーになる場合はサポートするので、discordやissueに報告をお願いします
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
#!/usr/bin/env ruby
|
33
|
+
|
34
|
+
require 'bundler/inline'
|
35
|
+
|
36
|
+
gemfile do
|
37
|
+
source 'https://rubygems.org'
|
38
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
39
|
+
gem 'procon_bypass_man', '0.1.16.1'
|
40
|
+
end
|
41
|
+
|
42
|
+
ProconBypassMan.configure do |config|
|
43
|
+
config.root = File.expand_path(__dir__)
|
44
|
+
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
|
45
|
+
config.logger.level = :debug
|
46
|
+
# config.api_servers = ['https://...']
|
47
|
+
config.enable_critical_error_logging = true
|
48
|
+
end
|
49
|
+
|
50
|
+
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
51
|
+
```
|
52
|
+
|
53
|
+
```diff
|
54
|
+
- gem 'procon_bypass_man', '0.1.16.1'
|
55
|
+
+ gem 'procon_bypass_man', '0.1.17'
|
56
|
+
```
|
data/lib/ext/module.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# pluginの定数未定義を握りつぶす
|
2
|
+
class Module
|
3
|
+
module ExtModule
|
4
|
+
def const_missing(id)
|
5
|
+
if self.name =~ /^ProconBypassMan::Plugin/
|
6
|
+
parent_const = Object.const_get("#{self.name}")
|
7
|
+
parent_const.const_set(id, Module.new)
|
8
|
+
Object.const_get("#{self.name}::#{id}")
|
9
|
+
else
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
prepend ExtModule
|
16
|
+
end
|
@@ -8,7 +8,7 @@ module ProconBypassMan
|
|
8
8
|
self.flips = {}
|
9
9
|
self.macros = {}
|
10
10
|
self.remaps = {}
|
11
|
-
self.left_analog_stick_caps =
|
11
|
+
self.left_analog_stick_caps = []
|
12
12
|
self.disables = []
|
13
13
|
end
|
14
14
|
|
@@ -53,12 +53,18 @@ module ProconBypassMan
|
|
53
53
|
self.flips[button] = hash
|
54
54
|
end
|
55
55
|
|
56
|
+
# @param [String, Class] プラグインのclass
|
56
57
|
def macro(name, if_pressed: )
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
macro_name = name.to_s.to_sym
|
59
|
+
self.macros[macro_name] = { if_pressed: if_pressed }
|
60
|
+
end
|
61
|
+
|
62
|
+
# 設定ファイルに直接マクロを打ち込める
|
63
|
+
# @param [String, Class] macroの識別子
|
64
|
+
# @paramh[Array<Symbol>] macroの本体. ボタンの配列
|
65
|
+
def open_macro(name, steps: , if_pressed: )
|
66
|
+
macro_name = name || "OpenMacro-#{steps.join}".to_sym
|
67
|
+
ProconBypassMan::Procon::MacroRegistry.install_plugin(macro_name, steps: steps)
|
62
68
|
self.macros[macro_name] = { if_pressed: if_pressed }
|
63
69
|
end
|
64
70
|
|
@@ -88,6 +94,10 @@ module ProconBypassMan
|
|
88
94
|
raise "not support value"
|
89
95
|
end
|
90
96
|
|
97
|
+
if if_pressed
|
98
|
+
hash[:if_pressed] = if_pressed
|
99
|
+
end
|
100
|
+
|
91
101
|
case force_neutral
|
92
102
|
when TrueClass
|
93
103
|
raise "ボタンを渡してください"
|
@@ -101,7 +111,7 @@ module ProconBypassMan
|
|
101
111
|
raise "not support value"
|
102
112
|
end
|
103
113
|
|
104
|
-
left_analog_stick_caps
|
114
|
+
left_analog_stick_caps << hash
|
105
115
|
end
|
106
116
|
|
107
117
|
def disable(button)
|
@@ -123,6 +133,22 @@ module ProconBypassMan
|
|
123
133
|
def flip_buttons
|
124
134
|
flips
|
125
135
|
end
|
136
|
+
|
137
|
+
# @return [String]
|
138
|
+
def to_json(*)
|
139
|
+
to_hash.to_json
|
140
|
+
end
|
141
|
+
|
142
|
+
# @return [Hash]
|
143
|
+
def to_hash
|
144
|
+
{ mode: mode,
|
145
|
+
flips: flips,
|
146
|
+
macros: macros,
|
147
|
+
remaps: remaps,
|
148
|
+
disables: disables,
|
149
|
+
left_analog_stick_caps: left_analog_stick_caps,
|
150
|
+
}
|
151
|
+
end
|
126
152
|
end
|
127
153
|
end
|
128
154
|
end
|
@@ -3,6 +3,7 @@ module ProconBypassMan
|
|
3
3
|
module Loader
|
4
4
|
require 'digest/md5'
|
5
5
|
|
6
|
+
# @return [ProconBypassMan::ButtonsSettingConfiguration]
|
6
7
|
def self.load(setting_path: )
|
7
8
|
ProconBypassMan::ButtonsSettingConfiguration.switch_new_context(:validation) do |new_instance|
|
8
9
|
yaml = YAML.load_file(setting_path) or raise "読み込みに失敗しました"
|
@@ -14,7 +15,9 @@ module ProconBypassMan
|
|
14
15
|
raise ProconBypassMan::CouldNotLoadConfigError, validator.errors
|
15
16
|
end
|
16
17
|
rescue SyntaxError
|
17
|
-
raise ProconBypassMan::CouldNotLoadConfigError, "Ruby
|
18
|
+
raise ProconBypassMan::CouldNotLoadConfigError, "Rubyスクリプトのシンタックスエラーです"
|
19
|
+
rescue NoMethodError
|
20
|
+
raise ProconBypassMan::CouldNotLoadConfigError, "Rubyスクリプトに未定義の定数・変数があります"
|
18
21
|
rescue Psych::SyntaxError
|
19
22
|
raise ProconBypassMan::CouldNotLoadConfigError, "yamlのシンタックスエラーです"
|
20
23
|
end
|
@@ -2,6 +2,8 @@ module ProconBypassMan
|
|
2
2
|
class ButtonsSettingConfiguration
|
3
3
|
class Validator
|
4
4
|
def initialize(config)
|
5
|
+
@macro_plugins = config.macro_plugins
|
6
|
+
@mode_plugins = config.mode_plugins
|
5
7
|
@layers = config.layers
|
6
8
|
@prefix_keys = config.prefix_keys
|
7
9
|
end
|
@@ -14,6 +16,8 @@ module ProconBypassMan
|
|
14
16
|
validate_config_of_button_lonely
|
15
17
|
validate_verify_button_existence
|
16
18
|
validate_flip_and_remap_are_hate_each_other
|
19
|
+
validate_verify_mode_plugins
|
20
|
+
validate_verify_macro_plugins
|
17
21
|
|
18
22
|
@errors.empty?
|
19
23
|
end
|
@@ -86,6 +90,38 @@ module ProconBypassMan
|
|
86
90
|
end
|
87
91
|
end
|
88
92
|
end
|
93
|
+
|
94
|
+
def validate_verify_mode_plugins
|
95
|
+
@mode_plugins.each do |key, mode|
|
96
|
+
begin
|
97
|
+
Module.const_get(key.to_s)
|
98
|
+
rescue NameError
|
99
|
+
next
|
100
|
+
end
|
101
|
+
|
102
|
+
if(const = Module.const_get(key.to_s))
|
103
|
+
if not (const.respond_to?(:binaries) && mode.call)
|
104
|
+
@errors[:mode] << "モード #{key}を読み込めませんでした。"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def validate_verify_macro_plugins
|
111
|
+
@macro_plugins.each do |key, macro|
|
112
|
+
begin
|
113
|
+
Module.const_get(key.to_s)
|
114
|
+
rescue NameError
|
115
|
+
next
|
116
|
+
end
|
117
|
+
|
118
|
+
if(const = Module.const_get(key.to_s))
|
119
|
+
if not (const.respond_to?(:steps) && macro.call)
|
120
|
+
@errors[:macro] << "マクロ #{key}を読み込めませんでした。"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
89
125
|
end
|
90
126
|
end
|
91
127
|
end
|
@@ -10,27 +10,33 @@ module ProconBypassMan
|
|
10
10
|
:setting_path,
|
11
11
|
:mode_plugins,
|
12
12
|
:macro_plugins,
|
13
|
-
:context,
|
14
|
-
:current_context_key,
|
15
13
|
:neutral_position
|
16
14
|
|
17
15
|
def self.instance
|
18
|
-
@@current_context_key ||= :main
|
19
16
|
@@context ||= {}
|
20
|
-
@@context[
|
17
|
+
@@context[current_context_key] ||= new
|
21
18
|
end
|
22
19
|
|
23
|
-
def self.
|
24
|
-
@@
|
25
|
-
|
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
|
26
31
|
if block_given?
|
27
|
-
@@current_context_key =
|
28
|
-
value = yield(@@context[
|
29
|
-
@@current_context_key = previous_key
|
32
|
+
@@current_context_key = new_context_key
|
33
|
+
value = yield(@@context[new_context_key])
|
30
34
|
return value
|
31
35
|
else
|
32
|
-
@@current_context_key =
|
36
|
+
@@current_context_key = new_context_key
|
33
37
|
end
|
38
|
+
ensure
|
39
|
+
@@current_context_key = previous_key
|
34
40
|
end
|
35
41
|
|
36
42
|
def initialize
|
@@ -39,19 +45,26 @@ module ProconBypassMan
|
|
39
45
|
|
40
46
|
module ManualMode
|
41
47
|
def self.name
|
42
|
-
|
48
|
+
:manual
|
43
49
|
end
|
44
50
|
end
|
45
51
|
def layer(direction, mode: ManualMode, &block)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
if ProconBypassMan::ButtonsSettingConfiguration::ManualMode == mode
|
53
|
+
mode_name = mode.name
|
54
|
+
else
|
55
|
+
mode_name = case mode
|
56
|
+
when ProconBypassMan::ButtonsSettingConfiguration::ManualMode
|
57
|
+
mode.name
|
58
|
+
when String
|
59
|
+
mode.to_sym
|
60
|
+
when Symbol
|
61
|
+
mode
|
62
|
+
else
|
63
|
+
mode.to_s.to_sym
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
unless ([ManualMode.name] + ProconBypassMan::Procon::ModeRegistry.plugins.keys).include?(mode_name)
|
55
68
|
raise("#{mode_name} mode is unknown")
|
56
69
|
end
|
57
70
|
|
@@ -28,10 +28,12 @@ class ProconBypassMan::Bypass
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
ProconBypassMan.
|
32
|
-
ProconBypassMan
|
33
|
-
|
34
|
-
|
31
|
+
if ProconBypassMan.config.enable_reporting_pressed_buttons
|
32
|
+
ProconBypassMan.cache.fetch key: 'pressed_buttons_reporter', expires_in: 5 do
|
33
|
+
ProconBypassMan::ReportPressedButtonsJob.perform_async(
|
34
|
+
bypass_value.binary.to_procon_reader.to_hash
|
35
|
+
)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
@@ -40,7 +40,7 @@ class ProconBypassMan::BypassCommand
|
|
40
40
|
monitor1.shutdown
|
41
41
|
puts "10秒経過したのでThread1を終了します"
|
42
42
|
break
|
43
|
-
rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError => e
|
43
|
+
rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError, Errno::ESHUTDOWN => e
|
44
44
|
ProconBypassMan::SendErrorCommand.execute(error: "Switchとの切断されました.終了処理を開始します. #{e.full_message}")
|
45
45
|
Process.kill "TERM", Process.ppid
|
46
46
|
rescue Errno::ETIMEDOUT => e
|
@@ -62,7 +62,7 @@ class ProconBypassMan::BypassCommand
|
|
62
62
|
rescue EOFError => e
|
63
63
|
ProconBypassMan::SendErrorCommand.execute(error: "Proconが切断されました。終了処理を開始します. #{e.full_message}")
|
64
64
|
Process.kill "TERM", Process.ppid
|
65
|
-
rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError => e
|
65
|
+
rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError, Errno::ESHUTDOWN => e
|
66
66
|
ProconBypassMan::SendErrorCommand.execute(error: "Proconが切断されました。終了処理を開始します2. #{e.full_message}")
|
67
67
|
Process.kill "TERM", Process.ppid
|
68
68
|
end
|
@@ -41,7 +41,7 @@ class ProconBypassMan::Configuration
|
|
41
41
|
end
|
42
42
|
|
43
43
|
attr_accessor :enable_critical_error_logging
|
44
|
-
attr_writer :verbose_bypass_log, :raw_setting
|
44
|
+
attr_writer :verbose_bypass_log, :raw_setting, :enable_reporting_pressed_buttons
|
45
45
|
|
46
46
|
def root=(path)
|
47
47
|
@root = path
|
@@ -154,4 +154,8 @@ class ProconBypassMan::Configuration
|
|
154
154
|
def raw_setting
|
155
155
|
@raw_setting ||= {}
|
156
156
|
end
|
157
|
+
|
158
|
+
def enable_reporting_pressed_buttons
|
159
|
+
@enable_reporting_pressed_buttons ||= false
|
160
|
+
end
|
157
161
|
end
|
@@ -8,4 +8,18 @@ class ProconBypassMan::Domains::Binary::Base
|
|
8
8
|
def binary
|
9
9
|
raise NotImplementedError
|
10
10
|
end
|
11
|
+
|
12
|
+
# @return [String]
|
13
|
+
def raw
|
14
|
+
binary
|
15
|
+
end
|
16
|
+
|
17
|
+
def unpack
|
18
|
+
binary.unpack("H*")
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [ProconBypassMan::ProconReader]
|
22
|
+
def to_procon_reader
|
23
|
+
ProconBypassMan::ProconReader.new(binary: binary)
|
24
|
+
end
|
11
25
|
end
|
@@ -2,20 +2,6 @@
|
|
2
2
|
class ProconBypassMan::Domains::InboundProconBinary < ProconBypassMan::Domains::Binary::Base
|
3
3
|
include ProconBypassMan::Domains::HasImmutableBinary
|
4
4
|
|
5
|
-
# @return [String]
|
6
|
-
def raw
|
7
|
-
binary.dup
|
8
|
-
end
|
9
|
-
|
10
|
-
def unpack
|
11
|
-
binary.unpack("H*")
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [ProconBypassMan::ProconReader]
|
15
|
-
def to_procon_reader
|
16
|
-
ProconBypassMan::ProconReader.new(binary: binary)
|
17
|
-
end
|
18
|
-
|
19
5
|
# @return [Boolean]
|
20
6
|
def user_operation_data?
|
21
7
|
binary[0] == "\x30".b
|
@@ -4,15 +4,6 @@ class ProconBypassMan::Domains::ProcessingProconBinary < ProconBypassMan::Domain
|
|
4
4
|
|
5
5
|
ALL_ZERO_BIT = ["0"].pack("H*").freeze
|
6
6
|
|
7
|
-
# @return [String]
|
8
|
-
def raw
|
9
|
-
binary
|
10
|
-
end
|
11
|
-
|
12
|
-
def unpack
|
13
|
-
binary.unpack("H*")
|
14
|
-
end
|
15
|
-
|
16
7
|
def set_no_action!
|
17
8
|
binary[3] = ALL_ZERO_BIT
|
18
9
|
binary[4] = ALL_ZERO_BIT
|
@@ -48,7 +39,7 @@ class ProconBypassMan::Domains::ProcessingProconBinary < ProconBypassMan::Domain
|
|
48
39
|
raise "already pressing button(#{button})" if ProconBypassMan::PressButtonAware.new(binary).pressing_button?(button)
|
49
40
|
|
50
41
|
button_obj = ProconBypassMan::Procon::Button.new(button)
|
51
|
-
value = binary[button_obj.byte_position].unpack("
|
42
|
+
value = binary[button_obj.byte_position].unpack("C").first + (2**button_obj.bit_position)
|
52
43
|
binary[button_obj.byte_position] = ["%02X" % value.to_s].pack("H*")
|
53
44
|
end
|
54
45
|
|
@@ -57,7 +48,7 @@ class ProconBypassMan::Domains::ProcessingProconBinary < ProconBypassMan::Domain
|
|
57
48
|
raise "not press button(#{button}) yet" if not ProconBypassMan::PressButtonAware.new(binary).pressing_button?(button)
|
58
49
|
|
59
50
|
button_obj = ProconBypassMan::Procon::Button.new(button)
|
60
|
-
value = binary[button_obj.byte_position].unpack("
|
51
|
+
value = binary[button_obj.byte_position].unpack("C").first - (2**button_obj.bit_position)
|
61
52
|
binary[button_obj.byte_position] = ["%02X" % value.to_s].pack("H*")
|
62
53
|
end
|
63
54
|
|
@@ -72,9 +63,4 @@ class ProconBypassMan::Domains::ProcessingProconBinary < ProconBypassMan::Domain
|
|
72
63
|
analog_stick_cap = ProconBypassMan::Procon::AnalogStickCap.new(binary)
|
73
64
|
binary[6..8] = analog_stick_cap.capped_position(cap_hypotenuse: cap).to_binary
|
74
65
|
end
|
75
|
-
|
76
|
-
# @return [ProconBypassMan::ProconReader]
|
77
|
-
def to_procon_reader
|
78
|
-
ProconBypassMan::ProconReader.new(binary: binary)
|
79
|
-
end
|
80
66
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module Plugin
|
3
|
+
module Splatoon2
|
4
|
+
module Macro
|
5
|
+
module SokuwariForSplashBomb
|
6
|
+
def self.display_name
|
7
|
+
:sokuwari_for_splash_bomb
|
8
|
+
end
|
9
|
+
|
10
|
+
# procon_bypass_man: 0.1.18以上が必要
|
11
|
+
def self.steps
|
12
|
+
[ :toggle_r_for_0_2sec,
|
13
|
+
:toggle_thumbr_for_0_14sec,
|
14
|
+
:toggle_thumbr_and_toggle_zr_for_0_34sec,
|
15
|
+
:toggle_r_for_1sec,
|
16
|
+
].freeze
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -3,6 +3,7 @@ require_relative "plugin/splatoon2/macro/fast_return"
|
|
3
3
|
require_relative "plugin/splatoon2/macro/jump_to_right_key"
|
4
4
|
require_relative "plugin/splatoon2/macro/jump_to_up_key"
|
5
5
|
require_relative "plugin/splatoon2/macro/jump_to_left_key"
|
6
|
+
require_relative "plugin/splatoon2/macro/sokuwari_for_splash_bomb"
|
6
7
|
require_relative "plugin/splatoon2/mode/guruguru"
|
7
8
|
|
8
9
|
module ProconBypassMan
|
@@ -4,7 +4,7 @@ class ProconBypassMan::Procon::Button
|
|
4
4
|
attr_accessor :byte_position, :bit_position
|
5
5
|
|
6
6
|
def initialize(key)
|
7
|
-
b = ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP[key] or raise(UnknownButtonFoundError,
|
7
|
+
b = ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP[key] or raise(UnknownButtonFoundError, "#{key}は定義にないボタンです")
|
8
8
|
self.byte_position = b[:byte_position]
|
9
9
|
self.bit_position = b[:bit_position]
|
10
10
|
end
|
@@ -37,4 +37,12 @@ class ProconBypassMan::Procon::ButtonCollection
|
|
37
37
|
BUTTONS = ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP.keys.freeze
|
38
38
|
|
39
39
|
LEFT_ANALOG_STICK = { byte_position: 6..8 }
|
40
|
+
|
41
|
+
# @param [Array<Symbol>] buttons
|
42
|
+
# @return [Array<Symbol>]
|
43
|
+
def self.normalize(buttons)
|
44
|
+
buttons.select { |x|
|
45
|
+
!!ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP[x]
|
46
|
+
}
|
47
|
+
end
|
40
48
|
end
|