procon_bypass_man 0.1.23 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +13 -0
- data/.github/workflows/gitleacks.yml +12 -0
- data/.github/workflows/release.yml +1 -0
- data/.github/workflows/ruby.yml +1 -1
- data/CHANGELOG.md +20 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +3 -3
- data/README.md +2 -2
- data/bin/generate_default_app +10 -0
- data/docs/getting_started.md +52 -7
- data/docs/setup_raspi.md +0 -1
- data/lib/procon_bypass_man/background/jobs/base_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/concerns/{job_runnable.rb → job_performable.rb} +1 -1
- data/lib/procon_bypass_man/background.rb +1 -1
- data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +1 -1
- data/lib/procon_bypass_man/{commands → bypass}/bypass_command.rb +11 -19
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +0 -1
- data/lib/procon_bypass_man/bypass.rb +9 -14
- data/lib/procon_bypass_man/commands/print_boot_message_command.rb +1 -2
- data/lib/procon_bypass_man/commands/send_error_command.rb +2 -2
- data/lib/procon_bypass_man/commands.rb +0 -3
- data/lib/procon_bypass_man/configuration.rb +22 -3
- data/lib/procon_bypass_man/device_connection/command.rb +28 -0
- data/lib/procon_bypass_man/{device_connector.rb → device_connection/executor.rb} +51 -38
- data/lib/procon_bypass_man/device_connection/output_report_generator.rb +42 -0
- data/lib/procon_bypass_man/device_connection/output_report_markerable.rb +28 -0
- data/lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb +133 -0
- data/lib/procon_bypass_man/device_connection/output_report_watcher.rb +41 -0
- data/lib/procon_bypass_man/device_connection/pre_bypass.rb +67 -0
- data/lib/procon_bypass_man/device_connection/procon_setting_overrider.rb +78 -0
- data/lib/procon_bypass_man/device_connection/spoofing_output_report_watcher.rb +39 -0
- data/lib/procon_bypass_man/device_connection.rb +16 -0
- data/lib/procon_bypass_man/device_model.rb +17 -0
- data/lib/procon_bypass_man/io_monitor.rb +20 -1
- data/lib/procon_bypass_man/procon/macro_builder.rb +5 -3
- data/lib/procon_bypass_man/procon_display/bypass_hook.rb +11 -0
- data/lib/procon_bypass_man/procon_display/http_request.rb +31 -0
- data/lib/procon_bypass_man/procon_display/http_response.rb +23 -0
- data/lib/procon_bypass_man/procon_display/server.rb +33 -0
- data/lib/procon_bypass_man/procon_display/server_app.rb +17 -0
- data/lib/procon_bypass_man/procon_display/status.rb +20 -0
- data/lib/procon_bypass_man/procon_display.rb +11 -0
- data/lib/procon_bypass_man/{commands → remote_pbm_action/commands}/run_remote_pbm_action_dispatch_command.rb +0 -0
- data/lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb +7 -1
- data/lib/procon_bypass_man/remote_pbm_action.rb +1 -0
- data/lib/procon_bypass_man/runner.rb +4 -7
- data/lib/procon_bypass_man/support/callbacks.rb +68 -34
- data/lib/procon_bypass_man/support/never_exit_accidentally.rb +3 -3
- data/lib/procon_bypass_man/support/usb_device_controller.rb +2 -2
- data/lib/procon_bypass_man/support/yaml_loader.rb +12 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/client.rb +1 -4
- data/lib/procon_bypass_man.rb +66 -41
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/README.md +0 -5
- data/project_template/app.rb +24 -6
- data/project_template/app.rb.erb +64 -0
- data/project_template/lib/app_generator.rb +31 -0
- data/project_template/web.rb +1 -1
- data/sig/main.rbs +3 -3
- data/tmp/.keep +0 -0
- metadata +30 -8
- data/lib/procon_bypass_man/commands/connect_device_command.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd4d6700d287ed85a9361e1cf49cfa3a0eaaf64647556fa4eccdf8d7c20a49f5
|
4
|
+
data.tar.gz: b662feb50dce18c8777631f7164b0524c57cb782c5952fab8d558a6ae753543c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f32bbbf4c03872be73e8bde95c4b42a03c300fb80d4b546e5b17abcc77e98cf9e46fcc4f7c196cc2652b240a520330f58594ed335b8b5fcc7f34c0a1b7e3d166
|
7
|
+
data.tar.gz: c9152a14f18c0ab48dbccb6b655723db3c23b1520087dc87f788ef06450286a7a6dc0d432a44f058bd49d6e2e5809d907a364d568ef4c402e6871815e5c94272
|
data/.circleci/config.yml
CHANGED
@@ -55,6 +55,14 @@ jobs:
|
|
55
55
|
- run: ruby -cw project_template/web.rb
|
56
56
|
- run: ruby -ryaml -e 'puts YAML.load_file("./project_template/setting.yml")["setting"]' > /tmp/content_of_setting.rb && ruby -cw /tmp/content_of_setting.rb
|
57
57
|
|
58
|
+
outdated_app_checker:
|
59
|
+
executor:
|
60
|
+
name: ruby
|
61
|
+
tag: 3.0.1
|
62
|
+
steps:
|
63
|
+
- checkout
|
64
|
+
- run: ruby bin/generate_default_app && git diff --exit-code project_template/app.rb
|
65
|
+
|
58
66
|
bundle_install:
|
59
67
|
parameters:
|
60
68
|
ruby-version:
|
@@ -101,10 +109,12 @@ jobs:
|
|
101
109
|
|
102
110
|
build_jobs: &build_jobs
|
103
111
|
- check_pbm_version
|
112
|
+
- outdated_app_checker
|
104
113
|
- syntax_check:
|
105
114
|
matrix:
|
106
115
|
parameters:
|
107
116
|
ruby-version:
|
117
|
+
- "2.5.5"
|
108
118
|
- "3.0.1"
|
109
119
|
- "3.0.2"
|
110
120
|
- "3.1.1"
|
@@ -112,6 +122,7 @@ build_jobs: &build_jobs
|
|
112
122
|
matrix:
|
113
123
|
parameters:
|
114
124
|
ruby-version:
|
125
|
+
- "2.5.5"
|
115
126
|
- "3.0.1"
|
116
127
|
- "3.0.2"
|
117
128
|
- "3.1.1"
|
@@ -119,6 +130,7 @@ build_jobs: &build_jobs
|
|
119
130
|
matrix:
|
120
131
|
parameters:
|
121
132
|
ruby-version:
|
133
|
+
- "2.5.5"
|
122
134
|
- "3.0.1"
|
123
135
|
- "3.0.2"
|
124
136
|
- "3.1.1"
|
@@ -137,6 +149,7 @@ build_jobs: &build_jobs
|
|
137
149
|
matrix:
|
138
150
|
parameters:
|
139
151
|
ruby-version:
|
152
|
+
- "2.5.5"
|
140
153
|
- "3.0.1"
|
141
154
|
- "3.0.2"
|
142
155
|
- "3.1.1"
|
data/.github/workflows/ruby.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## [0.2.2] - 2022-07-10
|
2
|
+
* project_template/app.rbを動的に生成する仕組みを追加しました
|
3
|
+
* ドキュメントからpbm_webに関する記述を削除しました
|
4
|
+
* 起動スクリプト(app.rb) がたまに意図せず /usr/share/pbm/current を削除してしまう不具合を修正しました
|
5
|
+
|
6
|
+
## [0.2.1] - 2022-05-29
|
7
|
+
- 入力表示機能を提供するSwitchProconInputViewerに対応しました
|
8
|
+
- https://github.com/splaplapla/switch-procon-input-viewer
|
9
|
+
- app.rb内のバグ修正, ログファイルとして残る世代を減らしました
|
10
|
+
|
11
|
+
## [0.2.0] - 2022-05-20
|
12
|
+
- 3つ以上のボタンを操作するマクロに対応しました
|
13
|
+
- IOに関するログをデフォルトで無効にしました
|
14
|
+
- 有効にする場合はapp.rbに `config.io_monitor_logging = true` を記述してください
|
15
|
+
- 接続が安定化するまでの時間が短くなりました
|
16
|
+
- 接続中にプロコンのケーブルを抜くと、エラーを吐いて終了できなくなる不具合を修正しました
|
17
|
+
- プロセスをCtrl+Cで停止するときに終了するまでの時間が短くなりました
|
18
|
+
- 接続に成功するとhomeボタンのledが光るようになりました
|
19
|
+
- 無効にする場合はapp.rbに `config.enable_home_led_on_connect = false` を記述してください
|
20
|
+
|
1
21
|
## [0.1.23] - 2022-05-04
|
2
22
|
- プロセスを停止するとプロコンがBluetooth経由でSwitchと接続するようになりました
|
3
23
|
- 起動時に表示するdevice_idを一部のみ表示するようになりました
|
data/Gemfile
CHANGED
@@ -10,8 +10,11 @@ gem "rspec"
|
|
10
10
|
gem "pry"
|
11
11
|
gem "timecop"
|
12
12
|
gem "rubocop", require: false
|
13
|
-
gem "steep", require: false
|
14
|
-
gem 'typeprof', require: false
|
15
|
-
gem 'rbs', require: false
|
16
13
|
gem "sinatra", require: false
|
17
14
|
gem "webrick", require: false
|
15
|
+
|
16
|
+
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new("2.6.0")
|
17
|
+
gem 'typeprof', require: false
|
18
|
+
gem 'rbs', require: false
|
19
|
+
gem "steep", require: false
|
20
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.
|
4
|
+
procon_bypass_man (0.2.2)
|
5
5
|
action_cable_client
|
6
6
|
pbmenv (>= 0.1.9)
|
7
7
|
sorted_set
|
@@ -36,11 +36,11 @@ GEM
|
|
36
36
|
parallel (1.21.0)
|
37
37
|
parser (3.0.3.2)
|
38
38
|
ast (~> 2.4.1)
|
39
|
-
pbmenv (0.1.
|
39
|
+
pbmenv (0.1.10)
|
40
40
|
pry (0.14.1)
|
41
41
|
coderay (~> 1.1)
|
42
42
|
method_source (~> 1.0)
|
43
|
-
rack (2.2.3)
|
43
|
+
rack (2.2.3.1)
|
44
44
|
rack-protection (2.2.0)
|
45
45
|
rack
|
46
46
|
rainbow (3.0.0)
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
<img width="880" alt="スクリーンショット 2022-04-02 9 10 38" src="https://user-images.githubusercontent.com/1664497/161356057-71e4bc2a-0217-4434-9bf1-0002b9fb261a.png">
|
14
14
|
|
15
|
-
|
15
|
+
https://user-images.githubusercontent.com/1664497/171327108-f12f56a5-fc36-48da-95a5-65e976553a20.mov
|
16
16
|
|
17
17
|
<!--
|
18
18
|
![image](https://user-images.githubusercontent.com/1664497/123414210-942f6980-d5ee-11eb-8192-955bd9e37e0b.png)
|
@@ -33,7 +33,7 @@ Switch <-- (PBM): ZR連打
|
|
33
33
|
* データ通信が可能なUSBケーブル
|
34
34
|
|
35
35
|
## 使うソフトウェア
|
36
|
-
* ruby
|
36
|
+
* ruby 2.5 以上
|
37
37
|
|
38
38
|
## Usage
|
39
39
|
* USBガジェットモードで起動するRaspberry Pi4を用意する
|
data/docs/getting_started.md
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
* モード
|
14
14
|
* [マクロ](#マクロ)
|
15
15
|
* [左スティックの感度調整](#左スティックの感度調整)
|
16
|
+
* [入力表示](#入力表示)
|
16
17
|
* 設定ファイルの書き方
|
17
18
|
* プラグインの書き方
|
18
19
|
* [設定ファイルの書き方がわからない、エラーが起きるとき](#設定ファイルの書き方がわからない、エラーが起きるとき)
|
@@ -39,6 +40,8 @@
|
|
39
40
|
* [設定方法](/docs/setting/left-analogstick-cap.md)
|
40
41
|
* WEBから設定状態の閲覧・反映
|
41
42
|
* ボタンリマップ
|
43
|
+
* 入力表示
|
44
|
+
* https://github.com/splaplapla/switch-procon-input-viewer
|
42
45
|
|
43
46
|
## セットアップ
|
44
47
|
### ラズベリーパイのセットアップ
|
@@ -47,26 +50,64 @@
|
|
47
50
|
|
48
51
|
### procon_bypass_manのインストール
|
49
52
|
|
50
|
-
pbmenvを使うと https://pbm-cloud.herokuapp.com と連携ができるのでおすすめですが、pbmenvを使わなくてもprocon_bypass_manをインストールすることは可能です。
|
53
|
+
pbmenvを使うと https://pbm-cloud.herokuapp.com と連携ができるのでおすすめですが、pbmenvを使わなくてもprocon_bypass_manをインストールすることは可能です。
|
54
|
+
次の4つからインストール方法を1つ選んでください。
|
51
55
|
|
52
|
-
|
56
|
+
* pbmenvを使う方法
|
57
|
+
* systemにインストールされているrubyを使う場合(初心者におすすめ)
|
58
|
+
* rbenvでインストールしたrubyを使う場合
|
59
|
+
* pbmenvを使わない方法
|
60
|
+
* systemにインストールされているrubyを使う場合(初心者におすすめ)
|
61
|
+
* rbenvでインストールしたrubyを使う場合
|
62
|
+
|
63
|
+
#### 1) pbmenvを使う方法
|
53
64
|
|
54
65
|
https://github.com/splaplapla/pbmenv
|
55
|
-
pbmenvはprocon_bypass_manのバージョンマネジャーです。
|
66
|
+
pbmenvはprocon_bypass_manのバージョンマネジャーです。
|
67
|
+
procon_bypass_manはバージョンアップによって起動スクリプトに変更が入ることがあって、バージョンアップするときはpbmenvを使うとエラーが起きることなくインストールができるようになります。また、pbm-cloudと連携してすべての機能を使うには、pbmenvの利用が必須になります。
|
68
|
+
|
69
|
+
##### 1-1) systemにインストールされているrubyを使う場合(初心者におすすめ)
|
56
70
|
|
71
|
+
```bash
|
72
|
+
sudo apt-get install ruby ruby-dev
|
73
|
+
sudo gem i bundler pbmenv
|
74
|
+
sudo pbmenv install latest --use
|
75
|
+
cd /usr/share/pbm/current
|
76
|
+
sudo ruby app.rb
|
57
77
|
```
|
58
|
-
|
59
|
-
|
78
|
+
|
79
|
+
##### 1-2) rbenvでインストールしたrubyを使う場合
|
80
|
+
rbenvはrubyのパッケージマネージャーです。
|
81
|
+
|
82
|
+
```bash
|
83
|
+
rbenv install 3.0.1
|
84
|
+
sudo gem install pbmenv
|
85
|
+
sudo pbmenv install latest --use
|
60
86
|
cd /usr/share/pbm/current
|
61
87
|
sudo /home/pi/.rbenv/versions/3.0.1/bin/ruby app.rb
|
62
88
|
```
|
63
89
|
|
64
|
-
#### pbmenvを使わない方法
|
90
|
+
#### 2) pbmenvを使わない方法
|
91
|
+
https://github.com/jiikko/procon_bypass_man_sample にある app.rb と setting.yml を Raspberry Pi にダウンロードすれば、起動することができます。
|
65
92
|
|
66
|
-
|
93
|
+
##### 2-1) systemにインストールされているrubyを使う場合(初心者におすすめ)
|
67
94
|
|
95
|
+
```bash
|
96
|
+
sudo apt-get install ruby ruby-dev wget
|
97
|
+
wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/app.rb
|
98
|
+
wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/setting.yml
|
99
|
+
sudo gem i bundler
|
100
|
+
sudo ruby app.rb
|
68
101
|
```
|
102
|
+
|
103
|
+
##### 2-2) rbenvでインストールしたrubyを使う場合
|
104
|
+
rbenvはrubyのパッケージマネージャーです。
|
105
|
+
|
106
|
+
```bash
|
69
107
|
rbenv install 3.0.1
|
108
|
+
sudo apt-get install wget
|
109
|
+
wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/app.rb
|
110
|
+
wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/setting.yml
|
70
111
|
sudo /home/pi/.rbenv/versions/3.0.1/bin/ruby app.rb
|
71
112
|
```
|
72
113
|
|
@@ -162,6 +203,10 @@ open_macro :sokuwari, steps: [:toggle_r_for_0_2sec, :toggle_thumbr_for_0_14sec,
|
|
162
203
|
## 左スティックの感度調整
|
163
204
|
[左スティックの感度調整](/docs/setting/left-analogstick-cap.md)
|
164
205
|
|
206
|
+
## 入力表示
|
207
|
+
* https://github.com/splaplapla/switch-procon-input-viewer
|
208
|
+
* 後で書きます
|
209
|
+
|
165
210
|
## 設定ファイルの書き方
|
166
211
|
* 後で書きます
|
167
212
|
|
data/docs/setup_raspi.md
CHANGED
@@ -33,7 +33,6 @@ https://github.com/splaplapla/procon_bypass_man/blob/master/docs/setup_raspi_by_
|
|
33
33
|
* chmod 755 ~/add_procon_gadget.sh
|
34
34
|
* sudo reboot
|
35
35
|
* sudo sh ~/add_procon_gadget.sh の実行に成功させる
|
36
|
-
* /etc/rc.local に sh /home/pi/add_procon_gadget.sh って書く
|
37
36
|
* cd ~ && mkdir -p src && cd ~/src && git clone https://github.com/jiikko/procon_bypass_man_sample && cd procon_bypass_man_sample
|
38
37
|
|
39
38
|
おわり. 起動する時は都度 sudo ruby app.rb を実行する
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "procon_bypass_man/background/jobs/concerns/has_internal_api_setting"
|
2
2
|
require "procon_bypass_man/background/jobs/concerns/has_external_api_setting"
|
3
|
-
require "procon_bypass_man/background/jobs/concerns/
|
3
|
+
require "procon_bypass_man/background/jobs/concerns/job_performable"
|
4
4
|
require "procon_bypass_man/background/job_runner"
|
5
5
|
require "procon_bypass_man/background/job_performer"
|
6
6
|
require "procon_bypass_man/background/jobs/base_job"
|
@@ -32,7 +32,7 @@ module ProconBypassMan
|
|
32
32
|
ProconBypassMan::ButtonsSettingConfiguration.instance.reset!
|
33
33
|
ProconBypassMan.reset!
|
34
34
|
|
35
|
-
yaml =
|
35
|
+
yaml = ProconBypassMan::YamlLoader.load(path: setting_path)
|
36
36
|
ProconBypassMan.config.raw_setting = yaml.dup
|
37
37
|
case yaml["version"]
|
38
38
|
when 1.0, nil
|
@@ -10,7 +10,7 @@ class ProconBypassMan::BypassCommand
|
|
10
10
|
@gadget = gadget
|
11
11
|
@procon = procon
|
12
12
|
|
13
|
-
ProconBypassMan::IOMonitor.start!
|
13
|
+
ProconBypassMan::IOMonitor.start! if ProconBypassMan.io_monitor_logging
|
14
14
|
ProconBypassMan::Background::JobRunner.queue.clear # forkしたときに残留物も移ってしまうため
|
15
15
|
ProconBypassMan::Background::JobRunner.start!
|
16
16
|
end
|
@@ -33,32 +33,22 @@ class ProconBypassMan::BypassCommand
|
|
33
33
|
monitor2 = ProconBypassMan::IOMonitor.new(label: "procon -> switch")
|
34
34
|
ProconBypassMan.logger.info "Thread1を起動します"
|
35
35
|
|
36
|
-
cycle_sleep = ProconBypassMan::CycleSleep.new(cycle_interval:
|
36
|
+
cycle_sleep = ProconBypassMan::CycleSleep.new(cycle_interval: 1, execution_cycle: ProconBypassMan.config.bypass_mode.gadget_to_procon_interval)
|
37
37
|
|
38
38
|
t1 = Thread.new do
|
39
|
-
|
40
|
-
|
39
|
+
if ProconBypassMan.config.bypass_mode.mode == ProconBypassMan::BypassMode::TYPE_AGGRESSIVE
|
40
|
+
ProconBypassMan.logger.info "TYPE_AGGRESSIVEなのでThread1を終了します"
|
41
|
+
monitor1.shutdown
|
42
|
+
next
|
43
|
+
end
|
44
|
+
|
41
45
|
loop do
|
42
46
|
break if $will_terminate_token
|
43
47
|
|
44
48
|
cycle_sleep.sleep_or_execute do
|
45
49
|
bypass = ProconBypassMan::Bypass.new(gadget: @gadget, procon: @procon, monitor: monitor1)
|
46
|
-
!@did_first_step && timer.throw_if_timeout!
|
47
50
|
bypass.send_gadget_to_procon!
|
48
51
|
end
|
49
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
50
|
-
case ProconBypassMan.config.bypass_mode.mode
|
51
|
-
when ProconBypassMan::BypassMode::TYPE_AGGRESSIVE
|
52
|
-
ProconBypassMan.logger.info "10秒経過したのでThread1を終了します"
|
53
|
-
monitor1.shutdown
|
54
|
-
break
|
55
|
-
when ProconBypassMan::BypassMode::TYPE_NORMAL
|
56
|
-
ProconBypassMan.logger.info "10秒経過したのでsend_intervalを長くします"
|
57
|
-
cycle_sleep = ProconBypassMan::CycleSleep.new(cycle_interval: 1, execution_cycle: ProconBypassMan.config.bypass_mode.gadget_to_procon_interval)
|
58
|
-
else
|
59
|
-
raise "unknown type"
|
60
|
-
end
|
61
|
-
@did_first_step = true
|
62
52
|
rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError, Errno::ESHUTDOWN => e
|
63
53
|
ProconBypassMan::SendErrorCommand.execute(error: "Switchとの切断されました.終了処理を開始します. #{e.full_message}")
|
64
54
|
Process.kill "TERM", Process.ppid
|
@@ -67,6 +57,7 @@ class ProconBypassMan::BypassCommand
|
|
67
57
|
ProconBypassMan::SendErrorCommand.execute(error: "Switchと意図せず切断されました.終了処理を開始します. #{e.full_message}")
|
68
58
|
Process.kill "TERM", Process.ppid
|
69
59
|
end
|
60
|
+
|
70
61
|
ProconBypassMan.logger.info "Thread1を終了します"
|
71
62
|
end
|
72
63
|
|
@@ -79,7 +70,6 @@ class ProconBypassMan::BypassCommand
|
|
79
70
|
if $will_terminate_token
|
80
71
|
if $will_terminate_token == WILL_TERMINATE_TOKEN::TERMINATE
|
81
72
|
bypass.direct_connect_switch_via_bluetooth
|
82
|
-
bypass.be_empty_procon
|
83
73
|
end
|
84
74
|
break
|
85
75
|
end
|
@@ -88,9 +78,11 @@ class ProconBypassMan::BypassCommand
|
|
88
78
|
rescue EOFError => e
|
89
79
|
ProconBypassMan::SendErrorCommand.execute(error: "Proconが切断されました。終了処理を開始します. #{e.full_message}")
|
90
80
|
Process.kill "TERM", Process.ppid
|
81
|
+
break
|
91
82
|
rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError, Errno::ESHUTDOWN => e
|
92
83
|
ProconBypassMan::SendErrorCommand.execute(error: "Proconが切断されました。終了処理を開始します2. #{e.full_message}")
|
93
84
|
Process.kill "TERM", Process.ppid
|
85
|
+
break
|
94
86
|
end
|
95
87
|
ProconBypassMan.logger.info "Thread2を終了します"
|
96
88
|
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
require "procon_bypass_man/bypass/usb_hid_logger"
|
2
|
+
require "procon_bypass_man/bypass/bypass_command"
|
2
3
|
|
3
4
|
class ProconBypassMan::Bypass
|
4
|
-
|
5
|
+
extend ProconBypassMan::CallbacksRegisterable
|
6
|
+
|
7
|
+
register_callback_module(ProconBypassMan::Bypass::UsbHidLogger)
|
8
|
+
register_callback_module(ProconBypassMan::ProconDisplay::BypassHook)
|
5
9
|
|
6
10
|
class BypassValue < Struct.new(:binary)
|
7
11
|
def to_text
|
@@ -28,7 +32,6 @@ class ProconBypassMan::Bypass
|
|
28
32
|
|
29
33
|
raw_input = nil
|
30
34
|
begin
|
31
|
-
# TODO blocking readにしたいが、接続時のフェーズによって長さが違うので厳しい
|
32
35
|
raw_input = self.gadget.read_nonblock(64)
|
33
36
|
self.bypass_value.binary = ProconBypassMan::Domains::InboundProconBinary.new(binary: raw_input)
|
34
37
|
rescue IO::EAGAINWaitReadable
|
@@ -97,20 +100,12 @@ class ProconBypassMan::Bypass
|
|
97
100
|
# @return [void]
|
98
101
|
def direct_connect_switch_via_bluetooth
|
99
102
|
ProconBypassMan.logger.debug { "direct_connect_switch_via_bluetooth!" }
|
103
|
+
self.procon.write_nonblock(["010500000000000000003800"].pack("H*")) # home led off
|
104
|
+
self.procon.write_nonblock(["010600000000000000003800"].pack("H*")) # home led off
|
105
|
+
self.procon.write_nonblock(["010700000000000000003800"].pack("H*")) # home led off
|
106
|
+
self.procon.write_nonblock(["010800000000000000003800"].pack("H*")) # home led off
|
100
107
|
self.procon.write_nonblock(["8005"].pack("H*"))
|
101
108
|
self.procon.write_nonblock(["8005"].pack("H*"))
|
102
109
|
self.procon.write_nonblock(["8005"].pack("H*"))
|
103
110
|
end
|
104
|
-
|
105
|
-
# @return [void] 入力してから取り出さないと接続しっぱなしになるっぽいのでこれが必要っぽい
|
106
|
-
def be_empty_procon
|
107
|
-
timer = ProconBypassMan::SafeTimeout.new(timeout: Time.now + 5)
|
108
|
-
loop do
|
109
|
-
break if timer.timeout?
|
110
|
-
output = self.procon.read_nonblock(64)
|
111
|
-
ProconBypassMan.logger.debug { "[ProconBypassMan::Bypass#be_empty_procon] #{output.unpack("H*").first}" }
|
112
|
-
rescue IO::EAGAINWaitReadable
|
113
|
-
# no-op
|
114
|
-
end
|
115
|
-
end
|
116
111
|
end
|
@@ -32,8 +32,8 @@ class ProconBypassMan::PrintBootMessageCommand
|
|
32
32
|
def to_s
|
33
33
|
booted_message = <<~EOF
|
34
34
|
----
|
35
|
-
RUBY_VERSION: #{@table[:ruby_version]}
|
36
35
|
ProconBypassMan::VERSION: #{@table[:pbm_version]}
|
36
|
+
RUBY_VERSION: #{@table[:ruby_version]}
|
37
37
|
Pbmenv::VERSION: #{@table[:pbmenv_version]}
|
38
38
|
pid: #{@table[:pid]}
|
39
39
|
root: #{@table[:root_path]}
|
@@ -58,7 +58,6 @@ class ProconBypassMan::PrintBootMessageCommand
|
|
58
58
|
def self.execute
|
59
59
|
message = BootMessage.new
|
60
60
|
ProconBypassMan::ReportBootJob.perform_async(message.to_hash)
|
61
|
-
ProconBypassMan::ReportLoadConfigJob.perform_async(ProconBypassMan.config.raw_setting)
|
62
61
|
puts message.to_s
|
63
62
|
end
|
64
63
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class ProconBypassMan::SendErrorCommand
|
2
2
|
# @param [String, Hash, Exception] error
|
3
3
|
# @return [void]
|
4
|
-
def self.execute(error: )
|
4
|
+
def self.execute(error: , stdout: true)
|
5
5
|
body =
|
6
6
|
case error
|
7
7
|
when String, Hash
|
@@ -12,7 +12,7 @@ class ProconBypassMan::SendErrorCommand
|
|
12
12
|
|
13
13
|
ProconBypassMan.logger.error body
|
14
14
|
ProconBypassMan.error_logger.error body
|
15
|
-
puts body
|
15
|
+
puts body if stdout
|
16
16
|
|
17
17
|
ProconBypassMan::ReportErrorJob.perform(error)
|
18
18
|
end
|
@@ -4,6 +4,3 @@ require "procon_bypass_man/commands/write_session_id_command"
|
|
4
4
|
require "procon_bypass_man/commands/write_device_id_command"
|
5
5
|
require "procon_bypass_man/commands/send_reload_config_event_command"
|
6
6
|
require "procon_bypass_man/commands/send_error_command"
|
7
|
-
require "procon_bypass_man/commands/connect_device_command"
|
8
|
-
require "procon_bypass_man/commands/bypass_command"
|
9
|
-
require "procon_bypass_man/commands/run_remote_pbm_action_dispatch_command"
|
@@ -47,10 +47,14 @@ class ProconBypassMan::Configuration
|
|
47
47
|
def fallback_setting_path
|
48
48
|
"/tmp/procon_bypass_man_fallback_setting.yaml"
|
49
49
|
end
|
50
|
+
|
51
|
+
def io_monitor_logging
|
52
|
+
config.io_monitor_logging
|
53
|
+
end
|
50
54
|
end
|
51
55
|
|
52
56
|
attr_accessor :enable_critical_error_logging
|
53
|
-
attr_writer :verbose_bypass_log, :raw_setting, :enable_reporting_pressed_buttons, :never_exit_accidentally
|
57
|
+
attr_writer :verbose_bypass_log, :raw_setting, :enable_reporting_pressed_buttons, :never_exit_accidentally, :io_monitor_logging, :enable_home_led_on_connect
|
54
58
|
|
55
59
|
def root=(path)
|
56
60
|
@root = path
|
@@ -100,7 +104,7 @@ class ProconBypassMan::Configuration
|
|
100
104
|
|
101
105
|
def error_logger
|
102
106
|
if enable_critical_error_logging
|
103
|
-
@error_logger ||= Logger.new("#{ProconBypassMan.root}/error.log",
|
107
|
+
@error_logger ||= Logger.new("#{ProconBypassMan.root}/error.log", 1, 1024 * 1024 * 1)
|
104
108
|
else
|
105
109
|
Logger.new(File.open("/dev/null"))
|
106
110
|
end
|
@@ -186,12 +190,27 @@ class ProconBypassMan::Configuration
|
|
186
190
|
@raw_setting ||= {}
|
187
191
|
end
|
188
192
|
|
193
|
+
# @return [Boolean] default false
|
189
194
|
def enable_reporting_pressed_buttons
|
190
195
|
@enable_reporting_pressed_buttons ||= false
|
191
196
|
end
|
192
197
|
|
193
|
-
# @return [Boolean]
|
198
|
+
# @return [Boolean] default false
|
194
199
|
def never_exit_accidentally
|
195
200
|
@never_exit_accidentally || false
|
196
201
|
end
|
202
|
+
|
203
|
+
# @return [Boolean] default false
|
204
|
+
def io_monitor_logging
|
205
|
+
@io_monitor_logging ||= false
|
206
|
+
end
|
207
|
+
|
208
|
+
# @return [Boolean] default true
|
209
|
+
def enable_home_led_on_connect
|
210
|
+
if defined?(@enable_home_led_on_connect)
|
211
|
+
return @enable_home_led_on_connect
|
212
|
+
else
|
213
|
+
true
|
214
|
+
end
|
215
|
+
end
|
197
216
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class ProconBypassMan::DeviceConnection::Command
|
2
|
+
MAX_RETRY_COUNT = 3
|
3
|
+
|
4
|
+
# @return [void]
|
5
|
+
def self.execute!(retry_count: 0)
|
6
|
+
begin
|
7
|
+
gadget, procon = ProconBypassMan::DeviceConnection::Executer.execute!
|
8
|
+
rescue ProconBypassMan::DeviceConnection::TimeoutErrorInConditionalRoute
|
9
|
+
if retry_count >= MAX_RETRY_COUNT
|
10
|
+
ProconBypassMan::SendErrorCommand.execute(error: "リトライしましたが、接続できませんでした")
|
11
|
+
raise ProconBypassMan::DeviceConnection::TimeoutError
|
12
|
+
else
|
13
|
+
ProconBypassMan::SendErrorCommand.execute(error: "接続に失敗したのでリトライします")
|
14
|
+
end
|
15
|
+
|
16
|
+
retry_count = retry_count + 1
|
17
|
+
retry
|
18
|
+
rescue ProconBypassMan::DeviceConnection::NotFoundProconError => e
|
19
|
+
raise
|
20
|
+
rescue ProconBypassMan::SafeTimeout::Timeout
|
21
|
+
raise ProconBypassMan::DeviceConnection::TimeoutError
|
22
|
+
end
|
23
|
+
|
24
|
+
ProconBypassMan::DeviceConnection::PreBypass.new(gadget: gadget, procon: procon).execute!
|
25
|
+
ProconBypassMan::DeviceConnection::ProconSettingOverrider.new(procon: procon).execute!
|
26
|
+
return [gadget, procon]
|
27
|
+
end
|
28
|
+
end
|