procon_bypass_man 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +11 -11
  5. data/README.md +10 -7
  6. data/lib/procon_bypass_man/background/http_client.rb +5 -8
  7. data/lib/procon_bypass_man/background/job_runner.rb +6 -5
  8. data/lib/procon_bypass_man/background/jobs/report_load_config_job.rb +10 -0
  9. data/lib/procon_bypass_man/background.rb +2 -0
  10. data/lib/procon_bypass_man/boot_message.rb +3 -1
  11. data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +34 -29
  12. data/lib/procon_bypass_man/buttons_setting_configuration.rb +2 -2
  13. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +7 -1
  14. data/lib/procon_bypass_man/commands/bypass_command.rb +86 -0
  15. data/lib/procon_bypass_man/commands/connect_device_command.rb +1 -1
  16. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +1 -1
  17. data/lib/procon_bypass_man/commands/send_error_command.rb +1 -0
  18. data/lib/procon_bypass_man/commands/send_reload_config_event_command.rb +1 -0
  19. data/lib/procon_bypass_man/commands/write_device_id_command.rb +1 -0
  20. data/lib/procon_bypass_man/commands.rb +1 -0
  21. data/lib/procon_bypass_man/configuration.rb +7 -4
  22. data/lib/procon_bypass_man/device_connector.rb +30 -23
  23. data/lib/procon_bypass_man/procon/analog_stick_cap.rb +1 -1
  24. data/lib/procon_bypass_man/procon/layer_changer.rb +1 -1
  25. data/lib/procon_bypass_man/runner.rb +5 -94
  26. data/lib/procon_bypass_man/splatoon2/macro/fast_return.rb +15 -0
  27. data/lib/procon_bypass_man/splatoon2/macro/jump_to_left_key.rb +15 -0
  28. data/lib/procon_bypass_man/splatoon2/macro/jump_to_right_key.rb +15 -0
  29. data/lib/procon_bypass_man/splatoon2/macro/jump_to_up_key.rb +15 -0
  30. data/lib/procon_bypass_man/splatoon2/mode/guruguru.rb +57 -0
  31. data/lib/procon_bypass_man/splatoon2/version.rb +7 -0
  32. data/lib/procon_bypass_man/splatoon2.rb +11 -0
  33. data/lib/procon_bypass_man/{callbacks.rb → support/callbacks.rb} +0 -0
  34. data/lib/procon_bypass_man/support/compress_array.rb +56 -0
  35. data/lib/procon_bypass_man/{on_memory_cache.rb → support/on_memory_cache.rb} +0 -0
  36. data/lib/procon_bypass_man/{timer.rb → support/safe_timeout.rb} +1 -1
  37. data/lib/procon_bypass_man/support/signal_handler.rb +11 -0
  38. data/lib/procon_bypass_man/{uptime.rb → support/uptime.rb} +0 -0
  39. data/lib/procon_bypass_man/version.rb +1 -1
  40. data/lib/procon_bypass_man.rb +11 -6
  41. data/procon_bypass_man.gemspec +2 -2
  42. data/project_template/README.md +18 -11
  43. data/project_template/app.rb +1 -2
  44. data/sig/{README.rb → README.md} +0 -0
  45. metadata +21 -9
@@ -48,6 +48,7 @@ class ProconBypassMan::DeviceConnector
48
48
  end
49
49
 
50
50
  def drain_all
51
+ debug_log_buffer = []
51
52
  unless @initialized_devices
52
53
  init_devices
53
54
  end
@@ -55,11 +56,13 @@ class ProconBypassMan::DeviceConnector
55
56
  while(item = @stack.shift)
56
57
  item.values.each do |value|
57
58
  data = nil
58
- timer = ProconBypassMan::Timer.new
59
+ timer = ProconBypassMan::SafeTimeout.new
59
60
  begin
60
61
  timer.throw_if_timeout!
61
62
  data = from_device(item).read_nonblock(64)
63
+ debug_log_buffer << "read_from(#{item.read_from}): #{data}"
62
64
  rescue IO::EAGAINWaitReadable
65
+ debug_log_buffer << "read_from(#{item.read_from}): IO::EAGAINWaitReadable"
63
66
  retry
64
67
  end
65
68
 
@@ -74,15 +77,19 @@ class ProconBypassMan::DeviceConnector
74
77
  end
75
78
  if result
