procon_bypass_man 0.1.3 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0ba281c9129f770b6cf905d9221bc39de1957f33d0091e2a5217c1fb4547be8
4
- data.tar.gz: ca0fbffd26fb3a7ad928803ea912a1fe6412a4b8d10a65acefbc21d0fe2f0b49
3
+ metadata.gz: 59fe04b1f616674f3f4a500fbc0abf1dce166482b2e7c880e94d0247a7162877
4
+ data.tar.gz: 55217706d204a06777fb9c9bfe87a64113dc2bdcfd0efa1079e79afc266690ce
5
5
  SHA512:
6
- metadata.gz: 0425a0610a7ec5d583724a167f45eaf8f352d552f4158901d02138dbfe89a5b66972f7767c72eab7ed30c6b199af25db10a1c9ef1fb826c188fc30255e81ea98
7
- data.tar.gz: 271542b52dce9d7b0980fb5f97c4fbab80b8fa9f03fc726dbf5034899d8a4f7a7cbdc10456a6016bcc81c038d8f0f3463a732d4a4cf7f4940b2ab652d0125d58
6
+ metadata.gz: 1c57e7ca180ec142258a4725197e928cf073358743c8e98a78cbd87c4419b05f47859d97428f86dabcaee68f7856596a697a9f211b1f928efd3bb88b9a840c2a
7
+ data.tar.gz: fa60bd01934dc80f811bd8871ba256c2cc70fb6cc6cbaa33fd180922fdde5bc70476234d00ce28303acb37229cace8137de540e29483af9d7dce926cd7e75fc6
data/.circleci/config.yml CHANGED
@@ -2,19 +2,46 @@ version: 2.1
2
2
  orbs:
3
3
  ruby: circleci/ruby@0.1.2
4
4
 
5
- jobs:
6
- build:
5
+ executors:
6
+ ruby:
7
+ parameters:
8
+ tag:
9
+ type: string
10
+ default: "latest"
7
11
  docker:
8
- - image: circleci/ruby:3.0.1
9
- executor: ruby/default
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
- 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: run test
20
- command: bundle exec rspec
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
+
36
+ build_jobs: &build_jobs
37
+ - rspec:
38
+ matrix:
39
+ parameters:
40
+ version:
41
+ - "2.5"
42
+ - "2.7"
43
+ - "3.0"
44
+ workflows:
45
+ version: 2
46
+ build:
47
+ jobs: *build_jobs
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,3 +1,23 @@
1
+ ## [0.1.7] - 2021-09-11
2
+ - Support pbmenv
3
+
4
+ ## [0.1.6] - 2021-08-19
5
+ - 設定ファイルを読み込むと内容のmd5を `pbm_root_dir/.setting_yaml_digest` へ出力するようにしました
6
+
7
+ ## [0.1.5] - 2021-07-29
8
+ - siwtch, proコンが電源OFF時にCPU使いまくるのを修正した
9
+ - 連打中に無視するボタンを複数登録できるようにした
10
+ - キーのリマップ先に複数ボタンを登録できるようにした
11
+ - 1つのボタンへ連打とリマップをできないようにしました
12
+ - NG ex)
13
+ - flip :zr, if_pressed: [:y]
14
+ - remap :zr, to: [:x]
15
+
16
+ ## [0.1.4] - 2021-07-11
17
+ - ProconBypassMan.rootの定義を、gem rootからproject rootへ変更した
18
+ - 連打の頻度を変更できるようにした
19
+ - シグナルで設定ファイルを読み直すとpid_pathが消滅する不具合を修正した
20
+
1
21
  ## [0.1.3] - 2021-07-03
2
22
  - 接続のしやすさ向上
3
23
 
data/Gemfile CHANGED
@@ -8,3 +8,5 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
  gem "rspec"
10
10
  gem "pry"
