int main(int argc, char **argv) { if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0))) { if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0))) { if ((LayersBase = OpenLibrary("layers.library", 0))) { if ((DOSBase = (struct DosLibrary *) OpenLibrary("dos.library",0))) { if ((screen = openscreen())) { doall(); closescreen(screen); } CloseLibrary((struct Library *)DOSBase); } CloseLibrary(LayersBase); } CloseLibrary((struct Library *)GfxBase); } CloseLibrary((struct Library *) IntuitionBase); } return 0; } /* main */
int main(int argc, char **argv) { fd_set rfds; struct timeval tv; int retval; int fd; unsigned long mode; lirc_t data; lirc_t x1,y1,x2,y2; int result; char textbuffer[80]; int div=5; int dmode=0; struct stat s; char *device=LIRC_DRIVER_DEVICE; char *progname; progname="xmode2"; while(1) { int c; static struct option long_options[] = { {"help",no_argument,NULL,'h'}, {"version",no_argument,NULL,'v'}, {"device",required_argument,NULL,'d'}, {"timediv",required_argument,NULL,'t'}, {"mode",required_argument,NULL,'m'}, {0, 0, 0, 0} }; c = getopt_long(argc,argv,"hvd:t:m",long_options,NULL); if(c==-1) break; switch (c) { case 'h': printf("Usage: %s [options]\n",progname); printf("\t -h --help\t\tdisplay usage summary\n"); printf("\t -v --version\t\tdisplay version\n"); printf("\t -d --device=device\tread from given device\n"); printf("\t -t --timediv=value\tms per unit\n"); printf("\t -m --mode\t\tenable alternative display mode\n"); return(EXIT_SUCCESS); case 'v': printf("%s %s\n",progname, VERSION); return(EXIT_SUCCESS); case 'd': device=optarg; break; case 't': /* timediv */ div = strtol(optarg,NULL,10); break; case 'm': dmode=1; break; default: printf("Usage: %s [options]\n",progname); return(EXIT_FAILURE); } } if (optind < argc-1) { fprintf(stderr,"%s: too many arguments\n",progname); return(EXIT_FAILURE); } fd=open(device,O_RDONLY); if(fd==-1) { perror(progname); fprintf(stderr,"%s: error opening %s\n",progname,device); exit(EXIT_FAILURE); }; if ( (fstat(fd,&s)!=-1) && (S_ISFIFO(s.st_mode)) ) { /* can't do ioctls on a pipe */ } else if(ioctl(fd,LIRC_GET_REC_MODE,&mode)==-1 || mode!=LIRC_MODE_MODE2) { printf("This program is only intended for receivers " "supporting the pulse/space layer.\n"); printf("Note that this is no error, but this program simply " "makes no sense for your\nreceiver.\n"); close(fd); exit(EXIT_FAILURE); } initscreen(); y1=20; x1=x2=0; sprintf(textbuffer,"%d ms/unit",div); for (y2=0;y2<w1_w;y2+=10) XDrawLine(d1,w1,gc1,y2,0,y2,w1_h); XDrawString(d1,w1,gc2,w1_w-100,10,textbuffer,strlen(textbuffer)); XFlush(d1); while(1) { if (XCheckWindowEvent(d1, w1, KeyPressMask|StructureNotifyMask, &event_return1)) { switch(event_return1.type) { case KeyPress: if (event_return1.xkey.keycode==XKeysymToKeycode(d1,XStringToKeysym("q"))) { closescreen(); exit(1); } break; case ConfigureNotify: w1_w=event_return1.xconfigure.width; w1_h=event_return1.xconfigure.height; for (y2=0;y2<w1_w;y2+=10) XDrawLine(d1,w1,gc1,y2,0,y2,w1_h); XDrawString(d1,w1,gc2,w1_w-100,10,textbuffer,strlen(textbuffer)); // printf("resize \n"); break; default: ; } } /* Watch stdin (fd 0) to see when it has input. */ FD_ZERO(&rfds); FD_SET(fd, &rfds); /* Wait up to one second. */ tv.tv_sec = 1; tv.tv_usec = 0; retval = select(fd+1, &rfds, NULL, NULL, &tv); if (FD_ISSET(fd,&rfds)) { result=read(fd,&data,sizeof(data)); if (result!=0) { // printf("%.8x\t",data); x2=(data&PULSE_MASK)/(div*50); if(x2>400) { if(!dmode) { y1+=15; } else { y1++; } x1=0; } else { if (x1==0) { if(!dmode) XDrawLine(d1,w1,gc2,x1, y1+10, x1+10, y1+10); x1+=10; if(!dmode) XDrawLine(d1,w1,gc2,x1, y1+10, x1, y1); } if (x1<w1_w) { if(dmode) { if(data&PULSE_BIT) XDrawLine(d1,w1,gc2,x1,y1,x1+x2,y1); x1+=x2; } else { XDrawLine(d1,w1,gc2,x1, ((data&PULSE_BIT) ? y1:y1+10),x1+x2, ((data&PULSE_BIT) ? y1:y1+10)); x1+=x2; XDrawLine(d1,w1,gc2,x1, ((data&PULSE_BIT) ? y1:y1+10),x1, ((data&PULSE_BIT) ? y1+10:y1)); } } } if (y1>w1_h) { y1=20; XClearWindow(d1,w1); for (y2=0;y2<w1_w;y2+=10) XDrawLine(d1,w1,gc1,y2,0,y2,w1_h); XDrawString(d1,w1,gc2,w1_w-100,10,textbuffer,strlen(textbuffer)); } } } // gl_copyscreen(physicalscreen); // XFlush(d1); }; exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { int fd; __u32 mode; lirc_t data; lirc_t x1, y1, x2, y2; int result; int c = 10; char textbuffer[80]; int div = 5; char *device = LIRC_DRIVER_DEVICE; char *progname; struct stat s; progname = "smode2"; while (1) { int c; static struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"device", required_argument, NULL, 'd'}, {"timediv", required_argument, NULL, 't'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "hvd:t:", long_options, NULL); if (c == -1) break; switch (c) { case 'h': printf("Usage: %s [options]\n", progname); printf("\t -h --help\t\tdisplay usage summary\n"); printf("\t -v --version\t\tdisplay version\n"); printf("\t -d --device=device\tread from given device\n"); printf("\t -t --timediv=value\tms per unit\n"); return (EXIT_SUCCESS); case 'v': printf("%s %s\n", progname, VERSION); return (EXIT_SUCCESS); case 'd': device = optarg; break; case 't': /* timediv */ div = strtol(optarg, NULL, 10); break; default: printf("Usage: %s [options]\n", progname); return (EXIT_FAILURE); } } if (optind < argc - 1) { fprintf(stderr, "%s: too many arguments\n", progname); return (EXIT_FAILURE); } fd = open(device, O_RDONLY); if (fd == -1) { perror(progname); fprintf(stderr, "%s: error opening %s\n", progname, device); exit(EXIT_FAILURE); }; if ((fstat(fd, &s) != -1) && (S_ISFIFO(s.st_mode))) { /* can't do ioctls on a pipe */ } else if (ioctl(fd, LIRC_GET_REC_MODE, &mode) == -1 || mode != LIRC_MODE_MODE2) { printf("This program is only intended for receivers supporting the pulse/space layer.\n"); printf("Note that this is no error, but this program simply makes no sense for your\nreceiver.\n"); printf("In order to test your setup run lircd with the " "--nodaemon option and \n" "then check if the remote works with the irw tool.\n"); close(fd); exit(EXIT_FAILURE); } initscreen(); y1 = 20; x1 = x2 = 0; for (y2 = 0; y2 < 640; y2 += 20) gl_line(y2, 0, y2, 480, 1); sprintf(textbuffer, "%d ms/unit", div); gl_write(500, 10, textbuffer); gl_copyscreen(physicalscreen); while (1) { result = read(fd, &data, sizeof(data)); if (result == sizeof(data)) { // printf("%.8lx\t",(unsigned long) data); x2 = (data & PULSE_MASK) / (div * 50); if (x2 > 400) { y1 += 15; x1 = 0; gl_copyscreen(physicalscreen); } else { if (x1 < 640) { gl_line(x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1 + x2, ((data & PULSE_BIT) ? y1 : y1 + 10), c); x1 += x2; gl_line(x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1, ((data & PULSE_BIT) ? y1 + 10 : y1), c); } } if (y1 > 480) { y1 = 20; gl_clearscreen(0); for (y2 = 0; y2 < 640; y2 += 10) gl_line(y2, 0, y2, 480, 1); gl_write(500, 10, textbuffer); } } // gl_copyscreen(physicalscreen); }; closescreen(); exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { fd_set rfds; int xfd, maxfd; int fd; __u32 mode; lirc_t data; lirc_t x1, y1, x2, y2; int result; char textbuffer[80]; int div = 5; int dmode = 0; struct stat s; int use_stdin = 0; int have_device = 0; int use_raw_access = 0; char *device = LIRC_DRIVER_DEVICE; char *geometry = NULL; progname = "xmode2"; hw_choose_driver(NULL); while (1) { int c; static struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"device", required_argument, NULL, 'd'}, {"driver", required_argument, NULL, 'H'}, {"geometry", required_argument, NULL, 'g'}, {"timediv", required_argument, NULL, 't'}, {"mode", no_argument, NULL, 'm'}, {"raw", no_argument, NULL, 'r'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "hvd:H:g:t:mr", long_options, NULL); if (c == -1) break; switch (c) { case 'h': printf("Usage: %s [options]\n", progname); printf("\t -h --help\t\tdisplay usage summary\n"); printf("\t -v --version\t\tdisplay version\n"); printf("\t -d --device=device\tread from given device\n"); printf("\t -H --driver=driver\t\tuse given driver\n"); printf("\t -g --geometry=geometry\twindow geometry\n"); printf("\t -t --timediv=value\tms per unit\n"); printf("\t -m --mode\t\tenable alternative display mode\n"); printf("\t -r --raw\t\taccess device directly\n"); return (EXIT_SUCCESS); case 'H': if (hw_choose_driver(optarg) != 0) { fprintf(stderr, "Driver `%s' not supported.\n", optarg); hw_print_drivers(stderr); exit(EXIT_FAILURE); } break; case 'v': printf("%s %s\n", progname, VERSION); return (EXIT_SUCCESS); case 'd': device = optarg; have_device = 1; break; case 'g': geometry = optarg; break; case 't': /* timediv */ div = strtol(optarg, NULL, 10); break; case 'm': dmode = 1; break; case 'r': use_raw_access = 1; break; default: printf("Usage: %s [options]\n", progname); return (EXIT_FAILURE); } } if (optind < argc) { fprintf(stderr, "%s: too many arguments\n", progname); return (EXIT_FAILURE); } if (strcmp(device, LIRCD) == 0) { fprintf(stderr, "%s: refusing to connect to lircd socket\n", progname); return EXIT_FAILURE; } if (!isatty(STDIN_FILENO)) { use_stdin = 1; fd = STDIN_FILENO; } else if (use_raw_access) { fd = open(device, O_RDONLY); if (fd == -1) { fprintf(stderr, "%s: error opening %s\n", progname, device); perror(progname); exit(EXIT_FAILURE); }; if ((fstat(fd, &s) != -1) && (S_ISFIFO(s.st_mode))) { /* can't do ioctls on a pipe */ } else if ((fstat(fd, &s) != -1) && (!S_ISCHR(s.st_mode))) { fprintf(stderr, "%s: %s is not a character device\n", progname, device); fprintf(stderr, "%s: use the -d option to specify the correct device\n", progname); close(fd); exit(EXIT_FAILURE); } else if (ioctl(fd, LIRC_GET_REC_MODE, &mode) == -1) { printf("This program is only intended for receivers supporting the pulse/space layer.\n"); printf("Note that this is no error, but this program " "simply makes no sense for your\n" "receiver.\n"); printf("In order to test your setup run lircd with " "the --nodaemon option and \n" "then check if the remote works with the irw tool.\n"); close(fd); exit(EXIT_FAILURE); } } else { if (have_device) hw.device = device; if (!hw.init_func()) { return EXIT_FAILURE; } fd = hw.fd; /* please compiler */ mode = hw.rec_mode; if (mode != LIRC_MODE_MODE2) { if (strcmp(hw.name, "default") == 0) { printf("Please use the --raw option to access " "the device directly instead through\n" "the abstraction layer.\n"); } else { printf("This program does not work for this hardware yet\n"); } exit(EXIT_FAILURE); } } initscreen(geometry); xfd = XConnectionNumber(d1); maxfd = fd > xfd ? fd : xfd; y1 = 20; x1 = x2 = 0; sprintf(textbuffer, "%d ms/unit", div); for (y2 = 0; y2 < w1_w; y2 += 10) XDrawLine(d1, w1, gc1, y2, 0, y2, w1_h); XDrawString(d1, w1, gc2, w1_w - 100, 10, textbuffer, strlen(textbuffer)); XFlush(d1); while (1) { while (XPending(d1) > 0) { XNextEvent(d1, &event_return1); switch (event_return1.type) { case KeyPress: if (event_return1.xkey.keycode == XKeysymToKeycode(d1, XStringToKeysym("q"))) { closescreen(); exit(1); } break; case Expose: case ConfigureNotify: switch (event_return1.type) { case Expose: break; case ConfigureNotify: if (w1_w == event_return1.xconfigure.width && w1_h == event_return1.xconfigure.height) { continue; } w1_w = event_return1.xconfigure.width; w1_h = event_return1.xconfigure.height; break; } XClearWindow(d1, w1); for (y2 = 0; y2 < w1_w; y2 += 10) XDrawLine(d1, w1, gc1, y2, 0, y2, w1_h); XDrawString(d1, w1, gc2, w1_w - 100, 10, textbuffer, strlen(textbuffer)); XFlush(d1); // printf("resize \n"); break; default: ; } } FD_ZERO(&rfds); FD_SET(fd, &rfds); FD_SET(xfd, &rfds); select(maxfd + 1, &rfds, NULL, NULL, NULL); if (FD_ISSET(fd, &rfds)) { if (use_stdin) { static int space = 1; unsigned long scan; if (space) { result = fscanf(stdin, "space %ld\n", &scan); } else { result = fscanf(stdin, "pulse %ld\n", &scan); } if (result == 1) { data = (lirc_t) scan; if (!space) data |= PULSE_BIT; } else { fd = STDOUT_FILENO; } space = !space; } else { result = read(fd, &data, sizeof(data)); } if (result != 0) { // printf("%.8x\t",data); x2 = (data & PULSE_MASK) / (div * 50); if (x2 > 400) { if (!dmode) { y1 += 15; } else { y1++; } x1 = 0; } else { if (x1 == 0) { if (!dmode) XDrawLine(d1, w1, gc2, x1, y1 + 10, x1 + 10, y1 + 10); x1 += 10; if (!dmode) XDrawLine(d1, w1, gc2, x1, y1 + 10, x1, y1); } if (x1 < w1_w) { if (dmode) { if (data & PULSE_BIT) XDrawLine(d1, w1, gc2, x1, y1, x1 + x2, y1); x1 += x2; } else { XDrawLine(d1, w1, gc2, x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1 + x2, ((data & PULSE_BIT) ? y1 : y1 + 10)); x1 += x2; XDrawLine(d1, w1, gc2, x1, ((data & PULSE_BIT) ? y1 : y1 + 10), x1, ((data & PULSE_BIT) ? y1 + 10 : y1)); } } } if (y1 > w1_h) { y1 = 20; XClearWindow(d1, w1); for (y2 = 0; y2 < w1_w; y2 += 10) XDrawLine(d1, w1, gc1, y2, 0, y2, w1_h); XDrawString(d1, w1, gc2, w1_w - 100, 10, textbuffer, strlen(textbuffer)); } } XFlush(d1); } } exit(EXIT_SUCCESS); }