procon_bypass_man 0.1.6 → 0.1.10
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 +41 -16
- data/.github/workflows/ruby.yml +34 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +17 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +57 -6
- data/README.md +18 -10
- data/Rakefile +10 -1
- data/Steepfile +39 -0
- data/bin/report_receive_server.rb +11 -0
- data/docs/setup_raspi.md +12 -7
- data/docs/setup_raspi.mitamae.rb +60 -0
- data/docs/setup_raspi_by_mitamae.md +14 -0
- data/lib/procon_bypass_man/analog_stick_position.rb +8 -0
- data/lib/procon_bypass_man/boot_message.rb +40 -0
- data/lib/procon_bypass_man/buttons_setting_configuration.rb +100 -0
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +20 -0
- data/lib/procon_bypass_man/bypass.rb +61 -29
- data/lib/procon_bypass_man/callbacks.rb +70 -0
- data/lib/procon_bypass_man/configuration/layer.rb +50 -4
- data/lib/procon_bypass_man/configuration/loader.rb +8 -8
- data/lib/procon_bypass_man/configuration/validator.rb +1 -1
- data/lib/procon_bypass_man/configuration.rb +68 -64
- data/lib/procon_bypass_man/device_connector.rb +13 -30
- data/lib/procon_bypass_man/io_monitor.rb +7 -4
- data/lib/procon_bypass_man/on_memory_cache.rb +34 -0
- data/lib/procon_bypass_man/outbound/base.rb +40 -0
- data/lib/procon_bypass_man/outbound/error_reporter.rb +13 -0
- data/lib/procon_bypass_man/outbound/reporter.rb +12 -0
- data/lib/procon_bypass_man/outbound/usb_hid_data_reporter.rb +13 -0
- data/lib/procon_bypass_man/procon/analog_stick_cap.rb +88 -0
- data/lib/procon_bypass_man/procon/button_collection.rb +14 -6
- data/lib/procon_bypass_man/procon/debug_dumper.rb +17 -0
- data/lib/procon_bypass_man/procon/layer_changeable.rb +2 -2
- data/lib/procon_bypass_man/procon/macro_registry.rb +2 -2
- data/lib/procon_bypass_man/procon/mode_registry.rb +4 -4
- data/lib/procon_bypass_man/procon/press_button_aware.rb +13 -0
- data/lib/procon_bypass_man/procon/pressed_button_helper.rb +0 -10
- data/lib/procon_bypass_man/procon/user_operation.rb +14 -3
- data/lib/procon_bypass_man/procon.rb +23 -5
- data/lib/procon_bypass_man/runner.rb +36 -48
- data/lib/procon_bypass_man/uptime.rb +15 -0
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man.rb +26 -33
- data/project_template/README.md +17 -0
- data/project_template/app.rb +20 -0
- data/project_template/setting.yml +35 -0
- data/project_template/systemd_units/pbm.service +13 -0
- data/project_template/systemd_units/pbm_web.service +11 -0
- data/project_template/web.rb +16 -0
- data/sig/README.rb +4 -0
- data/sig/main.rbs +507 -0
- metadata +30 -5
- data/examples/pbm.service +0 -27
- data/examples/simple.rb +0 -13
data/lib/procon_bypass_man.rb
CHANGED
@@ -1,39 +1,54 @@
|
|
1
1
|
require "logger"
|
2
2
|
require 'yaml'
|
3
|
+
require "json"
|
4
|
+
require "net/http"
|
3
5
|
require "fileutils"
|
4
6
|
|
5
7
|
require_relative "procon_bypass_man/version"
|
8
|
+
require_relative "procon_bypass_man/callbacks"
|
9
|
+
require_relative "procon_bypass_man/analog_stick_position"
|
6
10
|
require_relative "procon_bypass_man/timer"
|
7
11
|
require_relative "procon_bypass_man/bypass"
|
8
12
|
require_relative "procon_bypass_man/device_connector"
|
9
13
|
require_relative "procon_bypass_man/runner"
|
10
14
|
require_relative "procon_bypass_man/processor"
|
11
15
|
require_relative "procon_bypass_man/configuration"
|
16
|
+
require_relative "procon_bypass_man/buttons_setting_configuration"
|
12
17
|
require_relative "procon_bypass_man/procon"
|
18
|
+
require_relative "procon_bypass_man/procon/debug_dumper"
|
19
|
+
require_relative "procon_bypass_man/procon/analog_stick_cap"
|
20
|
+
require_relative "procon_bypass_man/outbound/reporter"
|
21
|
+
require_relative "procon_bypass_man/outbound/error_reporter"
|
22
|
+
require_relative "procon_bypass_man/outbound/usb_hid_data_reporter"
|
23
|
+
require_relative "procon_bypass_man/on_memory_cache"
|
13
24
|
|
14
25
|
STDOUT.sync = true
|
15
26
|
Thread.abort_on_exception = true
|
16
27
|
|
17
28
|
module ProconBypassMan
|
29
|
+
extend ProconBypassMan::Configuration::ClassAttributes
|
30
|
+
|
18
31
|
class ProConRejected < StandardError; end
|
19
32
|
class CouldNotLoadConfigError < StandardError; end
|
20
33
|
class FirstConnectionError < StandardError; end
|
21
34
|
class EternalConnectionError < StandardError; end
|
22
35
|
|
23
|
-
def self.
|
36
|
+
def self.buttons_setting_configure(setting_path: nil, &block)
|
24
37
|
unless setting_path
|
25
38
|
logger.warn "setting_pathが未設定です。設定ファイルのライブリロードが使えません。"
|
26
39
|
end
|
27
40
|
|
28
41
|
if block_given?
|
29
|
-
ProconBypassMan::
|
42
|
+
ProconBypassMan::ButtonsSettingConfiguration.instance.instance_eval(&block)
|
30
43
|
else
|
31
|
-
ProconBypassMan::
|
44
|
+
ProconBypassMan::ButtonsSettingConfiguration::Loader.load(setting_path: setting_path)
|
32
45
|
end
|
33
46
|
end
|
34
47
|
|
35
48
|
def self.run(setting_path: nil, &block)
|
36
|
-
|
49
|
+
ProconBypassMan.logger.info "PBMを起動しています"
|
50
|
+
puts "PBMを起動しています"
|
51
|
+
buttons_setting_configure(setting_path: setting_path, &block)
|
37
52
|
File.write(pid_path, $$)
|
38
53
|
Runner.new.run
|
39
54
|
rescue CouldNotLoadConfigError
|
@@ -52,43 +67,21 @@ module ProconBypassMan
|
|
52
67
|
retry
|
53
68
|
end
|
54
69
|
|
55
|
-
def self.
|
56
|
-
@@
|
70
|
+
def self.configure(&block)
|
71
|
+
@@configuration = ProconBypassMan::Configuration.new
|
72
|
+
@@configuration.instance_eval(&block)
|
73
|
+
@@configuration
|
57
74
|
end
|
58
75
|
|
59
|
-
def self.
|
60
|
-
|
61
|
-
@@logger
|
62
|
-
else
|
63
|
-
Logger.new(nil)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.pid_path
|
68
|
-
@@pid_path ||= File.expand_path("#{root}/pbm_pid", __dir__).freeze
|
76
|
+
def self.config
|
77
|
+
@@configuration ||= ProconBypassMan::Configuration.new
|
69
78
|
end
|
70
79
|
|
71
80
|
def self.reset!
|
72
81
|
ProconBypassMan::Procon::MacroRegistry.reset!
|
73
82
|
ProconBypassMan::Procon::ModeRegistry.reset!
|
74
83
|
ProconBypassMan::Procon.reset!
|
75
|
-
ProconBypassMan::
|
84
|
+
ProconBypassMan::ButtonsSettingConfiguration.instance.reset!
|
76
85
|
ProconBypassMan::IOMonitor.reset!
|
77
86
|
end
|
78
|
-
|
79
|
-
def self.root
|
80
|
-
if defined?(@@root)
|
81
|
-
@@root
|
82
|
-
else
|
83
|
-
File.expand_path('..', __dir__).freeze
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.root=(path)
|
88
|
-
@@root = path
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.digest_path
|
92
|
-
"#{root}/.setting_yaml_digest"
|
93
|
-
end
|
94
87
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Project Template
|
2
|
+
https://github.com/splaplapla/pbmenv で使っているファイルです
|
3
|
+
|
4
|
+
## systemd
|
5
|
+
* sudo ln -s /usr/share/pbm/current/systemd_units/pbm.service /etc/systemd/system/pbm.service
|
6
|
+
* sudo ln -s /usr/share/pbm/current/systemd_units/pbm_web.service /etc/systemd/system/pbm_web.service
|
7
|
+
* commands
|
8
|
+
* systemctl daemon-reload
|
9
|
+
* systemctl enable pbm.service
|
10
|
+
* systemctl disable pbm.service
|
11
|
+
* systemctl start pbm.service
|
12
|
+
* systemctl status pbm.service
|
13
|
+
* systemctl restart pbm.service
|
14
|
+
* systemctl list-unit-files --type=service
|
15
|
+
|
16
|
+
### ログ
|
17
|
+
* journalctl -xe -f
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/inline'
|
4
|
+
|
5
|
+
gemfile do
|
6
|
+
source 'https://rubygems.org'
|
7
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
8
|
+
gem 'procon_bypass_man', '0.1.9'
|
9
|
+
gem 'procon_bypass_man-splatoon2', github: 'splaplapla/procon_bypass_man-splatoon2', tag: "0.1.1"
|
10
|
+
end
|
11
|
+
|
12
|
+
ProconBypassMan.configure do |config|
|
13
|
+
config.root = File.expand_path(__dir__)
|
14
|
+
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 5, 1024 * 1024 * 10)
|
15
|
+
config.logger.level = :debug
|
16
|
+
# pbm.api_server = 'https://...'
|
17
|
+
config.enable_critical_error_logging!
|
18
|
+
end
|
19
|
+
|
20
|
+
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
@@ -0,0 +1,35 @@
|
|
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_macro_plugin ProconBypassMan::Splatoon2::Macro::JumpToUpKey
|
8
|
+
install_macro_plugin ProconBypassMan::Splatoon2::Macro::JumpToRightKey
|
9
|
+
install_macro_plugin ProconBypassMan::Splatoon2::Macro::JumpToLeftKey
|
10
|
+
install_mode_plugin guruguru
|
11
|
+
|
12
|
+
prefix_keys_for_changing_layer [:zr, :zl, :l]
|
13
|
+
|
14
|
+
layer :up, mode: :manual do
|
15
|
+
# flip :zr, if_pressed: :zr, force_neutral: :zl
|
16
|
+
flip :zr, if_pressed: :zr, force_neutral: :zl
|
17
|
+
flip :zl, if_pressed: [:y, :b, :zl]
|
18
|
+
flip :a, if_pressed: [:a]
|
19
|
+
flip :down, if_pressed: :down
|
20
|
+
macro fast_return.name, if_pressed: [:y, :b, :down]
|
21
|
+
macro ProconBypassMan::Splatoon2::Macro::JumpToUpKey, if_pressed: [:y, :b, :up]
|
22
|
+
macro ProconBypassMan::Splatoon2::Macro::JumpToRightKey, if_pressed: [:y, :b, :right]
|
23
|
+
macro ProconBypassMan::Splatoon2::Macro::JumpToLeftKey, if_pressed: [:y, :b, :left]
|
24
|
+
remap :l, to: :zr
|
25
|
+
end
|
26
|
+
layer :right, mode: guruguru.name
|
27
|
+
layer :left do
|
28
|
+
# flip :zr, if_pressed: :zr, force_neutral: :zl
|
29
|
+
remap :l, to: :zr
|
30
|
+
end
|
31
|
+
layer :down do
|
32
|
+
# flip :zl
|
33
|
+
# flip :zr, if_pressed: :zr, force_neutral: :zl, flip_interval: "1F"
|
34
|
+
remap :l, to: :zr
|
35
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=PBM
|
3
|
+
After=network.target
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
Type=simple
|
7
|
+
WorkingDirectory=/usr/share/pbm/current
|
8
|
+
ExecStart=/bin/bash -c "/home/pi/.rbenv/versions/3.0.1/bin/ruby /usr/share/pbm/current/app.rb"
|
9
|
+
Restart=always
|
10
|
+
Nice=-19
|
11
|
+
|
12
|
+
[Install]
|
13
|
+
WantedBy=multi-user.target
|
@@ -0,0 +1,11 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=PBM WEB
|
3
|
+
|
4
|
+
[Service]
|
5
|
+
Type=simple
|
6
|
+
WorkingDirectory=/home/pi/src/procon_bypass_man_sample
|
7
|
+
ExecStart=/bin/bash -c "/home/pi/.rbenv/versions/3.0.1/bin/ruby /usr/share/pbm/current/web.rb"
|
8
|
+
Restart=always
|
9
|
+
|
10
|
+
[Install]
|
11
|
+
WantedBy=multi-user.target
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/inline'
|
4
|
+
|
5
|
+
gemfile do
|
6
|
+
source 'https://rubygems.org'
|
7
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
8
|
+
gem 'procon_bypass_man-web', '0.1.2'
|
9
|
+
end
|
10
|
+
|
11
|
+
ProconBypassMan::Web.configure do |config|
|
12
|
+
config.root = File.expand_path(__dir__)
|
13
|
+
config.logger = Logger.new("#{ProconBypassMan::Web.root}/web.log", 1, 1024 * 1024 * 10)
|
14
|
+
end
|
15
|
+
|
16
|
+
ProconBypassMan::Web::Server.start
|
data/sig/README.rb
ADDED