class Uinput::Device::Initializer
Public Class Methods
new(device, &block)
click to toggle source
# File lib/uinput/device/initializer.rb, line 6 def initialize(device, &block) @file = Uinput.open_file(Fcntl::O_RDWR | Fcntl::O_NONBLOCK) if Uinput.version == 5 @device = UinputSetup.new else @device = UinputUserDev.new end self.name = "Virtual Ruby Device" self.type = LinuxInput::BUS_VIRTUAL self.vendor = 0 self.product = 0 self.version = 0 instance_exec &block if block if Uinput.version >= 5 @file.ioctl UI_DEV_SETUP, @device.pointer.read_bytes(@device.size) else @file.syswrite @device.pointer.read_bytes(@device.size) end end
Public Instance Methods
add_event(event)
click to toggle source
# File lib/uinput/device/initializer.rb, line 55 def add_event(event) @file.ioctl(UI_SET_EVBIT, (event.is_a? Symbol) ? LinuxInput.const_get(event) : event) end
add_key(key)
click to toggle source
# File lib/uinput/device/initializer.rb, line 50 def add_key(key) @file.ioctl(UI_SET_KEYBIT, (key.is_a? Symbol) ? LinuxInput.const_get(key) : key) end
Also aliased as: add_button
create()
click to toggle source
# File lib/uinput/device/initializer.rb, line 59 def create if @file.ioctl(UI_DEV_CREATE).zero? @file end end
name=(name)
click to toggle source
# File lib/uinput/device/initializer.rb, line 30 def name=(name) @device[:name] = name[0,UINPUT_MAX_NAME_SIZE] end
product=(product)
click to toggle source
# File lib/uinput/device/initializer.rb, line 42 def product=(product) @device[:id][:product] = product end
type=(type)
click to toggle source
# File lib/uinput/device/initializer.rb, line 34 def type=(type) @device[:id][:bustype] = (type.is_a? Symbol) ? LinuxInput.const_get(type) : type end
vendor=(vendor)
click to toggle source
# File lib/uinput/device/initializer.rb, line 38 def vendor=(vendor) @device[:id][:vendor] = vendor end
version=(version)
click to toggle source
# File lib/uinput/device/initializer.rb, line 46 def version=(version) @device[:id][:version] = version end