procon_bypass_man 0.1.22 → 0.1.23
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 +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +4 -4
- data/docs/getting_started.md +2 -1
- data/lib/procon_bypass_man/bypass.rb +45 -22
- data/lib/procon_bypass_man/commands/bypass_command.rb +30 -10
- data/lib/procon_bypass_man/commands/print_boot_message_command.rb +1 -1
- data/lib/procon_bypass_man/device_connector.rb +54 -170
- data/lib/procon_bypass_man/procon/suppress_rumble.rb +13 -0
- data/lib/procon_bypass_man/{domains → procon/value_objects}/analog_stick_position.rb +0 -0
- data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/base.rb +0 -0
- data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/has_immutable_binary.rb +0 -0
- data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/has_mutable_binary.rb +0 -0
- data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/inbound_procon_binary.rb +5 -0
- data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/processing_procon_binary.rb +0 -0
- data/lib/procon_bypass_man/procon/value_objects/binary.rb +11 -0
- data/lib/procon_bypass_man/{domains → procon/value_objects}/bypass_mode.rb +0 -0
- data/lib/procon_bypass_man/procon/value_objects/rumble_binary.rb +18 -0
- data/lib/procon_bypass_man/procon.rb +8 -0
- data/lib/procon_bypass_man/runner.rb +7 -7
- data/lib/procon_bypass_man/support/cycle_sleep.rb +22 -0
- data/lib/procon_bypass_man/support/device_mouse_finder.rb +60 -0
- data/lib/procon_bypass_man/{device_procon_finder.rb → support/device_procon_finder.rb} +0 -0
- data/lib/procon_bypass_man/support/safe_timeout.rb +7 -1
- data/lib/procon_bypass_man/{usb_device_controller.rb → support/usb_device_controller.rb} +7 -2
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man.rb +10 -20
- data/project_template/app.rb +13 -4
- data/sig/main.rbs +1 -13
- metadata +16 -12
- data/lib/procon_bypass_man/domains.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: f0250a1a8546982fa0d1924606cfeb65b0376b1f0bbd2849a8c6faba39551c1a
|
4
|
+
data.tar.gz: 94301f2c9540d370e55479f9ae818de0b0e64ece99b7ad7b44698f8828e241d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8819eed593368519dde453cdb44168c4d05066ec6a52d22b8ca61f57a4f67d59307b41d4cb814a9b89dc2590cab17036ab2c2acf6c460213193cecf3380f8cb7
|
7
|
+
data.tar.gz: 5ba74b2733493a2efb74fd9f73ffa5d6a9103acb5e1bd2d050e5c14146e739da4b48e25e84431cab1655e3d9a48a5f8249974f66da5ecc55f8efb4a66c3e86e7
|
data/.circleci/config.yml
CHANGED
@@ -40,7 +40,7 @@ jobs:
|
|
40
40
|
tag: 3.0.1
|
41
41
|
steps:
|
42
42
|
- checkout
|
43
|
-
- run: GEM_VERSION=$(grep -o -E '[0-9.]+' lib/procon_bypass_man/version.rb) && GEM_VERSION_IN_BUNDER=$(grep procon_bypass_man project_template/app.rb | grep -o -E '[0-9.]+') && test "$GEM_VERSION" = "$GEM_VERSION_IN_BUNDER"
|
43
|
+
- run: GEM_VERSION=$(grep -o -E '[0-9.]+' lib/procon_bypass_man/version.rb) && GEM_VERSION_IN_BUNDER=$(grep procon_bypass_man project_template/app.rb | grep "gem 'procon_bypass_man'" | grep -o -E '[0-9.]+') && test "$GEM_VERSION" = "$GEM_VERSION_IN_BUNDER"
|
44
44
|
|
45
45
|
syntax_check:
|
46
46
|
parameters:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.1.23] - 2022-05-04
|
2
|
+
- プロセスを停止するとプロコンがBluetooth経由でSwitchと接続するようになりました
|
3
|
+
- 起動時に表示するdevice_idを一部のみ表示するようになりました
|
4
|
+
- ライブリロードが不安定になっていたのを修正しました
|
5
|
+
- コントローラのバイブレーションを無効にしました
|
6
|
+
- プロセスを停止後、再接続しやすくなりました
|
7
|
+
|
1
8
|
## [0.1.22] - 2022-04-09
|
2
9
|
* スティックを左右に入れるマクロが使えるようになりました
|
3
10
|
* スプラトゥーン2でのタンサンボムのチャージに使えます
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.1.
|
4
|
+
procon_bypass_man (0.1.23)
|
5
5
|
action_cable_client
|
6
6
|
pbmenv (>= 0.1.9)
|
7
7
|
sorted_set
|
@@ -41,7 +41,7 @@ GEM
|
|
41
41
|
coderay (~> 1.1)
|
42
42
|
method_source (~> 1.0)
|
43
43
|
rack (2.2.3)
|
44
|
-
rack-protection (2.
|
44
|
+
rack-protection (2.2.0)
|
45
45
|
rack
|
46
46
|
rainbow (3.0.0)
|
47
47
|
rake (13.0.6)
|
@@ -79,10 +79,10 @@ GEM
|
|
79
79
|
ruby-progressbar (1.11.0)
|
80
80
|
ruby2_keywords (0.0.5)
|
81
81
|
set (1.0.2)
|
82
|
-
sinatra (2.
|
82
|
+
sinatra (2.2.0)
|
83
83
|
mustermann (~> 1.0)
|
84
84
|
rack (~> 2.2)
|
85
|
-
rack-protection (= 2.
|
85
|
+
rack-protection (= 2.2.0)
|
86
86
|
tilt (~> 2.0)
|
87
87
|
sorted_set (1.0.3)
|
88
88
|
rbtree
|
data/docs/getting_started.md
CHANGED
@@ -180,6 +180,7 @@ discordで質問してみてください。
|
|
180
180
|
https://pbm-cloud.herokuapp.com/
|
181
181
|
procon_bypass_man_cloudの運用をWEBで完結できるようになる無料のWEBサービスです。
|
182
182
|
|
183
|
-
procon_bypass_man_cloudとの接続が完了後、Raspberry Piを起動時に
|
183
|
+
procon_bypass_man_cloudとの接続が完了後、Raspberry Piを起動時にprocon_bypass_manが自動で立ち上がるように設定すれば、Raspberry Piへのログインが不要で設定ファイルの変更やprocon_bypass_man自体のアップグレードができます。
|
184
184
|
セットアップ方法などでわからないことがあればdiscordで質問してみてください。
|
185
|
+
|
185
186
|
セットアップ方法は https://pbm-cloud.herokuapp.com/faq に書いています。
|
@@ -3,10 +3,10 @@ require "procon_bypass_man/bypass/usb_hid_logger"
|
|
3
3
|
class ProconBypassMan::Bypass
|
4
4
|
include ProconBypassMan::Bypass::UsbHidLogger
|
5
5
|
|
6
|
-
class BypassValue < Struct.new(:binary
|
6
|
+
class BypassValue < Struct.new(:binary)
|
7
7
|
def to_text
|
8
8
|
return unless binary
|
9
|
-
|
9
|
+
binary.unpack.first
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -21,23 +21,32 @@ class ProconBypassMan::Bypass
|
|
21
21
|
# ゆっくりでいい
|
22
22
|
def send_gadget_to_procon!
|
23
23
|
monitor.record(:start_function)
|
24
|
-
|
25
|
-
self.bypass_value = BypassValue.new(nil, sent = false)
|
24
|
+
self.bypass_value = BypassValue.new(nil)
|
26
25
|
|
27
26
|
run_callbacks(:send_gadget_to_procon) do
|
27
|
+
break if $will_terminate_token
|
28
|
+
|
29
|
+
raw_input = nil
|
28
30
|
begin
|
29
|
-
break if $will_terminate_token
|
30
31
|
# TODO blocking readにしたいが、接続時のフェーズによって長さが違うので厳しい
|
31
|
-
|
32
|
-
self.bypass_value.binary = ProconBypassMan::Domains::InboundProconBinary.new(binary:
|
32
|
+
raw_input = self.gadget.read_nonblock(64)
|
33
|
+
self.bypass_value.binary = ProconBypassMan::Domains::InboundProconBinary.new(binary: raw_input)
|
33
34
|
rescue IO::EAGAINWaitReadable
|
34
35
|
monitor.record(:eagain_wait_readable_on_read)
|
35
36
|
end
|
36
37
|
|
37
|
-
if
|
38
|
+
if self.bypass_value.binary
|
38
39
|
begin
|
39
|
-
|
40
|
-
|
40
|
+
raw_data =
|
41
|
+
case
|
42
|
+
when self.bypass_value.binary.rumble_data?
|
43
|
+
binary = ProconBypassMan::RumbleBinary.new(binary: self.bypass_value.binary.raw)
|
44
|
+
binary.noop!
|
45
|
+
binary.raw
|
46
|
+
else
|
47
|
+
self.bypass_value.binary.raw
|
48
|
+
end
|
49
|
+
self.procon.write_nonblock(raw_data)
|
41
50
|
rescue IO::EAGAINWaitReadable
|
42
51
|
monitor.record(:eagain_wait_readable_on_write)
|
43
52
|
break
|
@@ -50,15 +59,15 @@ class ProconBypassMan::Bypass
|
|
50
59
|
|
51
60
|
def send_procon_to_gadget!
|
52
61
|
monitor.record(:start_function)
|
53
|
-
|
54
|
-
self.bypass_value = BypassValue.new(nil, sent = false)
|
62
|
+
self.bypass_value = BypassValue.new(nil)
|
55
63
|
|
56
64
|
run_callbacks(:send_procon_to_gadget) do
|
65
|
+
break if $will_terminate_token
|
66
|
+
|
57
67
|
begin
|
58
|
-
break if $will_terminate_token
|
59
68
|
Timeout.timeout(1) do
|
60
|
-
|
61
|
-
self.bypass_value.binary = ProconBypassMan::Domains::InboundProconBinary.new(binary:
|
69
|
+
raw_output = self.procon.read(64)
|
70
|
+
self.bypass_value.binary = ProconBypassMan::Domains::InboundProconBinary.new(binary: raw_output)
|
62
71
|
end
|
63
72
|
rescue Timeout::Error
|
64
73
|
ProconBypassMan.logger.debug { "read timeout! do sleep. by send_procon_to_gadget!" }
|
@@ -73,16 +82,10 @@ class ProconBypassMan::Bypass
|
|
73
82
|
retry
|
74
83
|
end
|
75
84
|
|
76
|
-
# blocking readをしているのでnilが入ることはないが、雑なテストでnilが通るので分岐を入れる。できれば消したい
|
77
|
-
break if output.nil?
|
78
|
-
|
79
85
|
begin
|
80
86
|
self.gadget.write_nonblock(
|
81
|
-
ProconBypassMan::Processor.new(
|
82
|
-
ProconBypassMan::Domains::InboundProconBinary.new(binary: output)
|
83
|
-
).process
|
87
|
+
ProconBypassMan::Processor.new(bypass_value.binary).process
|
84
88
|
)
|
85
|
-
self.bypass_value.sent = true
|
86
89
|
rescue IO::EAGAINWaitReadable
|
87
90
|
monitor.record(:eagain_wait_readable_on_write)
|
88
91
|
break
|
@@ -90,4 +93,24 @@ class ProconBypassMan::Bypass
|
|
90
93
|
end
|
91
94
|
monitor.record(:end_function)
|
92
95
|
end
|
96
|
+
|
97
|
+
# @return [void]
|
98
|
+
def direct_connect_switch_via_bluetooth
|
99
|
+
ProconBypassMan.logger.debug { "direct_connect_switch_via_bluetooth!" }
|
100
|
+
self.procon.write_nonblock(["8005"].pack("H*"))
|
101
|
+
self.procon.write_nonblock(["8005"].pack("H*"))
|
102
|
+
self.procon.write_nonblock(["8005"].pack("H*"))
|
103
|
+
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
|
93
116
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
class ProconBypassMan::BypassCommand
|
2
2
|
include ProconBypassMan::SignalHandler
|
3
3
|
|
4
|
+
module WILL_TERMINATE_TOKEN
|
5
|
+
TERMINATE = :terminate
|
6
|
+
RESTART = :restart
|
7
|
+
end
|
8
|
+
|
4
9
|
def initialize(gadget:, procon:)
|
5
10
|
@gadget = gadget
|
6
11
|
@procon = procon
|
@@ -12,7 +17,7 @@ class ProconBypassMan::BypassCommand
|
|
12
17
|
|
13
18
|
def execute
|
14
19
|
self_read, self_write = IO.pipe
|
15
|
-
%w(TERM INT).each do |sig|
|
20
|
+
%w(TERM INT USR2).each do |sig|
|
16
21
|
begin
|
17
22
|
trap sig do
|
18
23
|
self_write.puts(sig)
|
@@ -28,17 +33,19 @@ class ProconBypassMan::BypassCommand
|
|
28
33
|
monitor2 = ProconBypassMan::IOMonitor.new(label: "procon -> switch")
|
29
34
|
ProconBypassMan.logger.info "Thread1を起動します"
|
30
35
|
|
31
|
-
|
36
|
+
cycle_sleep = ProconBypassMan::CycleSleep.new(cycle_interval: 0.005, execution_cycle: 0)
|
32
37
|
|
33
38
|
t1 = Thread.new do
|
34
39
|
timer = ProconBypassMan::SafeTimeout.new(timeout: Time.now + 10)
|
35
40
|
@did_first_step = false
|
36
41
|
loop do
|
37
|
-
bypass = ProconBypassMan::Bypass.new(gadget: @gadget, procon: @procon, monitor: monitor1)
|
38
42
|
break if $will_terminate_token
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
|
44
|
+
cycle_sleep.sleep_or_execute do
|
45
|
+
bypass = ProconBypassMan::Bypass.new(gadget: @gadget, procon: @procon, monitor: monitor1)
|
46
|
+
!@did_first_step && timer.throw_if_timeout!
|
47
|
+
bypass.send_gadget_to_procon!
|
48
|
+
end
|
42
49
|
rescue ProconBypassMan::SafeTimeout::Timeout
|
43
50
|
case ProconBypassMan.config.bypass_mode.mode
|
44
51
|
when ProconBypassMan::BypassMode::TYPE_AGGRESSIVE
|
@@ -47,7 +54,7 @@ class ProconBypassMan::BypassCommand
|
|
47
54
|
break
|
48
55
|
when ProconBypassMan::BypassMode::TYPE_NORMAL
|
49
56
|
ProconBypassMan.logger.info "10秒経過したのでsend_intervalを長くします"
|
50
|
-
|
57
|
+
cycle_sleep = ProconBypassMan::CycleSleep.new(cycle_interval: 1, execution_cycle: ProconBypassMan.config.bypass_mode.gadget_to_procon_interval)
|
51
58
|
else
|
52
59
|
raise "unknown type"
|
53
60
|
end
|
@@ -69,7 +76,14 @@ class ProconBypassMan::BypassCommand
|
|
69
76
|
t2 = Thread.new do
|
70
77
|
bypass = ProconBypassMan::Bypass.new(gadget: @gadget, procon: @procon, monitor: monitor2)
|
71
78
|
loop do
|
72
|
-
|
79
|
+
if $will_terminate_token
|
80
|
+
if $will_terminate_token == WILL_TERMINATE_TOKEN::TERMINATE
|
81
|
+
bypass.direct_connect_switch_via_bluetooth
|
82
|
+
bypass.be_empty_procon
|
83
|
+
end
|
84
|
+
break
|
85
|
+
end
|
86
|
+
|
73
87
|
bypass.send_procon_to_gadget!
|
74
88
|
rescue EOFError => e
|
75
89
|
ProconBypassMan::SendErrorCommand.execute(error: "Proconが切断されました。終了処理を開始します. #{e.full_message}")
|
@@ -87,12 +101,18 @@ class ProconBypassMan::BypassCommand
|
|
87
101
|
signal = readable_io.first[0].gets.strip
|
88
102
|
handle_signal(signal)
|
89
103
|
end
|
104
|
+
rescue ProconBypassMan::Runner::InterruptForRestart
|
105
|
+
$will_terminate_token = WILL_TERMINATE_TOKEN::RESTART
|
106
|
+
[t1, t2].each(&:join)
|
107
|
+
@gadget&.close
|
108
|
+
@procon&.close
|
109
|
+
exit! 1 # child processなのでexitしていい
|
90
110
|
rescue Interrupt
|
91
|
-
$will_terminate_token =
|
111
|
+
$will_terminate_token = WILL_TERMINATE_TOKEN::TERMINATE
|
92
112
|
[t1, t2].each(&:join)
|
93
113
|
@gadget&.close
|
94
114
|
@procon&.close
|
95
|
-
exit 1 # child processなのでexitしていい
|
115
|
+
exit! 1 # child processなのでexitしていい
|
96
116
|
end
|
97
117
|
end
|
98
118
|
end
|
@@ -42,7 +42,7 @@ class ProconBypassMan::PrintBootMessageCommand
|
|
42
42
|
uptime from boot: #{@table[:uptime_from_boot]} sec
|
43
43
|
use_pbmenv: #{@table[:use_pbmenv]}
|
44
44
|
session_id: #{ProconBypassMan.session_id}
|
45
|
-
device_id: #{ProconBypassMan.device_id}
|
45
|
+
device_id: #{ProconBypassMan.device_id.gsub(/.{25}$/, "*"*25)}
|
46
46
|
bypass_mode: #{ProconBypassMan.config.bypass_mode}
|
47
47
|
----
|
48
48
|
EOF
|
@@ -1,17 +1,22 @@
|
|
1
|
+
require "timeout"
|
2
|
+
|
1
3
|
class ProconBypassMan::DeviceConnector
|
2
4
|
class BytesMismatchError < StandardError; end
|
3
5
|
class NotFoundProconError < StandardError; end
|
4
6
|
|
5
7
|
class Value
|
6
|
-
attr_accessor :read_from, :values
|
7
|
-
|
8
|
+
attr_accessor :read_from, :values, :call_block_if_receive, :block
|
9
|
+
|
10
|
+
def initialize(values: , read_from: , call_block_if_receive: false, &block)
|
8
11
|
@values = values
|
9
12
|
@read_from = read_from
|
13
|
+
@call_block_if_receive = call_block_if_receive
|
14
|
+
@block = block
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
13
18
|
def self.connect
|
14
|
-
s = new(throw_error_if_timeout: true
|
19
|
+
s = new(throw_error_if_timeout: true)
|
15
20
|
s.add([
|
16
21
|
["0000"],
|
17
22
|
["0000"],
|
@@ -26,23 +31,30 @@ class ProconBypassMan::DeviceConnector
|
|
26
31
|
s.add([/^8102/], read_from: :procon)
|
27
32
|
# 3
|
28
33
|
s.add([/^0100/], read_from: :switch)
|
29
|
-
s.add([/^21/], read_from: :procon)
|
34
|
+
s.add([/^21/], read_from: :procon, call_block_if_receive: /^8101/) do |this|
|
35
|
+
ProconBypassMan.logger.info "(start special route)"
|
36
|
+
this.blocking_read_with_timeout_from_procon # <<< 810100032dbd42e9b698000
|
37
|
+
this.write_to_procon("8002")
|
38
|
+
this.blocking_read_with_timeout_from_procon # <<< 8102
|
39
|
+
this.write_to_procon("01000000000000000000033000000000000000000000000000000000000000000000000000000000000000000000000000")
|
40
|
+
this.blocking_read_with_timeout_from_procon # <<< 21
|
41
|
+
end
|
42
|
+
|
30
43
|
# 4. Forces the Joy-Con or Pro Controller to only talk over USB HID without any timeouts. This is required for the Pro Controller to not time out and revert to Bluetooth.
|
31
44
|
s.add([["8004"]], read_from: :switch)
|
32
45
|
s.drain_all
|
33
46
|
return [s.switch, s.procon]
|
34
47
|
end
|
35
48
|
|
36
|
-
def initialize(throw_error_if_timeout: false, throw_error_if_mismatch: false
|
37
|
-
@
|
49
|
+
def initialize(throw_error_if_timeout: false, throw_error_if_mismatch: false)
|
50
|
+
@queue = []
|
38
51
|
@initialized_devices = false
|
39
52
|
@throw_error_if_timeout = throw_error_if_timeout
|
40
53
|
@throw_error_if_mismatch = throw_error_if_mismatch
|
41
|
-
@enable_at_exit = enable_at_exit
|
42
54
|
end
|
43
55
|
|
44
|
-
def add(values, read_from: )
|
45
|
-
@
|
56
|
+
def add(values, read_from: , call_block_if_receive: false, &block)
|
57
|
+
@queue << Value.new(values: values, read_from: read_from, call_block_if_receive: call_block_if_receive, &block)
|
46
58
|
end
|
47
59
|
|
48
60
|
def drain_all
|
@@ -51,181 +63,47 @@ class ProconBypassMan::DeviceConnector
|
|
51
63
|
init_devices
|
52
64
|
end
|
53
65
|
|
54
|
-
while(item = @
|
66
|
+
while(item = @queue.shift)
|
55
67
|
item.values.each do |value|
|
56
|
-
|
68
|
+
raw_data = nil
|
57
69
|
timer = ProconBypassMan::SafeTimeout.new
|
58
70
|
begin
|
59
71
|
timer.throw_if_timeout!
|
60
|
-
|
61
|
-
debug_log_buffer << "read_from(#{item.read_from}): #{
|
72
|
+
raw_data = from_device(item).read_nonblock(64)
|
73
|
+
debug_log_buffer << "read_from(#{item.read_from}): #{raw_data.unpack("H*")}"
|
62
74
|
rescue IO::EAGAINWaitReadable
|
63
75
|
# debug_log_buffer << "read_from(#{item.read_from}): IO::EAGAINWaitReadable"
|
64
76
|
retry
|
65
77
|
end
|
66
78
|
|
79
|
+
if item.call_block_if_receive =~ raw_data.unpack("H*").first
|
80
|
+
raw_data = item.block.call(self)
|
81
|
+
end
|
82
|
+
|
67
83
|
result =
|
68
84
|
case value
|
69
85
|
when String, Array
|
70
|
-
value ==
|
86
|
+
value == raw_data.unpack("H*")
|
71
87
|
when Regexp
|
72
|
-
value =~
|
88
|
+
value =~ raw_data.unpack("H*").first
|
73
89
|
else
|
74
90
|
raise "#{value}は知りません"
|
75
91
|
end
|
76
92
|
if result
|
77
|
-
ProconBypassMan.logger.info "OK(expected: #{value}, got: #{
|
78
|
-
debug_log_buffer << "OK(expected: #{value}, got: #{
|
93
|
+
ProconBypassMan.logger.info "OK(expected: #{value}, got: #{raw_data.unpack("H*")})"
|
94
|
+
debug_log_buffer << "OK(expected: #{value}, got: #{raw_data.unpack("H*")})"
|
79
95
|
else
|
80
|
-
ProconBypassMan.logger.info "NG(expected: #{value}, got: #{
|
81
|
-
debug_log_buffer << "NG(expected: #{value}, got: #{
|
82
|
-
raise BytesMismatchError if @throw_error_if_mismatch
|
96
|
+
ProconBypassMan.logger.info "NG(expected: #{value}, got: #{raw_data.unpack("H*")})"
|
97
|
+
debug_log_buffer << "NG(expected: #{value}, got: #{raw_data.unpack("H*")})"
|
98
|
+
raise BytesMismatchError.new(debug_log_buffer) if @throw_error_if_mismatch
|
83
99
|
end
|
84
|
-
to_device(item).write_nonblock(
|
100
|
+
to_device(item).write_nonblock(raw_data)
|
85
101
|
end
|
86
102
|
end
|
87
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
88
|
-
ProconBypassMan.logger.error "timeoutになりました"
|
89
|
-
|
90
|
-
ProconBypassMan::SendErrorCommand.execute(error:
|
91
|
-
raise if @throw_error_if_timeout
|
92
|
-
end
|
93
|
-
|
94
|
-
# switchに任意の命令を入力して、switchから読み取る
|
95
|
-
def write_switch(data, only_write: false)
|
96
|
-
if data.encoding.name == "UTF-8"
|
97
|
-
data = [data].pack("H*")
|
98
|
-
end
|
99
|
-
unless @initialized_devices
|
100
|
-
init_devices
|
101
|
-
end
|
102
|
-
|
103
|
-
timer = ProconBypassMan::SafeTimeout.new
|
104
|
-
data = nil
|
105
|
-
begin
|
106
|
-
timer.throw_if_timeout!
|
107
|
-
switch.write_nonblock(data)
|
108
|
-
rescue IO::EAGAINWaitReadable
|
109
|
-
retry
|
110
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
111
|
-
ProconBypassMan.logger.error "writeでtimeoutになりました"
|
112
|
-
raise
|
113
|
-
end
|
114
|
-
return(data.unpack("H*")) if only_write
|
115
|
-
|
116
|
-
timer = ProconBypassMan::SafeTimeout.new
|
117
|
-
begin
|
118
|
-
timer.throw_if_timeout!
|
119
|
-
data = switch.read_nonblock(64)
|
120
|
-
ProconBypassMan.logger.debug { " >>> #{data.unpack("H*")})" }
|
121
|
-
rescue IO::EAGAINWaitReadable
|
122
|
-
retry
|
123
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
124
|
-
ProconBypassMan.logger.error "readでtimeoutになりました"
|
125
|
-
raise
|
126
|
-
end
|
127
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
128
|
-
raise if @throw_error_if_timeout
|
129
|
-
end
|
130
|
-
|
131
|
-
def write_procon(data, only_write: false)
|
132
|
-
if data.encoding.name == "UTF-8"
|
133
|
-
data = [data].pack("H*")
|
134
|
-
end
|
135
|
-
unless @initialized_devices
|
136
|
-
init_devices
|
137
|
-
end
|
138
|
-
|
139
|
-
timer = ProconBypassMan::SafeTimeout.new
|
140
|
-
begin
|
141
|
-
timer.throw_if_timeout!
|
142
|
-
procon.write_nonblock(data)
|
143
|
-
rescue IO::EAGAINWaitReadable
|
144
|
-
retry
|
145
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
146
|
-
ProconBypassMan.logger.error "writeでtimeoutになりました"
|
147
|
-
raise
|
148
|
-
end
|
149
|
-
return(data.unpack("H*")) if only_write
|
150
|
-
|
151
|
-
timer = ProconBypassMan::SafeTimeout.new
|
152
|
-
begin
|
153
|
-
timer.throw_if_timeout!
|
154
|
-
data = procon.read_nonblock(64)
|
155
|
-
ProconBypassMan.logger.error " <<< #{data.unpack("H*")})"
|
156
|
-
rescue IO::EAGAINWaitReadable
|
157
|
-
retry
|
158
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
159
|
-
ProconBypassMan.logger.error "readでtimeoutになりました"
|
160
|
-
raise
|
161
|
-
end
|
162
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
163
|
-
raise if @throw_error_if_timeout
|
164
|
-
end
|
165
|
-
|
166
|
-
def read_procon(only_read: false)
|
167
|
-
unless @initialized_devices
|
168
|
-
init_devices
|
169
|
-
end
|
170
|
-
|
171
|
-
data = nil
|
172
|
-
timer = ProconBypassMan::SafeTimeout.new
|
173
|
-
begin
|
174
|
-
timer.throw_if_timeout!
|
175
|
-
data = procon.read_nonblock(64)
|
176
|
-
ProconBypassMan.logger.debug { " <<< #{data.unpack("H*")})" }
|
177
|
-
rescue IO::EAGAINWaitReadable
|
178
|
-
retry
|
179
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
180
|
-
ProconBypassMan.logger.error "readでtimeoutになりました"
|
181
|
-
raise
|
182
|
-
end
|
183
|
-
return(data.unpack("H*")) if only_read
|
184
|
-
|
185
|
-
timer = ProconBypassMan::SafeTimeout.new
|
186
|
-
begin
|
187
|
-
timer.throw_if_timeout!
|
188
|
-
switch.write_nonblock(data)
|
189
|
-
rescue IO::EAGAINWaitReadable
|
190
|
-
retry
|
191
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
192
|
-
ProconBypassMan.logger.error "writeでtimeoutになりました"
|
193
|
-
raise
|
194
|
-
end
|
195
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
196
|
-
raise if @throw_error_if_timeout
|
197
|
-
end
|
198
|
-
|
199
|
-
def read_switch(only_read: false)
|
200
|
-
unless @initialized_devices
|
201
|
-
init_devices
|
202
|
-
end
|
203
|
-
|
204
|
-
data = nil
|
205
|
-
timer = ProconBypassMan::SafeTimeout.new
|
206
|
-
begin
|
207
|
-
timer.throw_if_timeout!
|
208
|
-
data = switch.read_nonblock(64)
|
209
|
-
ProconBypassMan.logger.debug { " >>> #{data.unpack("H*")})" }
|
210
|
-
rescue IO::EAGAINWaitReadable
|
211
|
-
retry
|
212
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
213
|
-
ProconBypassMan.logger.error "readでtimeoutになりました"
|
214
|
-
raise
|
215
|
-
end
|
216
|
-
return(data.unpack("H*")) if only_read
|
217
|
-
|
218
|
-
timer = ProconBypassMan::SafeTimeout.new
|
219
|
-
begin
|
220
|
-
timer.throw_if_timeout!
|
221
|
-
procon.write_nonblock(data)
|
222
|
-
rescue IO::EAGAINWaitReadable
|
223
|
-
retry
|
224
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
225
|
-
ProconBypassMan.logger.error "writeでtimeoutになりました"
|
226
|
-
raise
|
227
|
-
end
|
228
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
103
|
+
rescue ProconBypassMan::SafeTimeout::Timeout, Timeout::Error => e
|
104
|
+
ProconBypassMan.logger.error "timeoutになりました(#{e.message})"
|
105
|
+
compressed_buffer_text = ProconBypassMan::CompressArray.new(debug_log_buffer).compress.join("\n")
|
106
|
+
ProconBypassMan::SendErrorCommand.execute(error: compressed_buffer_text)
|
229
107
|
raise if @throw_error_if_timeout
|
230
108
|
end
|
231
109
|
|
@@ -277,17 +155,23 @@ class ProconBypassMan::DeviceConnector
|
|
277
155
|
ProconBypassMan::UsbDeviceController.reset
|
278
156
|
|
279
157
|
@initialized_devices = true
|
280
|
-
|
281
|
-
if @enable_at_exit
|
282
|
-
at_exit do
|
283
|
-
@procon&.close
|
284
|
-
@gadget&.close
|
285
|
-
end
|
286
|
-
end
|
287
158
|
rescue Errno::ENXIO => e
|
288
159
|
# /dev/hidg0 をopenできないときがある
|
289
160
|
ProconBypassMan::SendErrorCommand.execute(error: "Errno::ENXIO (No such device or address @ rb_sysopen - /dev/hidg0)が起きました。resetします.\n #{e.full_message}")
|
290
161
|
ProconBypassMan::UsbDeviceController.reset
|
291
162
|
retry
|
292
163
|
end
|
164
|
+
|
165
|
+
def blocking_read_with_timeout_from_procon
|
166
|
+
Timeout.timeout(4) do
|
167
|
+
raw_data = procon.read(64)
|
168
|
+
ProconBypassMan.logger.info "<<< #{raw_data.unpack("H*").first}"
|
169
|
+
return raw_data
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def write_to_procon(data)
|
174
|
+
ProconBypassMan.logger.info ">>> #{data}"
|
175
|
+
procon.write_nonblock([data].pack("H*"))
|
176
|
+
end
|
293
177
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/procon_bypass_man/{domains → procon/value_objects}/binary/processing_procon_binary.rb
RENAMED
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module Domains
|
3
|
+
module Binary; end
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
require "procon_bypass_man/procon/value_objects/binary/base"
|
8
|
+
require "procon_bypass_man/procon/value_objects/binary/has_immutable_binary"
|
9
|
+
require "procon_bypass_man/procon/value_objects/binary/has_mutable_binary"
|
10
|
+
require "procon_bypass_man/procon/value_objects/binary/inbound_procon_binary"
|
11
|
+
require "procon_bypass_man/procon/value_objects/binary/processing_procon_binary"
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ProconBypassMan::RumbleBinary
|
2
|
+
# @param [String] binary
|
3
|
+
def initialize(binary: )
|
4
|
+
@binary = binary
|
5
|
+
end
|
6
|
+
|
7
|
+
def unpack
|
8
|
+
@binary.unpack("H*")
|
9
|
+
end
|
10
|
+
|
11
|
+
def noop!
|
12
|
+
@binary = ProconBypassMan::SuppressRumble.new(binary: @binary).execute
|
13
|
+
end
|
14
|
+
|
15
|
+
def raw
|
16
|
+
@binary
|
17
|
+
end
|
18
|
+
end
|
@@ -1,6 +1,13 @@
|
|
1
1
|
require "procon_bypass_man/procon/macro_plugin_map"
|
2
2
|
|
3
3
|
class ProconBypassMan::Procon
|
4
|
+
require "procon_bypass_man/procon/value_objects/analog_stick"
|
5
|
+
require "procon_bypass_man/procon/value_objects/analog_stick_position"
|
6
|
+
require "procon_bypass_man/procon/value_objects/procon_reader"
|
7
|
+
require "procon_bypass_man/procon/value_objects/rumble_binary"
|
8
|
+
require "procon_bypass_man/procon/value_objects/binary"
|
9
|
+
require "procon_bypass_man/procon/value_objects/bypass_mode"
|
10
|
+
|
4
11
|
require "procon_bypass_man/procon/consts"
|
5
12
|
require "procon_bypass_man/procon/mode_registry"
|
6
13
|
require "procon_bypass_man/procon/macro"
|
@@ -11,6 +18,7 @@ class ProconBypassMan::Procon
|
|
11
18
|
require "procon_bypass_man/procon/user_operation"
|
12
19
|
require "procon_bypass_man/procon/flip_cache"
|
13
20
|
require "procon_bypass_man/procon/press_button_aware"
|
21
|
+
require "procon_bypass_man/procon/suppress_rumble"
|
14
22
|
|
15
23
|
attr_accessor :user_operation
|
16
24
|
|
@@ -14,7 +14,7 @@ class ProconBypassMan::Runner
|
|
14
14
|
|
15
15
|
def run
|
16
16
|
self_read, self_write = IO.pipe
|
17
|
-
%w(TERM INT
|
17
|
+
%w(TERM INT USR2).each do |sig|
|
18
18
|
begin
|
19
19
|
trap sig do
|
20
20
|
self_write.puts(sig)
|
@@ -25,23 +25,23 @@ class ProconBypassMan::Runner
|
|
25
25
|
end
|
26
26
|
|
27
27
|
loop do
|
28
|
-
$will_terminate_token = false
|
29
28
|
# NOTE メインプロセスではThreadをいくつか起動しているので念のためパフォーマンスを優先するためにforkしていく
|
30
29
|
child_pid = Kernel.fork {
|
30
|
+
$will_terminate_token = false
|
31
31
|
DRb.start_service if defined?(DRb)
|
32
32
|
ProconBypassMan::RemoteMacroReceiver.start!
|
33
|
-
ProconBypassMan::BypassCommand.new(gadget: @gadget, procon: @procon).execute
|
33
|
+
ProconBypassMan::BypassCommand.new(gadget: @gadget, procon: @procon).execute # ここでblockingする
|
34
|
+
next
|
34
35
|
}
|
35
36
|
|
36
37
|
begin
|
37
|
-
# TODO
|
38
|
+
# TODO 子プロセスが消滅した時に、メインプロセスは生き続けてしまい、何もできなくなる問題がある
|
38
39
|
while(readable_io = IO.select([self_read]))
|
39
40
|
signal = readable_io.first[0].gets.strip
|
40
41
|
handle_signal(signal)
|
41
42
|
end
|
42
43
|
rescue InterruptForRestart
|
43
|
-
|
44
|
-
Process.kill("TERM", child_pid)
|
44
|
+
Process.kill("USR2", child_pid)
|
45
45
|
Process.wait
|
46
46
|
ProconBypassMan::PrintMessageCommand.execute(text: "Reloading config file")
|
47
47
|
begin
|
@@ -53,10 +53,10 @@ class ProconBypassMan::Runner
|
|
53
53
|
end
|
54
54
|
ProconBypassMan::PrintMessageCommand.execute(text: "バイパス処理を再開します")
|
55
55
|
rescue Interrupt
|
56
|
-
$will_terminate_token = true
|
57
56
|
Process.kill("TERM", child_pid)
|
58
57
|
Process.wait
|
59
58
|
ProconBypassMan::PrintMessageCommand.execute(text: "処理を終了します")
|
59
|
+
ProconBypassMan::UsbDeviceController.reset
|
60
60
|
@gadget&.close
|
61
61
|
@procon&.close
|
62
62
|
break
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# n秒間sleepしつつ、mainスレッドをm秒間隔で動かしたい時に使う
|
2
|
+
class ProconBypassMan::CycleSleep
|
3
|
+
attr_accessor :cycle_interval, :execution_cycle
|
4
|
+
|
5
|
+
def initialize(cycle_interval: , execution_cycle: )
|
6
|
+
@cycle_interval = cycle_interval
|
7
|
+
@execution_cycle = execution_cycle
|
8
|
+
@counter = 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def sleep_or_execute
|
12
|
+
result = nil
|
13
|
+
if @counter >= @execution_cycle
|
14
|
+
@counter = 0
|
15
|
+
result = yield
|
16
|
+
else
|
17
|
+
@counter += 1
|
18
|
+
end
|
19
|
+
sleep(@cycle_interval)
|
20
|
+
return result
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class ProconBypassMan::DeviceMouseFinder
|
2
|
+
class USBDevice < Struct.new(:display_name, :event_no)
|
3
|
+
# TODO bInterfaceProtocolの値を見てmouseかを判断したい
|
4
|
+
def mouse?
|
5
|
+
!!(display_name =~ /mouse/i)
|
6
|
+
end
|
7
|
+
|
8
|
+
def keyboard?
|
9
|
+
!!(display_name =~ /keyboard/i)
|
10
|
+
end
|
11
|
+
|
12
|
+
def event_device_path
|
13
|
+
"/dev/input/#{event_no}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Parser
|
18
|
+
def self.parse(shell_output)
|
19
|
+
instance = new
|
20
|
+
instance.set_usb_devices_from(shell_output)
|
21
|
+
instance
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_usb_devices_from(shell_output)
|
25
|
+
@usb_devices =
|
26
|
+
shell_output.split(/\n\n/).map do |text|
|
27
|
+
display_name = /N: Name="(.+?)"$/ =~ text && $1
|
28
|
+
event_no = /H: Handlers=.*?(event\d).*?$/ =~ text && $1
|
29
|
+
USBDevice.new(display_name, event_no)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def usb_devices
|
34
|
+
@usb_devices ||= []
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.find
|
39
|
+
new.find
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [String, NilClass]
|
43
|
+
def find
|
44
|
+
find_path
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def find_path
|
50
|
+
Parser.parse(shell_output).usb_devices.detect(&:mouse?)&.event_device_path
|
51
|
+
end
|
52
|
+
|
53
|
+
def shell_output
|
54
|
+
`bash -c '#{shell}'`
|
55
|
+
end
|
56
|
+
|
57
|
+
def shell
|
58
|
+
'cat /proc/bus/input/devices'
|
59
|
+
end
|
60
|
+
end
|
File without changes
|
@@ -7,8 +7,14 @@ module ProconBypassMan
|
|
7
7
|
@timeout = timeout
|
8
8
|
end
|
9
9
|
|
10
|
+
# @raise [Timeout]
|
10
11
|
def throw_if_timeout!
|
11
|
-
raise Timeout if
|
12
|
+
raise Timeout if timeout?
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Boolean]
|
16
|
+
def timeout?
|
17
|
+
@timeout < Time.now
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
class ProconBypassMan::UsbDeviceController
|
2
2
|
class << self
|
3
3
|
def reset
|
4
|
-
|
5
|
-
|
4
|
+
[ "echo > /sys/kernel/config/usb_gadget/procon/UDC",
|
5
|
+
"ls /sys/class/udc > /sys/kernel/config/usb_gadget/procon/UDC",
|
6
|
+
].each do |shell|
|
7
|
+
system shell
|
8
|
+
ProconBypassMan.logger.debug { "[SHELL] #{shell}" }
|
9
|
+
end
|
6
10
|
sleep 0.5
|
7
11
|
end
|
8
12
|
|
@@ -42,6 +46,7 @@ class ProconBypassMan::UsbDeviceController
|
|
42
46
|
EOH
|
43
47
|
|
44
48
|
`bash -c '#{shell}'`
|
49
|
+
sleep(1)
|
45
50
|
end
|
46
51
|
|
47
52
|
def initialized?
|
data/lib/procon_bypass_man.rb
CHANGED
@@ -14,6 +14,9 @@ require "pbmenv"
|
|
14
14
|
require_relative "procon_bypass_man/version"
|
15
15
|
require_relative "procon_bypass_man/remote_pbm_action"
|
16
16
|
require_relative "procon_bypass_man/remote_macro"
|
17
|
+
require_relative "procon_bypass_man/support/usb_device_controller"
|
18
|
+
require_relative "procon_bypass_man/support/device_procon_finder"
|
19
|
+
require_relative "procon_bypass_man/support/device_mouse_finder"
|
17
20
|
require_relative "procon_bypass_man/support/signal_handler"
|
18
21
|
require_relative "procon_bypass_man/support/callbacks"
|
19
22
|
require_relative "procon_bypass_man/support/yaml_writer"
|
@@ -29,22 +32,18 @@ require_relative "procon_bypass_man/support/send_device_stats_http_client"
|
|
29
32
|
require_relative "procon_bypass_man/support/server_pool"
|
30
33
|
require_relative "procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler"
|
31
34
|
require_relative "procon_bypass_man/support/never_exit_accidentally"
|
35
|
+
require_relative "procon_bypass_man/support/cycle_sleep"
|
32
36
|
require_relative "procon_bypass_man/background"
|
33
37
|
require_relative "procon_bypass_man/commands"
|
34
38
|
require_relative "procon_bypass_man/bypass"
|
35
|
-
require_relative "procon_bypass_man/domains"
|
36
39
|
require_relative "procon_bypass_man/device_connector"
|
37
|
-
require_relative "procon_bypass_man/device_procon_finder"
|
38
40
|
require_relative "procon_bypass_man/device_status"
|
39
|
-
require_relative "procon_bypass_man/usb_device_controller"
|
40
41
|
require_relative "procon_bypass_man/runner"
|
41
42
|
require_relative "procon_bypass_man/processor"
|
42
43
|
require_relative "procon_bypass_man/configuration"
|
43
44
|
require_relative "procon_bypass_man/buttons_setting_configuration"
|
44
45
|
require_relative "procon_bypass_man/procon"
|
45
46
|
require_relative "procon_bypass_man/procon/button"
|
46
|
-
require_relative "procon_bypass_man/procon/value_objects/analog_stick"
|
47
|
-
require_relative "procon_bypass_man/procon/value_objects/procon_reader"
|
48
47
|
require_relative "procon_bypass_man/procon/analog_stick_cap"
|
49
48
|
require_relative "procon_bypass_man/procon/analog_stick_manipulator"
|
50
49
|
require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
|
@@ -62,9 +61,7 @@ module ProconBypassMan
|
|
62
61
|
extend ProconBypassMan::NeverExitAccidentally
|
63
62
|
|
64
63
|
class CouldNotLoadConfigError < StandardError; end
|
65
|
-
class
|
66
|
-
class FirstConnectionError < ConnectionError; end
|
67
|
-
class EternalConnectionError < ConnectionError; end
|
64
|
+
class EternalConnectionError < StandardError; end
|
68
65
|
|
69
66
|
# @return [void]
|
70
67
|
def self.run(setting_path: nil)
|
@@ -99,18 +96,11 @@ module ProconBypassMan
|
|
99
96
|
FileUtils.rm_rf(ProconBypassMan.digest_path)
|
100
97
|
ProconBypassMan::QueueOverProcess.shutdown
|
101
98
|
end
|
102
|
-
rescue ProconBypassMan::
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
ProconBypassMan::DeviceStatus.change_to_connected_but_sleeping!
|
108
|
-
FileUtils.rm_rf(ProconBypassMan.pid_path)
|
109
|
-
eternal_sleep
|
110
|
-
rescue ProconBypassMan::FirstConnectionError
|
111
|
-
ProconBypassMan::SendErrorCommand.execute(error: "接続を確立できませんでした。やりなおします。")
|
112
|
-
retry
|
113
|
-
end
|
99
|
+
rescue ProconBypassMan::EternalConnectionError
|
100
|
+
ProconBypassMan::SendErrorCommand.execute(error: "接続の見込みがないのでsleepしまくります")
|
101
|
+
ProconBypassMan::DeviceStatus.change_to_connected_but_sleeping!
|
102
|
+
FileUtils.rm_rf(ProconBypassMan.pid_path)
|
103
|
+
eternal_sleep
|
114
104
|
end
|
115
105
|
|
116
106
|
def self.configure(&block)
|
data/project_template/app.rb
CHANGED
@@ -2,10 +2,19 @@
|
|
2
2
|
|
3
3
|
require 'bundler/inline'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
begin
|
6
|
+
gemfile do
|
7
|
+
source 'https://rubygems.org'
|
8
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
9
|
+
gem 'procon_bypass_man', '0.1.23'
|
10
|
+
end
|
11
|
+
rescue Bundler::Source::Git::GitCommandError => e
|
12
|
+
# install中に強制終了するとgitの管理ファイルが不正状態になり、次のエラーが起きるので発生したらcache directoryを削除する
|
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
|
+
if /try removing the cache directory '([^']+)'/ =~ e.message
|
15
|
+
FileUtils.rm_rf($1)
|
16
|
+
retry
|
17
|
+
end
|
9
18
|
end
|
10
19
|
|
11
20
|
ProconBypassMan.configure do |config|
|
data/sig/main.rbs
CHANGED
@@ -11,9 +11,6 @@ module ProconBypassMan
|
|
11
11
|
class CouldNotLoadConfigError < StandardError
|
12
12
|
end
|
13
13
|
|
14
|
-
class FirstConnectionError < StandardError
|
15
|
-
end
|
16
|
-
|
17
14
|
class EternalConnectionError < StandardError
|
18
15
|
end
|
19
16
|
|
@@ -255,21 +252,12 @@ class ProconBypassMan::DeviceConnector
|
|
255
252
|
|
256
253
|
def self.connect: () -> ::Array[untyped]
|
257
254
|
|
258
|
-
def initialize: (?throw_error_if_timeout: bool throw_error_if_timeout, ?throw_error_if_mismatch: bool throw_error_if_mismatch
|
255
|
+
def initialize: (?throw_error_if_timeout: bool throw_error_if_timeout, ?throw_error_if_mismatch: bool throw_error_if_mismatch) -> untyped
|
259
256
|
|
260
257
|
def add: (untyped values, read_from: untyped read_from) -> untyped
|
261
258
|
|
262
259
|
def drain_all: () -> untyped
|
263
260
|
|
264
|
-
# switchに任意の命令を入力して、switchから読み取る
|
265
|
-
def write_switch: (untyped data, ?only_write: bool only_write) -> untyped
|
266
|
-
|
267
|
-
def write_procon: (untyped data, ?only_write: bool only_write) -> untyped
|
268
|
-
|
269
|
-
def read_procon: (?only_read: bool only_read) -> untyped
|
270
|
-
|
271
|
-
def read_switch: (?only_read: bool only_read) -> untyped
|
272
|
-
|
273
261
|
def from_device: (untyped item) -> untyped
|
274
262
|
|
275
263
|
# fromの対になる
|
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.1.
|
4
|
+
version: 0.1.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pbmenv
|
@@ -135,16 +135,7 @@ files:
|
|
135
135
|
- lib/procon_bypass_man/commands/write_session_id_command.rb
|
136
136
|
- lib/procon_bypass_man/configuration.rb
|
137
137
|
- lib/procon_bypass_man/device_connector.rb
|
138
|
-
- lib/procon_bypass_man/device_procon_finder.rb
|
139
138
|
- lib/procon_bypass_man/device_status.rb
|
140
|
-
- lib/procon_bypass_man/domains.rb
|
141
|
-
- lib/procon_bypass_man/domains/analog_stick_position.rb
|
142
|
-
- lib/procon_bypass_man/domains/binary/base.rb
|
143
|
-
- lib/procon_bypass_man/domains/binary/has_immutable_binary.rb
|
144
|
-
- lib/procon_bypass_man/domains/binary/has_mutable_binary.rb
|
145
|
-
- lib/procon_bypass_man/domains/binary/inbound_procon_binary.rb
|
146
|
-
- lib/procon_bypass_man/domains/binary/processing_procon_binary.rb
|
147
|
-
- lib/procon_bypass_man/domains/bypass_mode.rb
|
148
139
|
- lib/procon_bypass_man/io_monitor.rb
|
149
140
|
- lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb
|
150
141
|
- lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb
|
@@ -171,9 +162,19 @@ files:
|
|
171
162
|
- lib/procon_bypass_man/procon/macro_registry.rb
|
172
163
|
- lib/procon_bypass_man/procon/mode_registry.rb
|
173
164
|
- lib/procon_bypass_man/procon/press_button_aware.rb
|
165
|
+
- lib/procon_bypass_man/procon/suppress_rumble.rb
|
174
166
|
- lib/procon_bypass_man/procon/user_operation.rb
|
175
167
|
- lib/procon_bypass_man/procon/value_objects/analog_stick.rb
|
168
|
+
- lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
|
169
|
+
- lib/procon_bypass_man/procon/value_objects/binary.rb
|
170
|
+
- lib/procon_bypass_man/procon/value_objects/binary/base.rb
|
171
|
+
- lib/procon_bypass_man/procon/value_objects/binary/has_immutable_binary.rb
|
172
|
+
- lib/procon_bypass_man/procon/value_objects/binary/has_mutable_binary.rb
|
173
|
+
- lib/procon_bypass_man/procon/value_objects/binary/inbound_procon_binary.rb
|
174
|
+
- lib/procon_bypass_man/procon/value_objects/binary/processing_procon_binary.rb
|
175
|
+
- lib/procon_bypass_man/procon/value_objects/bypass_mode.rb
|
176
176
|
- lib/procon_bypass_man/procon/value_objects/procon_reader.rb
|
177
|
+
- lib/procon_bypass_man/procon/value_objects/rumble_binary.rb
|
177
178
|
- lib/procon_bypass_man/remote_macro.rb
|
178
179
|
- lib/procon_bypass_man/remote_macro/queue_over_process.rb
|
179
180
|
- lib/procon_bypass_man/remote_macro/remote_macro_object.rb
|
@@ -194,6 +195,9 @@ files:
|
|
194
195
|
- lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb
|
195
196
|
- lib/procon_bypass_man/support/callbacks.rb
|
196
197
|
- lib/procon_bypass_man/support/compress_array.rb
|
198
|
+
- lib/procon_bypass_man/support/cycle_sleep.rb
|
199
|
+
- lib/procon_bypass_man/support/device_mouse_finder.rb
|
200
|
+
- lib/procon_bypass_man/support/device_procon_finder.rb
|
197
201
|
- lib/procon_bypass_man/support/http_client.rb
|
198
202
|
- lib/procon_bypass_man/support/never_exit_accidentally.rb
|
199
203
|
- lib/procon_bypass_man/support/on_memory_cache.rb
|
@@ -205,8 +209,8 @@ files:
|
|
205
209
|
- lib/procon_bypass_man/support/signal_handler.rb
|
206
210
|
- lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb
|
207
211
|
- lib/procon_bypass_man/support/uptime.rb
|
212
|
+
- lib/procon_bypass_man/support/usb_device_controller.rb
|
208
213
|
- lib/procon_bypass_man/support/yaml_writer.rb
|
209
|
-
- lib/procon_bypass_man/usb_device_controller.rb
|
210
214
|
- lib/procon_bypass_man/version.rb
|
211
215
|
- lib/procon_bypass_man/websocket/client.rb
|
212
216
|
- lib/procon_bypass_man/websocket/forever.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
module Domains
|
3
|
-
module Binary; end
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
require_relative "domains/bypass_mode"
|
8
|
-
require_relative "domains/analog_stick_position"
|
9
|
-
require_relative "domains/binary/base"
|
10
|
-
require_relative "domains/binary/has_mutable_binary"
|
11
|
-
require_relative "domains/binary/has_immutable_binary"
|
12
|
-
require_relative "domains/binary/inbound_procon_binary"
|
13
|
-
require_relative "domains/binary/processing_procon_binary"
|