procon_bypass_man 0.1.5 → 0.1.9
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 +41 -13
- data/.github/workflows/ruby.yml +34 -0
- data/.rubocop.yml +24 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +15 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +75 -3
- data/README.md +22 -8
- data/Rakefile +10 -1
- data/Steepfile +39 -0
- data/bin/report_receive_server.rb +11 -0
- data/docs/setup_raspi.md +12 -7
- data/docs/setup_raspi.mitamae.rb +60 -0
- data/docs/setup_raspi_by_mitamae.md +14 -0
- data/examples/practical/app.rb +2 -2
- data/lib/procon_bypass_man/analog_stick_position.rb +14 -0
- data/lib/procon_bypass_man/boot_message.rb +40 -0
- data/lib/procon_bypass_man/bypass.rb +20 -7
- data/lib/procon_bypass_man/configuration/layer.rb +33 -3
- data/lib/procon_bypass_man/configuration/loader.rb +17 -16
- data/lib/procon_bypass_man/configuration/validator.rb +20 -19
- data/lib/procon_bypass_man/configuration.rb +24 -12
- data/lib/procon_bypass_man/device_connector.rb +14 -31
- data/lib/procon_bypass_man/error_reporter.rb +44 -0
- data/lib/procon_bypass_man/io_monitor.rb +7 -4
- data/lib/procon_bypass_man/on_memory_cache.rb +34 -0
- data/lib/procon_bypass_man/procon/analog_stick_cap.rb +88 -0
- data/lib/procon_bypass_man/procon/button_collection.rb +14 -6
- data/lib/procon_bypass_man/procon/debug_dumper.rb +17 -0
- data/lib/procon_bypass_man/procon/mode_registry.rb +2 -2
- data/lib/procon_bypass_man/procon/press_button_aware.rb +13 -0
- data/lib/procon_bypass_man/procon/pressed_button_helper.rb +1 -11
- data/lib/procon_bypass_man/procon/user_operation.rb +10 -3
- data/lib/procon_bypass_man/procon.rb +15 -1
- data/lib/procon_bypass_man/reporter.rb +42 -0
- data/lib/procon_bypass_man/runner.rb +39 -50
- data/lib/procon_bypass_man/uptime.rb +13 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man.rb +53 -2
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/README.md +17 -0
- data/project_template/app.rb +20 -0
- data/project_template/setting.yml +35 -0
- data/project_template/systemd_units/pbm.service +13 -0
- data/sig/README.rb +4 -0
- data/sig/main.rbs +467 -0
- metadata +27 -8
- data/examples/pbm.service +0 -27
- data/examples/simple.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e4ad788ed57ca3bac1d4d17b1648285c8bc8d89d23a3c0a4ca4d5aaa58e4dfd
|
4
|
+
data.tar.gz: 512a1f754cf255c6692ab597c7997d6bad3f3004c2f1203a1ce6adaec603e655
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a059a91051aee0fa59beb62aa7bd952b1c8db15a75d66c47a66fdbda96a60cd9285094524e1d3c619ec215fa47dc5f9ee44e4dd7524f6c2bd60a4d0dfcf25e3
|
7
|
+
data.tar.gz: 9748ad5293f1e3cc902d9b74bbb40997d0c9588e43e78ab4299eb4ddbb9bfd030a7f3bf717d58a3207ac51e348cc090b1a726d7f63780d705807e04db7d9201d
|
data/.circleci/config.yml
CHANGED
@@ -2,19 +2,47 @@ version: 2.1
|
|
2
2
|
orbs:
|
3
3
|
ruby: circleci/ruby@0.1.2
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
executors:
|
6
|
+
ruby:
|
7
|
+
parameters:
|
8
|
+
tag:
|
9
|
+
type: string
|
10
|
+
default: "latest"
|
7
11
|
docker:
|
8
|
-
- image:
|
9
|
-
|
12
|
+
- image: ruby:<< parameters.tag >>
|
13
|
+
environment:
|
14
|
+
BUNDLE_PATH: vendor/bundle
|
15
|
+
BUNDLE_JOBS: 4
|
16
|
+
working_directory: ~/app
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
rspec:
|
20
|
+
parameters:
|
21
|
+
version:
|
22
|
+
type: string
|
23
|
+
executor:
|
24
|
+
name: ruby
|
25
|
+
tag: << parameters.version >>
|
10
26
|
steps:
|
11
27
|
- checkout
|
12
|
-
- run:
|
13
|
-
|
14
|
-
|
15
|
-
- run:
|
16
|
-
|
17
|
-
|
18
|
-
- run:
|
19
|
-
|
20
|
-
|
28
|
+
- run: ruby --version
|
29
|
+
- run: bundle --version
|
30
|
+
- run: gem --version
|
31
|
+
- run: gem install bundler
|
32
|
+
- run: bundle install --jobs 4
|
33
|
+
- run: bundle exec rubocop
|
34
|
+
- run: bundle exec rspec
|
35
|
+
- run: bundle exec steep check
|
36
|
+
|
37
|
+
build_jobs: &build_jobs
|
38
|
+
- rspec:
|
39
|
+
matrix:
|
40
|
+
parameters:
|
41
|
+
version:
|
42
|
+
- "2.7"
|
43
|
+
- "3.0.1"
|
44
|
+
- "3.0.2"
|
45
|
+
workflows:
|
46
|
+
version: 2
|
47
|
+
build:
|
48
|
+
jobs: *build_jobs
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
[push]
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
ruby-version: ['2.7', '3.0.1']
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v2
|
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
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby-version }}
|
30
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
31
|
+
- name: Run tests
|
32
|
+
run: |-
|
33
|
+
bundle exec rake
|
34
|
+
bundle exec steep check
|
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/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [0.1.9] - 2021-10-20
|
2
|
+
- 左スティックを傾けた時に設定した最大値内に丸めることができるようになりました
|
3
|
+
- 関連メソッド: set_neutral_position, left_analog_stick_cap
|
4
|
+
- 数時間に一度起きる、数秒間入力が通らなくなる問題の改善
|
5
|
+
|
6
|
+
## [0.1.8] - 2021-09-19
|
7
|
+
- 使える場合、GC.auto_compactを有効にしました
|
8
|
+
- 起動ログにuptimeからの経過時間を表示しました
|
9
|
+
|
10
|
+
## [0.1.7] - 2021-09-11
|
11
|
+
- Support pbmenv
|
12
|
+
|
13
|
+
## [0.1.6] - 2021-08-19
|
14
|
+
- 設定ファイルを読み込むと内容のmd5を `pbm_root_dir/.setting_yaml_digest` へ出力するようにしました
|
15
|
+
|
1
16
|
## [0.1.5] - 2021-07-29
|
2
17
|
- siwtch, proコンが電源OFF時にCPU使いまくるのを修正した
|
3
18
|
- 連打中に無視するボタンを複数登録できるようにした
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.1.
|
4
|
+
procon_bypass_man (0.1.9)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
activesupport (6.1.4.1)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 1.6, < 2)
|
12
|
+
minitest (>= 5.1)
|
13
|
+
tzinfo (~> 2.0)
|
14
|
+
zeitwerk (~> 2.3)
|
15
|
+
ast (2.4.2)
|
9
16
|
coderay (1.1.3)
|
17
|
+
concurrent-ruby (1.1.9)
|
10
18
|
diff-lcs (1.4.4)
|
19
|
+
ffi (1.15.4)
|
20
|
+
i18n (1.8.10)
|
21
|
+
concurrent-ruby (~> 1.0)
|
22
|
+
language_server-protocol (3.16.0.3)
|
23
|
+
listen (3.7.0)
|
24
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
25
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
11
26
|
method_source (1.0.0)
|
27
|
+
minitest (5.14.4)
|
28
|
+
mustermann (1.1.1)
|
29
|
+
ruby2_keywords (~> 0.0.1)
|
30
|
+
parallel (1.20.1)
|
31
|
+
parser (3.0.2.0)
|
32
|
+
ast (~> 2.4.1)
|
12
33
|
pry (0.14.1)
|
13
34
|
coderay (~> 1.1)
|
14
35
|
method_source (~> 1.0)
|
15
|
-
|
36
|
+
rack (2.2.3)
|
37
|
+
rack-protection (2.1.0)
|
38
|
+
rack
|
39
|
+
rainbow (3.0.0)
|
40
|
+
rake (13.0.6)
|
41
|
+
rb-fsevent (0.11.0)
|
42
|
+
rb-inotify (0.10.1)
|
43
|
+
ffi (~> 1.0)
|
44
|
+
rbs (1.6.2)
|
45
|
+
regexp_parser (2.1.1)
|
46
|
+
rexml (3.2.5)
|
16
47
|
rspec (3.10.0)
|
17
48
|
rspec-core (~> 3.10.0)
|
18
49
|
rspec-expectations (~> 3.10.0)
|
@@ -26,19 +57,60 @@ GEM
|
|
26
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
58
|
rspec-support (~> 3.10.0)
|
28
59
|
rspec-support (3.10.2)
|
60
|
+
rubocop (1.20.0)
|
61
|
+
parallel (~> 1.10)
|
62
|
+
parser (>= 3.0.0.0)
|
63
|
+
rainbow (>= 2.2.2, < 4.0)
|
64
|
+
regexp_parser (>= 1.8, < 3.0)
|
65
|
+
rexml
|
66
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
67
|
+
ruby-progressbar (~> 1.7)
|
68
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
69
|
+
rubocop-ast (1.11.0)
|
70
|
+
parser (>= 3.0.1.1)
|
71
|
+
ruby-progressbar (1.11.0)
|
72
|
+
ruby2_keywords (0.0.5)
|
73
|
+
sinatra (2.1.0)
|
74
|
+
mustermann (~> 1.0)
|
75
|
+
rack (~> 2.2)
|
76
|
+
rack-protection (= 2.1.0)
|
77
|
+
tilt (~> 2.0)
|
78
|
+
steep (0.46.0)
|
79
|
+
activesupport (>= 5.1)
|
80
|
+
language_server-protocol (>= 3.15, < 4.0)
|
81
|
+
listen (~> 3.0)
|
82
|
+
parallel (>= 1.0.0)
|
83
|
+
parser (>= 3.0)
|
84
|
+
rainbow (>= 2.2.2, < 4.0)
|
85
|
+
rbs (>= 1.2.0)
|
86
|
+
terminal-table (>= 2, < 4)
|
87
|
+
terminal-table (3.0.2)
|
88
|
+
unicode-display_width (>= 1.1.1, < 3)
|
89
|
+
tilt (2.0.10)
|
29
90
|
timecop (0.9.4)
|
91
|
+
tzinfo (2.0.4)
|
92
|
+
concurrent-ruby (~> 1.0)
|
93
|
+
unicode-display_width (2.0.0)
|
94
|
+
webrick (1.7.0)
|
95
|
+
zeitwerk (2.4.2)
|
30
96
|
|
31
97
|
PLATFORMS
|
32
98
|
arm-linux
|
33
99
|
arm64-darwin-20
|
34
100
|
armv7l-linux
|
101
|
+
x86_64-linux
|
35
102
|
|
36
103
|
DEPENDENCIES
|
37
104
|
procon_bypass_man!
|
38
105
|
pry
|
39
106
|
rake (~> 13.0)
|
107
|
+
rbs
|
40
108
|
rspec
|
109
|
+
rubocop
|
110
|
+
sinatra
|
111
|
+
steep
|
41
112
|
timecop
|
113
|
+
webrick
|
42
114
|
|
43
115
|
BUNDLED WITH
|
44
|
-
2.2.
|
116
|
+
2.2.22
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# ProconBypassMan
|
2
|
+
[![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
|
+
|
2
4
|
* Switchに繋いだプロコンを連射機にしたり、キーのリマップをしたり、マクロを実行できるツールです
|
3
5
|
* 設定ファイルはrubyスクリプトで記述します
|
4
6
|
* 特定のタイトルに特化した振る舞いにしたい時は各プラグインを使ってください
|
@@ -17,20 +19,20 @@ Switch <-- (PBM): ZR連打
|
|
17
19
|
* Switch本体とドック
|
18
20
|
* Raspberry Pi4 Model B/4GB(Raspberry Pi OS (32-bit))
|
19
21
|
* 他のシリーズは未確認です
|
22
|
+
* zeroは非対応
|
20
23
|
* データ通信が可能なUSBケーブル
|
21
24
|
|
22
25
|
## 使うソフトウェア
|
23
|
-
*
|
24
|
-
* ruby-3.0.x
|
26
|
+
* ruby-3.0.x
|
25
27
|
|
26
28
|
## Usage
|
27
29
|
* USBガジェットモードで起動するRaspberry Pi4を用意する
|
28
|
-
* https://github.com/
|
30
|
+
* https://github.com/splaplapla/procon_bypass_man/blob/master/docs/setup_raspi.md
|
29
31
|
* Raspberry Pi4で https://github.com/jiikko/procon_bypass_man_sample をclone して実行ファイルを動かす
|
30
|
-
* 実行ファイルと設定ファイルについては https://github.com/
|
32
|
+
* 実行ファイルと設定ファイルについては https://github.com/splaplapla/procon_bypass_man/wiki に詳細を書いていますが、まず動かすためにはcloneしたほうが早いです
|
31
33
|
|
32
34
|
## Plugins
|
33
|
-
* https://github.com/
|
35
|
+
* https://github.com/splaplapla/procon_bypass_man-splatoon2
|
34
36
|
|
35
37
|
## FAQ
|
36
38
|
* どうやって動かすの?
|
@@ -38,7 +40,7 @@ Switch <-- (PBM): ZR連打
|
|
38
40
|
* どうやって使うの?
|
39
41
|
* ケーブルでそれらを接続した状態で、Raspberry Pi4にsshして本プログラムを起動することで使用します
|
40
42
|
* ラズベリーパイ4のセットアップ方法は?
|
41
|
-
* https://github.com/
|
43
|
+
* https://github.com/splaplapla/procon_bypass_man/tree/master/docs/setup_raspi.md
|
42
44
|
* モード, マクロの違いは?
|
43
45
|
* modeはProconの入力をそのまま再現するため機能。レイヤーを切り替えるまで繰り返し続ける
|
44
46
|
* マクロは特定のキーを順番に入れていく機能。キーの入力が終わったらマクロは終了する
|
@@ -52,10 +54,9 @@ Switch <-- (PBM): ZR連打
|
|
52
54
|
* 操作するdeviceファイルの所有者がrootだから
|
53
55
|
|
54
56
|
## TODO
|
55
|
-
* 設定ファイルをwebから反映できる
|
56
|
-
* ラズパイのプロビジョニングを楽にしたい
|
57
57
|
* レコーディング機能(プロコンの入力をマクロとして登録ができる)
|
58
58
|
* マクロにdelayを入れれるようにする
|
59
|
+
* 設定ファイル マクロの引数に、ボタンを取れるようにする
|
59
60
|
|
60
61
|
## 開発系
|
61
62
|
```ruby
|
@@ -71,6 +72,19 @@ end
|
|
71
72
|
sudo kill -USR2 `cat ./pbm_pid`
|
72
73
|
```
|
73
74
|
|
75
|
+
### 起動ログをサーバに送信する
|
76
|
+
* `ProconBypassMan.api_server = "http://.."` を設定すると、 `POST /api/reports` に対して起動ログを送信するようになります
|
77
|
+
|
78
|
+
### 開発環境でログの送信を確認する方法
|
79
|
+
* `bundle exec bin/report_receive_server.rb`
|
80
|
+
* `bin/console`
|
81
|
+
* `ProconBypassMan.api_server = "http://localhost:4567"`
|
82
|
+
* `message = ProconBypassMan::BootMessage.new; ProconBypassMan::Reporter.report(body: message.to_hash)"`
|
83
|
+
|
84
|
+
### リリース手順
|
85
|
+
* project_template/app.rb, lib/procon_bypass_man/version.rb のバージョンをあげる
|
86
|
+
* be rake release
|
87
|
+
|
74
88
|
## License
|
75
89
|
|
76
90
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
data/Steepfile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# D = Steep::Diagnostic
|
2
|
+
#
|
3
|
+
# target :lib do
|
4
|
+
# signature "sig"
|
5
|
+
#
|
6
|
+
# check "lib" # Directory name
|
7
|
+
# check "Gemfile" # File name
|
8
|
+
# check "app/models/**/*.rb" # Glob
|
9
|
+
# # ignore "lib/templates/*.rb"
|
10
|
+
#
|
11
|
+
# # library "pathname", "set" # Standard libraries
|
12
|
+
# # library "strong_json" # Gems
|
13
|
+
#
|
14
|
+
# # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
|
15
|
+
# # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
|
16
|
+
# # configure_code_diagnostics do |hash| # You can setup everything yourself
|
17
|
+
# # hash[D::Ruby::NoMethod] = :information
|
18
|
+
# # end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# target :test do
|
22
|
+
# signature "sig", "sig-private"
|
23
|
+
#
|
24
|
+
# check "test"
|
25
|
+
#
|
26
|
+
# # library "pathname", "set" # Standard libraries
|
27
|
+
# end
|
28
|
+
|
29
|
+
target :lib do
|
30
|
+
check "lib/procon_bypass_man/timer.rb"
|
31
|
+
check "lib/procon_bypass_man/uptime.rb"
|
32
|
+
check "lib/procon_bypass_man/configuration.rb"
|
33
|
+
|
34
|
+
signature "sig"
|
35
|
+
|
36
|
+
library "time"
|
37
|
+
library "logger"
|
38
|
+
library "monitor"
|
39
|
+
end
|
data/docs/setup_raspi.md
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
* /etc/dphys-swapfile を CONF_SWAPSIZE=1024 にする
|
14
14
|
* sudo /etc/init.d/dphys-swapfile restart && swapon -s
|
15
15
|
* tailscale をインストールする(optional)
|
16
|
-
* sudo apt-get install vim rbenv
|
16
|
+
* sudo apt-get install vim rbenv git -y
|
17
17
|
* rbenvでrubyを入れる
|
18
18
|
* git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
|
19
19
|
* rbenv install 3.0.1
|
@@ -22,20 +22,25 @@
|
|
22
22
|
* sshkeyを作成する
|
23
23
|
* github に鍵を登録する
|
24
24
|
* ~/.ssh/authorized_keys に鍵を登録する
|
25
|
-
* sudo pip3 install fluent-logger pytz
|
26
25
|
* ガジェットモードで起動する
|
27
26
|
* /boot/config.txtに、dtoverlay=dwc2を追記
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
* echo "dwc2" | sudo tee -a /etc/modules
|
28
|
+
* echo "libcomposite" | sudo tee -a /etc/modules
|
29
|
+
* sudo cat /etc/modules
|
31
30
|
* cd ~ && wget https://gist.githubusercontent.com/jiikko/3f9fb3194c0cc7685e31fbfcb5b5f9ff/raw/23ddee29d94350be80b79d290ac3c8ce8400bd88/add_procon_gadget.sh
|
32
31
|
* chmod 755 ~/add_procon_gadget.sh
|
33
32
|
* sudo reboot
|
34
33
|
* sudo sh ~/add_procon_gadget.sh の実行に成功させる
|
35
34
|
* /etc/rc.local に sh /home/pi/add_procon_gadget.sh って書く
|
36
|
-
* cd ~ && mkdir -p src && cd ~/src && git clone https://github.com/jiikko/procon_bypass_man_sample && cd
|
35
|
+
* cd ~ && mkdir -p src && cd ~/src && git clone https://github.com/jiikko/procon_bypass_man_sample && cd procon_bypass_man_sample
|
37
36
|
|
38
|
-
おわり. 起動する時は都度sudo ruby app.rb を実行する
|
37
|
+
おわり. 起動する時は都度 sudo ruby app.rb を実行する
|
39
38
|
|
40
39
|
## 参考
|
41
40
|
* https://mtosak-tech.hatenablog.jp/entry/2020/08/22/114622
|
41
|
+
|
42
|
+
# TIPS
|
43
|
+
* SDカードにイメージを焼くときは、ImagerのAdvanced Optionsを使うとセットアップが楽になる
|
44
|
+
* raspios_liteにした方が起動が早くなりそう
|
45
|
+
* https://qiita.com/Liesegang/items/dcdc669f80d1bf721c21
|
46
|
+
* http://ftp.jaist.ac.jp/pub/raspberrypi/raspios_lite_armhf
|
@@ -0,0 +1,60 @@
|
|
1
|
+
run_command "apt-get update"
|
2
|
+
|
3
|
+
package 'ruby' do
|
4
|
+
action :install
|
5
|
+
end
|
6
|
+
|
7
|
+
package 'vim' do
|
8
|
+
action :install
|
9
|
+
end
|
10
|
+
|
11
|
+
package 'git' do
|
12
|
+
action :install
|
13
|
+
end
|
14
|
+
|
15
|
+
gem_package 'bundler' do
|
16
|
+
action :install
|
17
|
+
end
|
18
|
+
|
19
|
+
# OTG
|
20
|
+
execute "append dtoverlay=dwc2 to /boot/config.txt" do
|
21
|
+
not_if "grep dtoverlay=dwc2 /boot/config.txt"
|
22
|
+
command "echo 'dtoverlay=dwc2' >> /boot/config.txt"
|
23
|
+
end
|
24
|
+
|
25
|
+
execute "append dwc2 to /etc/modules" do
|
26
|
+
not_if "grep dwc2 /etc/modules"
|
27
|
+
command "echo dwc2 >> /etc/modules"
|
28
|
+
end
|
29
|
+
|
30
|
+
execute "append libcomposite to /etc/modules" do
|
31
|
+
not_if "grep libcomposite /etc/modules"
|
32
|
+
command "echo libcomposite >> /etc/modules"
|
33
|
+
end
|
34
|
+
|
35
|
+
# PBM
|
36
|
+
execute "Initialize PBM" do
|
37
|
+
command <<~SHELL
|
38
|
+
sudo mkdir -p /usr/share/pbm/shared
|
39
|
+
wget https://gist.githubusercontent.com/jiikko/3f9fb3194c0cc7685e31fbfcb5b5f9ff/raw/23ddee29d94350be80b79d290ac3c8ce8400bd88/add_procon_gadget.sh -O /usr/share/pbm/shared/add_procon_gadget.sh
|
40
|
+
chmod +x /usr/share/pbm/shared/add_procon_gadget.sh
|
41
|
+
SHELL
|
42
|
+
end
|
43
|
+
|
44
|
+
# rbenv
|
45
|
+
execute "Install rbenv" do
|
46
|
+
not_if "which rbenv"
|
47
|
+
command "git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build"
|
48
|
+
end
|
49
|
+
|
50
|
+
# ruby
|
51
|
+
execute "Install ruby" do
|
52
|
+
not_if "rbenv versions | grep 3.0.1"
|
53
|
+
command "rbenv install 3.0.1"
|
54
|
+
end
|
55
|
+
|
56
|
+
run_command 'sudo systemctl disable triggerhappy.socket'
|
57
|
+
run_command 'sudo systemctl disable triggerhappy.service'
|
58
|
+
run_command 'sudo systemctl disable bluetooth'
|
59
|
+
run_command 'sudo systemctl disable apt-daily-upgrade.timer'
|
60
|
+
run_command 'sudo systemctl disable apt-daily.timer'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Raspberry Pi4のセットアップ手順 With mitamae
|
2
|
+
* SDカードにRaspberry Pi OS lite (32-bit)を焼く
|
3
|
+
* sshをできる状態で焼いておく
|
4
|
+
* SDカードをRaspberry Pi4本体に挿して起動する
|
5
|
+
* sshする
|
6
|
+
* curl -L https://github.com/itamae-kitchen/mitamae/releases/latest/download/mitamae-armhf-linux.tar.gz | tar xvz
|
7
|
+
* wget https://raw.githubusercontent.com/splaplapla/procon_bypass_man/master/docs/setup_raspi.mitamae.rb -O setup_raspi.mitamae.rb
|
8
|
+
* sudo ./mitamae-armhf-linux local setup_raspi.mitamae.rb -l debug
|
9
|
+
* sudo reboot
|
10
|
+
* sudo sh /usr/share/pbm/shared/add_procon_gadget.sh の実行に成功させる
|
11
|
+
* /etc/rc.local に sh /usr/share/pbm/shared/add_procon_gadget.sh って書く
|
12
|
+
* PCとRaspberry Pi4を接続し、プロコンとして認識していることを確認する
|
13
|
+
* sudo gem i pbmenv
|
14
|
+
* sudo pbmenv install latest
|
data/examples/practical/app.rb
CHANGED
@@ -8,8 +8,8 @@ require 'bundler/inline'
|
|
8
8
|
|
9
9
|
gemfile do
|
10
10
|
source 'https://rubygems.org'
|
11
|
-
gem 'procon_bypass_man', github: '
|
12
|
-
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"
|
13
13
|
end
|
14
14
|
|
15
15
|
ProconBypassMan.tap do |pbm|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class ProconBypassMan::BootMessage
|
2
|
+
def initialize
|
3
|
+
@table = {}
|
4
|
+
@table[:ruby_version] = RUBY_VERSION
|
5
|
+
@table[:pbm_version] = ProconBypassMan::VERSION
|
6
|
+
@table[:pid] = $$
|
7
|
+
@table[:root_path] = ProconBypassMan.root
|
8
|
+
@table[:pid_path] = ProconBypassMan.pid_path
|
9
|
+
@table[:setting_path] = ProconBypassMan::Configuration.instance.setting_path
|
10
|
+
@table[:uptime_from_boot] = ProconBypassMan::Uptime.from_boot
|
11
|
+
|
12
|
+
build_version = `git rev-parse --short HEAD`.chomp
|
13
|
+
if build_version.empty?
|
14
|
+
@table[:build_version] = 'release version'
|
15
|
+
else
|
16
|
+
@table[:build_version] = build_version
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
def to_s
|
22
|
+
booted_message = <<~EOF
|
23
|
+
----
|
24
|
+
RUBY_VERSION: #{@table[:ruby_version]}
|
25
|
+
ProconBypassMan: #{@table[:pbm_version]}
|
26
|
+
pid: #{@table[:pid]}
|
27
|
+
root: #{@table[:root_path]}
|
28
|
+
pid_path: #{@table[:pid_path]}
|
29
|
+
setting_path: #{@table[:setting_path]}
|
30
|
+
uptime from boot: #{@table[:uptime_from_boot]} sec
|
31
|
+
build version: #{@table[:build_version]}
|
32
|
+
----
|
33
|
+
EOF
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Hash]
|
37
|
+
def to_hash
|
38
|
+
@table
|
39
|
+
end
|
40
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class ProconBypassMan::Bypass
|
2
2
|
attr_accessor :gadget, :procon, :monitor
|
3
|
+
|
3
4
|
def initialize(gadget: , procon: , monitor: )
|
4
5
|
self.gadget = gadget
|
5
6
|
self.procon = procon
|
@@ -11,12 +12,13 @@ class ProconBypassMan::Bypass
|
|
11
12
|
monitor.record(:start_function)
|
12
13
|
input = nil
|
13
14
|
begin
|
14
|
-
|
15
|
-
|
15
|
+
return if $will_terminate_token
|
16
|
+
# TODO blocking readにしたい
|
17
|
+
input = self.gadget.read_nonblock(64)
|
16
18
|
ProconBypassMan.logger.debug { ">>> #{input.unpack("H*")}" }
|
17
19
|
rescue IO::EAGAINWaitReadable
|
18
20
|
monitor.record(:eagain_wait_readable_on_read)
|
19
|
-
|
21
|
+
sleep(0.001)
|
20
22
|
retry
|
21
23
|
end
|
22
24
|
|
@@ -26,23 +28,34 @@ class ProconBypassMan::Bypass
|
|
26
28
|
monitor.record(:eagain_wait_readable_on_write)
|
27
29
|
return
|
28
30
|
end
|
31
|
+
|
29
32
|
monitor.record(:end_function)
|
30
33
|
end
|
31
34
|
|
32
35
|
def send_procon_to_gadget!
|
33
36
|
monitor.record(:start_function)
|
34
37
|
output = nil
|
38
|
+
|
35
39
|
begin
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
return if $will_terminate_token
|
41
|
+
Timeout.timeout(1) do
|
42
|
+
output = self.procon.read(64)
|
43
|
+
ProconBypassMan.logger.debug { "<<< #{output.unpack("H*")}" }
|
44
|
+
end
|
45
|
+
rescue Timeout::Error
|
46
|
+
ProconBypassMan.logger.debug { "read timeout! do sleep. by send_procon_to_gadget!" }
|
47
|
+
ProconBypassMan.error_logger.error { "read timeout! do sleep. by send_procon_to_gadget!" }
|
48
|
+
monitor.record(:eagain_wait_readable_on_read)
|
49
|
+
retry
|
39
50
|
rescue IO::EAGAINWaitReadable
|
51
|
+
ProconBypassMan.logger.debug { "EAGAINWaitReadable" }
|
40
52
|
monitor.record(:eagain_wait_readable_on_read)
|
41
|
-
|
53
|
+
sleep(0.005)
|
42
54
|
retry
|
43
55
|
end
|
44
56
|
|
45
57
|
begin
|
58
|
+
# ProconBypassMan::Procon::DebugDumper.new(binary: output).dump_analog_sticks
|
46
59
|
self.gadget.write_nonblock(ProconBypassMan::Processor.new(output).process)
|
47
60
|
rescue IO::EAGAINWaitReadable
|
48
61
|
monitor.record(:eagain_wait_readable_on_write)
|