procon_bypass_man 0.1.21 → 0.2.0
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 +9 -0
- data/.github/workflows/gitleacks.yml +11 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile.lock +4 -4
- data/README.md +4 -1
- data/docs/getting_started.md +70 -5
- data/docs/setting/left-analogstick-cap.md +1 -1
- data/docs/setting/splatoon2_macro_dasei_cancel.md +4 -0
- data/docs/setting/splatoon2_macro_sokuwari_bubble.md +4 -0
- data/docs/setting/splatoon2_shake_tansan.md +47 -0
- data/docs/setup_raspi.md +0 -1
- data/lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb +17 -0
- data/lib/procon_bypass_man/background.rb +1 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +142 -80
- data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +3 -1
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button.rb +28 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button_list.rb +31 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/disable_macro_if_pressed.rb +28 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/flip_if_pressed.rb +31 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/force_neutral.rb +28 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed.rb +26 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil.rb +28 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/open_macro_steps.rb +26 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/param_normalizer.rb +17 -0
- data/lib/procon_bypass_man/buttons_setting_configuration.rb +5 -4
- data/lib/procon_bypass_man/{commands → bypass}/bypass_command.rb +36 -24
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +4 -0
- data/lib/procon_bypass_man/bypass.rb +43 -23
- data/lib/procon_bypass_man/commands/print_boot_message_command.rb +2 -3
- data/lib/procon_bypass_man/commands/send_error_command.rb +2 -2
- data/lib/procon_bypass_man/commands.rb +0 -3
- data/lib/procon_bypass_man/configuration.rb +29 -3
- data/lib/procon_bypass_man/device_connection/command.rb +28 -0
- data/lib/procon_bypass_man/device_connection/executor.rb +190 -0
- data/lib/procon_bypass_man/device_connection/output_report_generator.rb +42 -0
- data/lib/procon_bypass_man/device_connection/output_report_markerable.rb +28 -0
- data/lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb +133 -0
- data/lib/procon_bypass_man/device_connection/output_report_watcher.rb +41 -0
- data/lib/procon_bypass_man/device_connection/pre_bypass.rb +67 -0
- data/lib/procon_bypass_man/device_connection/procon_setting_overrider.rb +78 -0
- data/lib/procon_bypass_man/device_connection/spoofing_output_report_watcher.rb +39 -0
- data/lib/procon_bypass_man/device_connection.rb +16 -0
- data/lib/procon_bypass_man/device_model.rb +17 -0
- data/lib/procon_bypass_man/io_monitor.rb +20 -1
- data/lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb +21 -0
- data/lib/procon_bypass_man/plugin/splatoon2/version.rb +1 -1
- data/lib/procon_bypass_man/plugins.rb +1 -0
- data/lib/procon_bypass_man/procon/analog_stick_cap.rb +4 -23
- data/lib/procon_bypass_man/procon/analog_stick_manipulator.rb +36 -0
- data/lib/procon_bypass_man/procon/layer_changer.rb +4 -1
- data/lib/procon_bypass_man/procon/macro.rb +5 -2
- data/lib/procon_bypass_man/procon/macro_builder.rb +20 -20
- data/lib/procon_bypass_man/procon/macro_plugin_map.rb +23 -0
- data/lib/procon_bypass_man/procon/macro_registry.rb +21 -10
- data/lib/procon_bypass_man/procon/suppress_rumble.rb +13 -0
- data/lib/procon_bypass_man/procon/user_operation.rb +29 -15
- data/lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb +18 -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 +6 -1
- 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 +27 -5
- data/lib/procon_bypass_man/remote_macro/queue_over_process.rb +62 -0
- data/lib/procon_bypass_man/remote_macro/remote_macro_object.rb +30 -0
- data/lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb +37 -0
- data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +8 -0
- data/lib/procon_bypass_man/remote_macro/task.rb +6 -0
- data/lib/procon_bypass_man/remote_macro/task_queue.rb +13 -0
- data/lib/procon_bypass_man/remote_macro.rb +14 -0
- data/lib/procon_bypass_man/{commands → remote_pbm_action/commands}/run_remote_pbm_action_dispatch_command.rb +0 -0
- data/lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb +7 -1
- data/lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb +1 -1
- data/lib/procon_bypass_man/remote_pbm_action.rb +2 -0
- data/lib/procon_bypass_man/runner.rb +13 -13
- 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 -2
- data/lib/procon_bypass_man/support/never_exit_accidentally.rb +3 -3
- data/lib/procon_bypass_man/support/remote_macro_http_client.rb +9 -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} +9 -6
- data/lib/procon_bypass_man/support/yaml_loader.rb +12 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/{pbm_job_client.rb → client.rb} +32 -10
- data/lib/procon_bypass_man.rb +69 -46
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/app.rb +19 -4
- data/sig/main.rbs +4 -16
- metadata +55 -17
- data/lib/procon_bypass_man/commands/connect_device_command.rb +0 -18
- data/lib/procon_bypass_man/device_connector.rb +0 -296
- data/lib/procon_bypass_man/domains.rb +0 -12
@@ -1,296 +0,0 @@
|
|
1
|
-
class ProconBypassMan::DeviceConnector
|
2
|
-
class BytesMismatchError < StandardError; end
|
3
|
-
class NotFoundProconError < StandardError; end
|
4
|
-
|
5
|
-
class Value
|
6
|
-
attr_accessor :read_from, :values
|
7
|
-
def initialize(values: , read_from: )
|
8
|
-
@values = values
|
9
|
-
@read_from = read_from
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
PROCON_PATH = "/dev/hidraw0"
|
14
|
-
PROCON2_PATH = "/dev/hidraw1"
|
15
|
-
|
16
|
-
def self.connect
|
17
|
-
s = new(throw_error_if_timeout: true, enable_at_exit: false)
|
18
|
-
s.add([
|
19
|
-
["0000"],
|
20
|
-
["0000"],
|
21
|
-
["8005"],
|
22
|
-
["0010"],
|
23
|
-
], read_from: :switch)
|
24
|
-
# 1. Sends current connection status, and if the Joy-Con are connected,
|
25
|
-
s.add([["8001"]], read_from: :switch)
|
26
|
-
s.add([/^8101/], read_from: :procon) # <<< 81010003176d96e7a5480000000, macaddressとコントローラー番号を返す
|
27
|
-
# 2. Sends handshaking packets over UART to the Joy-Con or Pro Controller Broadcom chip. This command can only be called once per session.
|
28
|
-
s.add([["8002"]], read_from: :switch)
|
29
|
-
s.add([/^8102/], read_from: :procon)
|
30
|
-
# 3
|
31
|
-
s.add([/^0100/], read_from: :switch)
|
32
|
-
s.add([/^21/], read_from: :procon)
|
33
|
-
# 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.
|
34
|
-
s.add([["8004"]], read_from: :switch)
|
35
|
-
s.drain_all
|
36
|
-
return [s.switch, s.procon]
|
37
|
-
end
|
38
|
-
|
39
|
-
def initialize(throw_error_if_timeout: false, throw_error_if_mismatch: false , enable_at_exit: true)
|
40
|
-
@stack = []
|
41
|
-
@initialized_devices = false
|
42
|
-
@throw_error_if_timeout = throw_error_if_timeout
|
43
|
-
@throw_error_if_mismatch = throw_error_if_mismatch
|
44
|
-
@enable_at_exit = enable_at_exit
|
45
|
-
end
|
46
|
-
|
47
|
-
def add(values, read_from: )
|
48
|
-
@stack << Value.new(values: values, read_from: read_from)
|
49
|
-
end
|
50
|
-
|
51
|
-
def drain_all
|
52
|
-
debug_log_buffer = []
|
53
|
-
unless @initialized_devices
|
54
|
-
init_devices
|
55
|
-
end
|
56
|
-
|
57
|
-
while(item = @stack.shift)
|
58
|
-
item.values.each do |value|
|
59
|
-
data = nil
|
60
|
-
timer = ProconBypassMan::SafeTimeout.new
|
61
|
-
begin
|
62
|
-
timer.throw_if_timeout!
|
63
|
-
data = from_device(item).read_nonblock(64)
|
64
|
-
debug_log_buffer << "read_from(#{item.read_from}): #{data.unpack("H*")}"
|
65
|
-
rescue IO::EAGAINWaitReadable
|
66
|
-
# debug_log_buffer << "read_from(#{item.read_from}): IO::EAGAINWaitReadable"
|
67
|
-
retry
|
68
|
-
end
|
69
|
-
|
70
|
-
result =
|
71
|
-
case value
|
72
|
-
when String, Array
|
73
|
-
value == data.unpack("H*")
|
74
|
-
when Regexp
|
75
|
-
value =~ data.unpack("H*").first
|
76
|
-
else
|
77
|
-
raise "#{value}は知りません"
|
78
|
-
end
|
79
|
-
if result
|
80
|
-
ProconBypassMan.logger.info "OK(expected: #{value}, got: #{data.unpack("H*")})"
|
81
|
-
debug_log_buffer << "OK(expected: #{value}, got: #{data.unpack("H*")})"
|
82
|
-
else
|
83
|
-
ProconBypassMan.logger.info "NG(expected: #{value}, got: #{data.unpack("H*")})"
|
84
|
-
debug_log_buffer << "NG(expected: #{value}, got: #{data.unpack("H*")})"
|
85
|
-
raise BytesMismatchError if @throw_error_if_mismatch
|
86
|
-
end
|
87
|
-
to_device(item).write_nonblock(data)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
91
|
-
ProconBypassMan.logger.error "timeoutになりました"
|
92
|
-
copressed_buffer_text = ProconBypassMan::CompressArray.new(debug_log_buffer).compress.join("\n")
|
93
|
-
ProconBypassMan::SendErrorCommand.execute(error: copressed_buffer_text)
|
94
|
-
raise if @throw_error_if_timeout
|
95
|
-
end
|
96
|
-
|
97
|
-
# switchに任意の命令を入力して、switchから読み取る
|
98
|
-
def write_switch(data, only_write: false)
|
99
|
-
if data.encoding.name == "UTF-8"
|
100
|
-
data = [data].pack("H*")
|
101
|
-
end
|
102
|
-
unless @initialized_devices
|
103
|
-
init_devices
|
104
|
-
end
|
105
|
-
|
106
|
-
timer = ProconBypassMan::SafeTimeout.new
|
107
|
-
data = nil
|
108
|
-
begin
|
109
|
-
timer.throw_if_timeout!
|
110
|
-
switch.write_nonblock(data)
|
111
|
-
rescue IO::EAGAINWaitReadable
|
112
|
-
retry
|
113
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
114
|
-
ProconBypassMan.logger.error "writeでtimeoutになりました"
|
115
|
-
raise
|
116
|
-
end
|
117
|
-
return(data.unpack("H*")) if only_write
|
118
|
-
|
119
|
-
timer = ProconBypassMan::SafeTimeout.new
|
120
|
-
begin
|
121
|
-
timer.throw_if_timeout!
|
122
|
-
data = switch.read_nonblock(64)
|
123
|
-
ProconBypassMan.logger.debug { " >>> #{data.unpack("H*")})" }
|
124
|
-
rescue IO::EAGAINWaitReadable
|
125
|
-
retry
|
126
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
127
|
-
ProconBypassMan.logger.error "readでtimeoutになりました"
|
128
|
-
raise
|
129
|
-
end
|
130
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
131
|
-
raise if @throw_error_if_timeout
|
132
|
-
end
|
133
|
-
|
134
|
-
def write_procon(data, only_write: false)
|
135
|
-
if data.encoding.name == "UTF-8"
|
136
|
-
data = [data].pack("H*")
|
137
|
-
end
|
138
|
-
unless @initialized_devices
|
139
|
-
init_devices
|
140
|
-
end
|
141
|
-
|
142
|
-
timer = ProconBypassMan::SafeTimeout.new
|
143
|
-
begin
|
144
|
-
timer.throw_if_timeout!
|
145
|
-
procon.write_nonblock(data)
|
146
|
-
rescue IO::EAGAINWaitReadable
|
147
|
-
retry
|
148
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
149
|
-
ProconBypassMan.logger.error "writeでtimeoutになりました"
|
150
|
-
raise
|
151
|
-
end
|
152
|
-
return(data.unpack("H*")) if only_write
|
153
|
-
|
154
|
-
timer = ProconBypassMan::SafeTimeout.new
|
155
|
-
begin
|
156
|
-
timer.throw_if_timeout!
|
157
|
-
data = procon.read_nonblock(64)
|
158
|
-
ProconBypassMan.logger.error " <<< #{data.unpack("H*")})"
|
159
|
-
rescue IO::EAGAINWaitReadable
|
160
|
-
retry
|
161
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
162
|
-
ProconBypassMan.logger.error "readでtimeoutになりました"
|
163
|
-
raise
|
164
|
-
end
|
165
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
166
|
-
raise if @throw_error_if_timeout
|
167
|
-
end
|
168
|
-
|
169
|
-
def read_procon(only_read: false)
|
170
|
-
unless @initialized_devices
|
171
|
-
init_devices
|
172
|
-
end
|
173
|
-
|
174
|
-
data = nil
|
175
|
-
timer = ProconBypassMan::SafeTimeout.new
|
176
|
-
begin
|
177
|
-
timer.throw_if_timeout!
|
178
|
-
data = procon.read_nonblock(64)
|
179
|
-
ProconBypassMan.logger.debug { " <<< #{data.unpack("H*")})" }
|
180
|
-
rescue IO::EAGAINWaitReadable
|
181
|
-
retry
|
182
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
183
|
-
ProconBypassMan.logger.error "readでtimeoutになりました"
|
184
|
-
raise
|
185
|
-
end
|
186
|
-
return(data.unpack("H*")) if only_read
|
187
|
-
|
188
|
-
timer = ProconBypassMan::SafeTimeout.new
|
189
|
-
begin
|
190
|
-
timer.throw_if_timeout!
|
191
|
-
switch.write_nonblock(data)
|
192
|
-
rescue IO::EAGAINWaitReadable
|
193
|
-
retry
|
194
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
195
|
-
ProconBypassMan.logger.error "writeでtimeoutになりました"
|
196
|
-
raise
|
197
|
-
end
|
198
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
199
|
-
raise if @throw_error_if_timeout
|
200
|
-
end
|
201
|
-
|
202
|
-
def read_switch(only_read: false)
|
203
|
-
unless @initialized_devices
|
204
|
-
init_devices
|
205
|
-
end
|
206
|
-
|
207
|
-
data = nil
|
208
|
-
timer = ProconBypassMan::SafeTimeout.new
|
209
|
-
begin
|
210
|
-
timer.throw_if_timeout!
|
211
|
-
data = switch.read_nonblock(64)
|
212
|
-
ProconBypassMan.logger.debug { " >>> #{data.unpack("H*")})" }
|
213
|
-
rescue IO::EAGAINWaitReadable
|
214
|
-
retry
|
215
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
216
|
-
ProconBypassMan.logger.error "readでtimeoutになりました"
|
217
|
-
raise
|
218
|
-
end
|
219
|
-
return(data.unpack("H*")) if only_read
|
220
|
-
|
221
|
-
timer = ProconBypassMan::SafeTimeout.new
|
222
|
-
begin
|
223
|
-
timer.throw_if_timeout!
|
224
|
-
procon.write_nonblock(data)
|
225
|
-
rescue IO::EAGAINWaitReadable
|
226
|
-
retry
|
227
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
228
|
-
ProconBypassMan.logger.error "writeでtimeoutになりました"
|
229
|
-
raise
|
230
|
-
end
|
231
|
-
rescue ProconBypassMan::SafeTimeout::Timeout
|
232
|
-
raise if @throw_error_if_timeout
|
233
|
-
end
|
234
|
-
|
235
|
-
def from_device(item)
|
236
|
-
case item.read_from
|
237
|
-
when :switch
|
238
|
-
switch
|
239
|
-
when :procon
|
240
|
-
procon
|
241
|
-
else
|
242
|
-
raise
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
# fromの対になる
|
247
|
-
def to_device(item)
|
248
|
-
case item.read_from
|
249
|
-
when :switch
|
250
|
-
procon
|
251
|
-
when :procon
|
252
|
-
switch
|
253
|
-
else
|
254
|
-
raise
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
def switch
|
259
|
-
@gadget
|
260
|
-
end
|
261
|
-
|
262
|
-
def procon
|
263
|
-
@procon
|
264
|
-
end
|
265
|
-
|
266
|
-
def init_devices
|
267
|
-
if @initialized_devices
|
268
|
-
return
|
269
|
-
end
|
270
|
-
ProconBypassMan::UsbDeviceController.init
|
271
|
-
|
272
|
-
if path = ProconBypassMan::DeviceProconFinder.find
|
273
|
-
@procon = File.open(path, "w+b")
|
274
|
-
ProconBypassMan.logger.info "proconのデバイスファイルは#{path}を使います"
|
275
|
-
else
|
276
|
-
raise(ProconBypassMan::DeviceConnector::NotFoundProconError)
|
277
|
-
end
|
278
|
-
@gadget = File.open('/dev/hidg0', "w+b")
|
279
|
-
|
280
|
-
ProconBypassMan::UsbDeviceController.reset
|
281
|
-
|
282
|
-
@initialized_devices = true
|
283
|
-
|
284
|
-
if @enable_at_exit
|
285
|
-
at_exit do
|
286
|
-
@procon&.close
|
287
|
-
@gadget&.close
|
288
|
-
end
|
289
|
-
end
|
290
|
-
rescue Errno::ENXIO => e
|
291
|
-
# /dev/hidg0 をopenできないときがある
|
292
|
-
ProconBypassMan::SendErrorCommand.execute(error: "Errno::ENXIO (No such device or address @ rb_sysopen - /dev/hidg0)が起きました。resetします.\n #{e.full_message}")
|
293
|
-
ProconBypassMan::UsbDeviceController.reset
|
294
|
-
retry
|
295
|
-
end
|
296
|
-
end
|
@@ -1,12 +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/binary/base"
|
9
|
-
require_relative "domains/binary/has_mutable_binary"
|
10
|
-
require_relative "domains/binary/has_immutable_binary"
|
11
|
-
require_relative "domains/binary/inbound_procon_binary"
|
12
|
-
require_relative "domains/binary/processing_procon_binary"
|