summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-02-01 22:48:12 (UTC)
committer mickeyl <mickeyl>2005-02-01 22:48:12 (UTC)
commit7500adc8443f9044da7773e32742dbae51391bef (patch) (unidiff)
treedf7de21648dcf28e09a475b67e3572c818be77ab
parentef4a5ca1b376158bfc26b832333c6908e35d181b (diff)
downloadopie-7500adc8443f9044da7773e32742dbae51391bef.zip
opie-7500adc8443f9044da7773e32742dbae51391bef.tar.gz
opie-7500adc8443f9044da7773e32742dbae51391bef.tar.bz2
add skeleton for oinputsystem classes (thin wrapper of Linux Input Subsystem API)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--examples/opiecore/oinputsystemdemo/.cvsignore6
-rw-r--r--examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp250
-rw-r--r--examples/opiecore/oinputsystemdemo/oinputsystemdemo.pro16
-rw-r--r--examples/opiecore/onotifydemo/onotifydemo.pro1
-rw-r--r--examples/opiecore/opiecore.pro2
-rw-r--r--libopie2/opiecore/oinputsystem.cpp31
-rw-r--r--libopie2/opiecore/oinputsystem.h48
-rw-r--r--libopie2/opiecore/opiecore.pro4
8 files changed, 355 insertions, 3 deletions
diff --git a/examples/opiecore/oinputsystemdemo/.cvsignore b/examples/opiecore/oinputsystemdemo/.cvsignore
new file mode 100644
index 0000000..8f7300c
--- a/dev/null
+++ b/examples/opiecore/oinputsystemdemo/.cvsignore
@@ -0,0 +1,6 @@
1Makefile*
2moc*
3*moc
4*.o
5~*
6
diff --git a/examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp b/examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp
new file mode 100644
index 0000000..89209a7
--- a/dev/null
+++ b/examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp
@@ -0,0 +1,250 @@
1#include <fcntl.h>
2#include <unistd.h>
3#include <cstdlib>
4#include <cstdio>
5#include <string>
6
7#include <sys/types.h>
8#include <linux/input.h>
9
10using std::string;
11
12const unsigned char BUT1 = 0x01;
13const unsigned char BUT2 = 0x04;
14const unsigned char BUT3 = 0x02;
15const unsigned char BUT4 = 0x40;
16const unsigned char BUT5 = 0x80;
17
18#define BITMASK( name, numbits ) \
19 unsigned short name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ]; \
20 memset( name, 0, sizeof( name ) )
21
22#define TEST_BIT( bitmask, bit ) \
23 ( bitmask[ (bit) / sizeof(short) / 8 ] & (1u << ( (bit) % (sizeof(short) * 8))) )
24
25int Open_cPad()
26{
27 size_t MAX_DEVICES = 1;
28 int fd = -1;
29 input_id info;
30
31 for( size_t i = 0; i < MAX_DEVICES; ++i )
32 {
33 string devpath( "/dev/input/event0" );
34
35 //devpath << (int)i;
36
37 fd = open( devpath.c_str(), O_RDONLY, &info );
38
39 if( fd >= 0 )
40 {
41 int version = -1;
42 /* ioctl() accesses the underlying driver */
43 if (ioctl(fd, EVIOCGVERSION, &version)) {
44 perror("evdev ioctl");
45 }
46
47 /* the EVIOCGVERSION ioctl() returns an int */
48 /* so we unpack it and display it */
49 printf("evdev driver version is %d.%d.%d\n",
50 version >> 16, (version >> 8) & 0xff,
51 version & 0xff);
52
53 // Get Identifying info
54
55 if( ioctl( fd, EVIOCGID, &info) )
56 {
57 perror( "event device ioctl" );
58 return -1;
59 }
60 printf( "Bus: %#x, Vendor: %#x, Product: %#x, Version: %#x\n",
61 info.bustype, info.vendor, info.product, info.version );
62
63 switch ( info.bustype)
64 {
65 case BUS_PCI :
66 printf(" is on a PCI bus\n");
67 break;
68 case BUS_USB :
69 printf(" is on a Universal Serial Bus\n");
70 break;
71 /* ... */
72 }
73
74 // Get device 'name'
75
76 char name[256] = "Unknown";
77 if( ioctl( fd, EVIOCGNAME(sizeof name ), name) < 0 )
78 {
79 perror( "event device ioctl" );
80 }else
81 printf( "Device name '%s'\n", name );
82
83 if(ioctl(fd, EVIOCGPHYS(sizeof(name)), name) < 0) {
84 perror("event ioctl");
85 }else
86 printf("Device path '%s'\n", name );
87
88 if(ioctl(fd, EVIOCGUNIQ(sizeof(name)), name) < 0) {
89 perror("event ioctl");
90 }else
91 printf("Device identity '%s'\n", name );
92
93 // Get feature types
94
95 BITMASK( features, EV_MAX );
96
97 if( ioctl( fd, EVIOCGBIT( 0, EV_MAX ), features) < 0 )
98 {
99 perror( "event device ioctl" );
100 return -1;
101 }
102
103 printf( "Supported features:\n" );
104 for( size_t bit = 0; bit < EV_MAX; ++bit )
105 {
106 if( TEST_BIT( features, bit ) )
107 {
108 switch( bit )
109 {
110 case EV_SYN :
111 printf(" Sync. Events\n");
112 break;
113 //case EV_RST:
114 // printf( " Reset?\n" );
115 // break;
116 case EV_KEY:
117 printf( " Keys or buttons\n" );
118 break;
119 case EV_REL:
120 printf( " Relative axes\n" );
121 break;
122 case EV_ABS:
123 printf( " Absolute axes\n" );
124 break;
125 case EV_MSC:
126 printf( " Misc\n" );
127 break;
128 case EV_LED:
129 printf( " Led's\n" );
130 break;
131 case EV_SND:
132 printf( " Sounds\n" );
133 break;
134 case EV_REP:
135 printf( " Repeat\n" );
136 break;
137 case EV_FF : // fallthrough
138 case EV_FF_STATUS:
139 printf(" Force Feedback\n");
140 break;
141 case EV_PWR:
142 printf(" Power Management\n");
143 break;
144 default:
145 printf( " Unknown (bit %d)\n", bit );
146 }
147 }
148 }
149
150 // Check keystate
151
152 BITMASK( keys, KEY_MAX );
153
154 if( ioctl( fd, EVIOCGKEY( sizeof(keys) ), keys ) < 0 )
155 {
156 perror( "event device ioctl" );
157 return -1;
158 }
159
160 printf( "Key global status:\n" );
161 for( size_t bit = 0; bit < KEY_MAX; ++bit )
162 {
163 if( TEST_BIT( keys, bit ) )
164 {
165 printf( "Key (bit %d) active\n", bit );
166 }
167 }
168 }
169 else
170 printf( "Failed to open device\n" );
171
172 close( fd );
173 }
174 return fd;
175}
176
177
178int main( int argc, char **argv )
179{
180 //printf(" Long: %d, int %d, short %d\n", sizeof( long ), sizeof( int ), sizeof( short ) );
181 //printf( "num chars %d\n", snprintf( NULL, 0, 0 ) );
182 //exit( 0 );
183 Open_cPad();
184
185#if 1
186 int fd = open( "/dev/input/event0", O_RDONLY );
187
188 if( fd == -1 )
189 {
190 printf( "Failed to open device\n" );
191 goto hell;
192 }
193
194 struct input_event evbuf;
195
196 for(;;)
197 {
198 if( read( fd, &evbuf, sizeof evbuf ) == -1 )
199 {
200 printf( "Read error\n" );
201 goto hell;
202 }
203
204 printf( "Type: %d, Code: %d, Value: %d\n", evbuf.type, evbuf.code, evbuf.value );
205 }
206
207#endif
208#if 0
209 unsigned char buf[ 4 ];
210
211 for(;;)
212 {
213 if( read( fd, buf, sizeof buf ) == -1 )
214 {
215 printf( "Read error\n" );
216 goto hell;
217 }
218
219 printf( "Raw:\t%#x\t%#x\t%#x\t%#x\n", buf[ 0 ], buf[ 1 ], buf[ 2 ], buf[ 3 ] );
220
221 int dx = buf[ 1 ];
222
223 if( ( buf[ 0 ] & 0x10 ) != 0 )
224 dx -= 256;
225
226 int dy = - buf[ 2 ];
227
228 if( ( buf[ 0 ] & 0x20 ) != 0 )
229 dy += 256;
230
231 printf( "( %d, %d )\t", dx, dy );
232
233 if( buf[ 0 ] & BUT1 )
234 printf( "Left\t" );
235 if( buf[ 0 ] & BUT2 )
236 printf( "Middle\t" );
237 if( buf[ 0 ] & BUT3 )
238 printf( "Right\t" );
239
240 printf( "\n" );
241 }
242#endif
243
244 //close( fd );
245
246 exit( EXIT_SUCCESS );
247hell:
248 exit( EXIT_FAILURE );
249}
250
diff --git a/examples/opiecore/oinputsystemdemo/oinputsystemdemo.pro b/examples/opiecore/oinputsystemdemo/oinputsystemdemo.pro
new file mode 100644
index 0000000..0a53a5e
--- a/dev/null
+++ b/examples/opiecore/oinputsystemdemo/oinputsystemdemo.pro
@@ -0,0 +1,16 @@
1TEMPLATE = app
2CONFIG = qt warn_on
3HEADERS =
4SOURCES = oinputsystemdemo.cpp
5INCLUDEPATH += $(OPIEDIR)/include
6DEPENDPATH += $(OPIEDIR)/include
7LIBS += -lopiecore2 -lopieui2
8TARGET = oinputsystemdemo
9
10!contains( platform, x11 ) {
11 include( $(OPIEDIR)/include.pro )
12}
13
14contains( platform, x11 ) {
15 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
16}
diff --git a/examples/opiecore/onotifydemo/onotifydemo.pro b/examples/opiecore/onotifydemo/onotifydemo.pro
index d2c9138..1c1040c 100644
--- a/examples/opiecore/onotifydemo/onotifydemo.pro
+++ b/examples/opiecore/onotifydemo/onotifydemo.pro
@@ -1,18 +1,17 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on 2CONFIG = qt warn_on
3HEADERS = 3HEADERS =
4SOURCES = onotifydemo.cpp 4SOURCES = onotifydemo.cpp
5INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
6DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
7LIBS += -lopiecore2 -lopieui2 7LIBS += -lopiecore2 -lopieui2
8TARGET = onotifydemo 8TARGET = onotifydemo
9 9
10!contains( platform, x11 ) { 10!contains( platform, x11 ) {
11 include( $(OPIEDIR)/include.pro ) 11 include( $(OPIEDIR)/include.pro )
12} 12}
13 13
14contains( platform, x11 ) { 14contains( platform, x11 ) {
15 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 15 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
16} 16}
17 17
18MOC_DIR = moc
diff --git a/examples/opiecore/opiecore.pro b/examples/opiecore/opiecore.pro
index 39ffd3b..1f86a40 100644
--- a/examples/opiecore/opiecore.pro
+++ b/examples/opiecore/opiecore.pro
@@ -1,2 +1,2 @@
1TEMPLATE = subdirs 1TEMPLATE = subdirs
2unix:SUBDIRS = odebugdemo oconfigdemo oglobalsettingsdemo onotifydemo oprocessdemo oplugins 2unix:SUBDIRS = odebugdemo oconfigdemo oglobalsettingsdemo onotifydemo oprocessdemo oplugins oinputsystemdemo
diff --git a/libopie2/opiecore/oinputsystem.cpp b/libopie2/opiecore/oinputsystem.cpp
new file mode 100644
index 0000000..c33d5c8
--- a/dev/null
+++ b/libopie2/opiecore/oinputsystem.cpp
@@ -0,0 +1,31 @@
1/*
2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l.
5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
28
29#include "oinputsystem.h"
30
31using namespace Opie::Core;
diff --git a/libopie2/opiecore/oinputsystem.h b/libopie2/opiecore/oinputsystem.h
new file mode 100644
index 0000000..2bcdc3a
--- a/dev/null
+++ b/libopie2/opiecore/oinputsystem.h
@@ -0,0 +1,48 @@
1/*
2                 This file is part of the Opie Project
3 =. (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l.
5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
28
29#ifndef OINPUTSYSTEM_H
30#define OINPUTSYSTEM_H
31
32#include <qobject.h>
33
34namespace Opie {
35namespace Core {
36
37/**
38 * ...
39 *
40 */
41
42class OInputSystem : public QObject
43{
44};
45}
46}
47
48#endif // OINPUTSYSTEM_H
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro
index f133433..8f76c48 100644
--- a/libopie2/opiecore/opiecore.pro
+++ b/libopie2/opiecore/opiecore.pro
@@ -1,61 +1,63 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = oapplication.h \ 4HEADERS = oapplication.h \
5 oconfig.h \ 5 oconfig.h \
6 odebug.h \ 6 odebug.h \
7 oglobal.h \ 7 oglobal.h \
8 oglobalsettings.h \ 8 oglobalsettings.h \
9 oinputsystem.h \
9 okeyconfigmanager.h \ 10 okeyconfigmanager.h \
10 okeyfilter.h \ 11 okeyfilter.h \
11 opluginloader.h \ 12 opluginloader.h \
12 oprocess.h \ 13 oprocess.h \
13 oprocctrl.h \ 14 oprocctrl.h \
14 osharedpointer.h \ 15 osharedpointer.h \
15 osmartpointer.h \ 16 osmartpointer.h \
16 ostorageinfo.h \ 17 ostorageinfo.h \
17 xmltree.h 18 xmltree.h
18 19
19SOURCES = oapplication.cpp \ 20SOURCES = oapplication.cpp \
20 oconfig.cpp \ 21 oconfig.cpp \
21 odebug.cpp \ 22 odebug.cpp \
22 oglobal.cpp \ 23 oglobal.cpp \
23 oglobalsettings.cpp \ 24 oglobalsettings.cpp \
25 oinputsystem.cpp \
24 okeyconfigmanager.cpp \ 26 okeyconfigmanager.cpp \
25 okeyfilter.cpp \ 27 okeyfilter.cpp \
26 opluginloader.cpp \ 28 opluginloader.cpp \
27 oprocess.cpp \ 29 oprocess.cpp \
28 oprocctrl.cpp \ 30 oprocctrl.cpp \
29 osmartpointer.cpp \ 31 osmartpointer.cpp \
30 ostorageinfo.cpp \ 32 ostorageinfo.cpp \
31 xmltree.cpp 33 xmltree.cpp
32 34
33 35
34# The following files are currently not compileable on mac ! 36# The following files are currently not compileable on mac !
35# Therfore I removed them from the build .. (eilers) 37# Therfore I removed them from the build .. (eilers)
36 38
37CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 39CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
38!contains( CONFTEST, y ) { 40!contains( CONFTEST, y ) {
39HEADERS += ofilenotify.h 41HEADERS += ofilenotify.h
40SOURCES += ofilenotify.cpp 42SOURCES += ofilenotify.cpp
41} else { 43} else {
42 message( "ofilenotify is not available in a mac build !" ) 44 message( "ofilenotify is not available in a mac build !" )
43} 45}
44 46
45include( device/device.pro ) 47include( device/device.pro )
46 48
47INTERFACES = 49INTERFACES =
48TARGET = opiecore2 50TARGET = opiecore2
49VERSION = 1.9.2 51VERSION = 1.9.3
50INCLUDEPATH += $(OPIEDIR)/include 52INCLUDEPATH += $(OPIEDIR)/include
51DEPENDPATH += $(OPIEDIR)/include 53DEPENDPATH += $(OPIEDIR)/include
52 54
53!contains( platform, x11 ) { 55!contains( platform, x11 ) {
54 LIBS = -lqpe 56 LIBS = -lqpe
55 include( $(OPIEDIR)/include.pro ) 57 include( $(OPIEDIR)/include.pro )
56} 58}
57 59
58contains( platform, x11 ) { 60contains( platform, x11 ) {
59 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 61 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
60} 62}
61 63