Class: Revdev::InputEvent
- Inherits:
-
Object
- Object
- Revdev::InputEvent
- Includes:
- EachValuesEqual
- Defined in:
- lib/revdev/input_event.rb,
lib/revdev.rb
Overview
wraper of “struct input_event” on “input.h”
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#time ⇒ Object
Returns the value of attribute time.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#hr_code ⇒ Object
human readable @code of input event.
-
#hr_type ⇒ Object
human readable @type of input event.
-
#hr_value ⇒ Object
human readable @code of input event not implement.
-
#initialize(arg = nil, type = nil, code = nil, value = nil) ⇒ InputEvent
constructor
arg: String(byte string), Hash, Time type, code, value: Integer (ignored values if arg is String or Hash).
Methods included from EachValuesEqual
Constructor Details
#initialize(arg = nil, type = nil, code = nil, value = nil) ⇒ InputEvent
arg: String(byte string), Hash, Time type, code, value: Integer (ignored values if arg is String or Hash)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/revdev/input_event.rb', line 12 def initialize arg=nil, type = nil, code = nil, value = nil if arg.kind_of? String raw_initialize arg elsif arg.kind_of? Hash [:time, :type, :code, :value].each do |iv| instance_variable_set("@#{iv}", arg[iv] || arg[iv.to_s]) end @time ||= Time.now else @time = arg || Time.now @type = type @code = code @value = value end end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
8 9 10 |
# File 'lib/revdev/input_event.rb', line 8 def code @code end |
#time ⇒ Object
Returns the value of attribute time.
8 9 10 |
# File 'lib/revdev/input_event.rb', line 8 def time @time end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/revdev/input_event.rb', line 8 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/revdev/input_event.rb', line 8 def value @value end |
Instance Method Details
#hr_code ⇒ Object
human readable @code of input event
34 35 36 37 38 39 40 |
# File 'lib/revdev/input_event.rb', line 34 def hr_code ht = hr_type suffix = Revdev.extract_suffix ht return nil if suffix.nil? map = REVERSE_MAPS[suffix] map && map[@code] end |
#hr_type ⇒ Object
human readable @type of input event
29 30 31 |
# File 'lib/revdev/input_event.rb', line 29 def hr_type REVERSE_MAPS[:EV][@type] end |
#hr_value ⇒ Object
human readable @code of input event not implement
44 45 46 |
# File 'lib/revdev/input_event.rb', line 44 def hr_value nil end |