Skip to content

Commit

Permalink
Evtest added (from beagleboard guys, just copied in for convenience)
Browse files Browse the repository at this point in the history
evmapperd properly detects power button now .. so can now do lid, power, and pandora-menu buttons
... soon to add power level blinking
  • Loading branch information
skeezix committed Feb 17, 2010
1 parent 7e8148b commit 7f8b697
Show file tree
Hide file tree
Showing 3 changed files with 429 additions and 8 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ SOLIB1 = libpnd.so.1.0.1 # versioned name
XMLOBJ = lib/tinyxml/tinystr.o lib/tinyxml/tinyxml.o lib/tinyxml/tinyxmlerror.o lib/tinyxml/tinyxmlparser.o
ALLOBJ = pnd_conf.o pnd_container.o pnd_discovery.o pnd_pxml.o pnd_notify.o pnd_locate.o pnd_tinyxml.o pnd_pndfiles.o pnd_apps.o pnd_utility.o pnd_desktop.o pnd_io_gpio.o pnd_logger.o pnd_dbusnotify.o

all: ${SOLIB} ${LIB} conftest discotest notifytest pndnotifyd rawpxmltest pndvalidator loggertest dbusnotifytest pnd_run pndevmapperd pnd_info
all: ${SOLIB} ${LIB} conftest discotest notifytest pndnotifyd rawpxmltest pndvalidator loggertest dbusnotifytest pnd_run pndevmapperd pnd_info evtest

clean:
${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest dbusnotifytest.o bin/dbusnotifytest loggertest.o bin/loggertest bin/notifytest notifytest.o bin/rawpxmltest rawpxmltest.o bin/pnd_run pnd_run.o pnd_info.o bin/pnd_info bin/pndevmapperd pndevmapperd.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop testdata/menu/*.desktop testdata/apps/*.pnd testdata/dotdesktop/*.png deployment/usr/lib/libpnd* deployment/usr/bin/pndnotifyd deployment/usr/bin/pnd_run deployment/usr/bin/pnd_info deployment/usr/pandora/scripts/* deployment/etc/sudoers deployment/etc/init.d/pndnotifyd bin/pndvalidator pndvalidator.o deployment/usr/bin/pndevmapperd testdata/menuicons/*
${RM} -f ${ALLOBJ} ${XMLOBJ} ${LIB} ${SOLIB1} locatetest.o bin/locatetest conftest.o bin/conftest discotest.o bin/discotest dbusnotifytest.o bin/dbusnotifytest loggertest.o bin/loggertest bin/notifytest notifytest.o bin/rawpxmltest rawpxmltest.o bin/pnd_run pnd_run.o pnd_info.o bin/pnd_info bin/pndevmapperd pndevmapperd.o bin/pndnotifyd pndnotifyd.o ${SOLIB} testdata/dotdesktop/*.desktop testdata/menu/*.desktop testdata/apps/*.pnd testdata/dotdesktop/*.png deployment/usr/lib/libpnd* deployment/usr/bin/pndnotifyd deployment/usr/bin/pnd_run deployment/usr/bin/pnd_info deployment/usr/pandora/scripts/* deployment/etc/sudoers deployment/etc/init.d/pndnotifyd bin/pndvalidator pndvalidator.o deployment/usr/bin/pndevmapperd testdata/menuicons/* evtest.o bin/evtest
${RM} -rf deployment/media
find . -name "*~*" -exec rm {} \; -print

Expand Down Expand Up @@ -116,3 +116,6 @@ loggertest: loggertest.o ${LIB}

dbusnotifytest: dbusnotifytest.o ${LIB}
${CC} -lstdc++ -o bin/dbusnotifytest dbusnotifytest.o libpnd.a

evtest: evtest.o
${CC} -o bin/evtest evtest.o
38 changes: 32 additions & 6 deletions apps/pndevmapperd.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ int main ( int argc, char *argv[] ) {

// try to locate the appropriate devices
int id;
int fds [ 5 ] = { -1, -1, -1, -1, -1 }; // 0 = keypad, 1 = gpio keys
int fds [ 8 ] = { -1, -1, -1, -1, -1, -1, -1, -1 }; // 0 = keypad, 1 = gpio keys
int imaxfd = 0;

for ( id = 0; ; id++ ) {
Expand All @@ -378,21 +378,36 @@ int main ( int argc, char *argv[] ) {
break;
}

ioctl (fd, EVIOCGNAME(sizeof(name)), name );
if ( ioctl (fd, EVIOCGNAME(sizeof(name)), name ) < 0 ) {
name [ 0 ] = '\0';
}

pnd_log ( pndn_rem, "%s maps to %s\n", fname, name );

if ( strcmp ( name, "omap_twl4030keypad" ) == 0 ) {
fds [ 0 ] = fd;
} else if ( strcmp ( name, "gpio-keys" ) == 0) {
fds [ 1 ] = fd;
} else if ( strcmp ( name, "AT Translated Set 2 keyboard" ) == 0) { // for vmware, my dev environment
fds [ 0 ] = fd;
} else if ( strcmp ( name, "triton2-pwrbutton" ) == 0) {
fds [ 2 ] = fd;
} else if ( strcmp ( name, "ADS784x Touchscreen" ) == 0) {
fds [ 3 ] = fd;
} else if ( strcmp ( name, "vsense66" ) == 0) {
fds [ 4 ] = fd;
} else if ( strcmp ( name, "vsense67" ) == 0) {
fds [ 5 ] = fd;
} else {
pnd_log ( pndn_rem, "Ignoring unknown device '%s'\n", name );
//fds [ 6 ] = fd;
close ( fd );
fd = -1;
continue;
}

if (imaxfd < fd) imaxfd = fd;

} // for

if ( fds [ 0 ] == -1 ) {
Expand All @@ -414,14 +429,21 @@ int main ( int argc, char *argv[] ) {
while ( 1 ) {
struct input_event ev[64];

unsigned int max_fd = 3; /* imaxfd */
int fd = -1, rd, ret;
fd_set fdset;

FD_ZERO ( &fdset );

for (i = 0; i < 2; i++) {
imaxfd = 0;
for (i = 0; i < max_fd /*imaxfd*/; i++) {
if ( fds [ i ] != -1 ) {
FD_SET( fds [ i ], &fdset );

if ( fds [ i ] > imaxfd ) {
imaxfd = fds [ i ];
}

}
}

Expand All @@ -432,11 +454,11 @@ int main ( int argc, char *argv[] ) {
continue; // retry!
}

for ( i = 0; i < 2; i++ ) {
for ( i = 0; i < max_fd; i++ ) {
if ( fds [ i ] != -1 && FD_ISSET ( fds [ i ], &fdset ) ) {
fd = fds [ i ];
}
}
} // fd is set?
} // for

/* buttons or keypad */
rd = read ( fd, ev, sizeof(struct input_event) * 64 );
Expand Down Expand Up @@ -515,6 +537,8 @@ void dispatch_key ( int keycode, int val ) {
// 2 - down again (hold)
// 0 - up (released)

pnd_log ( pndn_rem, "Dispatching Key..\n" );

for ( i = 0; i < g_evmap_max; i++ ) {

if ( ( g_evmap [ i ].key_p ) &&
Expand Down Expand Up @@ -572,6 +596,8 @@ void dispatch_event ( int code, int val ) {
// 1 - closing
// 0 - opening

pnd_log ( pndn_rem, "Dispatching Event..\n" );

for ( i = 0; i < g_evmap_max; i++ ) {

if ( ( g_evmap [ i ].key_p == 0 ) &&
Expand Down
Loading

0 comments on commit 7f8b697

Please sign in to comment.