Module: Vigilem::Evdev::DOM::InputEventUtils

Extended by:
Support::Utils, InputEventUtils
Includes:
DOM::Utils
Included in:
InputEventConverter, InputEventUtils
Defined in:
lib/vigilem/evdev/dom/input_event_utils.rb

Instance Method Summary collapse

Instance Method Details

#event_code_to_keycode_str(event_code) ⇒ String

takes a InputEvent#code and returns a String representing the keycode value

Parameters:

  • event_code, (Integer)

    the number to convert

Returns:

  • (String)

    i.e. “keycode30”



13
14
15
# File 'lib/vigilem/evdev/dom/input_event_utils.rb', line 13

def event_code_to_keycode_str(event_code)
  "keycode#{event_code}"
end

#location_str_from_keycode_name(keycode_name) ⇒ String || NilClass

takes a keycode_name and returns a common location string if available

Parameters:

  • keycode_name, (String || Symbol)

    i.e. KEY_RIGTHCTRL

Returns:

  • (String || NilClass)

    a common locaiton string i.e. ‘Right’



21
22
23
24
25
# File 'lib/vigilem/evdev/dom/input_event_utils.rb', line 21

def location_str_from_keycode_name(keycode_name)
  if loc = keycode_name.to_s.gsub('KP', 'NUMPAD').scan(/LEFT|RIGHT|NUMPAD/i).first
    loc.downcase.tap {|obj| obj[0] = obj[0].upcase }
  end
end

#modifier_keymap_name(keycode_name) ⇒ String

TODO:

meta

takes a keycode name and returns the keymap modifier name

Parameters:

  • keycode_name, (String ||Symbol)

    i.e. KEY_RIGHTCTRL

Returns:

  • (String)

    keymap_name of the modifier



31
32
33
34
35
36
37
38
39
# File 'lib/vigilem/evdev/dom/input_event_utils.rb', line 31

def modifier_keymap_name(keycode_name)
  if (keycode_name) =~ /caps|shift|alt|c(on)?tro?l/i
    if keycode_name == :KEY_CAPSLOCK
      'capsshift'
    else
      keycode_name.to_s.gsub(/KEY_/, '').split(/ight|eft/i).reverse.join.downcase
    end
  end
end