procon_bypass_man 0.1.2 → 0.1.6
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 +23 -0
- data/.rubocop.yml +24 -0
- data/CHANGELOG.md +27 -8
- data/Gemfile +2 -0
- data/Gemfile.lock +24 -1
- data/README.md +34 -115
- data/docs/setup_raspi.md +4 -1
- data/examples/pbm.service +27 -0
- data/examples/practical/app.rb +8 -3
- data/examples/practical/setting.yml +1 -1
- data/lib/procon_bypass_man.rb +38 -10
- data/lib/procon_bypass_man/configuration.rb +10 -7
- data/lib/procon_bypass_man/configuration/layer.rb +39 -10
- data/lib/procon_bypass_man/configuration/loader.rb +17 -16
- data/lib/procon_bypass_man/configuration/validator.rb +70 -5
- data/lib/procon_bypass_man/device_connector.rb +336 -0
- data/lib/procon_bypass_man/io_monitor.rb +0 -8
- data/lib/procon_bypass_man/procon.rb +20 -11
- data/lib/procon_bypass_man/procon/button_collection.rb +3 -2
- data/lib/procon_bypass_man/procon/flip_cache.rb +22 -0
- data/lib/procon_bypass_man/procon/pressed_button_helper.rb +1 -1
- data/lib/procon_bypass_man/runner.rb +36 -35
- data/lib/procon_bypass_man/timer.rb +14 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/procon_bypass_man.gemspec +2 -2
- metadata +13 -9
- data/CODE_OF_CONDUCT.md +0 -84
- data/lib/procon_bypass_man/device_registry.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21149148015d5d8194ba9b0dc35fc1699ba1fe4eff6aaf1dd0956e0b35856e14
|
4
|
+
data.tar.gz: 6af893ef0a8ff0fdad56b53d9bd117f6cbd39ec7bdb5c216d44cf2d773b9974f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7185d5bf2246b3c1e2ae00eb08e170db017e78b7ed43fecde3757f2fc99bf1132f01b4e541ba669b9fc2ef39ee17e035368eabe7d4b973728c8ae49fd2873a0a
|
7
|
+
data.tar.gz: 6c3152904d3f4af9e3e3e4f519d4fbe3391cf7d727c3ee42966d9492672bb9ead227ce451e8b97088d8b5e27176e9427939009ff59873fac507cbdabeb7fa61a
|
@@ -0,0 +1,23 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.1.2
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:3.0.1
|
9
|
+
executor: ruby/default
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- run:
|
13
|
+
name: install bundler
|
14
|
+
command: gem install bundler:2.2.20
|
15
|
+
- run:
|
16
|
+
name: bundle install
|
17
|
+
command: bundle install --jobs 4
|
18
|
+
- run:
|
19
|
+
name: rubocop
|
20
|
+
command: bundle exec rubocop
|
21
|
+
- run:
|
22
|
+
name: run test
|
23
|
+
command: bundle exec rspec
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
SuggestExtensions: false
|
4
|
+
Include:
|
5
|
+
- 'lib/**/*.rb'
|
6
|
+
- 'spec/**/*.rb'
|
7
|
+
Style:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Layout:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Naming:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Lint/ConstantDefinitionInBlock:
|
20
|
+
Enabled: false
|
21
|
+
Lint/UselessAssignment:
|
22
|
+
Enabled: false
|
23
|
+
Lint/EmptyBlock:
|
24
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,31 @@
|
|
1
|
-
## [0.1.
|
2
|
-
-
|
3
|
-
- 設定ファイルのライブリロードができるようになった
|
4
|
-
- 設定ファイルのバリデーションエラーとシンタックスエラーを投げるようになった
|
5
|
-
- key remap
|
6
|
-
- breking changes
|
7
|
-
- 設定情報をyamlで書くようになった
|
1
|
+
## [0.1.6] - 2021-08-19
|
2
|
+
- 設定ファイルを読み込むと内容のmd5を `pbm_root_dir/.setting_yaml_digest` へ出力するようにしました
|
8
3
|
|
9
|
-
## [0.1.
|
4
|
+
## [0.1.5] - 2021-07-29
|
5
|
+
- siwtch, proコンが電源OFF時にCPU使いまくるのを修正した
|
6
|
+
- 連打中に無視するボタンを複数登録できるようにした
|
7
|
+
- キーのリマップ先に複数ボタンを登録できるようにした
|
8
|
+
- 1つのボタンへ連打とリマップをできないようにしました
|
9
|
+
- NG ex)
|
10
|
+
- flip :zr, if_pressed: [:y]
|
11
|
+
- remap :zr, to: [:x]
|
12
|
+
|
13
|
+
## [0.1.4] - 2021-07-11
|
14
|
+
- ProconBypassMan.rootの定義を、gem rootからproject rootへ変更した
|
15
|
+
- 連打の頻度を変更できるようにした
|
16
|
+
- シグナルで設定ファイルを読み直すとpid_pathが消滅する不具合を修正した
|
17
|
+
|
18
|
+
## [0.1.3] - 2021-07-03
|
19
|
+
- 接続のしやすさ向上
|
20
|
+
|
21
|
+
## [0.1.2] - 2021-06-25
|
22
|
+
- 設定ファイルのライブリロードができるようになった
|
23
|
+
- tmp/pidにUSR2シグナルを送信すると設定を再読み込みする
|
24
|
+
- 設定ファイルのバリデーションエラーとシンタックスエラーを投げるようになった
|
25
|
+
- Support key remap
|
26
|
+
- 設定情報をyamlで書くようになった
|
27
|
+
|
28
|
+
## [0.1.1] - 2021-06-19
|
10
29
|
- プロコンの出力をLoggerに書き出す
|
11
30
|
- コマンドの標準出力にstatsを出す
|
12
31
|
- graceful shutdown
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.1.
|
4
|
+
procon_bypass_man (0.1.6)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
ast (2.4.2)
|
9
10
|
coderay (1.1.3)
|
10
11
|
diff-lcs (1.4.4)
|
11
12
|
method_source (1.0.0)
|
13
|
+
parallel (1.20.1)
|
14
|
+
parser (3.0.2.0)
|
15
|
+
ast (~> 2.4.1)
|
12
16
|
pry (0.14.1)
|
13
17
|
coderay (~> 1.1)
|
14
18
|
method_source (~> 1.0)
|
19
|
+
rainbow (3.0.0)
|
15
20
|
rake (13.0.3)
|
21
|
+
regexp_parser (2.1.1)
|
22
|
+
rexml (3.2.5)
|
16
23
|
rspec (3.10.0)
|
17
24
|
rspec-core (~> 3.10.0)
|
18
25
|
rspec-expectations (~> 3.10.0)
|
@@ -26,6 +33,20 @@ GEM
|
|
26
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
34
|
rspec-support (~> 3.10.0)
|
28
35
|
rspec-support (3.10.2)
|
36
|
+
rubocop (1.18.4)
|
37
|
+
parallel (~> 1.10)
|
38
|
+
parser (>= 3.0.0.0)
|
39
|
+
rainbow (>= 2.2.2, < 4.0)
|
40
|
+
regexp_parser (>= 1.8, < 3.0)
|
41
|
+
rexml
|
42
|
+
rubocop-ast (>= 1.8.0, < 2.0)
|
43
|
+
ruby-progressbar (~> 1.7)
|
44
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
45
|
+
rubocop-ast (1.8.0)
|
46
|
+
parser (>= 3.0.1.1)
|
47
|
+
ruby-progressbar (1.11.0)
|
48
|
+
timecop (0.9.4)
|
49
|
+
unicode-display_width (2.0.0)
|
29
50
|
|
30
51
|
PLATFORMS
|
31
52
|
arm-linux
|
@@ -37,6 +58,8 @@ DEPENDENCIES
|
|
37
58
|
pry
|
38
59
|
rake (~> 13.0)
|
39
60
|
rspec
|
61
|
+
rubocop
|
62
|
+
timecop
|
40
63
|
|
41
64
|
BUNDLED WITH
|
42
65
|
2.2.20
|
data/README.md
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
# ProconBypassMan
|
2
|
-
*
|
2
|
+
* Switchに繋いだプロコンを連射機にしたり、キーのリマップをしたり、マクロを実行できるツールです
|
3
3
|
* 設定ファイルはrubyスクリプトで記述します
|
4
4
|
* 特定のタイトルに特化した振る舞いにしたい時は各プラグインを使ってください
|
5
5
|
|
6
|
+

