class Evdev
Constants
- VERSION
Attributes
event_channel[R]
file[R]
Public Class Methods
all(file_paths = '/dev/input/event*')
click to toggle source
# File lib/evdev.rb, line 18 def all(file_paths = '/dev/input/event*') Dir[file_paths].map{ |file_path| new(file_path) } end
finalize(device)
click to toggle source
# File lib/evdev.rb, line 14 def finalize(device) proc { Libevdev.free(device) } end
new(file_path)
click to toggle source
# File lib/evdev.rb, line 23 def initialize(file_path) @file = File.open(file_path) device_ptr = FFI::MemoryPointer.new :pointer Libevdev.new_from_fd(@file.fileno, device_ptr) @device = device_ptr.read_pointer ObjectSpace.define_finalizer(self, self.class.finalize(@device)) end
Public Instance Methods
abs_axis(code)
click to toggle source
# File lib/evdev.rb, line 71 def abs_axis(code) AbsAxis.new(@device, Converter.code_to_int(code)) end
bustype()
click to toggle source
# File lib/evdev.rb, line 55 def bustype Libevdev.get_id_bustype(@device) end
driver_version()
click to toggle source
# File lib/evdev.rb, line 63 def driver_version Libevdev.get_driver_version(@device) end
event_value(event)
click to toggle source
# File lib/evdev.rb, line 101 def event_value(event) return unless supports_event?(event) type = Converter.code_to_type(event) Libevdev.get_event_value(@device, Converter.type_to_int(type), Converter.code_to_int(event)) end
events_pending?()
click to toggle source
# File lib/evdev.rb, line 97 def events_pending? 1 == Libevdev.has_event_pending(@device) end
grab()
click to toggle source
# File lib/evdev.rb, line 75 def grab 0 == Libevdev.grab(@device, Libevdev::GRAB) end
handle_event(mode = :blocking)
click to toggle source
# File lib/evdev.rb, line 88 def handle_event(mode = :blocking) event = LinuxInput::InputEvent.new Libevdev.next_event(@device, Libevdev.const_get(:"READ_FLAG_#{mode.upcase}"), event.pointer) event_name = Converter.int_to_name(event[:type], event[:code]) trigger(event_name, event[:value], event_name) rescue Errno::EAGAIN => e raise e.extend AwaitEvent end
has_property?(property)
click to toggle source
# File lib/evdev.rb, line 67 def has_property?(property) 1 == Libevdev.has_property(@device, Converter.property_to_int(property)) end
name()
click to toggle source
# File lib/evdev.rb, line 35 def name Libevdev.get_name(@device) end
phys()
click to toggle source
# File lib/evdev.rb, line 39 def phys Libevdev.get_phys(@device) end
product_id()
click to toggle source
# File lib/evdev.rb, line 51 def product_id Libevdev.get_id_product(@device) end
supports_event?(event)
click to toggle source
# File lib/evdev.rb, line 83 def supports_event?(event) type = Converter.code_to_type(event) handles_event_type?(type) and handles_event_code?(type, event) end
ungrab()
click to toggle source
# File lib/evdev.rb, line 79 def ungrab 0 == Libevdev.grab(@device, Libevdev::UNGRAB) end
uniq()
click to toggle source
# File lib/evdev.rb, line 43 def uniq Libevdev.get_uniq(@device) end
vendor_id()
click to toggle source
# File lib/evdev.rb, line 47 def vendor_id Libevdev.get_id_vendor(@device) end
version()
click to toggle source
# File lib/evdev.rb, line 59 def version Libevdev.get_id_version(@device) end
Private Instance Methods
handles_event_code?(type, code)
click to toggle source
# File lib/evdev.rb, line 113 def handles_event_code?(type, code) 1 == Libevdev.has_event_code(@device, Converter.type_to_int(type), Converter.code_to_int(code)) end
handles_event_type?(type)
click to toggle source
# File lib/evdev.rb, line 109 def handles_event_type?(type) 1 == Libevdev.has_event_type(@device, Converter.type_to_int(type)) end