Skip to content
Generic ruby wrapper around uinput to create devices.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/uinput
.gitignore
.rakeTasks
.rspec
.travis.yml
Gemfile
README.md
Rakefile
test.rb
uinput-device.gemspec

README.md

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)
end

Symbols 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
You can’t perform that action at this time.