|
7
|
+
|
8
|
+
```
|
9
|
+
@startuml
|
10
|
+
ProController --> (PBM): ZR押しっぱなし
|
11
|
+
Switch <-- (PBM): ZR連打
|
12
|
+
@enduml
|
13
|
+
```
|
14
|
+
|
6
15
|
## 使うハードウェア
|
7
16
|
* プロコン
|
8
17
|
* Switch本体とドック
|
9
|
-
* Raspberry Pi4
|
18
|
+
* Raspberry Pi4 Model B/4GB(Raspberry Pi OS (32-bit))
|
10
19
|
* 他のシリーズは未確認です
|
11
20
|
* データ通信が可能なUSBケーブル
|
12
21
|
|
@@ -15,143 +24,53 @@
|
|
15
24
|
* ruby-3.0.x
|
16
25
|
|
17
26
|
## Usage
|
18
|
-
*
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# bundler inline
|
23
|
-
require 'bundler/inline'
|
24
|
-
|
25
|
-
gemfile do
|
26
|
-
gem 'procon_bypass_man', github: 'splaspla-hacker/procon_bypass_man', branch: "0.1.1"
|
27
|
-
end
|
28
|
-
|
29
|
-
ProconBypassMan.run(setting_path: "./setting.yml")
|
30
|
-
```
|
31
|
-
|
32
|
-
setting.yml
|
33
|
-
|
34
|
-
```yml
|
35
|
-
version: 1.0
|
36
|
-
setting: |-
|
37
|
-
prefix_keys_for_changing_layer [:zr, :r, :zl, :l]
|
38
|
-
layer :up do
|
39
|
-
flip :zr, if_pressed: :zr
|
40
|
-
flip :zl, if_pressed: [:y, :b, :zl]
|
41
|
-
flip :down, if_pressed: true
|
42
|
-
end
|
43
|
-
layer :right do
|
44
|
-
end
|
45
|
-
layer :left
|
46
|
-
layer :down do
|
47
|
-
flip :zl, if_pressed: true
|
48
|
-
remap :l, to: :zr
|
49
|
-
end
|
50
|
-
```
|
51
|
-
|
52
|
-
### プラグインを使った設定例
|
53
|
-
```ruby
|
54
|
-
#!/usr/bin/env ruby
|
55
|
-
|
56
|
-
require 'bundler/inline'
|
57
|
-
|
58
|
-
gemfile do
|
59
|
-
gem 'procon_bypass_man', github: 'splaspla-hacker/procon_bypass_man', branch: "0.1.1"
|
60
|
-
gem 'procon_bypass_man-splatoon2', github: 'splaspla-hacker/procon_bypass_man-splatoon2', branch: "0.1.0"
|
61
|
-
end
|
62
|
-
|
63
|
-
ProconBypassMan.run(setting_path: "./setting.yml")
|
64
|
-
```
|
65
|
-
setting.yml
|
66
|
-
|
67
|
-
```yml
|
68
|
-
version: 1.0
|
69
|
-
setting: |-
|
70
|
-
fast_return = ProconBypassMan::Splatoon2::Macro::FastReturn
|
71
|
-
guruguru = ProconBypassMan::Splatoon2::Mode::Guruguru
|
72
|
-
|
73
|
-
install_macro_plugin fast_return
|
74
|
-
install_mode_plugin guruguru
|
75
|
-
|
76
|
-
prefix_keys_for_changing_layer [:zr, :r, :zl, :l]
|
77
|
-
|
78
|
-
layer :up, mode: :manual do
|
79
|
-
flip :zr, if_pressed: :zr, force_neutral: :zl
|
80
|
-
flip :zl, if_pressed: [:y, :b, :zl]
|
81
|
-
flip :down, if_pressed: :down
|
82
|
-
macro fast_return.name, if_pressed: [:y, :b, :down]
|
83
|
-
end
|
84
|
-
layer :right, mode: guruguru.name
|
85
|
-
layer :left do
|
86
|
-
# no-op
|
87
|
-
end
|
88
|
-
layer :down do
|
89
|
-
flip :zl
|
90
|
-
end
|
91
|
-
```
|
92
|
-
|
93
|
-
* 設定ファイルの例
|
94
|
-
* https://github.com/jiikko/procon_bypass_man_sample
|
27
|
+
* USBガジェットモードで起動するRaspberry Pi4を用意する
|
28
|
+
* https://github.com/splaplapla/procon_bypass_man/blob/master/docs/setup_raspi.md
|
29
|
+
* Raspberry Pi4で https://github.com/jiikko/procon_bypass_man_sample をclone して実行ファイルを動かす
|
30
|
+
* 実行ファイルと設定ファイルについては https://github.com/splaplapla/procon_bypass_man/wiki に詳細を書いていますが、まず動かすためにはcloneしたほうが早いです
|
95
31
|
|
96
32
|
## Plugins
|
97
|
-
* https://github.com/
|
98
|
-
|
99
|
-
## プラグインの作り方
|
100
|
-
https://github.com/splaspla-hacker/procon_bypass_man-splatoon2 を見てみてください
|
101
|
-
|
102
|
-
### モード
|
103
|
-
* name, binariesの持つオブジェクトを定義してください
|
104
|
-
* binariesには、Proconが出力するバイナリに対して16進数化した文字列を配列で定義してください
|
105
|
-
|
106
|
-
### マクロ
|
107
|
-
* name, stepsの持つメソッドをオブジェクトを定義してください
|
108
|
-
* stepsには、プロコンで入力ができるキーを配列で定義してください
|
109
|
-
* 現在はintervalは設定できません
|
33
|
+
* https://github.com/splaplapla/procon_bypass_man-splatoon2
|
110
34
|
|
111
35
|
## FAQ
|
112
|
-
### ソフトウェアについて
|
113
36
|
* どうやって動かすの?
|
114
37
|
* このツールはRaspberry Pi4をUSBガジェットモードで起動して有線でプロコンとSwitchに接続して使います
|
115
38
|
* どうやって使うの?
|
116
39
|
* ケーブルでそれらを接続した状態で、Raspberry Pi4にsshして本プログラムを起動することで使用します
|
117
40
|
* ラズベリーパイ4のセットアップ方法は?
|
118
|
-
* https://github.com/
|
41
|
+
* https://github.com/splaplapla/procon_bypass_man/tree/master/docs/setup_raspi.md
|
119
42
|
* モード, マクロの違いは?
|
120
43
|
* modeはProconの入力をそのまま再現するため機能。レイヤーを切り替えるまで繰り返し続ける
|
121
44
|
* マクロは特定のキーを順番に入れていく機能。キーの入力が終わったらマクロは終了する
|
122
45
|
* レイヤーとは?
|
123
46
|
* 自作キーボードみたいな感じでレイヤー毎に設定内容を記述して切り替えれる
|
47
|
+
* このツールでできることは?
|
48
|
+
* キーリマップ, 連射, マクロ, 特定の同じ操作の繰り返し(mode)
|
49
|
+
* リマップは1つのキーを別のキーに割り当てます
|
50
|
+
* 連射中には特定のキーの入力を無視したり、複数のキーをトリガーに連射することができます
|
51
|
+
* どうしてsudoが必要なの?
|
52
|
+
* 操作するdeviceファイルの所有者がrootだから
|
124
53
|
|
125
54
|
## TODO
|
126
|
-
* ログをfluentdへ送信
|
127
|
-
* 設定ファイルをwebから反映できる
|
128
|
-
* ケーブルの抜き差しなし再接続(厳しい)
|
129
|
-
* 接続確立後、プロセスを強制停止し、接続したままプロセスを再起動すると、USBの経由での接続ができなくなる
|
130
|
-
* ケーブルを抜いてからリトライすると改善する
|
131
|
-
* ケーブルで繋がっているけどswitchとプロコンがBluetoothで繋がっている状態かつ非充電状態だとバイパスができない、ということがわかった
|
132
|
-
* ラズパイとプロコン間でBluetooth接続できれば解決するかもしれない
|
133
|
-
* ジャイロの入力を取る方法がまだ発見できていないらしく厳しいことがわかった
|
134
|
-
* https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/issues/7
|
135
|
-
* それとSwitchOS 12からペアリングの仕様に変更があって類似ツールが動かなくっている
|
136
55
|
* ラズパイのプロビジョニングを楽にしたい
|
137
56
|
* レコーディング機能(プロコンの入力をマクロとして登録ができる)
|
138
|
-
*
|
139
|
-
*
|
140
|
-
* webサーバのデーモンとPBMはプロセスを分ける(NOTE)
|
141
|
-
* プロセスを停止するときにtmp/pidを削除する
|
142
|
-
|
143
|
-
## Contributing
|
144
|
-
|
145
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/procon_bypass_man. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/procon_bypass_man/blob/master/CODE_OF_CONDUCT.md).
|
57
|
+
* マクロにdelayを入れれるようにする
|
58
|
+
* 設定ファイル マクロの引数に、ボタンを取れるようにする
|
146
59
|
|
147
|
-
|
148
|
-
```
|
60
|
+
## 開発系
|
61
|
+
```ruby
|
149
62
|
ProconBypassMan.tap do |pbm|
|
150
|
-
pbm.
|
63
|
+
pbm.root = File.expand_path(__dir__)
|
64
|
+
pbm.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
|
151
65
|
pbm.logger.level = :debug
|
152
66
|
end
|
153
67
|
```
|
154
68
|
|
69
|
+
### プロコンとの接続を維持したまま、現在の設定ファイルをPBMに反映する
|
70
|
+
```shell
|
71
|
+
sudo kill -USR2 `cat ./pbm_pid`
|
72
|
+
```
|
73
|
+
|
155
74
|
## License
|
156
75
|
|
157
76
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/docs/setup_raspi.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Raspberry Pi4のセットアップ手順
|
2
|
-
* SD
|
2
|
+
* SDカードにRaspberry Pi OS (32-bit)を焼く
|
3
3
|
* SDカードをRaspberry Pi4本体に挿して起動する
|
4
4
|
* ラズパイGUI
|
5
5
|
* 無線LANに接続する
|
@@ -36,3 +36,6 @@
|
|
36
36
|
* cd ~ && mkdir -p src && cd ~/src && git clone https://github.com/jiikko/procon_bypass_man_sample && cd procon_bypass_man && sudo bundle install
|
37
37
|
|
38
38
|
おわり. 起動する時は都度sudo ruby app.rb を実行する
|
39
|
+
|
40
|
+
## 参考
|
41
|
+
* https://mtosak-tech.hatenablog.jp/entry/2020/08/22/114622
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# sudo ln -s /home/pi/src/procon_bypass_man/examples/pbm.service /etc/systemd/system/pbm.service
|
2
|
+
# Usage:
|
3
|
+
# systemctl daemon-reload
|
4
|
+
# systemctl enable pbm.service
|
5
|
+
# systemctl start pbm.service
|
6
|
+
# systemctl status pbm.service
|
7
|
+
# systemctl restart pbm.service
|
8
|
+
# Debug:
|
9
|
+
# journalctl -xe -f
|
10
|
+
# TODO:
|
11
|
+
# do not make PIDFILE
|
12
|
+
|
13
|
+
[Unit]
|
14
|
+
Description=PBM
|
15
|
+
# After=network-online.target
|
16
|
+
After=network.target
|
17
|
+
|
18
|
+
[Service]
|
19
|
+
Type=simple
|
20
|
+
# PIDFile=/home/pi/src/procon_bypass_man/pbm_pid
|
21
|
+
# WatchdogSec=60
|
22
|
+
WorkingDirectory=/home/pi/src/procon_bypass_man
|
23
|
+
ExecStart=/home/pi/.rbenv/versions/3.0.1/bin/ruby examples/practical/app.rb
|
24
|
+
Restart=always
|
25
|
+
|
26
|
+
[Install]
|
27
|
+
WantedBy=multi-user.target
|
data/examples/practical/app.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# sudo ln -s /home/pi/src/procon_bypass_man/examples/practical/setting.yml /home/pi/src/procon_bypass_man/setting.yml
|
4
|
+
# cd src/procon_bypass_man
|
5
|
+
# sudo ruby examples/practical/app.rb
|
6
|
+
|
3
7
|
require 'bundler/inline'
|
4
8
|
|
5
9
|
gemfile do
|
6
10
|
source 'https://rubygems.org'
|
7
|
-
gem 'procon_bypass_man', github: '
|
8
|
-
gem 'procon_bypass_man-splatoon2', github: '
|
11
|
+
gem 'procon_bypass_man', github: 'splaplapla/procon_bypass_man', branch: "edge"
|
12
|
+
gem 'procon_bypass_man-splatoon2', github: 'splaplapla/procon_bypass_man-splatoon2', branch: "0.1.0"
|
9
13
|
end
|
10
14
|
|
11
15
|
ProconBypassMan.tap do |pbm|
|
12
|
-
pbm.logger = "
|
16
|
+
pbm.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10) # 5世代まで残して, 10MBでローテーション
|
13
17
|
pbm.logger.level = :debug
|
18
|
+
pbm.root = File.expand_path(__dir__)
|
14
19
|
end
|
15
20
|
|
16
21
|
ProconBypassMan.run(setting_path: "./setting.yml")
|
@@ -9,7 +9,7 @@ setting: |-
|
|
9
9
|
prefix_keys_for_changing_layer [:zr, :r, :zl, :l]
|
10
10
|
|
11
11
|
layer :up, mode: :manual do
|
12
|
-
flip :zr, if_pressed: :zr, force_neutral: :zl
|
12
|
+
flip :zr, if_pressed: :zr, force_neutral: :zl, flip_interval: "8F"
|
13
13
|
flip :zl, if_pressed: [:y, :b, :zl]
|
14
14
|
flip :down, if_pressed: :down
|
15
15
|
macro fast_return.name, if_pressed: [:y, :b, :down]
|
data/lib/procon_bypass_man.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require "logger"
|
2
2
|
require 'yaml'
|
3
|
+
require "fileutils"
|
3
4
|
|
4
5
|
require_relative "procon_bypass_man/version"
|
5
|
-
require_relative "procon_bypass_man/
|
6
|
+
require_relative "procon_bypass_man/timer"
|
6
7
|
require_relative "procon_bypass_man/bypass"
|
8
|
+
require_relative "procon_bypass_man/device_connector"
|
7
9
|
require_relative "procon_bypass_man/runner"
|
8
10
|
require_relative "procon_bypass_man/processor"
|
9
|
-
require_relative "procon_bypass_man/procon/data"
|
10
11
|
require_relative "procon_bypass_man/configuration"
|
11
12
|
require_relative "procon_bypass_man/procon"
|
12
13
|
|
@@ -16,7 +17,8 @@ Thread.abort_on_exception = true
|
|
16
17
|
module ProconBypassMan
|
17
18
|
class ProConRejected < StandardError; end
|
18
19
|
class CouldNotLoadConfigError < StandardError; end
|
19
|
-
class
|
20
|
+
class FirstConnectionError < StandardError; end
|
21
|
+
class EternalConnectionError < StandardError; end
|
20
22
|
|
21
23
|
def self.configure(setting_path: nil, &block)
|
22
24
|
unless setting_path
|
@@ -32,20 +34,26 @@ module ProconBypassMan
|
|
32
34
|
|
33
35
|
def self.run(setting_path: nil, &block)
|
34
36
|
configure(setting_path: setting_path, &block)
|
35
|
-
|
36
|
-
Runner.new
|
37
|
+
File.write(pid_path, $$)
|
38
|
+
Runner.new.run
|
37
39
|
rescue CouldNotLoadConfigError
|
38
40
|
ProconBypassMan.logger.error "設定ファイルが不正です。設定ファイルの読み込みに失敗しました"
|
39
41
|
puts "設定ファイルが不正です。設定ファイルの読み込みに失敗しました"
|
42
|
+
FileUtils.rm_rf(ProconBypassMan.pid_path)
|
43
|
+
FileUtils.rm_rf(ProconBypassMan.digest_path)
|
40
44
|
exit 1
|
41
|
-
rescue
|
42
|
-
ProconBypassMan.logger.error "
|
43
|
-
puts "
|
45
|
+
rescue EternalConnectionError
|
46
|
+
ProconBypassMan.logger.error "接続の見込みがないのでsleepしまくります"
|
47
|
+
puts "接続の見込みがないのでsleepしまくります"
|
48
|
+
FileUtils.rm_rf(ProconBypassMan.pid_path)
|
49
|
+
sleep(999999999)
|
50
|
+
rescue FirstConnectionError
|
51
|
+
puts "接続を確立できませんでした。やりなおします。"
|
44
52
|
retry
|
45
53
|
end
|
46
54
|
|
47
|
-
def self.logger=(
|
48
|
-
@@logger =
|
55
|
+
def self.logger=(logger)
|
56
|
+
@@logger = logger
|
49
57
|
end
|
50
58
|
|
51
59
|
def self.logger
|
@@ -56,6 +64,10 @@ module ProconBypassMan
|
|
56
64
|
end
|
57
65
|
end
|
58
66
|
|
67
|
+
def self.pid_path
|
68
|
+
@@pid_path ||= File.expand_path("#{root}/pbm_pid", __dir__).freeze
|
69
|
+
end
|
70
|
+
|
59
71
|
def self.reset!
|
60
72
|
ProconBypassMan::Procon::MacroRegistry.reset!
|
61
73
|
ProconBypassMan::Procon::ModeRegistry.reset!
|
@@ -63,4 +75,20 @@ module ProconBypassMan
|
|
63
75
|
ProconBypassMan::Configuration.instance.reset!
|
64
76
|
ProconBypassMan::IOMonitor.reset!
|
65
77
|
end
|
78
|
+
|
79
|
+
def self.root
|
80
|
+
if defined?(@@root)
|
81
|
+
@@root
|
82
|
+
else
|
83
|
+
File.expand_path('..', __dir__).freeze
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.root=(path)
|
88
|
+
@@root = path
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.digest_path
|
92
|
+
"#{root}/.setting_yaml_digest"
|
93
|
+
end
|
66
94
|
end
|