libdevinput 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +2 -0
- data/COPYING +165 -0
- data/README +31 -0
- data/Rakefile +23 -0
- data/examples/readlines.rb +22 -0
- data/lib/libdevinput.rb +499 -0
- metadata +60 -0
data/AUTHORS
ADDED
data/COPYING
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
libdevinput - a ruby library to read input device events from /dev/input/eventX on linux systems
|
2
|
+
|
3
|
+
This ruby library makes it easy to read events from linux event devices. These device files, residing in /dev/input/ get created for a number of different human input devices like keyboards, mice, touchscreens, joysticks and the like.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'libdevinput'
|
9
|
+
|
10
|
+
dev = DevInput.new "/dev/input/event0"
|
11
|
+
dev.each do |event|
|
12
|
+
puts "got event #{event}"
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
Each event consists of the following fields:
|
17
|
+
event.time: A Time object of the event time
|
18
|
+
event.tv_sec: An Integer with the number of seconds since epoch
|
19
|
+
event.tv_usec: An Integer with the sub-seconds value in milliseconds
|
20
|
+
event.type: An Integer with the type code
|
21
|
+
event.type_str: A String representation of the type if available
|
22
|
+
event.code: An Integer with the event code
|
23
|
+
event.code_str: A String representation of the code if available
|
24
|
+
event.value: An Integer with the event value
|
25
|
+
event.value_str: A String representation of the value if available
|
26
|
+
|
27
|
+
The library currently only reads raw events. It does not read the capabilities of a device via ioctl, nor does it interpret the states of modifier keys.
|
28
|
+
If you want to change this or something else, you are more than welcome to fork this project.
|
29
|
+
|
30
|
+
This library was influenced by evtest.c, the event device test program by Vojtech Pavlik
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
s.name = "libdevinput"
|
7
|
+
s.version = "0.0.1"
|
8
|
+
s.author = "Peter Rullmann"
|
9
|
+
s.email = "peter @nospam@ p4n.net"
|
10
|
+
s.summary = "A ruby library to read input device events on linux systems"
|
11
|
+
s.description = "This ruby library makes it easy to read events from linux event devices. These device files, residing in /dev/input/ get created for a number of different human input devices like keyboards, mice, touchscreens, joysticks and the like."
|
12
|
+
s.files = FileList['lib/*.rb', 'examples/*.rb', '[A-Z]*'].to_a
|
13
|
+
s.homepage = "http://github.com/prullmann/libdevinput"
|
14
|
+
end
|
15
|
+
|
16
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
17
|
+
pkg.need_tar = true
|
18
|
+
end
|
19
|
+
|
20
|
+
task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
|
21
|
+
puts 'generated latest version'
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This example shows how to read from /dev/input/event0, reject everything
|
4
|
+
# but key press events and print them to STDOUT
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'libdevinput'
|
8
|
+
|
9
|
+
filename = ARGV[0] || "/dev/input/event0"
|
10
|
+
puts "opening #{filename}"
|
11
|
+
dev = DevInput.new filename
|
12
|
+
|
13
|
+
puts "waiting for events to come..."
|
14
|
+
dev.each do |event|
|
15
|
+
puts "got event #{event}"
|
16
|
+
# reject everything but key events
|
17
|
+
next unless event.type == 1
|
18
|
+
# reject everything but press events
|
19
|
+
next unless event.value == 1
|
20
|
+
puts "got key press event of key >>#{event.code_str}<<!"
|
21
|
+
end
|
22
|
+
|
data/lib/libdevinput.rb
ADDED
@@ -0,0 +1,499 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# libdevinput
|
4
|
+
# A ruby library to read input device events on linux systems
|
5
|
+
#
|
6
|
+
# Copyright (c) 2010 Peter Rullmann (peter AT p4n.net / http://p4n.net)
|
7
|
+
# Homepage: http://github.com/prullmann/libdevinput
|
8
|
+
|
9
|
+
# This program is free software; you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation; either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# This program is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with this program; if not, write to the Free Software
|
21
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22
|
+
|
23
|
+
|
24
|
+
class DevInput
|
25
|
+
|
26
|
+
require 'time'
|
27
|
+
|
28
|
+
TYPES = []
|
29
|
+
TYPES[0] = 'Sync'
|
30
|
+
TYPES[1] = 'Key'
|
31
|
+
TYPES[2] = 'Relative'
|
32
|
+
TYPES[3] = 'Absolute'
|
33
|
+
TYPES[4] = 'Misc'
|
34
|
+
TYPES[17] = 'LED'
|
35
|
+
TYPES[18] = 'Sound'
|
36
|
+
TYPES[20] = 'Repeat'
|
37
|
+
TYPES[21] = 'ForceFeedback'
|
38
|
+
TYPES[22] = 'Power'
|
39
|
+
TYPES[23] = 'ForceFeedbackStatus'
|
40
|
+
|
41
|
+
EVENTS = []
|
42
|
+
EVENTS[0] = []
|
43
|
+
EVENTS[0][0] = 'Sync'
|
44
|
+
EVENTS[0][1] = 'Key'
|
45
|
+
EVENTS[0][2] = 'Relative'
|
46
|
+
EVENTS[0][3] = 'Absolute'
|
47
|
+
EVENTS[0][4] = 'Misc'
|
48
|
+
EVENTS[0][17] = 'LED'
|
49
|
+
EVENTS[0][18] = 'Sound'
|
50
|
+
EVENTS[0][20] = 'Repeat'
|
51
|
+
EVENTS[0][21] = 'ForceFeedback'
|
52
|
+
EVENTS[0][22] = 'Power'
|
53
|
+
EVENTS[0][23] = 'ForceFeedbackStatus'
|
54
|
+
EVENTS[1] = []
|
55
|
+
EVENTS[1][0] = 'Reserved'
|
56
|
+
EVENTS[1][1] = 'Esc'
|
57
|
+
EVENTS[1][2] = '1'
|
58
|
+
EVENTS[1][3] = '2'
|
59
|
+
EVENTS[1][4] = '3'
|
60
|
+
EVENTS[1][5] = '4'
|
61
|
+
EVENTS[1][6] = '5'
|
62
|
+
EVENTS[1][7] = '6'
|
63
|
+
EVENTS[1][8] = '7'
|
64
|
+
EVENTS[1][9] = '8'
|
65
|
+
EVENTS[1][10] = '9'
|
66
|
+
EVENTS[1][11] = '0'
|
67
|
+
EVENTS[1][12] = 'Minus'
|
68
|
+
EVENTS[1][13] = 'Equal'
|
69
|
+
EVENTS[1][14] = 'Backspace'
|
70
|
+
EVENTS[1][15] = 'Tab'
|
71
|
+
EVENTS[1][16] = 'Q'
|
72
|
+
EVENTS[1][17] = 'W'
|
73
|
+
EVENTS[1][18] = 'E'
|
74
|
+
EVENTS[1][19] = 'R'
|
75
|
+
EVENTS[1][20] = 'T'
|
76
|
+
EVENTS[1][21] = 'Y'
|
77
|
+
EVENTS[1][22] = 'U'
|
78
|
+
EVENTS[1][23] = 'I'
|
79
|
+
EVENTS[1][24] = 'O'
|
80
|
+
EVENTS[1][25] = 'P'
|
81
|
+
EVENTS[1][26] = 'LeftBrace'
|
82
|
+
EVENTS[1][27] = 'RightBrace'
|
83
|
+
EVENTS[1][28] = 'Enter'
|
84
|
+
EVENTS[1][29] = 'LeftControl'
|
85
|
+
EVENTS[1][30] = 'A'
|
86
|
+
EVENTS[1][31] = 'S'
|
87
|
+
EVENTS[1][32] = 'D'
|
88
|
+
EVENTS[1][33] = 'F'
|
89
|
+
EVENTS[1][34] = 'G'
|
90
|
+
EVENTS[1][35] = 'H'
|
91
|
+
EVENTS[1][36] = 'J'
|
92
|
+
EVENTS[1][37] = 'K'
|
93
|
+
EVENTS[1][38] = 'L'
|
94
|
+
EVENTS[1][39] = 'Semicolon'
|
95
|
+
EVENTS[1][40] = 'Apostrophe'
|
96
|
+
EVENTS[1][41] = 'Grave'
|
97
|
+
EVENTS[1][42] = 'LeftShift'
|
98
|
+
EVENTS[1][43] = 'BackSlash'
|
99
|
+
EVENTS[1][44] = 'Z'
|
100
|
+
EVENTS[1][45] = 'X'
|
101
|
+
EVENTS[1][46] = 'C'
|
102
|
+
EVENTS[1][47] = 'V'
|
103
|
+
EVENTS[1][48] = 'B'
|
104
|
+
EVENTS[1][49] = 'N'
|
105
|
+
EVENTS[1][50] = 'M'
|
106
|
+
EVENTS[1][51] = 'Comma'
|
107
|
+
EVENTS[1][52] = 'Dot'
|
108
|
+
EVENTS[1][53] = 'Slash'
|
109
|
+
EVENTS[1][54] = 'RightShift'
|
110
|
+
EVENTS[1][55] = 'KPAsterisk'
|
111
|
+
EVENTS[1][56] = 'LeftAlt'
|
112
|
+
EVENTS[1][57] = 'Space'
|
113
|
+
EVENTS[1][58] = 'CapsLock'
|
114
|
+
EVENTS[1][59] = 'F1'
|
115
|
+
EVENTS[1][60] = 'F2'
|
116
|
+
EVENTS[1][61] = 'F3'
|
117
|
+
EVENTS[1][62] = 'F4'
|
118
|
+
EVENTS[1][63] = 'F5'
|
119
|
+
EVENTS[1][64] = 'F6'
|
120
|
+
EVENTS[1][65] = 'F7'
|
121
|
+
EVENTS[1][66] = 'F8'
|
122
|
+
EVENTS[1][67] = 'F9'
|
123
|
+
EVENTS[1][68] = 'F10'
|
124
|
+
EVENTS[1][69] = 'NumLock'
|
125
|
+
EVENTS[1][70] = 'ScrollLock'
|
126
|
+
EVENTS[1][71] = 'KP7'
|
127
|
+
EVENTS[1][72] = 'KP8'
|
128
|
+
EVENTS[1][73] = 'KP9'
|
129
|
+
EVENTS[1][74] = 'KPMinus'
|
130
|
+
EVENTS[1][75] = 'KP4'
|
131
|
+
EVENTS[1][76] = 'KP5'
|
132
|
+
EVENTS[1][77] = 'KP6'
|
133
|
+
EVENTS[1][78] = 'KPPlus'
|
134
|
+
EVENTS[1][79] = 'KP1'
|
135
|
+
EVENTS[1][80] = 'KP2'
|
136
|
+
EVENTS[1][81] = 'KP3'
|
137
|
+
EVENTS[1][82] = 'KP0'
|
138
|
+
EVENTS[1][83] = 'KPDot'
|
139
|
+
EVENTS[1][85] = 'Zenkaku/Hankaku'
|
140
|
+
EVENTS[1][86] = '102nd'
|
141
|
+
EVENTS[1][87] = 'F11'
|
142
|
+
EVENTS[1][88] = 'F12'
|
143
|
+
EVENTS[1][89] = 'RO'
|
144
|
+
EVENTS[1][90] = 'Katakana'
|
145
|
+
EVENTS[1][91] = 'HIRAGANA'
|
146
|
+
EVENTS[1][92] = 'Henkan'
|
147
|
+
EVENTS[1][93] = 'Katakana/Hiragana'
|
148
|
+
EVENTS[1][94] = 'Muhenkan'
|
149
|
+
EVENTS[1][95] = 'KPJpComma'
|
150
|
+
EVENTS[1][96] = 'KPEnter'
|
151
|
+
EVENTS[1][97] = 'RightCtrl'
|
152
|
+
EVENTS[1][98] = 'KPSlash'
|
153
|
+
EVENTS[1][99] = 'SysRq'
|
154
|
+
EVENTS[1][100] = 'RightAlt'
|
155
|
+
EVENTS[1][101] = 'LineFeed'
|
156
|
+
EVENTS[1][102] = 'Home'
|
157
|
+
EVENTS[1][103] = 'Up'
|
158
|
+
EVENTS[1][104] = 'PageUp'
|
159
|
+
EVENTS[1][105] = 'Left'
|
160
|
+
EVENTS[1][106] = 'Right'
|
161
|
+
EVENTS[1][107] = 'End'
|
162
|
+
EVENTS[1][108] = 'Down'
|
163
|
+
EVENTS[1][109] = 'PageDown'
|
164
|
+
EVENTS[1][110] = 'Insert'
|
165
|
+
EVENTS[1][111] = 'Delete'
|
166
|
+
EVENTS[1][112] = 'Macro'
|
167
|
+
EVENTS[1][113] = 'Mute'
|
168
|
+
EVENTS[1][114] = 'VolumeDown'
|
169
|
+
EVENTS[1][115] = 'VolumeUp'
|
170
|
+
EVENTS[1][116] = 'Power'
|
171
|
+
EVENTS[1][117] = 'KPEqual'
|
172
|
+
EVENTS[1][118] = 'KPPlusMinus'
|
173
|
+
EVENTS[1][119] = 'Pause'
|
174
|
+
EVENTS[1][121] = 'KPComma'
|
175
|
+
EVENTS[1][122] = 'Hanguel'
|
176
|
+
EVENTS[1][123] = 'Hanja'
|
177
|
+
EVENTS[1][124] = 'Yen'
|
178
|
+
EVENTS[1][125] = 'LeftMeta'
|
179
|
+
EVENTS[1][126] = 'RightMeta'
|
180
|
+
EVENTS[1][127] = 'Compose'
|
181
|
+
EVENTS[1][128] = 'Stop'
|
182
|
+
EVENTS[1][129] = 'Again'
|
183
|
+
EVENTS[1][130] = 'Props'
|
184
|
+
EVENTS[1][131] = 'Undo'
|
185
|
+
EVENTS[1][132] = 'Front'
|
186
|
+
EVENTS[1][133] = 'Copy'
|
187
|
+
EVENTS[1][134] = 'Open'
|
188
|
+
EVENTS[1][135] = 'Paste'
|
189
|
+
EVENTS[1][136] = 'Find'
|
190
|
+
EVENTS[1][137] = 'Cut'
|
191
|
+
EVENTS[1][138] = 'Help'
|
192
|
+
EVENTS[1][139] = 'Menu'
|
193
|
+
EVENTS[1][140] = 'Calc'
|
194
|
+
EVENTS[1][141] = 'Setup'
|
195
|
+
EVENTS[1][142] = 'Sleep'
|
196
|
+
EVENTS[1][143] = 'WakeUp'
|
197
|
+
EVENTS[1][144] = 'File'
|
198
|
+
EVENTS[1][145] = 'SendFile'
|
199
|
+
EVENTS[1][146] = 'DeleteFile'
|
200
|
+
EVENTS[1][147] = 'X-fer'
|
201
|
+
EVENTS[1][148] = 'Prog1'
|
202
|
+
EVENTS[1][149] = 'Prog2'
|
203
|
+
EVENTS[1][150] = 'WWW'
|
204
|
+
EVENTS[1][151] = 'MSDOS'
|
205
|
+
EVENTS[1][152] = 'Coffee'
|
206
|
+
EVENTS[1][153] = 'Direction'
|
207
|
+
EVENTS[1][154] = 'CycleWindows'
|
208
|
+
EVENTS[1][155] = 'Mail'
|
209
|
+
EVENTS[1][156] = 'Bookmarks'
|
210
|
+
EVENTS[1][157] = 'Computer'
|
211
|
+
EVENTS[1][158] = 'Back'
|
212
|
+
EVENTS[1][159] = 'Forward'
|
213
|
+
EVENTS[1][160] = 'CloseCD'
|
214
|
+
EVENTS[1][161] = 'EjectCD'
|
215
|
+
EVENTS[1][162] = 'EjectCloseCD'
|
216
|
+
EVENTS[1][163] = 'NextSong'
|
217
|
+
EVENTS[1][164] = 'PlayPause'
|
218
|
+
EVENTS[1][165] = 'PreviousSong'
|
219
|
+
EVENTS[1][166] = 'StopCD'
|
220
|
+
EVENTS[1][167] = 'Record'
|
221
|
+
EVENTS[1][168] = 'Rewind'
|
222
|
+
EVENTS[1][169] = 'Phone'
|
223
|
+
EVENTS[1][170] = 'ISOKey'
|
224
|
+
EVENTS[1][171] = 'Config'
|
225
|
+
EVENTS[1][172] = 'HomePage'
|
226
|
+
EVENTS[1][173] = 'Refresh'
|
227
|
+
EVENTS[1][174] = 'Exit'
|
228
|
+
EVENTS[1][175] = 'Move'
|
229
|
+
EVENTS[1][176] = 'Edit'
|
230
|
+
EVENTS[1][177] = 'ScrollUp'
|
231
|
+
EVENTS[1][178] = 'ScrollDown'
|
232
|
+
EVENTS[1][179] = 'KPLeftParenthesis'
|
233
|
+
EVENTS[1][180] = 'KPRightParenthesis'
|
234
|
+
EVENTS[1][183] = 'F13'
|
235
|
+
EVENTS[1][184] = 'F14'
|
236
|
+
EVENTS[1][185] = 'F15'
|
237
|
+
EVENTS[1][186] = 'F16'
|
238
|
+
EVENTS[1][187] = 'F17'
|
239
|
+
EVENTS[1][188] = 'F18'
|
240
|
+
EVENTS[1][189] = 'F19'
|
241
|
+
EVENTS[1][190] = 'F20'
|
242
|
+
EVENTS[1][191] = 'F21'
|
243
|
+
EVENTS[1][192] = 'F22'
|
244
|
+
EVENTS[1][193] = 'F23'
|
245
|
+
EVENTS[1][194] = 'F24'
|
246
|
+
EVENTS[1][200] = 'PlayCD'
|
247
|
+
EVENTS[1][201] = 'PauseCD'
|
248
|
+
EVENTS[1][202] = 'Prog3'
|
249
|
+
EVENTS[1][203] = 'Prog4'
|
250
|
+
EVENTS[1][205] = 'Suspend'
|
251
|
+
EVENTS[1][206] = 'Close'
|
252
|
+
EVENTS[1][207] = 'Play'
|
253
|
+
EVENTS[1][208] = 'Fast Forward'
|
254
|
+
EVENTS[1][209] = 'Bass Boost'
|
255
|
+
EVENTS[1][210] = 'Print'
|
256
|
+
EVENTS[1][211] = 'HP'
|
257
|
+
EVENTS[1][212] = 'Camera'
|
258
|
+
EVENTS[1][213] = 'Sound'
|
259
|
+
EVENTS[1][214] = 'Question'
|
260
|
+
EVENTS[1][215] = 'Email'
|
261
|
+
EVENTS[1][216] = 'Chat'
|
262
|
+
EVENTS[1][217] = 'Search'
|
263
|
+
EVENTS[1][218] = 'Connect'
|
264
|
+
EVENTS[1][219] = 'Finance'
|
265
|
+
EVENTS[1][220] = 'Sport'
|
266
|
+
EVENTS[1][221] = 'Shop'
|
267
|
+
EVENTS[1][222] = 'Alternate Erase'
|
268
|
+
EVENTS[1][223] = 'Cancel'
|
269
|
+
EVENTS[1][224] = 'Brightness down'
|
270
|
+
EVENTS[1][225] = 'Brightness up'
|
271
|
+
EVENTS[1][226] = 'Media'
|
272
|
+
EVENTS[1][240] = 'Unknown'
|
273
|
+
EVENTS[1][256] = 'Btn0'
|
274
|
+
EVENTS[1][257] = 'Btn1'
|
275
|
+
EVENTS[1][258] = 'Btn2'
|
276
|
+
EVENTS[1][259] = 'Btn3'
|
277
|
+
EVENTS[1][260] = 'Btn4'
|
278
|
+
EVENTS[1][261] = 'Btn5'
|
279
|
+
EVENTS[1][262] = 'Btn6'
|
280
|
+
EVENTS[1][263] = 'Btn7'
|
281
|
+
EVENTS[1][264] = 'Btn8'
|
282
|
+
EVENTS[1][265] = 'Btn9'
|
283
|
+
EVENTS[1][272] = 'LeftBtn'
|
284
|
+
EVENTS[1][273] = 'RightBtn'
|
285
|
+
EVENTS[1][274] = 'MiddleBtn'
|
286
|
+
EVENTS[1][275] = 'SideBtn'
|
287
|
+
EVENTS[1][276] = 'ExtraBtn'
|
288
|
+
EVENTS[1][277] = 'ForwardBtn'
|
289
|
+
EVENTS[1][278] = 'BackBtn'
|
290
|
+
EVENTS[1][279] = 'TaskBtn'
|
291
|
+
EVENTS[1][288] = 'Trigger'
|
292
|
+
EVENTS[1][289] = 'ThumbBtn'
|
293
|
+
EVENTS[1][290] = 'ThumbBtn2'
|
294
|
+
EVENTS[1][291] = 'TopBtn'
|
295
|
+
EVENTS[1][292] = 'TopBtn2'
|
296
|
+
EVENTS[1][293] = 'PinkieBtn'
|
297
|
+
EVENTS[1][294] = 'BaseBtn'
|
298
|
+
EVENTS[1][295] = 'BaseBtn2'
|
299
|
+
EVENTS[1][296] = 'BaseBtn3'
|
300
|
+
EVENTS[1][297] = 'BaseBtn4'
|
301
|
+
EVENTS[1][298] = 'BaseBtn5'
|
302
|
+
EVENTS[1][299] = 'BaseBtn6'
|
303
|
+
EVENTS[1][303] = 'BtnDead'
|
304
|
+
EVENTS[1][304] = 'BtnA'
|
305
|
+
EVENTS[1][305] = 'BtnB'
|
306
|
+
EVENTS[1][306] = 'BtnC'
|
307
|
+
EVENTS[1][307] = 'BtnX'
|
308
|
+
EVENTS[1][308] = 'BtnY'
|
309
|
+
EVENTS[1][309] = 'BtnZ'
|
310
|
+
EVENTS[1][310] = 'BtnTL'
|
311
|
+
EVENTS[1][311] = 'BtnTR'
|
312
|
+
EVENTS[1][312] = 'BtnTL2'
|
313
|
+
EVENTS[1][313] = 'BtnTR2'
|
314
|
+
EVENTS[1][314] = 'BtnSelect'
|
315
|
+
EVENTS[1][315] = 'BtnStart'
|
316
|
+
EVENTS[1][316] = 'BtnMode'
|
317
|
+
EVENTS[1][317] = 'BtnThumbL'
|
318
|
+
EVENTS[1][318] = 'BtnThumbR'
|
319
|
+
EVENTS[1][320] = 'ToolPen'
|
320
|
+
EVENTS[1][321] = 'ToolRubber'
|
321
|
+
EVENTS[1][322] = 'ToolBrush'
|
322
|
+
EVENTS[1][323] = 'ToolPencil'
|
323
|
+
EVENTS[1][324] = 'ToolAirbrush'
|
324
|
+
EVENTS[1][325] = 'ToolFinger'
|
325
|
+
EVENTS[1][326] = 'ToolMouse'
|
326
|
+
EVENTS[1][327] = 'ToolLens'
|
327
|
+
EVENTS[1][330] = 'Touch'
|
328
|
+
EVENTS[1][331] = 'Stylus'
|
329
|
+
EVENTS[1][332] = 'Stylus2'
|
330
|
+
EVENTS[1][333] = 'Tool Doubletap'
|
331
|
+
EVENTS[1][334] = 'Tool Tripletap'
|
332
|
+
EVENTS[1][336] = 'WheelBtn'
|
333
|
+
EVENTS[1][337] = 'Gear up'
|
334
|
+
EVENTS[1][352] = 'Ok'
|
335
|
+
EVENTS[1][353] = 'Select'
|
336
|
+
EVENTS[1][354] = 'Goto'
|
337
|
+
EVENTS[1][355] = 'Clear'
|
338
|
+
EVENTS[1][356] = 'Power2'
|
339
|
+
EVENTS[1][357] = 'Option'
|
340
|
+
EVENTS[1][358] = 'Info'
|
341
|
+
EVENTS[1][359] = 'Time'
|
342
|
+
EVENTS[1][360] = 'Vendor'
|
343
|
+
EVENTS[1][361] = 'Archive'
|
344
|
+
EVENTS[1][362] = 'Program'
|
345
|
+
EVENTS[1][363] = 'Channel'
|
346
|
+
EVENTS[1][364] = 'Favorites'
|
347
|
+
EVENTS[1][365] = 'EPG'
|
348
|
+
EVENTS[1][366] = 'PVR'
|
349
|
+
EVENTS[1][367] = 'MHP'
|
350
|
+
EVENTS[1][368] = 'Language'
|
351
|
+
EVENTS[1][369] = 'Title'
|
352
|
+
EVENTS[1][370] = 'Subtitle'
|
353
|
+
EVENTS[1][371] = 'Angle'
|
354
|
+
EVENTS[1][372] = 'Zoom'
|
355
|
+
EVENTS[1][373] = 'Mode'
|
356
|
+
EVENTS[1][374] = 'Keyboard'
|
357
|
+
EVENTS[1][375] = 'Screen'
|
358
|
+
EVENTS[1][376] = 'PC'
|
359
|
+
EVENTS[1][377] = 'TV'
|
360
|
+
EVENTS[1][378] = 'TV2'
|
361
|
+
EVENTS[1][379] = 'VCR'
|
362
|
+
EVENTS[1][380] = 'VCR2'
|
363
|
+
EVENTS[1][381] = 'Sat'
|
364
|
+
EVENTS[1][382] = 'Sat2'
|
365
|
+
EVENTS[1][383] = 'CD'
|
366
|
+
EVENTS[1][384] = 'Tape'
|
367
|
+
EVENTS[1][385] = 'Radio'
|
368
|
+
EVENTS[1][386] = 'Tuner'
|
369
|
+
EVENTS[1][387] = 'Player'
|
370
|
+
EVENTS[1][388] = 'Text'
|
371
|
+
EVENTS[1][389] = 'DVD'
|
372
|
+
EVENTS[1][390] = 'Aux'
|
373
|
+
EVENTS[1][391] = 'MP3'
|
374
|
+
EVENTS[1][392] = 'Audio'
|
375
|
+
EVENTS[1][393] = 'Video'
|
376
|
+
EVENTS[1][394] = 'Directory'
|
377
|
+
EVENTS[1][395] = 'List'
|
378
|
+
EVENTS[1][396] = 'Memo'
|
379
|
+
EVENTS[1][397] = 'Calendar'
|
380
|
+
EVENTS[1][398] = 'Red'
|
381
|
+
EVENTS[1][399] = 'Green'
|
382
|
+
EVENTS[1][400] = 'Yellow'
|
383
|
+
EVENTS[1][401] = 'Blue'
|
384
|
+
EVENTS[1][402] = 'ChannelUp'
|
385
|
+
EVENTS[1][403] = 'ChannelDown'
|
386
|
+
EVENTS[1][404] = 'First'
|
387
|
+
EVENTS[1][405] = 'Last'
|
388
|
+
EVENTS[1][406] = 'AB'
|
389
|
+
EVENTS[1][407] = 'Next'
|
390
|
+
EVENTS[1][408] = 'Restart'
|
391
|
+
EVENTS[1][409] = 'Slow'
|
392
|
+
EVENTS[1][410] = 'Shuffle'
|
393
|
+
EVENTS[1][411] = 'Break'
|
394
|
+
EVENTS[1][412] = 'Previous'
|
395
|
+
EVENTS[1][413] = 'Digits'
|
396
|
+
EVENTS[1][414] = 'TEEN'
|
397
|
+
EVENTS[1][415] = 'TWEN'
|
398
|
+
EVENTS[1][448] = 'Delete EOL'
|
399
|
+
EVENTS[1][449] = 'Delete EOS'
|
400
|
+
EVENTS[1][450] = 'Insert line'
|
401
|
+
EVENTS[1][451] = 'Delete line'
|
402
|
+
EVENTS[2] = []
|
403
|
+
EVENTS[2][0] = 'X'
|
404
|
+
EVENTS[2][1] = 'Y'
|
405
|
+
EVENTS[2][2] = 'Z'
|
406
|
+
EVENTS[2][6] = 'HWheel'
|
407
|
+
EVENTS[2][7] = 'Dial'
|
408
|
+
EVENTS[2][8] = 'Wheel'
|
409
|
+
EVENTS[2][9] = 'Misc'
|
410
|
+
EVENTS[3] = []
|
411
|
+
EVENTS[3][0] = 'X'
|
412
|
+
EVENTS[3][1] = 'Y'
|
413
|
+
EVENTS[3][2] = 'Z'
|
414
|
+
EVENTS[3][3] = 'Rx'
|
415
|
+
EVENTS[3][4] = 'Ry'
|
416
|
+
EVENTS[3][5] = 'Rz'
|
417
|
+
EVENTS[3][6] = 'Throttle'
|
418
|
+
EVENTS[3][7] = 'Rudder'
|
419
|
+
EVENTS[3][8] = 'Wheel'
|
420
|
+
EVENTS[3][9] = 'Gas'
|
421
|
+
EVENTS[3][10] = 'Brake'
|
422
|
+
EVENTS[3][16] = 'Hat0X'
|
423
|
+
EVENTS[3][17] = 'Hat0Y'
|
424
|
+
EVENTS[3][18] = 'Hat1X'
|
425
|
+
EVENTS[3][19] = 'Hat1Y'
|
426
|
+
EVENTS[3][20] = 'Hat2X'
|
427
|
+
EVENTS[3][21] = 'Hat2Y'
|
428
|
+
EVENTS[3][22] = 'Hat3X'
|
429
|
+
EVENTS[3][23] = 'Hat 3Y'
|
430
|
+
EVENTS[3][24] = 'Pressure'
|
431
|
+
EVENTS[3][25] = 'Distance'
|
432
|
+
EVENTS[3][26] = 'XTilt'
|
433
|
+
EVENTS[3][27] = 'YTilt'
|
434
|
+
EVENTS[3][28] = 'Tool Width'
|
435
|
+
EVENTS[3][32] = 'Volume'
|
436
|
+
EVENTS[3][40] = 'Misc'
|
437
|
+
EVENTS[4] = []
|
438
|
+
EVENTS[4][0] = 'Serial'
|
439
|
+
EVENTS[4][1] = 'Pulseled'
|
440
|
+
EVENTS[4][2] = 'Gesture'
|
441
|
+
EVENTS[4][3] = 'RawData'
|
442
|
+
EVENTS[4][4] = 'ScanCode'
|
443
|
+
EVENTS[17] = []
|
444
|
+
EVENTS[17][0] = 'NumLock'
|
445
|
+
EVENTS[17][1] = 'CapsLock'
|
446
|
+
EVENTS[17][2] = 'ScrollLock'
|
447
|
+
EVENTS[17][3] = 'Compose'
|
448
|
+
EVENTS[17][4] = 'Kana'
|
449
|
+
EVENTS[17][5] = 'Sleep'
|
450
|
+
EVENTS[17][6] = 'Suspend'
|
451
|
+
EVENTS[17][7] = 'Mute'
|
452
|
+
EVENTS[17][8] = 'Misc'
|
453
|
+
EVENTS[18] = []
|
454
|
+
EVENTS[18][0] = 'Click'
|
455
|
+
EVENTS[18][1] = 'Bell'
|
456
|
+
EVENTS[18][2] = 'Tone'
|
457
|
+
EVENTS[20] = []
|
458
|
+
EVENTS[20][0] = 'Delay'
|
459
|
+
EVENTS[20][1] = 'Period'
|
460
|
+
|
461
|
+
KEY_VALUES = ['Release', 'Press', 'Repeat']
|
462
|
+
|
463
|
+
Event = Struct.new(:tv_sec, :tv_usec, :type, :code, :value)
|
464
|
+
# open Event class and add some convenience methods
|
465
|
+
class Event
|
466
|
+
def time; Time.at(tv_sec) end
|
467
|
+
def type_str; TYPES[type] end
|
468
|
+
def code_str; EVENTS[type][code] if EVENTS[type] end
|
469
|
+
def value_str; KEY_VALUES[value] if type == 1 end
|
470
|
+
def to_s
|
471
|
+
type_s = type.to_s
|
472
|
+
type_s += " (#{type_str})" if type_str
|
473
|
+
code_s = code.to_s
|
474
|
+
code_s += " (#{code_str})" if code_str
|
475
|
+
value_s = value.to_s
|
476
|
+
value_s += " (#{value_str})" if value_str
|
477
|
+
"#{time.iso8601} type: #{type_s} code: #{code_s} value: #{value_s}"
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
def initialize(filename)
|
482
|
+
@dev = File.open(filename)
|
483
|
+
end
|
484
|
+
|
485
|
+
def read
|
486
|
+
bin = @dev.read 16
|
487
|
+
Event.new *bin.unpack("llSSl")
|
488
|
+
end
|
489
|
+
|
490
|
+
def each
|
491
|
+
while true do
|
492
|
+
yield read
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
end
|
497
|
+
|
498
|
+
|
499
|
+
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: libdevinput
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Rullmann
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-05-20 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: This ruby library makes it easy to read events from linux event devices. These device files, residing in /dev/input/ get created for a number of different human input devices like keyboards, mice, touchscreens, joysticks and the like.
|
17
|
+
email: peter @nospam@ p4n.net
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/libdevinput.rb
|
26
|
+
- examples/readlines.rb
|
27
|
+
- AUTHORS
|
28
|
+
- README
|
29
|
+
- COPYING
|
30
|
+
- Rakefile
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://github.com/prullmann/libdevinput
|
33
|
+
licenses: []
|
34
|
+
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.3.5
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: A ruby library to read input device events on linux systems
|
59
|
+
test_files: []
|
60
|
+
|