procon_bypass_man 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +7 -1
- data/Gemfile.lock +2 -1
- data/README.md +10 -5
- data/docs/setting/splatoon2_macro_sokuwari_bubble.md +52 -0
- data/docs/upgrade_pbm.md +32 -0
- data/lib/ext/module.rb +16 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +3 -1
- data/lib/procon_bypass_man/commands/bypass_command.rb +2 -2
- data/lib/procon_bypass_man/plugin/splatoon2/macro/sokuwari_for_splash_bomb.rb +22 -0
- 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/macro.rb +89 -0
- data/lib/procon_bypass_man/procon/macro_builder.rb +123 -0
- data/lib/procon_bypass_man/procon/macro_registry.rb +2 -23
- data/lib/procon_bypass_man/procon/user_operation.rb +16 -2
- data/lib/procon_bypass_man/procon.rb +2 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man.rb +1 -13
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/app.rb +3 -2
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae61096a07d9982a4a88fd64c0ba41039d351b5925ff2953ca4b44c546d92715
|
4
|
+
data.tar.gz: 1c969b841734cd26e0d8ee58e182e8cfda86f69a40a57e4a88fb6f0d8e92e201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64507342d85810c8b92a3ed8b0098055ce984fd959d070c7259a04097bb295e4720ebe6c0e615493e233d04957783e259fc20fa78b5f2d0bbbd73d624c6154c5
|
7
|
+
data.tar.gz: a7ac7c9073422240e6f80d1d3aff3fc606dc6b718f3922cb05769783b5cfae62acb449bdba5b2282a922f1cf7a42f34e26e0818251ec89812f875b0c50dab46f
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
## [0.1.
|
1
|
+
## [0.1.18] - 2022-0
|
2
|
+
- macroでできることが増えました
|
3
|
+
- 1ステップで複数のボタン入力と継続時間を指定ができるようになりました
|
4
|
+
- スプラトゥーン2用のバブル即割マクロ(SokuwariForSplashBomb)が使えるようになりました
|
5
|
+
- https://github.com/splaplapla/procon_bypass_man-splatoon2
|
6
|
+
|
7
|
+
## [0.1.17] - 2022-01-26
|
2
8
|
- procon_bypass_man_cloudに組み込むために、内部のデータ構造を変更しました
|
3
9
|
- 設定ファイルにmacroを直接打ち込めるようになりました
|
4
10
|
- ex) `open_macro :special_command, steps: [:x, :y, :up], if_pressed: [:y]`
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.1.
|
4
|
+
procon_bypass_man (0.1.18)
|
5
5
|
action_cable_client
|
6
6
|
pbmenv
|
7
7
|
sorted_set
|
@@ -121,6 +121,7 @@ PLATFORMS
|
|
121
121
|
arm64-darwin-20
|
122
122
|
arm64-darwin-21
|
123
123
|
armv7l-linux
|
124
|
+
ruby
|
124
125
|
x86_64-linux
|
125
126
|
|
126
127
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# ProconBypassMan
|
2
|
+
<img src="https://user-images.githubusercontent.com/1664497/151661582-3a1e8ce9-6c38-4754-8075-7a4453b3109a.jpg" width="500px">
|
3
|
+
|
2
4
|
[![Ruby](https://github.com/splaplapla/procon_bypass_man/actions/workflows/ruby.yml/badge.svg?branch=master)](https://github.com/splaplapla/procon_bypass_man/actions/workflows/ruby.yml)
|
3
5
|
|
4
6
|
* Switchに繋いだプロコンを連射機にしたり、キーのリマップをしたり、マクロを実行できるツールです
|
@@ -45,12 +47,15 @@ Switch <-- (PBM): ZR連打
|
|
45
47
|
* https://github.com/splaplapla/procon_bypass_man-splatoon2
|
46
48
|
|
47
49
|
## 関連ソフトウェア
|
48
|
-
*
|
50
|
+
* procon_bypass_man_cloud
|
51
|
+
* webアプリケーション
|
49
52
|
* https://github.com/splaplapla/procon_bypass_man_cloud
|
50
|
-
*
|
51
|
-
*
|
53
|
+
* このwebアプリからOS自体の再起動、設定ファイルのバックアップ・変更、PBMのバージョンアップができます
|
54
|
+
* ご自身でホストティングもできますが、 私がホスティングをしている https://pbm-cloud.herokuapp.com を使うことができます
|
55
|
+
* [使い方](https://pbm-cloud.herokuapp.com/faq)
|
52
56
|
* pbmenv
|
53
|
-
*
|
57
|
+
* procon_bypass_manのバージョンマネージャー
|
58
|
+
* https://github.com/splaplapla/pbmenv
|
54
59
|
|
55
60
|
## FAQ
|
56
61
|
* どうやって動かすの?
|
@@ -81,7 +86,6 @@ Switch <-- (PBM): ZR連打
|
|
81
86
|
|
82
87
|
## TODO
|
83
88
|
* レコーディング機能(プロコンの入力をマクロとして登録ができる)
|
84
|
-
* マクロにdelayを入れれるようにする
|
85
89
|
|
86
90
|
## 開発系
|
87
91
|
### プロコンとの接続を維持したまま、現在の設定ファイルをPBMに反映する
|
@@ -101,6 +105,7 @@ sudo kill -USR2 `cat ./pbm_pid`
|
|
101
105
|
* project_template/web.rb, project_template/app.rb, lib/procon_bypass_man/version.rb のバージョンをあげる
|
102
106
|
* CHANGELOG.md に日付を書く
|
103
107
|
* be rake release
|
108
|
+
* githubのreleaseを作成する
|
104
109
|
|
105
110
|
## License
|
106
111
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# スプラトゥーン2: バブル即割(スプラッシュボム)マクロの設定方法
|
2
|
+
https://user-images.githubusercontent.com/1664497/152633205-ab44896b-9fa4-402c-b9aa-667e00676032.mp4
|
3
|
+
|
4
|
+
* procon_bypass_man: 0.1.18以上が必要です
|
5
|
+
* このマクロは、バブルの1個目のみを即割します
|
6
|
+
|
7
|
+
## 1. install_macro_pluginで即割マクロを有効化します
|
8
|
+
* `setting.yml` に`install_macro_plugin ProconBypassMan::Plugin::Splatoon2::Macro::SokuwariForSplashBomb` と書きます
|
9
|
+
* これを記述することで、layer内で呼び出せるようになります
|
10
|
+
|
11
|
+
## 2. どのlayerで発動するかを宣言します
|
12
|
+
* `setting.yml` のlayer内に`macro ProconBypassMan::Plugin::Splatoon2::Macro::SokuwariForSplashBomb, if_pressed: [:zl, :right]` と書きます
|
13
|
+
* `if_pressed` がどのボタンを押したときにこのマクロが発動するかの設定です
|
14
|
+
* ここのオプションは、自由に変更可能です
|
15
|
+
* この場合は、ZLと十字キーの左を同時すると、このマクロが発動します
|
16
|
+
|
17
|
+
## 3. 設定を反映させる
|
18
|
+
* 上記の記述を加えたsetting.ymlを起動中のprocon_bypass_manプロセスで読み込むには、プロセスにその旨を伝える必要があります
|
19
|
+
* ラズベリーパイを再起動して、プロセスを立ち上げ直す、でも目的は達成できますが、もっと簡単にsetting.ymlを再読み込みする必要があります
|
20
|
+
* 書き換えたsetting.ymlを、起動中のprocon_bypass_manプロセスへ即時反映するには、procon_bypass_manプロセスを動かしたまま、別のshellから 以下をを実行してください
|
21
|
+
* setting.ymlのシンタックスが正しければ、switchとの接続が継続したままsetting.ymlの内容を読み込んでいるはずです
|
22
|
+
|
23
|
+
## まとめ
|
24
|
+
* 次の2行の追加が必要です。
|
25
|
+
* `install_macro_plugin ProconBypassMan::Plugin::Splatoon2::Macro::SokuwariForSplashBomb`
|
26
|
+
* `macro ProconBypassMan::Plugin::Splatoon2::Macro::SokuwariForSplashBomb, if_pressed: [:zl, :right]`
|
27
|
+
|
28
|
+
## 設定例1
|
29
|
+
```yaml
|
30
|
+
version: 1.0
|
31
|
+
setting: |-
|
32
|
+
prefix_keys_for_changing_layer [:zr, :zl, :l]
|
33
|
+
install_macro_plugin ProconBypassMan::Plugin::Splatoon2::Macro::SokuwariForSplashBomb
|
34
|
+
|
35
|
+
layer :up do
|
36
|
+
macro ProconBypassMan::Plugin::Splatoon2::Macro::SokuwariForSplashBomb, if_pressed: [:zl, :right]
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## 設定例2
|
41
|
+
* `open_macro` キーワードを使っても同じことが実行可能です。
|
42
|
+
* この場合は、 `install_macro_plugin ProconBypassMan::Plugin::Splatoon2::Macro::SokuwariForSplashBomb` が不要です。
|
43
|
+
|
44
|
+
```yaml
|
45
|
+
version: 1.0
|
46
|
+
setting: |-
|
47
|
+
prefix_keys_for_changing_layer [:zr, :zl, :l]
|
48
|
+
|
49
|
+
layer :up do
|
50
|
+
open_macro :sokuwari, steps: [:toggle_r_for_0_2sec, :toggle_thumbr_for_0_14sec, :toggle_thumbr_and_toggle_zr_for_0_34sec, :toggle_r_for_1sec], if_pressed: [:zl, :right]
|
51
|
+
end
|
52
|
+
```
|
data/docs/upgrade_pbm.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# procon_bypass_man のアップグレード方法
|
2
|
+
* rbファイル内にある `gem 'procon_bypass_man', ` の後ろの番号を変更することで、procon_bypass_manのバージョンを変更できます
|
3
|
+
* 最新バージョンは https://rubygems.org/gems/procon_bypass_man を参照してください
|
4
|
+
* 変更後は、プログラムを実行し直してください。プログラムを起動中であればraspberry piを再起動後にプログラムを起動してください
|
5
|
+
* バージョンを変更後、エラーになる場合はサポートするので、discordやissueに報告をお願いします
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
#!/usr/bin/env ruby
|
9
|
+
|
10
|
+
require 'bundler/inline'
|
11
|
+
|
12
|
+
gemfile do
|
13
|
+
source 'https://rubygems.org'
|
14
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
15
|
+
gem 'procon_bypass_man', '0.1.16.1'
|
16
|
+
end
|
17
|
+
|
18
|
+
ProconBypassMan.configure do |config|
|
19
|
+
config.root = File.expand_path(__dir__)
|
20
|
+
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
|
21
|
+
config.logger.level = :debug
|
22
|
+
# config.api_servers = ['https://...']
|
23
|
+
config.enable_critical_error_logging = true
|
24
|
+
end
|
25
|
+
|
26
|
+
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
27
|
+
```
|
28
|
+
|
29
|
+
```diff
|
30
|
+
- gem 'procon_bypass_man', '0.1.16.1'
|
31
|
+
+ gem 'procon_bypass_man', '0.1.17'
|
32
|
+
```
|
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
|
@@ -15,7 +15,9 @@ module ProconBypassMan
|
|
15
15
|
raise ProconBypassMan::CouldNotLoadConfigError, validator.errors
|
16
16
|
end
|
17
17
|
rescue SyntaxError
|
18
|
-
raise ProconBypassMan::CouldNotLoadConfigError, "Ruby
|
18
|
+
raise ProconBypassMan::CouldNotLoadConfigError, "Rubyスクリプトのシンタックスエラーです"
|
19
|
+
rescue NoMethodError
|
20
|
+
raise ProconBypassMan::CouldNotLoadConfigError, "Rubyスクリプトに未定義の定数・変数があります"
|
19
21
|
rescue Psych::SyntaxError
|
20
22
|
raise ProconBypassMan::CouldNotLoadConfigError, "yamlのシンタックスエラーです"
|
21
23
|
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
|
@@ -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
|
@@ -0,0 +1,89 @@
|
|
1
|
+
class ProconBypassMan::Procon::Macro
|
2
|
+
class NestedStep
|
3
|
+
def initialize(value)
|
4
|
+
@hash = value
|
5
|
+
unless @hash[:end_at]
|
6
|
+
@hash[:end_at] = (Time.now + @hash[:continue_for]).round(4)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def over_end_at?
|
11
|
+
(@hash[:end_at] < Time.now).tap do |result|
|
12
|
+
if result
|
13
|
+
ProconBypassMan.logger.debug { "[Macro] nested step is finished(#{@hash})" }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def next_step
|
19
|
+
incr_step_index!
|
20
|
+
|
21
|
+
debug_incr_called_count!
|
22
|
+
if step = current_step
|
23
|
+
return step
|
24
|
+
else
|
25
|
+
reset_step_index!
|
26
|
+
return current_step
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def current_step
|
33
|
+
@hash[:steps][step_index]
|
34
|
+
end
|
35
|
+
|
36
|
+
def step_index
|
37
|
+
@hash[:step_index]
|
38
|
+
end
|
39
|
+
|
40
|
+
def incr_step_index!
|
41
|
+
if step_index
|
42
|
+
@hash[:step_index] += 1
|
43
|
+
else
|
44
|
+
@hash[:step_index] = 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def reset_step_index!
|
49
|
+
@hash[:step_index] = 0
|
50
|
+
end
|
51
|
+
|
52
|
+
def debug_incr_called_count!
|
53
|
+
@hash[:debug_called_count] ||= 0
|
54
|
+
@hash[:debug_called_count] += 1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
attr_accessor :name, :steps
|
59
|
+
|
60
|
+
def initialize(name: , steps: )
|
61
|
+
self.name = name
|
62
|
+
self.steps = steps
|
63
|
+
end
|
64
|
+
|
65
|
+
def next_step
|
66
|
+
step = steps.first
|
67
|
+
if step.is_a?(Symbol)
|
68
|
+
return steps.shift
|
69
|
+
end
|
70
|
+
|
71
|
+
if step.is_a?(Hash)
|
72
|
+
nested_step = NestedStep.new(step)
|
73
|
+
if nested_step.over_end_at?
|
74
|
+
steps.shift # NestedStepを破棄する
|
75
|
+
return next_step
|
76
|
+
else
|
77
|
+
return nested_step.next_step
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def finished?
|
83
|
+
steps.empty?
|
84
|
+
end
|
85
|
+
|
86
|
+
def ongoing?
|
87
|
+
!finished?
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
class ProconBypassMan::Procon::MacroBuilder
|
2
|
+
class SubjectMerger
|
3
|
+
def self.merge(subjects)
|
4
|
+
if subjects.size == 1
|
5
|
+
return subjects.first.to_steps
|
6
|
+
end
|
7
|
+
|
8
|
+
base = subjects.first
|
9
|
+
remain = subjects[1..-1]
|
10
|
+
remain.map { |x| base.to_steps.zip(x.to_steps) }.first
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Subject
|
15
|
+
def initialize(value)
|
16
|
+
@button =
|
17
|
+
if match = value.match(/_(\w+)\z/)
|
18
|
+
match[1]
|
19
|
+
else
|
20
|
+
:unknown
|
21
|
+
end
|
22
|
+
@type =
|
23
|
+
if value.start_with?("toggle_")
|
24
|
+
:toggle
|
25
|
+
else
|
26
|
+
:pressing
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def toggle?
|
31
|
+
@type == :toggle
|
32
|
+
end
|
33
|
+
|
34
|
+
def pressing?
|
35
|
+
not toggle?
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_steps
|
39
|
+
case @type
|
40
|
+
when :toggle
|
41
|
+
[@button.to_sym, :none]
|
42
|
+
when :pressing
|
43
|
+
[@button.to_sym, @button.to_sym]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
RESERVED_WORD_NONE = :none
|
49
|
+
RESERVED_WORDS = {
|
50
|
+
RESERVED_WORD_NONE => true,
|
51
|
+
}
|
52
|
+
|
53
|
+
def initialize(steps)
|
54
|
+
@steps = steps.map(&:to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Arary<Symbol>]
|
58
|
+
def build
|
59
|
+
steps = @steps.map { |step|
|
60
|
+
if is_reserved?(step: step) || v1_format?(step: step)
|
61
|
+
step.to_sym
|
62
|
+
elsif value = build_if_v2_format?(step: step)
|
63
|
+
value
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
}
|
68
|
+
steps.compact.flatten
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def is_reserved?(step: )
|
74
|
+
RESERVED_WORDS[step.to_sym]
|
75
|
+
end
|
76
|
+
|
77
|
+
def v1_format?(step: )
|
78
|
+
if is_button(step)
|
79
|
+
step
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def build_if_v2_format?(step: )
|
84
|
+
# 時間指定なし
|
85
|
+
if(match = step.match(%r!\Atoggle_(\w+)\z!)) && (button_candidate = match[1]) && is_button(button_candidate)
|
86
|
+
button = button_candidate
|
87
|
+
return [button.to_sym, :none]
|
88
|
+
end
|
89
|
+
|
90
|
+
# 時間指定あり
|
91
|
+
if %r!^(pressing_|toggle_)! =~ step && (subjects = step.scan(%r!pressing_[^_]+|toggle_[^_]+!)) && (match = step.match(%r!_for_([\d_]+)(sec)?\z!))
|
92
|
+
sec = match[1]
|
93
|
+
return [
|
94
|
+
{ continue_for: to_num(sec),
|
95
|
+
steps: SubjectMerger.merge(subjects.map { |x| Subject.new(x) }),
|
96
|
+
}
|
97
|
+
]
|
98
|
+
end
|
99
|
+
|
100
|
+
# no-op command
|
101
|
+
if(match = step.match(%r!wait_for_([\d_]+)(sec)?\z!))
|
102
|
+
sec = match[1]
|
103
|
+
return [
|
104
|
+
{ continue_for: to_num(sec),
|
105
|
+
steps: [:none],
|
106
|
+
}
|
107
|
+
]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# @return [Boolean]
|
112
|
+
def is_button(step)
|
113
|
+
!!ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP[step.to_sym]
|
114
|
+
end
|
115
|
+
|
116
|
+
def to_num(value)
|
117
|
+
if value.include?("_")
|
118
|
+
value.sub("_", ".").to_f
|
119
|
+
else
|
120
|
+
value.to_i
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -1,25 +1,4 @@
|
|
1
1
|
class ProconBypassMan::Procon::MacroRegistry
|
2
|
-
class Macro
|
3
|
-
attr_accessor :name, :steps
|
4
|
-
|
5
|
-
def initialize(name: , steps: )
|
6
|
-
self.name = name
|
7
|
-
self.steps = steps
|
8
|
-
end
|
9
|
-
|
10
|
-
def next_step
|
11
|
-
steps.shift
|
12
|
-
end
|
13
|
-
|
14
|
-
def finished?
|
15
|
-
steps.empty?
|
16
|
-
end
|
17
|
-
|
18
|
-
def ongoing?
|
19
|
-
!finished?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
2
|
PRESETS = {
|
24
3
|
null: [],
|
25
4
|
}
|
@@ -30,13 +9,13 @@ class ProconBypassMan::Procon::MacroRegistry
|
|
30
9
|
end
|
31
10
|
|
32
11
|
plugins[klass.to_s.to_sym] = ->{
|
33
|
-
ProconBypassMan::Procon::
|
12
|
+
ProconBypassMan::Procon::MacroBuilder.new(steps || klass.steps).build
|
34
13
|
}
|
35
14
|
end
|
36
15
|
|
37
16
|
def self.load(name)
|
38
17
|
steps = PRESETS[name] || plugins[name].call || raise("unknown macro")
|
39
|
-
Macro.new(name: name, steps: steps.dup)
|
18
|
+
ProconBypassMan::Procon::Macro.new(name: name, steps: steps.dup)
|
40
19
|
end
|
41
20
|
|
42
21
|
def self.reset!
|
@@ -33,9 +33,23 @@ class ProconBypassMan::Procon::UserOperation
|
|
33
33
|
binary.write_as_press_button(button)
|
34
34
|
end
|
35
35
|
|
36
|
-
# @param [Symbol] button
|
36
|
+
# @param [Symbol, Array<Symbol>] button
|
37
37
|
def press_button_only(button)
|
38
|
-
|
38
|
+
if button.is_a?(Array)
|
39
|
+
binary.set_no_action!
|
40
|
+
button.uniq.each do |b|
|
41
|
+
unless ProconBypassMan::Procon::MacroBuilder::RESERVED_WORD_NONE == b
|
42
|
+
binary.write_as_press_button(b)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
48
|
+
if ProconBypassMan::Procon::MacroBuilder::RESERVED_WORD_NONE == button
|
49
|
+
binary.set_no_action!
|
50
|
+
else
|
51
|
+
binary.write_as_press_button_only(button)
|
52
|
+
end
|
39
53
|
end
|
40
54
|
|
41
55
|
# @return [void]
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class ProconBypassMan::Procon
|
2
2
|
require "procon_bypass_man/procon/consts"
|
3
3
|
require "procon_bypass_man/procon/mode_registry"
|
4
|
+
require "procon_bypass_man/procon/macro"
|
4
5
|
require "procon_bypass_man/procon/macro_registry"
|
6
|
+
require "procon_bypass_man/procon/macro_builder"
|
5
7
|
require "procon_bypass_man/procon/layer_changer"
|
6
8
|
require "procon_bypass_man/procon/button_collection"
|
7
9
|
require "procon_bypass_man/procon/user_operation"
|
data/lib/procon_bypass_man.rb
CHANGED
@@ -7,6 +7,7 @@ require "securerandom"
|
|
7
7
|
require 'em/pure_ruby'
|
8
8
|
require "action_cable_client"
|
9
9
|
require "ext/em_pure_ruby"
|
10
|
+
require "ext/module"
|
10
11
|
|
11
12
|
require_relative "procon_bypass_man/version"
|
12
13
|
require_relative "procon_bypass_man/remote_pbm_action"
|
@@ -44,19 +45,6 @@ require_relative "procon_bypass_man/websocket/pbm_job_client"
|
|
44
45
|
STDOUT.sync = true
|
45
46
|
Thread.abort_on_exception = true
|
46
47
|
|
47
|
-
# pluginの定数を握りつぶす
|
48
|
-
class Module
|
49
|
-
def const_missing(id)
|
50
|
-
if self.name =~ /^ProconBypassMan::Plugin/
|
51
|
-
parent_const = Object.const_get("#{self.name}")
|
52
|
-
parent_const.const_set(id, Module.new)
|
53
|
-
Object.const_get("#{self.name}::#{id}")
|
54
|
-
else
|
55
|
-
super
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
48
|
module ProconBypassMan
|
61
49
|
extend ProconBypassMan::Configuration::ClassMethods
|
62
50
|
|
data/procon_bypass_man.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["jiikko"]
|
9
9
|
spec.email = ["n905i.1214@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary = "
|
11
|
+
spec.summary = "A programmable converter for Nintendo Switch Pro Controller"
|
12
12
|
spec.description = spec.summary
|
13
13
|
spec.homepage = "https://github.com/splaplapla/procon_bypass_man"
|
14
14
|
spec.license = "MIT"
|
data/project_template/app.rb
CHANGED
@@ -5,14 +5,15 @@ require 'bundler/inline'
|
|
5
5
|
gemfile do
|
6
6
|
source 'https://rubygems.org'
|
7
7
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
8
|
-
gem 'procon_bypass_man', '0.1.
|
8
|
+
gem 'procon_bypass_man', '0.1.18'
|
9
9
|
end
|
10
10
|
|
11
11
|
ProconBypassMan.configure do |config|
|
12
12
|
config.root = File.expand_path(__dir__)
|
13
13
|
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
|
14
14
|
config.logger.level = :debug
|
15
|
-
#
|
15
|
+
# webからProconBypassManを操作できるwebサービス
|
16
|
+
# config.api_servers = ['https://pbm-cloud.herokuapp.com']
|
16
17
|
config.enable_critical_error_logging = true
|
17
18
|
end
|
18
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procon_bypass_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pbmenv
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description: A programmable converter for Nintendo Switch Pro Controller
|
56
56
|
email:
|
57
57
|
- n905i.1214@gmail.com
|
58
58
|
executables: []
|
@@ -78,10 +78,13 @@ files:
|
|
78
78
|
- bin/setup
|
79
79
|
- docs/how_to_connect_procon.md
|
80
80
|
- docs/setting/left-analogstick-cap.md
|
81
|
+
- docs/setting/splatoon2_macro_sokuwari_bubble.md
|
81
82
|
- docs/setup_raspi.md
|
82
83
|
- docs/setup_raspi.mitamae.rb
|
83
84
|
- docs/setup_raspi_by_mitamae.md
|
85
|
+
- docs/upgrade_pbm.md
|
84
86
|
- lib/ext/em_pure_ruby.rb
|
87
|
+
- lib/ext/module.rb
|
85
88
|
- lib/procon_bypass_man.rb
|
86
89
|
- lib/procon_bypass_man/background.rb
|
87
90
|
- lib/procon_bypass_man/background/job_performer.rb
|
@@ -127,6 +130,7 @@ files:
|
|
127
130
|
- lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb
|
128
131
|
- lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb
|
129
132
|
- lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_up_key.rb
|
133
|
+
- lib/procon_bypass_man/plugin/splatoon2/macro/sokuwari_for_splash_bomb.rb
|
130
134
|
- lib/procon_bypass_man/plugin/splatoon2/mode/guruguru.rb
|
131
135
|
- lib/procon_bypass_man/plugin/splatoon2/version.rb
|
132
136
|
- lib/procon_bypass_man/plugins.rb
|
@@ -138,6 +142,8 @@ files:
|
|
138
142
|
- lib/procon_bypass_man/procon/consts.rb
|
139
143
|
- lib/procon_bypass_man/procon/flip_cache.rb
|
140
144
|
- lib/procon_bypass_man/procon/layer_changer.rb
|
145
|
+
- lib/procon_bypass_man/procon/macro.rb
|
146
|
+
- lib/procon_bypass_man/procon/macro_builder.rb
|
141
147
|
- lib/procon_bypass_man/procon/macro_registry.rb
|
142
148
|
- lib/procon_bypass_man/procon/mode_registry.rb
|
143
149
|
- lib/procon_bypass_man/procon/press_button_aware.rb
|
@@ -202,5 +208,5 @@ requirements: []
|
|
202
208
|
rubygems_version: 3.2.15
|
203
209
|
signing_key:
|
204
210
|
specification_version: 4
|
205
|
-
summary:
|
211
|
+
summary: A programmable converter for Nintendo Switch Pro Controller
|
206
212
|
test_files: []
|