procon_bypass_man 0.1.9 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +13 -12
- data/README.md +14 -16
- data/bin/console +4 -0
- data/bin/{report_receive_server.rb → dev_api_server.rb} +8 -1
- data/lib/procon_bypass_man/background/has_server_pool.rb +54 -0
- data/lib/procon_bypass_man/background/http_client.rb +67 -0
- data/lib/procon_bypass_man/background/job_performer.rb +16 -0
- data/lib/procon_bypass_man/background/job_runnable.rb +16 -0
- data/lib/procon_bypass_man/background/job_runner.rb +45 -0
- data/lib/procon_bypass_man/background/jobs/base_job.rb +12 -0
- data/lib/procon_bypass_man/background/jobs/report_boot_job.rb +10 -0
- data/lib/procon_bypass_man/background/jobs/report_error_job.rb +10 -0
- data/lib/procon_bypass_man/background/jobs/report_heartbeat_job.rb +10 -0
- data/lib/procon_bypass_man/background/jobs/report_load_config_job.rb +10 -0
- data/lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb +18 -0
- data/lib/procon_bypass_man/background/jobs/report_reload_config_job.rb +10 -0
- data/lib/procon_bypass_man/background.rb +12 -0
- data/lib/procon_bypass_man/boot_message.rb +13 -9
- data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/layer.rb +51 -30
- data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/loader.rb +12 -11
- data/lib/procon_bypass_man/{configuration → buttons_setting_configuration}/validator.rb +1 -1
- data/lib/procon_bypass_man/buttons_setting_configuration.rb +101 -0
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +42 -0
- data/lib/procon_bypass_man/bypass.rb +57 -38
- data/lib/procon_bypass_man/commands/bypass_command.rb +86 -0
- data/lib/procon_bypass_man/commands/connect_device_command.rb +11 -0
- data/lib/procon_bypass_man/commands/print_boot_message_command.rb +9 -0
- data/lib/procon_bypass_man/commands/send_error_command.rb +19 -0
- data/lib/procon_bypass_man/commands/send_reload_config_event_command.rb +11 -0
- data/lib/procon_bypass_man/commands/write_device_id_command.rb +12 -0
- data/lib/procon_bypass_man/commands/write_session_id_command.rb +13 -0
- data/lib/procon_bypass_man/commands.rb +7 -0
- data/lib/procon_bypass_man/configuration.rb +92 -78
- data/lib/procon_bypass_man/device_connector.rb +31 -25
- data/lib/procon_bypass_man/io_monitor.rb +9 -4
- 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/{data.rb → consts.rb} +1 -1
- data/lib/procon_bypass_man/procon/layer_changer.rb +40 -0
- data/lib/procon_bypass_man/procon/macro_registry.rb +2 -2
- data/lib/procon_bypass_man/procon/mode_registry.rb +2 -2
- data/lib/procon_bypass_man/procon/user_operation.rb +15 -17
- data/lib/procon_bypass_man/procon.rb +15 -15
- data/lib/procon_bypass_man/procon_reader.rb +31 -0
- data/lib/procon_bypass_man/runner.rb +15 -113
- data/lib/procon_bypass_man/splatoon2/macro/fast_return.rb +15 -0
- data/lib/procon_bypass_man/splatoon2/macro/jump_to_left_key.rb +15 -0
- data/lib/procon_bypass_man/splatoon2/macro/jump_to_right_key.rb +15 -0
- data/lib/procon_bypass_man/splatoon2/macro/jump_to_up_key.rb +15 -0
- data/lib/procon_bypass_man/splatoon2/mode/guruguru.rb +57 -0
- data/lib/procon_bypass_man/splatoon2/version.rb +7 -0
- data/lib/procon_bypass_man/splatoon2.rb +11 -0
- data/lib/procon_bypass_man/support/callbacks.rb +70 -0
- data/lib/procon_bypass_man/support/compress_array.rb +56 -0
- data/lib/procon_bypass_man/{on_memory_cache.rb → support/on_memory_cache.rb} +0 -0
- data/lib/procon_bypass_man/{timer.rb → support/safe_timeout.rb} +1 -1
- data/lib/procon_bypass_man/support/signal_handler.rb +11 -0
- data/lib/procon_bypass_man/support/uptime.rb +25 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man.rb +41 -82
- data/procon_bypass_man.gemspec +2 -2
- data/project_template/README.md +19 -12
- data/project_template/app.rb +7 -8
- data/project_template/systemd_units/pbm_web.service +11 -0
- data/project_template/web.rb +16 -0
- data/sig/{README.rb → README.md} +0 -0
- data/sig/main.rbs +54 -16
- metadata +53 -22
- data/examples/practical/app.rb +0 -21
- data/examples/practical/setting.yml +0 -24
- data/lib/procon_bypass_man/analog_stick_position.rb +0 -14
- data/lib/procon_bypass_man/error_reporter.rb +0 -44
- data/lib/procon_bypass_man/procon/debug_dumper.rb +0 -17
- data/lib/procon_bypass_man/procon/layer_changeable.rb +0 -28
- data/lib/procon_bypass_man/procon/pressed_button_helper.rb +0 -15
- data/lib/procon_bypass_man/reporter.rb +0 -42
- data/lib/procon_bypass_man/uptime.rb +0 -13
@@ -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
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module ProconBypassMan::Procon::LayerChangeable
|
2
|
-
def next_layer_key
|
3
|
-
case
|
4
|
-
when pressed_up?
|
5
|
-
:up
|
6
|
-
when pressed_right?
|
7
|
-
:right
|
8
|
-
when pressed_left?
|
9
|
-
:left
|
10
|
-
when pressed_down?
|
11
|
-
:down
|
12
|
-
else
|
13
|
-
ProconBypassMan.logger.warn("next_layer_key is unknown")
|
14
|
-
:up
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def change_layer?
|
19
|
-
if ProconBypassMan::Configuration.instance.prefix_keys.empty?
|
20
|
-
raise "prefix_keysが未設定です"
|
21
|
-
end
|
22
|
-
ProconBypassMan::Configuration.instance.prefix_keys.map { |b| pressed_button?(b) }.all?
|
23
|
-
end
|
24
|
-
|
25
|
-
def pressed_next_layer?
|
26
|
-
change_layer? && (pressed_up? || pressed_right? || pressed_left? || pressed_down?)
|
27
|
-
end
|
28
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module ProconBypassMan::Procon::PushedButtonHelper
|
2
|
-
module Dynamic
|
3
|
-
@@compiled = false
|
4
|
-
def compile_if_not_compile_yet!
|
5
|
-
unless @@compiled
|
6
|
-
::ProconBypassMan::Procon::ButtonCollection::BUTTONS_MAP.each do |button, _value|
|
7
|
-
define_method "pressed_#{button}?" do
|
8
|
-
pressed_button?(button)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
@@compiled = true
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "net/http"
|
2
|
-
require "json"
|
3
|
-
|
4
|
-
class ProconBypassMan::Reporter
|
5
|
-
PATH = "/api/reports" # POST
|
6
|
-
|
7
|
-
class Client
|
8
|
-
def initialize
|
9
|
-
@server = ProconBypassMan.api_server
|
10
|
-
@hostname = `hostname`.chomp
|
11
|
-
end
|
12
|
-
|
13
|
-
def post(body: )
|
14
|
-
# TODO ここでvalidationする
|
15
|
-
if @server.nil?
|
16
|
-
ProconBypassMan.logger.info('送信先が未設定なのでスキップしました')
|
17
|
-
return
|
18
|
-
end
|
19
|
-
|
20
|
-
uri = URI.parse("#{@server}#{PATH}")
|
21
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
22
|
-
http.use_ssl = uri.scheme === "https"
|
23
|
-
response = http.post(
|
24
|
-
uri.path,
|
25
|
-
{ report: body.to_json, hostname: @hostname }.to_json,
|
26
|
-
{ "Content-Type" => "application/json" },
|
27
|
-
)
|
28
|
-
unless response.code == /^20/
|
29
|
-
ProconBypassMan.logger.error(response.body)
|
30
|
-
end
|
31
|
-
rescue => e
|
32
|
-
puts e
|
33
|
-
ProconBypassMan.logger.error(e)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.report(body: )
|
38
|
-
Client.new.post(body: body)
|
39
|
-
rescue => e
|
40
|
-
ProconBypassMan.logger.error(e)
|
41
|
-
end
|
42
|
-
end
|