76
79
  ProconBypassMan.logger.info "OK(expected: #{value}, got: #{data.unpack("H*")})"
80
+ debug_log_buffer << "OK(expected: #{value}, got: #{data.unpack("H*")})"
77
81
  else
78
82
  ProconBypassMan.logger.info "NG(expected: #{value}, got: #{data.unpack("H*")})"
83
+ debug_log_buffer << "NG(expected: #{value}, got: #{data.unpack("H*")})"
79
84
  raise BytesMismatchError if @throw_error_if_mismatch
80
85
  end
81
86
  to_device(item).write_nonblock(data)
82
87
  end
83
88
  end
84
- rescue ProconBypassMan::Timer::Timeout
89
+ rescue ProconBypassMan::SafeTimeout::Timeout
85
90
  ProconBypassMan.logger.error "timeoutになりました"
91
+ copressed_buffer_text = ProconBypassMan::CompressArray.new(debug_log_buffer).compress.join("\n")
92
+ ProconBypassMan::SendErrorCommand.execute(error: copressed_buffer_text)
86
93
  raise if @throw_error_if_timeout
87
94
  end
88
95
 
@@ -95,31 +102,31 @@ class ProconBypassMan::DeviceConnector
95
102
  init_devices
96
103
  end
97
104
 
98
- timer = ProconBypassMan::Timer.new
105
+ timer = ProconBypassMan::SafeTimeout.new
99
106
  data = nil
100
107
  begin
101
108
  timer.throw_if_timeout!
102
109
  switch.write_nonblock(data)
103
110
  rescue IO::EAGAINWaitReadable
104
111
  retry
105
- rescue ProconBypassMan::Timer::Timeout
112
+ rescue ProconBypassMan::SafeTimeout::Timeout
106
113
  ProconBypassMan.logger.error "writeでtimeoutになりました"
107
114
  raise
108
115
  end
109
116
  return(data.unpack("H*")) if only_write
110
117
 
111
- timer = ProconBypassMan::Timer.new
118
+ timer = ProconBypassMan::SafeTimeout.new
112
119
  begin
113
120
  timer.throw_if_timeout!
114
121
  data = switch.read_nonblock(64)
115
122
  ProconBypassMan.logger.debug { " >>> #{data.unpack("H*")})" }
116
123
  rescue IO::EAGAINWaitReadable
117
124
  retry
118
- rescue ProconBypassMan::Timer::Timeout
125
+ rescue ProconBypassMan::SafeTimeout::Timeout
119
126
  ProconBypassMan.logger.error "readでtimeoutになりました"
120
127
  raise
121
128
  end
122
- rescue ProconBypassMan::Timer::Timeout
129
+ rescue ProconBypassMan::SafeTimeout::Timeout
123
130
  raise if @throw_error_if_timeout
124
131
  end
125
132
 
@@ -131,30 +138,30 @@ class ProconBypassMan::DeviceConnector
131
138
  init_devices
132
139
  end
133
140
 
134
- timer = ProconBypassMan::Timer.new
141
+ timer = ProconBypassMan::SafeTimeout.new
135
142
  begin
136
143
  timer.throw_if_timeout!
137
144
  procon.write_nonblock(data)
138
145
  rescue IO::EAGAINWaitReadable
139
146
  retry
140
- rescue ProconBypassMan::Timer::Timeout
147
+ rescue ProconBypassMan::SafeTimeout::Timeout
141
148
  ProconBypassMan.logger.error "writeでtimeoutになりました"
142
149
  raise
143
150
  end
144
151
  return(data.unpack("H*")) if only_write
145
152
 
146
- timer = ProconBypassMan::Timer.new
153
+ timer = ProconBypassMan::SafeTimeout.new
147
154
  begin
148
155
  timer.throw_if_timeout!
149
156
  data = procon.read_nonblock(64)
150
157
  ProconBypassMan.logger.error " <<< #{data.unpack("H*")})"
151
158
  rescue IO::EAGAINWaitReadable
152
159
  retry
153
- rescue ProconBypassMan::Timer::Timeout
160
+ rescue ProconBypassMan::SafeTimeout::Timeout
154
161
  ProconBypassMan.logger.error "readでtimeoutになりました"
155
162
  raise
156
163
  end
157
- rescue ProconBypassMan::Timer::Timeout
164
+ rescue ProconBypassMan::SafeTimeout::Timeout
158
165
  raise if @throw_error_if_timeout
