procon_bypass_man 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/Gemfile.lock +2 -1
- data/README.md +3 -3
- data/bin/console +4 -0
- data/bin/{report_receive_server.rb → dev_api_server.rb} +7 -0
- data/lib/procon_bypass_man/background/report_thread.rb +42 -0
- data/lib/procon_bypass_man/buttons_setting_configuration.rb +4 -2
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +7 -0
- data/lib/procon_bypass_man/bypass.rb +0 -1
- data/lib/procon_bypass_man/configuration.rb +1 -2
- data/lib/procon_bypass_man/outbound/base.rb +18 -5
- data/lib/procon_bypass_man/outbound/error_reporter.rb +1 -1
- data/lib/procon_bypass_man/outbound/{usb_hid_data_reporter.rb → pressed_buttons_reporter.rb} +3 -3
- data/lib/procon_bypass_man/outbound/reporter.rb +1 -1
- data/lib/procon_bypass_man/procon/analog_stick.rb +31 -0
- data/lib/procon_bypass_man/procon/analog_stick_cap.rb +9 -32
- data/lib/procon_bypass_man/procon/button_collection.rb +1 -0
- data/lib/procon_bypass_man/procon/pressed_button_helper.rb +1 -1
- data/lib/procon_bypass_man/procon/user_operation.rb +1 -1
- data/lib/procon_bypass_man/procon.rb +3 -1
- data/lib/procon_bypass_man/readonly_procon.rb +32 -0
- data/lib/procon_bypass_man/runner.rb +3 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man.rb +3 -3
- data/project_template/app.rb +2 -2
- data/project_template/web.rb +1 -1
- data/sig/main.rbs +3 -3
- metadata +8 -9
- data/examples/practical/app.rb +0 -21
- data/examples/practical/setting.yml +0 -24
- data/lib/procon_bypass_man/analog_stick_position.rb +0 -8
- data/lib/procon_bypass_man/procon/debug_dumper.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ead44cd36352dba5f4bd97af9c99936657a1a896fb9793a6735ce730a045b6f1
|
4
|
+
data.tar.gz: b8d115ef493d0b58a064fc7a0a7348a66e9e331e8173edd7543d96e9e213daba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3229e5e9f0fef53072b4869af2c6469b55703804d12bd8a9d077fe7c413d2198f747d482b30134daa4da55a0c5309eeda45d9928e46cd7778391ed865720ca00
|
7
|
+
data.tar.gz: 2de07a44334162b54ca8ba2464286c12a7a21d6ef74cb36b39a97bd5e22a833a5a6a5af2dac5ba6382da99a8635cdd9bd196a98d7f63dac311a4e61c2387ecad
|
data/CHANGELOG.md
CHANGED
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.11)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -97,6 +97,7 @@ GEM
|
|
97
97
|
PLATFORMS
|
98
98
|
arm-linux
|
99
99
|
arm64-darwin-20
|
100
|
+
arm64-darwin-21
|
100
101
|
armv7l-linux
|
101
102
|
x86_64-linux
|
102
103
|
|
data/README.md
CHANGED
@@ -70,13 +70,13 @@ sudo kill -USR2 `cat ./pbm_pid`
|
|
70
70
|
* `ProconBypassMan.api_server = "http://.."` を設定すると、 `POST /api/reports` に対して起動ログを送信するようになります
|
71
71
|
|
72
72
|
### 開発環境でログの送信を確認する方法
|
73
|
-
* `bundle exec bin/
|
74
|
-
* `bin/console`
|
75
|
-
* `ProconBypassMan.api_server = "http://localhost:4567"`
|
73
|
+
* `bundle exec bin/dev_api_server.rb`
|
74
|
+
* `INTERNAL_API_SERVER=http://localhost:4567 bin/console`
|
76
75
|
* `message = ProconBypassMan::BootMessage.new; ProconBypassMan::Reporter.report(body: message.to_hash)"`
|
77
76
|
|
78
77
|
### リリース手順
|
79
78
|
* project_template/web.rb, project_template/app.rb, lib/procon_bypass_man/version.rb のバージョンをあげる
|
79
|
+
* CHANGELOG.md に日付を書く
|
80
80
|
* be rake release
|
81
81
|
|
82
82
|
## License
|
data/bin/console
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require "bundler/setup"
|
5
5
|
require "procon_bypass_man"
|
6
|
+
require "pry"
|
6
7
|
|
7
8
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
9
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -12,4 +13,7 @@ require "procon_bypass_man"
|
|
12
13
|
# Pry.start
|
13
14
|
|
14
15
|
require "irb"
|
16
|
+
|
17
|
+
ProconBypassMan.config.logger = Logger.new($stdout)
|
18
|
+
|
15
19
|
IRB.start(__FILE__)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module Background
|
3
|
+
class Reporter
|
4
|
+
MAX_QUEUE_SIZE = 100
|
5
|
+
|
6
|
+
def self.start!
|
7
|
+
new.start!
|
8
|
+
end
|
9
|
+
|
10
|
+
def start!
|
11
|
+
return if defined?(@@thread)
|
12
|
+
@@latest_request_result = { stats: true, timestamp: Time.now }
|
13
|
+
@@queue = Queue.new
|
14
|
+
@@thread = Thread.new do
|
15
|
+
while(item = @@queue.pop)
|
16
|
+
begin
|
17
|
+
result = item[:reporter_class].report(body: item[:data])
|
18
|
+
@@latest_request_result = { stats: result.stats, timestamp: Time.now }
|
19
|
+
sleep(1)
|
20
|
+
rescue => e
|
21
|
+
ProconBypassMan.logger.error(e)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.queue
|
28
|
+
raise "Do not start this thread yet" unless defined?(@@queue)
|
29
|
+
@@queue
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.push(hash)
|
33
|
+
if queue.size > MAX_QUEUE_SIZE
|
34
|
+
ProconBypassMan.logger.error('Over queue size cap!!')
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
queue.push(hash)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -3,6 +3,8 @@ require "procon_bypass_man/configuration/loader"
|
|
3
3
|
require "procon_bypass_man/configuration/layer"
|
4
4
|
|
5
5
|
module ProconBypassMan
|
6
|
+
class AnalogStickPosition < Struct.new(:x, :y); end
|
7
|
+
|
6
8
|
class ButtonsSettingConfiguration
|
7
9
|
attr_accessor :layers,
|
8
10
|
:setting_path,
|
@@ -76,7 +78,7 @@ module ProconBypassMan
|
|
76
78
|
end
|
77
79
|
|
78
80
|
def set_neutral_position(x, y)
|
79
|
-
self.neutral_position = AnalogStickPosition.new(x
|
81
|
+
self.neutral_position = AnalogStickPosition.new(x, y)
|
80
82
|
self
|
81
83
|
end
|
82
84
|
|
@@ -94,7 +96,7 @@ module ProconBypassMan
|
|
94
96
|
left: Layer.new,
|
95
97
|
right: Layer.new,
|
96
98
|
}
|
97
|
-
@neutral_position = AnalogStickPosition.new(
|
99
|
+
@neutral_position = AnalogStickPosition.new(2124, 1808)
|
98
100
|
end
|
99
101
|
end
|
100
102
|
end
|
@@ -15,6 +15,13 @@ class ProconBypassMan::Bypass
|
|
15
15
|
|
16
16
|
def log_procon_to_gadget
|
17
17
|
ProconBypassMan.logger.debug { "<<< #{bypass_status.to_text}" }
|
18
|
+
|
19
|
+
ProconBypassMan.cache.fetch key: 'reporter', expires_in: 5 do
|
20
|
+
ProconBypassMan::Background::Reporter.push({
|
21
|
+
data: ProconBypassMan::ReadonlyProcon.new(binary: bypass_status.binary).to_hash,
|
22
|
+
reporter_class: ProconBypassMan::PressedButtonsReporter
|
23
|
+
})
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
20
27
|
end
|
@@ -72,7 +72,6 @@ class ProconBypassMan::Bypass
|
|
72
72
|
end
|
73
73
|
|
74
74
|
begin
|
75
|
-
# ProconBypassMan::Procon::DebugDumper.new(binary: output).dump_analog_sticks
|
76
75
|
self.gadget.write_nonblock(ProconBypassMan::Processor.new(output).process)
|
77
76
|
self.bypass_status.sent = true
|
78
77
|
rescue IO::EAGAINWaitReadable
|
@@ -2,9 +2,12 @@ module ProconBypassMan
|
|
2
2
|
module Outbound
|
3
3
|
class Base
|
4
4
|
class Client
|
5
|
+
class Result < Struct.new(:stats); end
|
6
|
+
|
5
7
|
def initialize(path: , server: )
|
6
8
|
@path = path
|
7
9
|
if server.is_a?(Array)
|
10
|
+
# TODO エラーが起きたらローテーションする
|
8
11
|
@server = server.first
|
9
12
|
else
|
10
13
|
@server = server
|
@@ -16,23 +19,33 @@ module ProconBypassMan
|
|
16
19
|
# TODO ここでvalidationする
|
17
20
|
if @server.nil?
|
18
21
|
ProconBypassMan.logger.info('送信先が未設定なのでスキップしました')
|
19
|
-
return
|
22
|
+
return Result.new(false)
|
23
|
+
end
|
24
|
+
|
25
|
+
unless body.is_a?(Hash)
|
26
|
+
body = { value: body }
|
20
27
|
end
|
21
28
|
|
22
29
|
uri = URI.parse("#{@server}#{@path}")
|
23
30
|
http = Net::HTTP.new(uri.host, uri.port)
|
24
31
|
http.use_ssl = uri.scheme === "https"
|
32
|
+
params = { hostname: @hostname }.merge(body)
|
25
33
|
response = http.post(
|
26
34
|
uri.path,
|
27
|
-
|
35
|
+
params.to_json,
|
28
36
|
{ "Content-Type" => "application/json" },
|
29
37
|
)
|
30
|
-
|
31
|
-
|
38
|
+
case response.code
|
39
|
+
when /^200/
|
40
|
+
return Result.new(true)
|
41
|
+
else
|
42
|
+
ProconBypassMan.logger.error("200以外(#{response.code})が帰ってきました. #{response.body}")
|
43
|
+
return Result.new(false)
|
32
44
|
end
|
33
45
|
rescue => e
|
34
46
|
puts e
|
35
|
-
ProconBypassMan.logger.error(e)
|
47
|
+
ProconBypassMan.logger.error("erro: #{e}")
|
48
|
+
Result.new(false)
|
36
49
|
end
|
37
50
|
end
|
38
51
|
end
|
data/lib/procon_bypass_man/outbound/{usb_hid_data_reporter.rb → pressed_buttons_reporter.rb}
RENAMED
@@ -1,13 +1,13 @@
|
|
1
1
|
require "procon_bypass_man/outbound/base"
|
2
2
|
|
3
|
-
class ProconBypassMan::
|
4
|
-
PATH = "/api/
|
3
|
+
class ProconBypassMan::PressedButtonsReporter < ProconBypassMan::Outbound::Base
|
4
|
+
PATH = "/api/pressed_buttons"
|
5
5
|
|
6
6
|
def self.report(body: )
|
7
7
|
Client.new(
|
8
8
|
path: PATH,
|
9
9
|
server: ProconBypassMan.config.internal_api_servers,
|
10
|
-
).post(body: body
|
10
|
+
).post(body: body)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class ProconBypassMan::Procon::AnalogStick
|
2
|
+
attr_accessor :neutral_position
|
3
|
+
attr_accessor :bin_x, :bin_y
|
4
|
+
|
5
|
+
def initialize(binary: )
|
6
|
+
@neutral_position = ProconBypassMan::ButtonsSettingConfiguration.instance.neutral_position
|
7
|
+
|
8
|
+
byte6 = binary[6].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
9
|
+
byte7 = binary[7].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
10
|
+
byte8 = binary[8].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
11
|
+
|
12
|
+
self.bin_x = "#{byte7[4..7]}#{byte6}"
|
13
|
+
self.bin_y = "#{byte8}#{byte7[0..3]}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def abs_x
|
17
|
+
bin_x.to_i(2)
|
18
|
+
end
|
19
|
+
|
20
|
+
def abs_y
|
21
|
+
bin_y.to_i(2)
|
22
|
+
end
|
23
|
+
|
24
|
+
def relative_x
|
25
|
+
bin_x.to_i(2) - neutral_position.x
|
26
|
+
end
|
27
|
+
|
28
|
+
def relative_y
|
29
|
+
bin_y.to_i(2) - neutral_position.y
|
30
|
+
end
|
31
|
+
end
|
@@ -18,19 +18,9 @@ class ProconBypassMan::Procon::AnalogStickCap
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
attr_accessor :bin_x, :bin_y
|
22
|
-
attr_accessor :neutral_position
|
23
|
-
|
24
21
|
def initialize(binary)
|
25
|
-
@neutral_position = ProconBypassMan::ButtonsSettingConfiguration.instance.neutral_position
|
26
22
|
@binary = binary
|
27
|
-
|
28
|
-
byte6 = binary[6].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
29
|
-
byte7 = binary[7].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
30
|
-
byte8 = binary[8].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
31
|
-
|
32
|
-
self.bin_x = "#{byte7[4..7]}#{byte6}"
|
33
|
-
self.bin_y = "#{byte8}#{byte7[0..3]}"
|
23
|
+
@analog_stick = ProconBypassMan::Procon::AnalogStick.new(binary: binary)
|
34
24
|
end
|
35
25
|
|
36
26
|
# @return [ProconBypassMan::Procon::AnalogStickCap::Position]
|
@@ -41,8 +31,8 @@ class ProconBypassMan::Procon::AnalogStickCap
|
|
41
31
|
relative_capped_x = -(relative_capped_x.abs) if relative_x.negative?
|
42
32
|
relative_capped_y = -(relative_capped_y.abs) if relative_y.negative?
|
43
33
|
return Position.new(
|
44
|
-
x: relative_capped_x + neutral_position.x,
|
45
|
-
y: relative_capped_y + neutral_position.y,
|
34
|
+
x: relative_capped_x + @analog_stick.neutral_position.x,
|
35
|
+
y: relative_capped_y + @analog_stick.neutral_position.y,
|
46
36
|
)
|
47
37
|
else
|
48
38
|
return position
|
@@ -54,23 +44,10 @@ class ProconBypassMan::Procon::AnalogStickCap
|
|
54
44
|
Position.new(x: abs_x, y: abs_y)
|
55
45
|
end
|
56
46
|
|
57
|
-
# 0, 0からのx
|
58
|
-
def
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
# 0, 0からのy
|
63
|
-
def abs_y
|
64
|
-
bin_y.to_i(2)
|
65
|
-
end
|
66
|
-
|
67
|
-
def relative_x
|
68
|
-
bin_x.to_i(2) - neutral_position.x
|
69
|
-
end
|
70
|
-
|
71
|
-
def relative_y
|
72
|
-
bin_y.to_i(2) - neutral_position.y
|
73
|
-
end
|
47
|
+
def abs_x; @analog_stick.abs_x; end # 0, 0からのx
|
48
|
+
def abs_y; @analog_stick.abs_y; end # 0, 0からのy
|
49
|
+
def relative_x; @analog_stick.relative_x; end
|
50
|
+
def relative_y; @analog_stick.relative_y; end
|
74
51
|
|
75
52
|
# @deprecated
|
76
53
|
def x; relative_x; end
|
@@ -78,11 +55,11 @@ class ProconBypassMan::Procon::AnalogStickCap
|
|
78
55
|
|
79
56
|
def rad
|
80
57
|
(
|
81
|
-
Math.atan(
|
58
|
+
Math.atan(relative_y / relative_x.to_f) * 180 / Math::PI
|
82
59
|
).floor(6)
|
83
60
|
end
|
84
61
|
|
85
62
|
def hypotenuse
|
86
|
-
Math.sqrt(
|
63
|
+
Math.sqrt(relative_x**2 + relative_y**2).floor(6)
|
87
64
|
end
|
88
65
|
end
|
@@ -37,6 +37,7 @@ class ProconBypassMan::Procon::ButtonCollection
|
|
37
37
|
BUTTONS_MAP = BYTES_MAP.reduce({}) { |acc, value|
|
38
38
|
next acc if value[1].nil?
|
39
39
|
value[1].reverse.each.with_index do |button, index|
|
40
|
+
next(acc) if button == :grip || button == :_undefined_key
|
40
41
|
acc[button] = { byte_position: value[0], bit_position: index }
|
41
42
|
end
|
42
43
|
acc
|
@@ -139,7 +139,9 @@ class ProconBypassMan::Procon
|
|
139
139
|
|
140
140
|
b = user_operation.binary
|
141
141
|
ProconBypassMan.cache.fetch key: 'user_operation.binary', expires_in: 60 do
|
142
|
-
ProconBypassMan::
|
142
|
+
left_analog_stick = ProconBypassMan::ReadonlyProcon.new(binary: b).left_analog_stick
|
143
|
+
ProconBypassMan.logger.debug "x: #{left_analog_stick[:x]}, val: #{left_analog_stick[:x].to_s(2)}"
|
144
|
+
ProconBypassMan.logger.debug "y: #{left_analog_stick[:y]}, val: #{left_analog_stick[:y].to_s(2)}"
|
143
145
|
end
|
144
146
|
b
|
145
147
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# read
|
2
|
+
class ProconBypassMan::ReadonlyProcon
|
3
|
+
def initialize(binary: )
|
4
|
+
@binary = binary
|
5
|
+
@user_operation = ProconBypassMan::Procon::UserOperation.new(binary.dup)
|
6
|
+
@analog_stick = ProconBypassMan::Procon::AnalogStick.new(binary: binary)
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [Array<Symbol>]
|
10
|
+
def pressed
|
11
|
+
pressed_table = ::ProconBypassMan::Procon::ButtonCollection::BUTTONS.reduce({}) do |acc, button|
|
12
|
+
acc[button] = @user_operation.pressed_button?(button)
|
13
|
+
acc
|
14
|
+
end
|
15
|
+
pressed_table.select { |_key, value| value }.keys
|
16
|
+
end
|
17
|
+
|
18
|
+
def left_analog_stick
|
19
|
+
{ x: @analog_stick.relative_x, y: @analog_stick.relative_y }
|
20
|
+
end
|
21
|
+
|
22
|
+
def left_analog_stick_by_abs
|
23
|
+
{ x: @analog_stick.abs_x, y: @analog_stick.abs_y }
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_hash
|
27
|
+
{ left_analog_stick: left_analog_stick,
|
28
|
+
left_analog_stick_by_abs: left_analog_stick_by_abs,
|
29
|
+
buttons: pressed,
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative "io_monitor"
|
2
2
|
require_relative "uptime"
|
3
3
|
require_relative "boot_message"
|
4
|
+
require_relative "background/report_thread"
|
4
5
|
|
5
6
|
class ProconBypassMan::Runner
|
6
7
|
class InterruptForRestart < StandardError; end
|
@@ -58,6 +59,8 @@ class ProconBypassMan::Runner
|
|
58
59
|
|
59
60
|
def main_loop
|
60
61
|
ProconBypassMan::IOMonitor.start!
|
62
|
+
ProconBypassMan::Background::Reporter.start!
|
63
|
+
|
61
64
|
# gadget => procon
|
62
65
|
# 遅くていい
|
63
66
|
monitor1 = ProconBypassMan::IOMonitor.new(label: "switch -> procon")
|
data/lib/procon_bypass_man.rb
CHANGED
@@ -6,7 +6,6 @@ require "fileutils"
|
|
6
6
|
|
7
7
|
require_relative "procon_bypass_man/version"
|
8
8
|
require_relative "procon_bypass_man/callbacks"
|
9
|
-
require_relative "procon_bypass_man/analog_stick_position"
|
10
9
|
require_relative "procon_bypass_man/timer"
|
11
10
|
require_relative "procon_bypass_man/bypass"
|
12
11
|
require_relative "procon_bypass_man/device_connector"
|
@@ -14,12 +13,13 @@ require_relative "procon_bypass_man/runner"
|
|
14
13
|
require_relative "procon_bypass_man/processor"
|
15
14
|
require_relative "procon_bypass_man/configuration"
|
16
15
|
require_relative "procon_bypass_man/buttons_setting_configuration"
|
16
|
+
require_relative "procon_bypass_man/readonly_procon"
|
17
17
|
require_relative "procon_bypass_man/procon"
|
18
|
-
require_relative "procon_bypass_man/procon/
|
18
|
+
require_relative "procon_bypass_man/procon/analog_stick"
|
19
19
|
require_relative "procon_bypass_man/procon/analog_stick_cap"
|
20
20
|
require_relative "procon_bypass_man/outbound/reporter"
|
21
21
|
require_relative "procon_bypass_man/outbound/error_reporter"
|
22
|
-
require_relative "procon_bypass_man/outbound/
|
22
|
+
require_relative "procon_bypass_man/outbound/pressed_buttons_reporter"
|
23
23
|
require_relative "procon_bypass_man/on_memory_cache"
|
24
24
|
|
25
25
|
STDOUT.sync = true
|
data/project_template/app.rb
CHANGED
@@ -5,7 +5,7 @@ require 'bundler/inline'
|
|
5
5
|
gemfile do
|
6
6
|
source 'https://rubygems.org'
|
7
7
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
8
|
-
gem 'procon_bypass_man', '0.1.
|
8
|
+
gem 'procon_bypass_man', '0.1.11'
|
9
9
|
gem 'procon_bypass_man-splatoon2', github: 'splaplapla/procon_bypass_man-splatoon2', tag: "0.1.1"
|
10
10
|
end
|
11
11
|
|
@@ -14,7 +14,7 @@ ProconBypassMan.configure do |config|
|
|
14
14
|
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
|
15
15
|
config.logger.level = :debug
|
16
16
|
# pbm.api_server = 'https://...'
|
17
|
-
config.enable_critical_error_logging
|
17
|
+
config.enable_critical_error_logging = true
|
18
18
|
end
|
19
19
|
|
20
20
|
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
data/project_template/web.rb
CHANGED
@@ -5,7 +5,7 @@ require 'bundler/inline'
|
|
5
5
|
gemfile do
|
6
6
|
source 'https://rubygems.org'
|
7
7
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
8
|
-
gem 'procon_bypass_man-web', '0.1.
|
8
|
+
gem 'procon_bypass_man-web', '0.1.3'
|
9
9
|
end
|
10
10
|
|
11
11
|
ProconBypassMan::Web.configure do |config|
|
data/sig/main.rbs
CHANGED
@@ -423,7 +423,7 @@ class ProconBypassMan::Procon::ModeRegistry
|
|
423
423
|
def self.plugins: () -> untyped
|
424
424
|
end
|
425
425
|
|
426
|
-
module ProconBypassMan::Procon::
|
426
|
+
module ProconBypassMan::Procon::PressedButtonHelper
|
427
427
|
module Static
|
428
428
|
def pressed_button?: (untyped button) -> untyped
|
429
429
|
end
|
@@ -437,9 +437,9 @@ class ProconBypassMan::Procon
|
|
437
437
|
class UserOperation
|
438
438
|
include LayerChangeable
|
439
439
|
|
440
|
-
include
|
440
|
+
include PressedButtonHelper::Static
|
441
441
|
|
442
|
-
extend
|
442
|
+
extend PressedButtonHelper::Dynamic
|
443
443
|
|
444
444
|
attr_reader binary: untyped
|
445
445
|
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: extension for Nintendo Switch Pro Controller
|
14
14
|
email:
|
@@ -31,16 +31,14 @@ files:
|
|
31
31
|
- Rakefile
|
32
32
|
- Steepfile
|
33
33
|
- bin/console
|
34
|
-
- bin/
|
34
|
+
- bin/dev_api_server.rb
|
35
35
|
- bin/setup
|
36
36
|
- docs/how_to_connect_procon.md
|
37
37
|
- docs/setup_raspi.md
|
38
38
|
- docs/setup_raspi.mitamae.rb
|
39
39
|
- docs/setup_raspi_by_mitamae.md
|
40
|
-
- examples/practical/app.rb
|
41
|
-
- examples/practical/setting.yml
|
42
40
|
- lib/procon_bypass_man.rb
|
43
|
-
- lib/procon_bypass_man/
|
41
|
+
- lib/procon_bypass_man/background/report_thread.rb
|
44
42
|
- lib/procon_bypass_man/boot_message.rb
|
45
43
|
- lib/procon_bypass_man/buttons_setting_configuration.rb
|
46
44
|
- lib/procon_bypass_man/bypass.rb
|
@@ -55,14 +53,14 @@ files:
|
|
55
53
|
- lib/procon_bypass_man/on_memory_cache.rb
|
56
54
|
- lib/procon_bypass_man/outbound/base.rb
|
57
55
|
- lib/procon_bypass_man/outbound/error_reporter.rb
|
56
|
+
- lib/procon_bypass_man/outbound/pressed_buttons_reporter.rb
|
58
57
|
- lib/procon_bypass_man/outbound/reporter.rb
|
59
|
-
- lib/procon_bypass_man/outbound/usb_hid_data_reporter.rb
|
60
58
|
- lib/procon_bypass_man/processor.rb
|
61
59
|
- lib/procon_bypass_man/procon.rb
|
60
|
+
- lib/procon_bypass_man/procon/analog_stick.rb
|
62
61
|
- lib/procon_bypass_man/procon/analog_stick_cap.rb
|
63
62
|
- lib/procon_bypass_man/procon/button_collection.rb
|
64
63
|
- lib/procon_bypass_man/procon/data.rb
|
65
|
-
- lib/procon_bypass_man/procon/debug_dumper.rb
|
66
64
|
- lib/procon_bypass_man/procon/flip_cache.rb
|
67
65
|
- lib/procon_bypass_man/procon/layer_changeable.rb
|
68
66
|
- lib/procon_bypass_man/procon/macro_registry.rb
|
@@ -70,6 +68,7 @@ files:
|
|
70
68
|
- lib/procon_bypass_man/procon/press_button_aware.rb
|
71
69
|
- lib/procon_bypass_man/procon/pressed_button_helper.rb
|
72
70
|
- lib/procon_bypass_man/procon/user_operation.rb
|
71
|
+
- lib/procon_bypass_man/readonly_procon.rb
|
73
72
|
- lib/procon_bypass_man/runner.rb
|
74
73
|
- lib/procon_bypass_man/timer.rb
|
75
74
|
- lib/procon_bypass_man/uptime.rb
|
@@ -104,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
103
|
- !ruby/object:Gem::Version
|
105
104
|
version: '0'
|
106
105
|
requirements: []
|
107
|
-
rubygems_version: 3.2.
|
106
|
+
rubygems_version: 3.2.30
|
108
107
|
signing_key:
|
109
108
|
specification_version: 4
|
110
109
|
summary: extension for Nintendo Switch Pro Controller
|
data/examples/practical/app.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# sudo ln -s /home/pi/src/procon_bypass_man/examples/practical/setting.yml /home/pi/src/procon_bypass_man/setting.yml
|
4
|
-
# cd src/procon_bypass_man
|
5
|
-
# sudo ruby examples/practical/app.rb
|
6
|
-
|
7
|
-
require 'bundler/inline'
|
8
|
-
|
9
|
-
gemfile do
|
10
|
-
source 'https://rubygems.org'
|
11
|
-
gem 'procon_bypass_man', github: 'splaplapla/procon_bypass_man', branch: "edge"
|
12
|
-
gem 'procon_bypass_man-splatoon2', github: 'splaplapla/procon_bypass_man-splatoon2', branch: "0.1.0"
|
13
|
-
end
|
14
|
-
|
15
|
-
ProconBypassMan.tap do |pbm|
|
16
|
-
pbm.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10) # 5世代まで残して, 10MBでローテーション
|
17
|
-
pbm.logger.level = :debug
|
18
|
-
pbm.root = File.expand_path(__dir__)
|
19
|
-
end
|
20
|
-
|
21
|
-
ProconBypassMan.run(setting_path: "./setting.yml")
|
@@ -1,24 +0,0 @@
|
|
1
|
-
version: 1.0
|
2
|
-
setting: |-
|
3
|
-
fast_return = ProconBypassMan::Splatoon2::Macro::FastReturn
|
4
|
-
guruguru = ProconBypassMan::Splatoon2::Mode::Guruguru
|
5
|
-
|
6
|
-
install_macro_plugin fast_return
|
7
|
-
install_mode_plugin guruguru
|
8
|
-
|
9
|
-
prefix_keys_for_changing_layer [:zr, :r, :zl, :l]
|
10
|
-
|
11
|
-
layer :up, mode: :manual do
|
12
|
-
flip :zr, if_pressed: :zr, force_neutral: :zl, flip_interval: "8F"
|
13
|
-
flip :zl, if_pressed: [:y, :b, :zl]
|
14
|
-
flip :down, if_pressed: :down
|
15
|
-
macro fast_return.name, if_pressed: [:y, :b, :down]
|
16
|
-
remap :l, to: :zr
|
17
|
-
end
|
18
|
-
layer :right, mode: guruguru.name
|
19
|
-
layer :left do
|
20
|
-
# no-op
|
21
|
-
end
|
22
|
-
layer :down do
|
23
|
-
flip :zl
|
24
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class ProconBypassMan::Procon::DebugDumper
|
2
|
-
def initialize(binary: )
|
3
|
-
@binary = binary
|
4
|
-
# ProconBypassMan.logger.debug { "<<< patched #{@binary.unpack("H*")}" }
|
5
|
-
end
|
6
|
-
|
7
|
-
def dump_analog_sticks
|
8
|
-
byte6 = @binary[6].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
9
|
-
byte7 = @binary[7].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
10
|
-
byte8 = @binary[8].unpack("H*").first.to_i(16).to_s(2).rjust(8, "0")
|
11
|
-
|
12
|
-
x = "#{byte7[4..7]}#{byte6}"
|
13
|
-
y = "#{byte8}#{byte7[0..3]}"
|
14
|
-
ProconBypassMan.logger.debug "x: #{x}, val: #{x.to_i(2)}"
|
15
|
-
ProconBypassMan.logger.debug "y: #{y}, val: #{y.to_i(2)}"
|
16
|
-
end
|
17
|
-
end
|