Class: Fusuma::Plugin::Remap::DeviceSelector
- Inherits:
-
Object
- Object
- Fusuma::Plugin::Remap::DeviceSelector
- Defined in:
- lib/fusuma/plugin/remap/device_selector.rb
Overview
Common device selector for touchpad and keyboard detection Unifies TouchpadSelector implementations across the codebase
Constant Summary collapse
- POLL_INTERVAL =
seconds
3
Instance Method Summary collapse
-
#initialize(name_patterns: nil, device_type: :touchpad) ⇒ DeviceSelector
constructor
A new instance of DeviceSelector.
-
#select(wait: false) ⇒ Array<Revdev::EventDevice>
Select devices that match the name patterns.
Constructor Details
#initialize(name_patterns: nil, device_type: :touchpad) ⇒ DeviceSelector
Returns a new instance of DeviceSelector.
16 17 18 19 20 |
# File 'lib/fusuma/plugin/remap/device_selector.rb', line 16 def initialize(name_patterns: nil, device_type: :touchpad) @name_patterns = name_patterns @device_type = device_type @displayed_waiting = false end |
Instance Method Details
#select(wait: false) ⇒ Array<Revdev::EventDevice>
Select devices that match the name patterns
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fusuma/plugin/remap/device_selector.rb', line 25 def select(wait: false) loop do Fusuma::Device.reset # reset cache to get the latest device information devices = find_devices return to_event_devices(devices) unless devices.empty? return [] unless wait unless @displayed_waiting sleep POLL_INTERVAL end end |