procon_bypass_man 0.2.0 → 0.2.1
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/.github/workflows/gitleacks.yml +1 -0
- data/.github/workflows/release.yml +1 -0
- data/.github/workflows/ruby.yml +1 -1
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +2 -2
- data/docs/getting_started.md +7 -0
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +3 -0
- data/lib/procon_bypass_man/bypass.rb +2 -5
- data/lib/procon_bypass_man/configuration.rb +1 -1
- data/lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb +1 -1
- 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 +10 -0
- data/lib/procon_bypass_man/runner.rb +1 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man.rb +1 -0
- data/project_template/app.rb +5 -4
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b867d9fe101999d57ded64ff71be83610f04fde36c1c1fffa43ca8495902fb0b
|
4
|
+
data.tar.gz: 8eb0b7506c7bdb5d4601fb0e6f33cff79cb71a4975449d0c84bcd6a2c0b6303a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a37867fc758ecb8aa45698fbb79be8b48cc221cd218bf6c29646b04587ae66514846709cd1bf951a651ec1ba737cab5dbae010334cb125bc8dca1644d19aa30e
|
7
|
+
data.tar.gz: d2cf7935350a3085251deb495051586b52b422d388bfd07da7842c09fbc3f50fa0b6090a41652e662d15e367863c76e0b3a2e9e061e87a7e100f3d1e7d9be58e
|
data/.github/workflows/ruby.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
+
## [0.2.1] - 2022-05-29
|
2
|
+
- 入力表示機能を提供するSwitchProconInputViewerに対応しました
|
3
|
+
- https://github.com/splaplapla/switch-procon-input-viewer
|
4
|
+
- app.rb内のバグ修正, ログファイルとして残る世代を減らしました
|
5
|
+
|
1
6
|
## [0.2.0] - 2022-05-20
|
2
|
-
- 3
|
7
|
+
- 3つ以上のボタンを操作するマクロに対応しました
|
3
8
|
- IOに関するログをデフォルトで無効にしました
|
4
9
|
- 有効にする場合はapp.rbに `config.io_monitor_logging = true` を記述してください
|
5
10
|
- 接続が安定化するまでの時間が短くなりました
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.2.
|
4
|
+
procon_bypass_man (0.2.1)
|
5
5
|
action_cable_client
|
6
6
|
pbmenv (>= 0.1.9)
|
7
7
|
sorted_set
|
@@ -40,7 +40,7 @@ GEM
|
|
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/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
|
### ラズベリーパイのセットアップ
|
@@ -162,6 +165,10 @@ open_macro :sokuwari, steps: [:toggle_r_for_0_2sec, :toggle_thumbr_for_0_14sec,
|
|
162
165
|
## 左スティックの感度調整
|
163
166
|
[左スティックの感度調整](/docs/setting/left-analogstick-cap.md)
|
164
167
|
|
168
|
+
## 入力表示
|
169
|
+
* https://github.com/splaplapla/switch-procon-input-viewer
|
170
|
+
* 後で書きます
|
171
|
+
|
165
172
|
## 設定ファイルの書き方
|
166
173
|
* 後で書きます
|
167
174
|
|
@@ -32,6 +32,9 @@ class ProconBypassMan::Bypass
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
# TODO 別のコールバッククラスから実行したい
|
36
|
+
ProconBypassMan::ProconDisplay::Status.instance.current = bypass_value.binary.to_procon_reader.to_hash.dup
|
37
|
+
|
35
38
|
if ProconBypassMan.config.enable_reporting_pressed_buttons
|
36
39
|
ProconBypassMan.cache.fetch key: 'pressed_buttons_reporter', expires_in: 5 do
|
37
40
|
ProconBypassMan::ReportPressedButtonsJob.perform_async(
|
@@ -3,6 +3,8 @@ require "procon_bypass_man/bypass/bypass_command"
|
|
3
3
|
|
4
4
|
class ProconBypassMan::Bypass
|
5
5
|
include ProconBypassMan::Bypass::UsbHidLogger
|
6
|
+
# TODO callbackモジュールを修正して複数のメソッドをチェインできるようにする
|
7
|
+
# include ProconBypassMan::ProconDisplay::BypassCallback
|
6
8
|
|
7
9
|
class BypassValue < Struct.new(:binary)
|
8
10
|
def to_text
|
@@ -105,9 +107,4 @@ class ProconBypassMan::Bypass
|
|
105
107
|
self.procon.write_nonblock(["8005"].pack("H*"))
|
106
108
|
self.procon.write_nonblock(["8005"].pack("H*"))
|
107
109
|
end
|
108
|
-
|
109
|
-
# @return [void] 入力してから取り出さないと接続しっぱなしになるっぽいのでこれが必要っぽい
|
110
|
-
def be_empty_procon
|
111
|
-
# タイムアウトまでブロッキングされるので、プロセスに逃す
|
112
|
-
end
|
113
110
|
end
|
@@ -104,7 +104,7 @@ class ProconBypassMan::Configuration
|
|
104
104
|
|
105
105
|
def error_logger
|
106
106
|
if enable_critical_error_logging
|
107
|
-
@error_logger ||= Logger.new("#{ProconBypassMan.root}/error.log",
|
107
|
+
@error_logger ||= Logger.new("#{ProconBypassMan.root}/error.log", 1, 1024 * 1024 * 1)
|
108
108
|
else
|
109
109
|
Logger.new(File.open("/dev/null"))
|
110
110
|
end
|
@@ -24,6 +24,7 @@ class ProconBypassMan::DeviceConnection::OutputReportSubCommandTable
|
|
24
24
|
IGNORE_SUB_COMMANDS = {
|
25
25
|
"48-01" => true,
|
26
26
|
"04-00" => true,
|
27
|
+
"10-28" => true, # 返ってこないことがあった
|
27
28
|
}
|
28
29
|
# レスポンスに引数が含まれない
|
29
30
|
SPECIAL_SUB_COMMANDS = [
|
@@ -46,7 +47,6 @@ class ProconBypassMan::DeviceConnection::OutputReportSubCommandTable
|
|
46
47
|
"10-80",
|
47
48
|
"10-98",
|
48
49
|
"10-10",
|
49
|
-
"10-28",
|
50
50
|
"30-",
|
51
51
|
"40-",
|
52
52
|
"48-", # Enable vibration
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ProconBypassMan::ProconDisplay
|
2
|
+
# NOTE Support GET only
|
3
|
+
class HttpRequest
|
4
|
+
def self.parse(conn)
|
5
|
+
headers = {}
|
6
|
+
loop do
|
7
|
+
line = conn.gets("\n")&.strip
|
8
|
+
break if line.nil? || line.strip.empty?
|
9
|
+
key, value = line.split(/:\s/, 2)
|
10
|
+
headers[key] = value
|
11
|
+
end
|
12
|
+
|
13
|
+
new(headers)
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(headers)
|
17
|
+
@headers = headers
|
18
|
+
end
|
19
|
+
|
20
|
+
def path
|
21
|
+
request_method_and_path = @headers.detect { |key, _value| key.start_with?("GET") }.first
|
22
|
+
if request_method_and_path =~ /(?:GET) ([^ ]+)/ && (path = $1)
|
23
|
+
return path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_hash
|
28
|
+
{ "PATH" => path }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ProconBypassMan::ProconDisplay
|
2
|
+
class HttpResponse
|
3
|
+
def initialize(body, status: , format: "text/json")
|
4
|
+
@body = body&.to_json
|
5
|
+
@status = status
|
6
|
+
@format = format
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
<<~EOH
|
11
|
+
HTTP/1.1 #{@status}
|
12
|
+
Content-Length: #{@body&.bytes&.size || 0}
|
13
|
+
Content-Type: #{@format}
|
14
|
+
Access-Control-Allow-Origin: *
|
15
|
+
Access-Control-Allow-Methods: GET
|
16
|
+
Access-Control-Allow-Private-Network:true
|
17
|
+
Connection: close
|
18
|
+
|
19
|
+
#{@body}
|
20
|
+
EOH
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
module ProconBypassMan::ProconDisplay
|
4
|
+
class Server
|
5
|
+
PORT = 9900
|
6
|
+
|
7
|
+
def self.start!
|
8
|
+
Thread.new do
|
9
|
+
new.start_with_foreground
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@server = TCPServer.new('0.0.0.0', PORT)
|
15
|
+
end
|
16
|
+
|
17
|
+
def start_with_foreground
|
18
|
+
loop do
|
19
|
+
conn = @server.accept
|
20
|
+
response = ServerApp.new(
|
21
|
+
HttpRequest.parse(conn).to_hash
|
22
|
+
).call
|
23
|
+
conn.write(response)
|
24
|
+
conn.close
|
25
|
+
end
|
26
|
+
rescue Errno::EADDRINUSE => e
|
27
|
+
ProconBypassMan::SendErrorCommand.execute(error: e)
|
28
|
+
rescue => e
|
29
|
+
ProconBypassMan::SendErrorCommand.execute(error: e)
|
30
|
+
retry
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ProconBypassMan::ProconDisplay
|
2
|
+
class ServerApp
|
3
|
+
def initialize(env)
|
4
|
+
@env = env
|
5
|
+
end
|
6
|
+
|
7
|
+
def call
|
8
|
+
case @env["PATH"]
|
9
|
+
when "/input"
|
10
|
+
response = ProconBypassMan::ProconDisplay::Status.instance.current
|
11
|
+
HttpResponse.new(response, status: 200).to_s
|
12
|
+
else
|
13
|
+
HttpResponse.new(nil, status: 404).to_s
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
class ProconBypassMan::ProconDisplay::Status
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
# @return [Hash]
|
7
|
+
def current
|
8
|
+
@current || {}
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [void]
|
12
|
+
# @param [Hash] value
|
13
|
+
def current=(value)
|
14
|
+
if value.is_a?(Hash)
|
15
|
+
@current = value
|
16
|
+
else
|
17
|
+
@current = nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# 入力表示用
|
2
|
+
|
3
|
+
module ProconBypassMan::ProconDisplay
|
4
|
+
end
|
5
|
+
|
6
|
+
require "procon_bypass_man/procon_display/server"
|
7
|
+
require "procon_bypass_man/procon_display/server_app"
|
8
|
+
require "procon_bypass_man/procon_display/status"
|
9
|
+
require "procon_bypass_man/procon_display/http_response"
|
10
|
+
require "procon_bypass_man/procon_display/http_request"
|
@@ -28,6 +28,7 @@ class ProconBypassMan::Runner
|
|
28
28
|
$will_terminate_token = false
|
29
29
|
DRb.start_service if defined?(DRb)
|
30
30
|
ProconBypassMan::RemoteMacroReceiver.start!
|
31
|
+
ProconBypassMan::ProconDisplay::Server.start!
|
31
32
|
ProconBypassMan::BypassCommand.new(gadget: @gadget, procon: @procon).execute # ここでblockingする
|
32
33
|
next
|
33
34
|
}
|
data/lib/procon_bypass_man.rb
CHANGED
@@ -36,6 +36,7 @@ require_relative "procon_bypass_man/support/server_pool"
|
|
36
36
|
require_relative "procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler"
|
37
37
|
require_relative "procon_bypass_man/support/never_exit_accidentally"
|
38
38
|
require_relative "procon_bypass_man/support/cycle_sleep"
|
39
|
+
require_relative "procon_bypass_man/procon_display"
|
39
40
|
require_relative "procon_bypass_man/background"
|
40
41
|
require_relative "procon_bypass_man/commands"
|
41
42
|
require_relative "procon_bypass_man/bypass"
|
data/project_template/app.rb
CHANGED
@@ -6,12 +6,13 @@ begin
|
|
6
6
|
gemfile do
|
7
7
|
source 'https://rubygems.org'
|
8
8
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
9
|
-
gem 'procon_bypass_man', '0.2.
|
9
|
+
gem 'procon_bypass_man', '0.2.1'
|
10
10
|
end
|
11
11
|
rescue Bundler::Source::Git::GitCommandError => e
|
12
12
|
# install中に強制終了するとgitの管理ファイルが不正状態になり、次のエラーが起きるので発生したらcache directoryを削除する
|
13
13
|
#"Git error: command `git fetch --force --quiet --tags https://github.com/splaplapla/procon_bypass_man refs/heads/\\*:refs/heads/\\*` in directory /home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af has failed.\n\nIf this error persists you could try removing the cache directory '/home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af'"
|
14
14
|
if /try removing the cache directory '([^']+)'/ =~ e.message
|
15
|
+
require 'fileutils'
|
15
16
|
FileUtils.rm_rf($1)
|
16
17
|
retry
|
17
18
|
end
|
@@ -19,7 +20,7 @@ end
|
|
19
20
|
|
20
21
|
ProconBypassMan.configure do |config|
|
21
22
|
config.root = File.expand_path(__dir__)
|
22
|
-
config.logger = Logger.new("#{ProconBypassMan.root}/app.log",
|
23
|
+
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 1, 1024 * 1024 * 1)
|
23
24
|
config.logger.level = :debug
|
24
25
|
|
25
26
|
# バイパスするログを全部app.logに流すか
|
@@ -40,8 +41,8 @@ ProconBypassMan.configure do |config|
|
|
40
41
|
# 接続に成功したらコントローラーのHOME LEDを光らせるか
|
41
42
|
config.enable_home_led_on_connect = true
|
42
43
|
|
43
|
-
# 操作が高頻度で固まるときは、 gadget_to_procon_interval
|
44
|
-
config.bypass_mode = { mode: :normal, gadget_to_procon_interval:
|
44
|
+
# 操作が高頻度で固まるときは、 gadget_to_procon_interval の数値を大きくしてください
|
45
|
+
config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 10 }
|
45
46
|
end
|
46
47
|
|
47
48
|
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pbmenv
|
@@ -184,6 +184,12 @@ files:
|
|
184
184
|
- lib/procon_bypass_man/procon/value_objects/bypass_mode.rb
|
185
185
|
- lib/procon_bypass_man/procon/value_objects/procon_reader.rb
|
186
186
|
- lib/procon_bypass_man/procon/value_objects/rumble_binary.rb
|
187
|
+
- lib/procon_bypass_man/procon_display.rb
|
188
|
+
- lib/procon_bypass_man/procon_display/http_request.rb
|
189
|
+
- lib/procon_bypass_man/procon_display/http_response.rb
|
190
|
+
- lib/procon_bypass_man/procon_display/server.rb
|
191
|
+
- lib/procon_bypass_man/procon_display/server_app.rb
|
192
|
+
- lib/procon_bypass_man/procon_display/status.rb
|
187
193
|
- lib/procon_bypass_man/remote_macro.rb
|
188
194
|
- lib/procon_bypass_man/remote_macro/queue_over_process.rb
|
189
195
|
- lib/procon_bypass_man/remote_macro/remote_macro_object.rb
|