Class: Revdev::EventDevice
- Inherits:
-
Object
- Object
- Revdev::EventDevice
- Defined in:
- lib/revdev.rb,
lib/revdev/event_device.rb
Instance Method Summary collapse
- #all_leds_status ⇒ Object
- #all_sounds_status ⇒ Object
- #all_switch_status ⇒ Object
- #device_name ⇒ Object
- #device_prop ⇒ Object
- #driver_version ⇒ Object
- #global_key_state ⇒ Object
-
#grab ⇒ Object
grab all input events of the event device.
-
#initialize(arg) ⇒ EventDevice
constructor
A new instance of EventDevice.
- #physical_location ⇒ Object
- #read_input_event ⇒ Object
- #read_ioctl_as_string_with(command) ⇒ Object
- #read_ioctl_with(command) ⇒ Object
-
#ungrab ⇒ Object
release the grabbed event device.
- #uniq_id ⇒ Object
- #write_input_event(ie) ⇒ Object
Constructor Details
#initialize(arg) ⇒ EventDevice
Returns a new instance of EventDevice.
6 7 8 9 10 11 12 |
# File 'lib/revdev/event_device.rb', line 6 def initialize arg if arg.kind_of? File @file = arg else @file = File.new arg, 'r+' end end |
Instance Method Details
#all_leds_status ⇒ Object
50 51 52 |
# File 'lib/revdev/event_device.rb', line 50 def all_leds_status read_ioctl_as_string_with EVIOCGLED end |
#all_sounds_status ⇒ Object
54 55 56 |
# File 'lib/revdev/event_device.rb', line 54 def all_sounds_status read_ioctl_as_string_with EVIOCGSND end |
#all_switch_status ⇒ Object
58 59 60 |
# File 'lib/revdev/event_device.rb', line 58 def all_switch_status read_ioctl_as_string_with EVIOCGSW end |
#device_name ⇒ Object
30 31 32 |
# File 'lib/revdev/event_device.rb', line 30 def device_name read_ioctl_as_string_with EVIOCGNAME end |
#device_prop ⇒ Object
42 43 44 |
# File 'lib/revdev/event_device.rb', line 42 def device_prop read_ioctl_as_string_with EVIOCGPROP end |
#driver_version ⇒ Object
20 21 22 23 |
# File 'lib/revdev/event_device.rb', line 20 def driver_version r = read_ioctl_with EVIOCGVERSION r.unpack('i').first end |
#global_key_state ⇒ Object
46 47 48 |
# File 'lib/revdev/event_device.rb', line 46 def global_key_state read_ioctl_as_string_with EVIOCGKEY end |
#grab ⇒ Object
grab all input events of the event device
63 64 65 |
# File 'lib/revdev/event_device.rb', line 63 def grab @file.ioctl EVIOCGRAB, 1 end |
#physical_location ⇒ Object
34 35 36 |
# File 'lib/revdev/event_device.rb', line 34 def physical_location read_ioctl_as_string_with EVIOCGPHYS end |
#read_input_event ⇒ Object
72 73 74 |
# File 'lib/revdev/event_device.rb', line 72 def read_input_event InputEvent.new @file.read InputEvent::SIZEOF end |
#read_ioctl_as_string_with(command) ⇒ Object
25 26 27 28 |
# File 'lib/revdev/event_device.rb', line 25 def read_ioctl_as_string_with command r = read_ioctl_with command r.unpack('Z*').first end |
#read_ioctl_with(command) ⇒ Object
14 15 16 17 18 |
# File 'lib/revdev/event_device.rb', line 14 def read_ioctl_with command r = "" @file.ioctl command, r return r end |
#ungrab ⇒ Object
release the grabbed event device
68 69 70 |
# File 'lib/revdev/event_device.rb', line 68 def ungrab @file.ioctl EVIOCGRAB, 0 end |
#uniq_id ⇒ Object
38 39 40 |
# File 'lib/revdev/event_device.rb', line 38 def uniq_id read_ioctl_as_string_with EVIOCGUNIQ end |
#write_input_event(ie) ⇒ Object
76 77 78 |
# File 'lib/revdev/event_device.rb', line 76 def write_input_event ie @file.syswrite ie.to_byte_string end |