Regards  
 Leslie
 Mr. Leslie Satenstein
50 years in Information Technology and going strong.
Yesterday was a good day, today is a better day,
and tomorrow will be even better.
 
mailto:[email protected]
alternative: [email protected] 
www.itbms.biz  www.eclipseguard.com
 
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */


#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <asm/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>

#include <linux/input.h>


int main (int argc, char **argv) {
    int fd = -1;        /* the file descriptor for the device */
    int yalv;           /* loop counter */
    size_t read_bytes;  /* how many bytes were read */
    struct input_event ev[64]; /* the events (up to 64 at once) */
	char * pf;
    /* read() requires a file descriptor, so we check for one, and then open it */

    	/* tmporary hack */
    argc=2;
    argv[1]="/dev/input/event1";

    if (argc != 2) {
	fprintf(stderr, "usage: %s event-device - probably /dev/input/event1\n", argv[0]);
	exit(1);
    }
    if ((fd = open(argv[1], O_RDONLY)) < 0) {
	perror("evdev open");
	exit(1);
    }

    while (1)
	{
	read_bytes = read(fd, ev, sizeof(struct input_event) * 64);

	if (read_bytes < (int) sizeof(struct input_event)) {
	    perror("evtest: short read");
	    exit (1);
	}

	for (yalv = 0; yalv < (int) (read_bytes / sizeof(struct input_event)); yalv++)
	  {
		if(ev[yalv].type ==1 && ev[yalv.value==1)
		switch ( ev[yalv.code)
		{
			case 14 :  pf= "bs"      	break;
			case 55 :  pf="*";			break;
			case 71 :  pf="7";    	    break;
			case 72:   pf="8"; 			break;
			case 73 :  pf="9";			break;
			case 74 :  pf="-";			break;
			case 75 :  pf="4" ;         break;
			case 76 :  pf="5" ;         break;
			case 77 :  pf="6" ;         break;
			case 78 :  pf="+" ;         break;
			case 79 :  pf="1" ;         break;
			case 80 :  pf="2" ;         break;
			case 81 :  pf="3" ;         break;
			case 82 :  pf="0" ;			break;
			case 83 :  pf="." ;         break;
			case 96 :  pf="enter";      break;
			case 98 :  pf="/" ;			break;
			default:   pf=" " ;			break;
		}
		  printf(pf);
	  }


    close(fd);

    exit(0);
}
_______________________________________________
mlug mailing list
[email protected]
https://listes.koumbit.net/cgi-bin/mailman/listinfo/mlug-listserv.mlug.ca

Reply via email to