Skip to content

Commit

Permalink
Merge pull request #25 from splaplapla/supress-internal-communication
Browse files Browse the repository at this point in the history
internal apiとの通信をdefault 無効にする
  • Loading branch information
jiikko authored Jan 22, 2022
2 parents 77fa1b7 + 8f7021c commit 255c63c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/procon_bypass_man/bypass/usb_hid_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ def log_procon_to_gadget
end
end

ProconBypassMan.cache.fetch key: 'pressed_buttons_reporter', expires_in: 5 do
ProconBypassMan::ReportPressedButtonsJob.perform_async(
bypass_value.binary.to_procon_reader.to_hash
)
if ProconBypassMan.config.enable_reporting_pressed_buttons
ProconBypassMan.cache.fetch key: 'pressed_buttons_reporter', expires_in: 5 do
ProconBypassMan::ReportPressedButtonsJob.perform_async(
bypass_value.binary.to_procon_reader.to_hash
)
end
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/procon_bypass_man/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def device_id
end

attr_accessor :enable_critical_error_logging
attr_writer :verbose_bypass_log, :raw_setting
attr_writer :verbose_bypass_log, :raw_setting, :enable_reporting_pressed_buttons

def root=(path)
@root = path
Expand Down Expand Up @@ -154,4 +154,8 @@ def verbose_bypass_log
def raw_setting
@raw_setting ||= {}
end

def enable_reporting_pressed_buttons
@enable_reporting_pressed_buttons ||= false
end
end
12 changes: 12 additions & 0 deletions spec/lib/procon_bypass_man/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,16 @@
end
end
end

describe '#enable_reporting_pressed_buttons' do
let(:config) { described_class.new }
it 'default false' do
expect(config.enable_reporting_pressed_buttons).to eq(false)
end

it do
config.enable_reporting_pressed_buttons = true
expect(config.enable_reporting_pressed_buttons).to eq(true)
end
end
end
2 changes: 2 additions & 0 deletions spec/lib/procon_bypass_man_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
:digest_path,
:raw_setting,
:raw_setting=,
:enable_reporting_pressed_buttons,
:enable_reporting_pressed_buttons=,
].each do |me|
it "has config.#{me} method" do
expect(described_class.config.respond_to?(me)).to eq(true)
Expand Down

0 comments on commit 255c63c

Please sign in to comment.