Class: Fusuma::Plugin::Remap::KeyboardRemapper::KeyboardSelector
- Inherits:
-
Object
- Object
- Fusuma::Plugin::Remap::KeyboardRemapper::KeyboardSelector
- Defined in:
- lib/fusuma/plugin/remap/keyboard_remapper.rb
Overview
Devices to detect key presses and releases
Instance Method Summary collapse
-
#initialize(names) ⇒ KeyboardSelector
constructor
A new instance of KeyboardSelector.
-
#select ⇒ Array<Revdev::EventDevice>
Select devices that match the name If no device is found, it will wait for 3 seconds and try again.
- #wait_for_device ⇒ Object
Constructor Details
#initialize(names) ⇒ KeyboardSelector
Returns a new instance of KeyboardSelector.
364 365 366 |
# File 'lib/fusuma/plugin/remap/keyboard_remapper.rb', line 364 def initialize(names) @names = names end |
Instance Method Details
#select ⇒ Array<Revdev::EventDevice>
Select devices that match the name If no device is found, it will wait for 3 seconds and try again
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/fusuma/plugin/remap/keyboard_remapper.rb', line 371 def select displayed_no_keyboard = false loop do Fusuma::Device.reset # reset cache to get the latest device information devices = Fusuma::Device.all.select do |d| next if d.name == VIRTUAL_KEYBOARD_NAME Array(@names).any? { |name| d.name =~ /#{name}/ } end if devices.empty? unless displayed_no_keyboard MultiLogger.warn "No keyboard found: #{@names}" displayed_no_keyboard = true end wait_for_device next end return devices.map { |d| Revdev::EventDevice.new("/dev/input/#{d.id}") } end end |
#wait_for_device ⇒ Object
394 395 396 |
# File 'lib/fusuma/plugin/remap/keyboard_remapper.rb', line 394 def wait_for_device sleep 3 end |