11
+ gem "timecop"
12
+ gem "rubocop", require: false
data/Gemfile.lock CHANGED
@@ -1,18 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- procon_bypass_man (0.1.3)
4
+ procon_bypass_man (0.1.7)
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)
15
- rake (13.0.3)
19
+ rainbow (3.0.0)
20
+ rake (13.0.6)
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.20.0)
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.9.1, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 1.4.0, < 3.0)
45
+ rubocop-ast (1.11.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
- 2.2.20
65
+ 2.2.15
data/README.md CHANGED
@@ -17,20 +17,20 @@ Switch <-- (PBM): ZR連打
17
17
  * Switch本体とドック
18
18
  * Raspberry Pi4 Model B/4GB(Raspberry Pi OS (32-bit))
19
19
  * 他のシリーズは未確認です
20
+ * zeroは非対応
20
21
  * データ通信が可能なUSBケーブル
21
22
 
22
23
  ## 使うソフトウェア
23
- * 必須
24
- * ruby-3.0.x
24
+ * ruby-3.0.x
25
25
 
26
26
  ## Usage
27
27
  * USBガジェットモードで起動するRaspberry Pi4を用意する
28
- * https://github.com/splaspla-hacker/procon_bypass_man/blob/master/docs/setup_raspi.md
28
+ * https://github.com/splaplapla/procon_bypass_man/blob/master/docs/setup_raspi.md
29
29
  * Raspberry Pi4で https://github.com/jiikko/procon_bypass_man_sample をclone して実行ファイルを動かす
30
- * 実行ファイルと設定ファイルについては https://github.com/splaspla-hacker/procon_bypass_man/wiki に詳細を書いていますが、まず動かすためにはcloneしたほうが早いです
30
+ * 実行ファイルと設定ファイルについては https://github.com/splaplapla/procon_bypass_man/wiki に詳細を書いていますが、まず動かすためにはcloneしたほうが早いです
31
31
 
32
32
  ## Plugins
33
- * https://github.com/splaspla-hacker/procon_bypass_man-splatoon2
33
+ * https://github.com/splaplapla/procon_bypass_man-splatoon2
34
34
 
35
35
  ## FAQ
36
36
  * どうやって動かすの?
@@ -38,7 +38,7 @@ Switch <-- (PBM): ZR連打
38
38
  * どうやって使うの?
39
39
  * ケーブルでそれらを接続した状態で、Raspberry Pi4にsshして本プログラムを起動することで使用します
40
40
  * ラズベリーパイ4のセットアップ方法は?
41
- * https://github.com/splaspla-hacker/procon_bypass_man/tree/master/docs/setup_raspi.md
41
+ * https://github.com/splaplapla/procon_bypass_man/tree/master/docs/setup_raspi.md
42
42
  * モード, マクロの違いは?
43
43
  * modeはProconの入力をそのまま再現するため機能。レイヤーを切り替えるまで繰り返し続ける
44
44
  * マクロは特定のキーを順番に入れていく機能。キーの入力が終わったらマクロは終了する
@@ -52,15 +52,14 @@ Switch <-- (PBM): ZR連打
52
52
  * 操作するdeviceファイルの所有者がrootだから
53
53
 
54
54
  ## TODO
55
- * 設定ファイルをwebから反映できる
56
- * ラズパイのプロビジョニングを楽にしたい
57
55
  * レコーディング機能(プロコンの入力をマクロとして登録ができる)
58
- * webページから設定ファイルを変更できるようにする(sshしたくない)
59
- * webサーバのデーモンとPBMはプロセスを分ける(NOTE)
56
+ * マクロにdelayを入れれるようにする
57
+ * 設定ファイル マクロの引数に、ボタンを取れるようにする
60
58
 
61
59
  ## 開発系
62
60
  ```ruby
63
61
  ProconBypassMan.tap do |pbm|
62
+ pbm.root = File.expand_path(__dir__)
64
63
  pbm.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
65
64
  pbm.logger.level = :debug
66
65
  end
@@ -71,6 +70,10 @@ end
71
70
  sudo kill -USR2 `cat ./pbm_pid`
72
71
  ```
73
72
 
73
+ ### リリース手順
74
+ * project_template/app.rb, lib/procon_bypass_man/version.rb のバージョンをあげる
75
+ * be rake release
76
+
74
77
  ## License
75
78
 
76
79
  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
@@ -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
-  * echo "dwc2" | sudo tee -a /etc/modules
29
-  * echo "libcomposite" | sudo tee -a /etc/modules
30
-  * sudo cat /etc/modules
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 procon_bypass_man && sudo bundle install
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,45 @@
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
+ run_command 'systemctl disable triggerhappy'
45
+ run_command 'systemctl disable bluetooth'
@@ -0,0 +1,13 @@
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
+ * TOOD install pbmenv
@@ -8,13 +8,14 @@ require 'bundler/inline'
8
8
 
9
9
  gemfile do
10
10
  source 'https://rubygems.org'
11
- gem 'procon_bypass_man', github: 'splaspla-hacker/procon_bypass_man', branch: "edge"
12
- gem 'procon_bypass_man-splatoon2', github: 'splaspla-hacker/procon_bypass_man-splatoon2', branch: "0.1.0"
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|
16
16
  pbm.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10) # 5世代まで残して, 10MBでローテーション
