Class: Uinput::Device::SystemInitializer
- Inherits:
-
Object
- Object
- Uinput::Device::SystemInitializer
- Defined in:
- lib/uinput/device/system_initializer.rb
Constant Summary collapse
- FILE =
'/dev/uinput'
Instance Method Summary collapse
- #add_event(event) ⇒ Object
- #add_key(key) ⇒ Object (also: #add_button)
- #create ⇒ Object
-
#initialize(device, &block) ⇒ SystemInitializer
constructor
A new instance of SystemInitializer.
- #name=(name) ⇒ Object
- #product=(product) ⇒ Object
- #type=(type) ⇒ Object
- #vendor=(vendor) ⇒ Object
- #version=(version) ⇒ Object
Constructor Details
#initialize(device, &block) ⇒ SystemInitializer
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/uinput/device/system_initializer.rb', line 6 def initialize(device, &block) @file = File.open(FILE, Fcntl::O_WRONLY | Fcntl::O_NDELAY) @device = UinputUserDev.new self.name = "Virtual Ruby Device" self.type = LinuxInput::BUS_VIRTUAL self.vendor = 0 self.product = 0 self.version = 0 instance_exec &block if block end |
Instance Method Details
#add_event(event) ⇒ Object
44 45 46 |
# File 'lib/uinput/device/system_initializer.rb', line 44 def add_event(event) @file.ioctl(UI_SET_EVBIT, event.is_a?(Symbol) ? LinuxInput.const_get(event) : event) end |
#add_key(key) ⇒ Object Also known as:
39 40 41 |
# File 'lib/uinput/device/system_initializer.rb', line 39 def add_key(key) @file.ioctl(UI_SET_KEYBIT, key.is_a?(Symbol) ? LinuxInput.const_get(key) : key) end |
#create ⇒ Object
48 49 50 51 |
# File 'lib/uinput/device/system_initializer.rb', line 48 def create @file.syswrite(@device.pointer.read_bytes(@device.size)) @file if @file.ioctl(UI_DEV_CREATE).zero? end |
#name=(name) ⇒ Object
19 20 21 |
# File 'lib/uinput/device/system_initializer.rb', line 19 def name=(name) @device[:name] = name end |
#product=(product) ⇒ Object
31 32 33 |
# File 'lib/uinput/device/system_initializer.rb', line 31 def product=(product) @device[:id][:product] = product end |
#type=(type) ⇒ Object
23 24 25 |
# File 'lib/uinput/device/system_initializer.rb', line 23 def type=(type) @device[:id][:bustype] = type.is_a?(Symbol) ? LinuxInput.const_get(type) : type end |
#vendor=(vendor) ⇒ Object
27 28 29 |
# File 'lib/uinput/device/system_initializer.rb', line 27 def vendor=(vendor) @device[:id][:vendor] = vendor end |
#version=(version) ⇒ Object
35 36 37 |
# File 'lib/uinput/device/system_initializer.rb', line 35 def version=(version) @device[:id][:version] = version end |