class Rkremap::Uinput

www.kernel.org/doc/html/v4.12/input/uinput.html

Constants

UI_DEV_CREATE
UI_DEV_SETUP
UI_SET_EVBIT
UI_SET_KEYBIT

Public Class Methods

new() click to toggle source
# File lib/rkremap/evdev.rb, line 128
def initialize
  @dev = File.open('/dev/uinput', 'w')
  setup
end

Public Instance Methods

setup() click to toggle source
# File lib/rkremap/evdev.rb, line 133
def setup
  @dev.ioctl(UI_SET_EVBIT, EV_KEY)
  KeyCode::KEY_CNT.times{|k| @dev.ioctl(UI_SET_KEYBIT, k)}
  bustype = 0x03    # BUS_USB
  vendor = 0x1234   # てきとー
  product = 0x5678  # てきとー
  version = 1       # てきとー
  name = 'rkremap'
  ff_efects_max = 0
  setup = [bustype, vendor, product, version, name, ff_efects_max].pack("SSSSZ80L") # struct uinput_setup
  @dev.ioctl(UI_DEV_SETUP, setup)
  @dev.ioctl(UI_DEV_CREATE)
end
write_event(type, code, value) click to toggle source

@param type [Integer] EV_KEY/ EV_SYN @param code [Integer] キーコード / SYN_REPORT @param value [Integer] 0:release / 1:press / 2:repeat

# File lib/rkremap/evdev.rb, line 150
def write_event(type, code, value)
  @dev.syswrite(['', type, code, value].pack('a16SSl'))
end