module Evdev::Converter
Public Class Methods
code_to_int(code)
click to toggle source
# File lib/evdev/converter.rb, line 16 def code_to_int(code) LinuxInput.const_get(code.upcase) end
code_to_type(code)
click to toggle source
# File lib/evdev/converter.rb, line 4 def code_to_type(code) :"EV_#{code.to_s.split('_').first}" end
int_to_name(type_int, code_int)
click to toggle source
# File lib/evdev/converter.rb, line 20 def int_to_name(type_int, code_int) @event_names ||= {} @event_names[type_int] ||= consts_starting_with("#{int_to_type(type_int)}_") @event_names[type_int][code_int] end
property_to_int(property)
click to toggle source
# File lib/evdev/converter.rb, line 8 def property_to_int(property) LinuxInput.const_get(:"INPUT_PROP_#{property.upcase}") end
type_to_int(type)
click to toggle source
# File lib/evdev/converter.rb, line 12 def type_to_int(type) LinuxInput.const_get(type.upcase) end
Private Class Methods
consts_starting_with(prefix)
click to toggle source
# File lib/evdev/converter.rb, line 33 def consts_starting_with(prefix) LinuxInput.constants(false).map do |const| [LinuxInput.const_get(const), const] if const.to_s.start_with? prefix end.compact.to_h end
int_to_type(int)
click to toggle source
# File lib/evdev/converter.rb, line 28 def int_to_type(int) @event_types ||= consts_starting_with('EV_') @event_types[int][3..-1] end