17
17
  pbm.logger.level = :debug
18
+ pbm.root = File.expand_path(__dir__)
18
19
  end
19
20
 
20
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]
@@ -12,11 +12,11 @@ module ProconBypassMan
12
12
  end
13
13
 
14
14
  # @param [Symbol] button
15
- def flip(button, if_pressed: false, channel: nil, force_neutral: nil)
15
+ def flip(button, if_pressed: false, force_neutral: nil, flip_interval: nil)
16
16
  case if_pressed
17
17
  when TrueClass
18
18
  if_pressed = [button]
19
- when Symbol
19
+ when Symbol, String
20
20
  if_pressed = [if_pressed]
21
21
  when Array, FalseClass
22
22
  # sono mama
@@ -24,23 +24,52 @@ module ProconBypassMan
24
24
  raise "not support class"
25
25
  end
26
26
  hash = { if_pressed: if_pressed }
27
- if channel
28
- hash[:channel] = channel
29
- end
30
27
  if force_neutral
31
- hash[:force_neutral] = force_neutral
28
+ case force_neutral
29
+ when TrueClass, FalseClass
30
+ raise "ボタンを渡してください"
31
+ when Symbol, String
32
+ hash[:force_neutral] = [force_neutral]
33
+ when Array
34
+ hash[:force_neutral] = force_neutral
35
+ end
36
+ end
37
+
38
+ if flip_interval
39
+ if /\A(\d+)F\z/i =~ flip_interval
40
+ interval = ((frame = $1.to_i) / 60.0).floor(2)
41
+ else
42
+ raise "8F みたいなフォーマットで入力してください"
43
+ end
44
+ hash[:flip_interval] = interval
45
+ end
46
+ if self.flips[button]
47
+ raise "#{button}への設定をすでに割り当て済みです"
48
+ else
49
+ self.flips[button] = hash
32
50
  end
33
- self.flips[button] = hash
34
51
  end
35
52
 
36
53
  PRESET_MACROS = [:fast_return]
37
54
  def macro(name, if_pressed: )
38
- self.macros[name] = { if_pressed: if_pressed }
55
+ if name.respond_to?(:name)
56
+ macro_name = name.name.to_sym
57
+ else
58
+ macro_name = name
59
+ end
60
+ self.macros[macro_name] = { if_pressed: if_pressed }
39
61
  end
40
62
 
41
63
  def remap(button, to: )
42
- raise "シンボル以外は設定できません" unless to.is_a?(Symbol)
43
- self.remaps[button] = to
64
+ case to
65
+ when TrueClass, FalseClass
66
+ raise "ボタンを渡してください"
67
+ when Symbol, String
68
+ self.remaps[button] = { to: [to] }
69
+ when Array
70
+ raise "ボタンを渡してください" if to.size.zero?
71
+ self.remaps[button] = { to: to }
72
+ end
44
73
  end
45
74
 
46
75
  # @return [Array]