159
166
  end
160
167
 
@@ -164,30 +171,30 @@ class ProconBypassMan::DeviceConnector
164
171
  end
165
172
 
166
173
  data = nil
167
- timer = ProconBypassMan::Timer.new
174
+ timer = ProconBypassMan::SafeTimeout.new
168
175
  begin
169
176
  timer.throw_if_timeout!
170
177
  data = procon.read_nonblock(64)
171
178
  ProconBypassMan.logger.debug { " <<< #{data.unpack("H*")})" }
172
179
  rescue IO::EAGAINWaitReadable
173
180
  retry
174
- rescue ProconBypassMan::Timer::Timeout
181
+ rescue ProconBypassMan::SafeTimeout::Timeout
175
182
  ProconBypassMan.logger.error "readでtimeoutになりました"
176
183
  raise
177
184
  end
178
185
  return(data.unpack("H*")) if only_read
179
186
 
180
- timer = ProconBypassMan::Timer.new
187
+ timer = ProconBypassMan::SafeTimeout.new
181
188
  begin
182
189
  timer.throw_if_timeout!
183
190
  switch.write_nonblock(data)
184
191
  rescue IO::EAGAINWaitReadable
185
192
  retry
186
- rescue ProconBypassMan::Timer::Timeout
193
+ rescue ProconBypassMan::SafeTimeout::Timeout
187
194
  ProconBypassMan.logger.error "writeでtimeoutになりました"
188
195
  raise
189
196
  end
190
- rescue ProconBypassMan::Timer::Timeout
197
+ rescue ProconBypassMan::SafeTimeout::Timeout
191
198
  raise if @throw_error_if_timeout
192
199
  end
193
200
 
@@ -197,30 +204,30 @@ class ProconBypassMan::DeviceConnector
197
204
  end
198
205
 
199
206
  data = nil
200
- timer = ProconBypassMan::Timer.new
207
+ timer = ProconBypassMan::SafeTimeout.new
201
208
  begin
202
209
  timer.throw_if_timeout!
203
210
  data = switch.read_nonblock(64)
204
211
  ProconBypassMan.logger.debug { " >>> #{data.unpack("H*")})" }
205
212
  rescue IO::EAGAINWaitReadable
206
213
  retry
207
- rescue ProconBypassMan::Timer::Timeout
214
+ rescue ProconBypassMan::SafeTimeout::Timeout
208
215
  ProconBypassMan.logger.error "readでtimeoutになりました"
209
216
  raise
210
217
  end
211
218
  return(data.unpack("H*")) if only_read
212
219
 
213
- timer = ProconBypassMan::Timer.new
220
+ timer = ProconBypassMan::SafeTimeout.new
214
221
  begin
215
222
  timer.throw_if_timeout!
216
223
  procon.write_nonblock(data)
217
224
  rescue IO::EAGAINWaitReadable
218
225
  retry
219
- rescue ProconBypassMan::Timer::Timeout
226
+ rescue ProconBypassMan::SafeTimeout::Timeout
220
227
  ProconBypassMan.logger.error "writeでtimeoutになりました"
221
228
  raise
222
229
  end
223
- rescue ProconBypassMan::Timer::Timeout
230
+ rescue ProconBypassMan::SafeTimeout::Timeout
224
231
  raise if @throw_error_if_timeout
225
232
  end
226
233
 
@@ -312,7 +319,7 @@ class ProconBypassMan::DeviceConnector
312
319
  ProconBypassMan::SendErrorCommand.execute(error: "Errno::ENXIO (No such device or address @ rb_sysopen - /dev/hidg0)が起きました。resetします. #{e.full_message}")
313
320
  system('echo > /sys/kernel/config/usb_gadget/procon/UDC')
314
321
  system('ls /sys/class/udc > /sys/kernel/config/usb_gadget/procon/UDC')
315
- sleep 2
322
+ sleep 0.5
316
323
  retry
317
324
  end
318
325
  end
@@ -60,6 +60,6 @@ class ProconBypassMan::Procon::AnalogStickCap
60
60
  end
61
61
 
62
62
  def hypotenuse
63
- Math.sqrt(relative_x**2 + relative_y**2).floor(6)
63
+ Math.sqrt((relative_x**2) + (relative_y**2)).floor(6)
64
64
  end
65
65
  end
