Skip to content

Commit

Permalink
chore: Add warning log for missing keyboard in selector
Browse files Browse the repository at this point in the history
  • Loading branch information
iberianpig committed Apr 29, 2024
1 parent 1e7f746 commit cdb0779
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/fusuma/plugin/remap/keyboard_remapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,15 @@ def initialize(names = ["keyboard", "Keyboard", "KEYBOARD"])
# If no device is found, it will wait for 3 seconds and try again
# @return [Array<Revdev::EventDevice>]
def select
displayed_no_keyboard = false
loop do
Fusuma::Device.reset # reset cache to get the latest device information
devices = Fusuma::Device.all.select { |d| Array(@names).any? { |name| d.name =~ /#{name}/ } }
if devices.empty?
unless displayed_no_keyboard
MultiLogger.warn "No keyboard found: #{@names}"
displayed_no_keyboard = true
end
wait_for_device

next
Expand Down
5 changes: 3 additions & 2 deletions spec/fusuma/plugin/remap/keyboard_remapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
allow(selector).to receive(:loop).and_yield
allow(Fusuma::Device).to receive(:all).and_return([])
end
it "wait for device" do
expect(selector).to receive(:loop).and_yield

it "wait for device, and logs warn message" do
expect(selector).to receive(:wait_for_device)
expect(Fusuma::MultiLogger).to receive(:warn).with(/No keyboard found/)
selector.select
end
end
Expand Down

0 comments on commit cdb0779

Please sign in to comment.