Module: Uinput

Defined in:
lib/uinput.rb

Constant Summary collapse

FILE_PATH =
'/dev/uinput'

Class Method Summary collapse

Class Method Details

.open_file(mode = Fcntl::O_RDWR) ⇒ Object



12
13
14
# File 'lib/uinput.rb', line 12

def self.open_file(mode = Fcntl::O_RDWR)
  File.open(FILE_PATH, mode)
end

.versionObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/uinput.rb', line 16

def self.version
  @version ||= begin
    pack_size = case FFI.type_size(:uint)
      when 2 then 's'
      when 4 then 'L'
      when 8 then 'Q'
    end

    version = [0].pack pack_size
    open_file.ioctl UI_GET_VERSION, version
    version.unpack(pack_size).first
  end
end