@@ -1,6 +1,6 @@
1
1
  class ProconBypassMan::Procon::LayerChanger
2
2
  def initialize(binary: )
3
- @procon_reader = ProconBypassMan::ProconReader.new(binary: binary)
3
+ @procon_reader = ProconBypassMan::ProconReader.new(binary: binary).freeze
4
4
  end
5
5
 
6
6
  # @return [Symbol]
@@ -1,17 +1,16 @@
1
1
  require_relative "io_monitor"
2
- require_relative "uptime"
3
2
  require_relative "boot_message"
4
- require_relative "background/job_runner"
5
3
 
6
4
  class ProconBypassMan::Runner
7
5
  class InterruptForRestart < StandardError; end
8
6
 
7
+ include ProconBypassMan::SignalHandler
8
+
9
9
  def initialize(gadget: , procon: )
10
10
  @gadget = gadget
11
11
  @procon = procon
12
12
 
13
13
  ProconBypassMan::PrintBootMessageCommand.execute
14
- ProconBypassMan::Background::JobRunner.start!
15
14
  end
16
15
 
17
16
  def run
@@ -28,7 +27,8 @@ class ProconBypassMan::Runner
28
27
 
29
28
  loop do
30
29
  $will_terminate_token = false
31
- main_loop_pid = fork { main_loop }
30
+ # TODO forkしないでThreadでいいのでは?
31
+ main_loop_pid = Kernel.fork { ProconBypassMan::BypassCommand.new(gadget: @gadget, procon: @procon).execute }
32
32
 
33
33
  begin
34
34
  while(readable_io = IO.select([self_read]))
@@ -42,10 +42,10 @@ class ProconBypassMan::Runner
42
42
  ProconBypassMan.logger.info("Reloading config file")
43
43
  begin
44
44
  ProconBypassMan::ButtonsSettingConfiguration::Loader.reload_setting
45
+ ProconBypassMan::SendReloadConfigEventCommand.execute
45
46
  rescue ProconBypassMan::CouldNotLoadConfigError
46
47
  ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。再読み込みができませんでした")
47
48
  end
48
- ProconBypassMan::SendReloadConfigEventCommand.execute
49
49
  ProconBypassMan.logger.info("バイパス処理を再開します")
50
50
  rescue Interrupt
51
51
  $will_terminate_token = true
@@ -59,93 +59,4 @@ class ProconBypassMan::Runner
59
59
  end
60
60
  end
61
61
  end
62
-
63
- private
64
-
65
- def main_loop
66
- ProconBypassMan::IOMonitor.start!
67
- ProconBypassMan::Background::JobRunner.start!
68
-
69
- # gadget => procon
70
- # 遅くていい
71
- monitor1 = ProconBypassMan::IOMonitor.new(label: "switch -> procon")
72
- monitor2 = ProconBypassMan::IOMonitor.new(label: "procon -> switch")
73
- ProconBypassMan.logger.info "Thread1を起動します"
74
- t1 = Thread.new do
75
- timer = ProconBypassMan::Timer.new(timeout: Time.now + 10)
76
- bypass = ProconBypassMan::Bypass.new(gadget: @gadget, procon: @procon, monitor: monitor1)
77
- loop do
78
- break if $will_terminate_token
79
- timer.throw_if_timeout!
80
- bypass.send_gadget_to_procon!
81
- sleep(0.005)
82
- rescue ProconBypassMan::Timer::Timeout
83
- ProconBypassMan.logger.info "10秒経過したのでThread1を終了します"
84
- monitor1.shutdown
85
- puts "10秒経過したのでThread1を終了します"
86
- break
87
- rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError => e
88
- ProconBypassMan::SendErrorCommand.execute(error: "Switchとの切断されました.終了処理を開始します. #{e.full_message}")
89
- Process.kill "TERM", Process.ppid
90
- rescue Errno::ETIMEDOUT => e
91
- # TODO まれにこれが発生する. 再接続したい
92
- ProconBypassMan::SendErrorCommand.execute(error: "Switchと意図せず切断されました.終了処理を開始します. #{e.full_message}")
93
- Process.kill "TERM", Process.ppid
94
- end
95
- ProconBypassMan.logger.info "Thread1を終了します"
96
- end
97
-
98
- # procon => gadget
99
- # シビア
100
- ProconBypassMan.logger.info "Thread2を起動します"
101
- t2 = Thread.new do
102
- bypass = ProconBypassMan::Bypass.new(gadget: @gadget, procon: @procon, monitor: monitor2)
103
- loop do
104
- break if $will_terminate_token
105
- bypass.send_procon_to_gadget!
106
- rescue EOFError => e
107
- ProconBypassMan::SendErrorCommand.execute(error: "Proconが切断されました。終了処理を開始します. #{e.full_message}")
108
- Process.kill "TERM", Process.ppid
109
- rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError => e
110
- ProconBypassMan::SendErrorCommand.execute(error: "Proconが切断されました。終了処理を開始します2. #{e.full_message}")
111
- Process.kill "TERM", Process.ppid
112
- end
113
- ProconBypassMan.logger.info "Thread2を終了します"
114
- end
115
-
116
- self_read, self_write = IO.pipe
117
- %w(TERM INT).each do |sig|
118
- begin
119
- trap sig do
120
- self_write.puts(sig)
121
- end
122
- rescue ArgumentError
123
- puts "プロセスでSignal #{sig} not supported"
124
- end
125
- end
126
-
127
- ProconBypassMan.logger.info "子プロセスでgraceful shutdownの準備ができました"
128
- begin
129
- while(readable_io = IO.select([self_read]))
130
- signal = readable_io.first[0].gets.strip
131
- handle_signal(signal)
132
- end
133
- rescue Interrupt
134
- $will_terminate_token = true
135
- [t1, t2].each(&:join)
136
- @gadget&.close
137
- @procon&.close
138
- exit 1
139
- end
140
- end
141
-
142
- def handle_signal(sig)
143
- ProconBypassMan.logger.info "#{$$}で#{sig}を受け取りました"
144
- case sig
145
- when 'USR2'
146
- raise InterruptForRestart
147
- when 'INT', 'TERM'
148
- raise Interrupt
149
- end
150
- end
151
62
  end
