Class: Xkbcommon::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/xkbcommon/key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keymap, code) ⇒ Key

Returns a new instance of Key.



25
26
27
28
29
30
# File 'lib/xkbcommon/key.rb', line 25

def initialize(keymap, code)
  @keymap = keymap
  @code = code
  @scan_code = code - 8 # about offset 8: http://xkbcommon.org/doc/current/xkbcommon_8h.html#ac29aee92124c08d1953910ab28ee1997
  @name = self.class.code_to_name(@scan_code)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



32
33
34
# File 'lib/xkbcommon/key.rb', line 32

def code
  @code
end

#keymapObject (readonly)

Returns the value of attribute keymap.



32
33
34
# File 'lib/xkbcommon/key.rb', line 32

def keymap
  @keymap
end

#nameObject (readonly)

Returns the value of attribute name.



32
33
34
# File 'lib/xkbcommon/key.rb', line 32

def name
  @name
end

#scan_codeObject (readonly)

Returns the value of attribute scan_code.



32
33
34
# File 'lib/xkbcommon/key.rb', line 32

def scan_code
  @scan_code
end

Class Method Details

.code_to_name(code) ⇒ Object



6
7
8
# File 'lib/xkbcommon/key.rb', line 6

def code_to_name(code)
  codes_to_names[code]
end

Instance Method Details

#inspectObject



34
35
36
# File 'lib/xkbcommon/key.rb', line 34

def inspect
  "#<#{self.class.name}:0x#{'%014x' % __id__} @code=#{code} @name=#{name.inspect}>"
end