Uinput::Device
Generic ruby wrapper around uinput to create devices.
Installation
Add this line to your application's Gemfile:
gem 'uinput-device'And then execute:
$ bundle
Or install it yourself as:
$ gem install uinput-device
Usage
require 'uinput/device'Initializing a new virtual device having an A key:
device = Uinput::Device.new do
self.name = "Our virtual device"
self.type = LinuxInput::BUS_VIRTUAL
self.add_key(:KEY_A)
self.add_event(:EV_KEY)
self.add_event(:EV_SYN)
endSymbols like :KEY_A are mapped to constants in the LinuxInput namespace (see
linux_input)
Typing an 'a' on our keyboard:
# key down
device.send_event(:EV_KEY, :KEY_A, 1)
device.send_event(:EV_SYN, :SYN_REPORT)
# key up
device.send_event(:EV_KEY, :KEY_A, 0)
device.send_event(:EV_SYN, :SYN_REPORT)Destroying the device:
device.destroy