@@ -0,0 +1,15 @@
1
+ module ProconBypassMan
2
+ module Splatoon2
3
+ module Macro
4
+ module FastReturn
5
+ def self.name
6
+ :fast_return
7
+ end
8
+
9
+ def self.steps
10
+ [:x, :down, :a, :a].freeze
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module ProconBypassMan
2
+ module Splatoon2
3
+ module Macro
4
+ module JumpToLeftKey
5
+ def self.name
6
+ :jump_to_left_key
7
+ end
8
+
9
+ def self.steps
10
+ [:x, :left, :a, :a].freeze
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module ProconBypassMan
2
+ module Splatoon2
3
+ module Macro
4
+ module JumpToRightKey
5
+ def self.name
6
+ :jump_to_right_key
7
+ end
8
+
9
+ def self.steps
10
+ [:x, :right, :a, :a].freeze
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module ProconBypassMan
2
+ module Splatoon2
3
+ module Macro
4
+ module JumpToUpKey
5
+ def self.name
6
+ :jump_to_up_key
7
+ end
8
+
9
+ def self.steps
10
+ [:x, :up, :a, :a].freeze
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,57 @@
1
+ module ProconBypassMan
2
+ module Splatoon2
3
+ module Mode
4
+ module Guruguru
5
+ def self.binaries
6
+ [ "309481408000362d684658750968f71cfe2c0e51000001480053f71ffedf0d4b000a013d00caf6ecfd4c0d480003011c00000000000000000000000000000000",
7
+ "30978140800037dd6748687509fdf6adfded0d6d0081005d00eef68dfdef0d6d00830059001bf791fd140e720090005400000000000000000000000000000000",
8
+ "309a8140800038cd67495875099af821fe120e40006400880042f8fcfdfd0d470067008900d4f7e0fdf20d4e006a008c00000000000000000000000000000000",
9
+ "309c8140800036ed67466875099bf878fe4a0e35005b004c00c1f875fe400e35005d004c00c4f856fe2d0e390063006c00000000000000000000000000000000",
10
+ "30a081408000371d6847587509b9f71bfee70d22002c002300e3f73afe150e2b003500280014f854fe300e2d0038002900000000000000000000000000000000",
11
+ "30a38140800039fd6743587509def70ffea10d1a0031001f00d1f70ffeb10d19002c002200c5f711feb80d18002c002500000000000000000000000000000000",
12
+ "30a58140800037dd6746687509d8f70bfe980d270035001200ddf70dfe980d240038001900dff70ffe9b0d1f0035001a00000000000000000000000000000000",
13
+ "30a98140800037ed67484875099cf7edfdb00d310020000d009ef7eefda30d310022000c00adf7f2fd980d300028000a00000000000000000000000000000000",
14
+ "30ac8140800036ed67484875099cf709fed40d3a002400160097f7fafdd30d39002200150096f7f0fdc80d380022001400000000000000000000000000000000",
15
+ "30ae8140800038fd674558750987f72efed40d360021001c0089f729fed50d39002400180092f715fed10d390022001800000000000000000000000000000000",
16
+ "30b18140800037dd6747487509b8f705fea90d19001d002000c5f70dfeb00d210019002200bff71efec20d280018002400000000000000000000000000000000",
17
+ "30b48140800038fd684868750980f7e9fdd40d0200080024007df7f1fdba0d060011001e0084f7f8fdaa0d12001a001a00000000000000000000000000000000",
18
+ "30b7814080003fdd694958750918f6a9fd510f0d00d1ff370024f7b0fda90e0100ecff30006cf7d1fd210efffff5ff2c00000000000000000000000000000000",
19
+ "30ba81408080482d744768750963f71ffe190f5e00d9fea100ccf62dfe650f510009ff980015f702fe580f4b002eff8400000000000000000000000000000000",
20
+ "30bd814080802f7d864758750974f70efe4c0f5e00c0fea000d1f726fe1c0f5d00c5fea30028f859fe0e0f5c00cafea800000000000000000000000000000000",
21
+ "30bf8140808057cc984758750961f73afe630f99009dfeae0050f738fe710f7500adfea40050f721fe720f6e00b2fea300000000000000000000000000000000",
22
+ "30c281408080f479bd483875092ef8b6feab0f0a0180feba00f1f798fe900f000181febd00c2f77dfe7c0fdb008efebd00000000000000000000000000000000",
23
+ "30c581408080ad87d846487509e1f80000a6107e0178fea2004ef88dff54106c0185fea70063f826ffe60f520182feae00000000000000000000000000000000",
24
+ "30c8810080800797d84868750995f8e1fe4b0f7a0161fe88000df96dffd00f700149fe990035f9cdff361088016afea000000000000000000000000000000000",
25
+ "30cb810080804586d848487509cef672fe8a0f6d0217ff42002df63cfe280f1d0219ff410059f61cfe070fed01f5fe4a00000000000000000000000000000000",
26
+ "30d08100808002c5d745687509d8f5aaff830f5e03e6fe3e01fbf55bffc30f3f03e4fe100158f600ff3e102903e5fee700000000000000000000000000000000",
27
+ "30d3810080807b94d14838750991f6cd00690f9903f0fff10147f6e200560f7e038fffc60101f6c900560f71033bffa901000000000000000000000000000000",
28
+ "30d681008080b743ca475875095af7f2009c0fca03a400320242f7ca00950fb503820028020af7b000820fa4034e001a02000000000000000000000000000000",
29
+ "30d9810080805be3c047587509e7f77a03c70f0e04bb00410258f79801940f0004b800410251f74401910fd803b3003602000000000000000000000000000000",
30
+ "30dc810080808a02b245587509c0fbd5086a10710475020a03b0fb8d085d106c042102e8027efb660876106a04bc01af02000000000000000000000000000000",
31
+ "30de8100808036d2a14568750970fbbf09ad103704af038003a9fb600989105c0459036103c2fb2a097210690412034603000000000000000000000000000000",
32
+ "30e281008000cbb18d4738750989f8b40b2812380341044c0429f99e0bef11510340043704f2f93c0b7911b0033704f003000000000000000000000000000000",
33
+ "30e581008000c9c18945587509a5f7ca0a2e13e400c6024c0547f7fd0a941264011703270578f74a0b6012e40168030205000000000000000000000000000000",
34
+ "30e781008000c6618948687509acf86909e813d0fe2801a1057cf8cf09ed130fff6301990516f8710aaa13ccff13028205000000000000000000000000000000",
35
+ "30ea81008000c77189475875093af93b0762136efbaeff19060cf90107b113a9fb99ff0906e1f85b07b113bafc9fffcd05000000000000000000000000000000",
36
+ "30ed81008000c791894568750950f9ce047c1432f900026007a5f9a6051f146ef9bb013707bff99206a813fef9ce00c606000000000000000000000000000000",
37
+ "30ef81008000c6d1894558750944f8ad0358143ef81c02f10780f8b403841484f84102d107ccf801049314bcf84202ad07000000000000000000000000000000",
38
+ "30f381008000c761884868750914f72105e4134cf6d001c00743f71a05f11391f6bf01e407a0f7c904fa13faf6b3011008000000000000000000000000000000",
39
+ "30f681008000c7718344587509eaf54a04c812a6f40002500627f66d041313f2f40d02940682f6a60468133ef51a02d806000000000000000000000000000000",
40
+ "30f881008000c4e1814668750b5cf5f803b51125f3b5000d0560f50f04e8118cf33c015d057df525042c1210f4b101cc05000000000000000000000000000000",
41
+ "30fb81008000c5e1814458750b19f65a02a410acf29effb804e2f5db02df10b7f2c0ffbf04a9f55c032011dcf22400d804000000000000000000000000000000",
42
+ "30fe8100800035e2814858750b81f65c00f80f8df231fe940471f6e6001f1088f2a6fe92044ef6b1015a1092f21fffa004000000000000000000000000000000",
43
+ "3001810080004b03814868750b69f6e6fdad0ffef20efdd40479f678feb40fd9f249fdc40484f6f4fec00fb0f29ffdad04000000000000000000000000000000",
44
+ "30048100800079e47d4858750b17f64cfb5f0f46f46afb430529f6c4fb710ff1f3d4fb300538f64bfc830fbbf315fc1d05000000000000000000000000000000",
45
+ "300781008000a7057e4668750bb1f5d3f9fb0e8ef5ccf96405cdf5fcf90c0f44f52dfa6505e1f52dfa210f29f550fa6305000000000000000000000000000000",
46
+ "30098100800041f67d4668750bcdf4b0f9ab0e21f602f955057ef5adf9d00ee1f559f95f05b1f5d3f9fb0e8ef5ccf96405000000000000000000000000000000",
47
+ "300d810080003d877c4838750b84f458f7dd0c89f6d0f8fc0436f4e2f7620d83f614f8430526f4c0f8a00e71f666f85c05000000000000000000000000000000",
48
+ "30108100800058e77a4668750bf7f2c3f57c0c9cf6abfa0a0470f30ef6790c89f65dfa420414f476f67e0c80f6d0f98a04000000000000000000000000000000",
49
+ "30128100800059f77a4658750b7ef249f5580cd9f69bfaa40389f269f56c0cd1f6a9fab503a3f286f5760cacf6c9faeb03000000000000000000000000000000",
50
+ "3016810080005b177b4868750ba9f298f4450b2cf774fa3102b8f2a5f47a0b24f765fa6e02b8f2b8f4b10b1df755faac02000000000000000000000000000000",
51
+ "30198100800057777a4558750b39f258f4480a80f73efaf40016f26af4940a5ef76bfa37014ef275f4d40a46f780fa8401000000000000000000000000000000",
52
+ ].map(&:freeze).freeze
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ProconBypassMan
4
+ module Splatoon2
5
+ VERSION = "0.1.1"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "splatoon2/version"
2
+ require_relative "splatoon2/macro/fast_return"
3
+ require_relative "splatoon2/macro/jump_to_right_key"
4
+ require_relative "splatoon2/macro/jump_to_up_key"
5
+ require_relative "splatoon2/macro/jump_to_left_key"
6
+ require_relative "splatoon2/mode/guruguru"
7
+
8
+ module ProconBypassMan
9
+ module Splatoon2
10
+ end
11
+ end
@@ -0,0 +1,56 @@
1
+ module ProconBypassMan
2
+ class CompressArray
3
+ class CompressibleValue
4
+ # @params [String] prev
5
+ # @params [String] current
6
+ def initialize(prev, current)
7
+ @prev = prev
8
+ @current = current
9
+ end
10
+
11
+ # @return [Boolean]
12
+ def compress?
13
+ @prev.include?(@current)
14
+ end
15
+
16
+ # @return [String]
17
+ def to_s_with_mark
18
+ if /^(.+) \* (\d+)/ =~ @prev
19
+ value = $1
20
+ count = $2
21
+ return "#{value} * #{count.to_i + 1}"
22
+ end
23
+ if /^(.+)/ =~ @prev
24
+ value = $1
25
+ return "#{value} * 1"
26
+ end
27
+ end
28
+ end
29
+
30
+ def initialize(array)
31
+ @array = array
32
+ end
33
+
34
+ # @return [Array<String>]
35
+ def compress
36
+ previous_value = nil
37
+ @array.reduce([]) do |acc, item|
38
+ if previous_value.nil?
39
+ acc << item
40
+ previous_value = item
41
+ next acc
42
+ end
43
+
44
+ if CompressibleValue.new(previous_value, item).compress?
45
+ registered_value = acc.pop
46
+ acc << CompressibleValue.new(registered_value, item).to_s_with_mark
47
+ else
48
+ acc << item
49
+ end
50
+
51
+ previous_value = item
52
+ next acc
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,5 +1,5 @@
1
1
  module ProconBypassMan
