Module: CMusBt::Device::Input
- Defined in:
- lib/cmus-bt/device/input.rb
Class Method Summary collapse
- .list ⇒ Object
- .put_bitmap(dst, s) ⇒ Object
- .put_handlers(dst, s) ⇒ Object
- .put_ident(dst, s) ⇒ Object
- .put_name(dst, s) ⇒ Object
- .put_phys(dst, s) ⇒ Object
- .put_sysfs(dst, s) ⇒ Object
- .put_uniq(dst, s) ⇒ Object
Class Method Details
.list ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cmus-bt/device/input.rb', line 62 def list ret = [] File.open("/proc/bus/input/devices") { |f| info = {} f.each_line { |l| case l when /^I: (.*)$/ put_ident(info, $1) when /^N: (.*)$/ put_name(info, $1) when /^P: (.*)/ put_phys(info, $1) when /^S: (.*)$/ put_sysfs(info, $1) when /^U: (.*)$/ put_uniq(info, $1) when /^H: Handlers=(.*)$/ put_handlers(info, $1) when /^B: (.*)$/ put_bitmap(info, $1) when /^\s*$/ ret << info info = {} next end } ret << info if not info.empty? } return ret end |
.put_bitmap(dst, s) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/cmus-bt/device/input.rb', line 54 def put_bitmap(dst, s) h = (dst[:bitmap] ||= {}) if /(.+)=(.+)/ =~ s h[$1] = $2 end end |
.put_handlers(dst, s) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cmus-bt/device/input.rb', line 40 def put_handlers(dst, s) a = [] s.split.each { |t| if /^event\d+$/ =~ t dst[:dev_file] = "/dev/input/#{t}" else a << t end } dst[:handlers] = a end |
.put_ident(dst, s) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/cmus-bt/device/input.rb', line 14 def put_ident(dst, s) h = {} s.scan(/([[:alpha:]]+)=(\h+)/) { |key, val| h[key.downcase.to_sym] = val.to_i } dst[:ident] = h end |
.put_name(dst, s) ⇒ Object
24 25 26 |
# File 'lib/cmus-bt/device/input.rb', line 24 def put_name(dst, s) dst[:name] = (/^Name=\"(.*)\"$/ =~ s) && $1 end |
.put_phys(dst, s) ⇒ Object
28 29 30 |
# File 'lib/cmus-bt/device/input.rb', line 28 def put_phys(dst, s) dst[:phys] = (/^Phys=(.*)$/ =~ s) && $1 end |
.put_sysfs(dst, s) ⇒ Object
32 33 34 |
# File 'lib/cmus-bt/device/input.rb', line 32 def put_sysfs(dst, s) dst[:sysfs] = (/^Sysfs=(.*)$/ =~ s) && $1 end |
.put_uniq(dst, s) ⇒ Object
36 37 38 |
# File 'lib/cmus-bt/device/input.rb', line 36 def put_uniq(dst, s) dst[:uniq] = (/^Uniq=(.*)$/ =~ s) && $1 end |