2
- class Timer
2
+ class SafeTimeout
3
3
  class Timeout < StandardError; end
4
4
 
5
5
  # 5秒後がタイムアウト
@@ -0,0 +1,11 @@
1
+ module ProconBypassMan::SignalHandler
2
+ def handle_signal(sig)
3
+ ProconBypassMan.logger.info "#{$$}で#{sig}を受け取りました"
4
+ case sig
5
+ when 'USR2'
6
+ raise ProconBypassMan::Runner::InterruptForRestart
7
+ when 'INT', 'TERM'
8
+ raise Interrupt
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProconBypassMan
4
- VERSION = "0.1.12"
4
+ VERSION = "0.1.13"
5
5
  end
@@ -6,21 +6,25 @@ require "fileutils"
6
6
  require "securerandom"
7
7
 
8
8
  require_relative "procon_bypass_man/version"
9
- require_relative "procon_bypass_man/callbacks"
10
- require_relative "procon_bypass_man/timer"
9
+ require_relative "procon_bypass_man/support/signal_handler"
10
+ require_relative "procon_bypass_man/support/callbacks"
11
+ require_relative "procon_bypass_man/support/safe_timeout"
12
+ require_relative "procon_bypass_man/support/compress_array"
13
+ require_relative "procon_bypass_man/support/uptime"
14
+ require_relative "procon_bypass_man/support/on_memory_cache"
15
+ require_relative "procon_bypass_man/background"
16
+ require_relative "procon_bypass_man/commands"
11
17
  require_relative "procon_bypass_man/bypass"
12
18
  require_relative "procon_bypass_man/device_connector"
13
19
  require_relative "procon_bypass_man/runner"
14
20
  require_relative "procon_bypass_man/processor"
15
21
  require_relative "procon_bypass_man/configuration"
16
22
  require_relative "procon_bypass_man/buttons_setting_configuration"
17
- require_relative "procon_bypass_man/procon_reader"
18
23
  require_relative "procon_bypass_man/procon"
24
+ require_relative "procon_bypass_man/procon_reader"
19
25
  require_relative "procon_bypass_man/procon/analog_stick"
20
26
  require_relative "procon_bypass_man/procon/analog_stick_cap"
21
- require_relative "procon_bypass_man/background"
22
- require_relative "procon_bypass_man/commands"
23
- require_relative "procon_bypass_man/on_memory_cache"
27
+ require_relative "procon_bypass_man/splatoon2"
24
28
 
25
29
  STDOUT.sync = true
26
30
  Thread.abort_on_exception = true
@@ -52,6 +56,7 @@ module ProconBypassMan
52
56
  initialize_pbm
53
57
  File.write(pid_path, $$)
54
58
  ProconBypassMan::WriteSessionIdCommand.execute
59
+ ProconBypassMan::Background::JobRunner.start!
55
60
  gadget, procon = ProconBypassMan::ConnectDeviceCommand.execute!
56
61
  Runner.new(gadget: gadget, procon: procon).run
57
62
  rescue CouldNotLoadConfigError
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["jiikko"]
9
9
  spec.email = ["n905i.1214@gmail.com"]
10
10
 
11
- spec.summary = "extension for Nintendo Switch Pro Controller"
11
+ spec.summary = "An extension for Nintendo Switch Pro Controller"
12
12
  spec.description = spec.summary
13
13
  spec.homepage = "https://github.com/splaplapla/procon_bypass_man"
14
14
  spec.license = "MIT"
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
19
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
+ spec.metadata["changelog_uri"] = "https://github.com/splaplapla/procon_bypass_man/blob/master/CHANGELOG.md"
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.