void usage(const char* prog) { fprintf(stderr, "Usage: %s [option ...]\n", prog); fprintf(stderr, "Valid options are:\n\ -i, --in input.mpg Input media file containing closed captions\n\ Required\n\ -l, --log logfile Log output file\n\ Default: stdout\n\ -v, --verbose Increment verbosity\n\ Default: 0\n\ -p, --prefix prefix Prefix to subtitle image file names\n\ If prefix is a directory, you must provide a trailing slash\n\ e.g. -p /tmp/\n\ Default: null string\n\ -P, --page pageno A closed caption or teletext page number\n\ Valid NTSC page numbers are:\n\ 1 - CC1, 2 - CC2, 3 - CC3, 4 - CC4,\n\ 5 - Text1, 6 - Text2, 7 - Text3, 8 - Text4\n\ Default: 1 (CC1)\n\ -x, --xml spumux.xml XML file created for input to spumux\n\ Default: spumux.xml\n\ -w, --width width DVD output frame width (not input media width)\n\ Default: 720\n\ -h, --height height DVD output frame height (not input media height)\n\ Default: 480 for NTSC, 576 for PAL\n\ -f, --fudge factor Multiply subtitle timestamps by this value\n\ For example, if transcoding changes video length from\n\ 1 hour to 1 hour and 10 seconds, use 3610/3600 = 1.00277\n\ Default: 1.00293 for nuv recordings\n\ 1.0 for all other recordings\n\ "); }
static void MultEqMM( const T alpha, const GenDiagMatrix<Ta>& A, LowerTriMatrixView<T> B) // B = alpha * A * B { TMVAssert(A.size() == B.size()); TMVAssert(alpha != T(0)); TMVAssert(B.dt() == NonUnitDiag); #ifdef XDEBUG //cout<<"Start MultEqMM: alpha = "<<alpha<<endl; //cout<<"A = "<<TMV_Text(A)<<" "<<A<<endl; //cout<<"B = "<<TMV_Text(B)<<" "<<B<<endl; Matrix<T> B0 = B; Matrix<Ta> A0 = A; Matrix<T> B2 = alpha*A0*B0; #endif if (B.isconj()) MultEqMM(TMV_CONJ(alpha),A.conjugate(),B.conjugate()); else if (A.size() > 0) { if (alpha == T(1)) if (A.diag().isconj()) DoMultEqMM<true,true>(TMV_REAL(alpha),A,B); else DoMultEqMM<true,false>(TMV_REAL(alpha),A,B); else if (TMV_IMAG(alpha) == TMV_RealType(T)(0)) if (A.diag().isconj()) DoMultEqMM<false,true>(TMV_REAL(alpha),A,B); else DoMultEqMM<false,false>(TMV_REAL(alpha),A,B); else if (A.diag().isconj()) DoMultEqMM<false,true>(alpha,A,B); else DoMultEqMM<false,false>(alpha,A,B); } #ifdef XDEBUG if (1(Norm(Matrix<T>(B)-B2) <= 0.001*(TMV_ABS(alpha)*Norm(A0)*Norm(B0)))) { cerr<<"MultEqMM: alpha = "<<alpha<<endl; cerr<<"A = "<<TMV_Text(A)<<" step "<<A.diag().step()<<" "<<A0<<endl; cerr<<"B = "<<TMV_Text(B)<<" "<<B0<<endl; cerr<<"-> B = "<<B<<endl; cerr<<"B2 = "<<B2<<endl; abort(); } #endif }
static void help(char *name) { banner(); fprintf(stderr, "Usage: %s [options] romfile\n", name); fprintf(stderr, " --source FILE read rc commands from FILE --bind KEY COMMAND bind KEY to perform COMMAND --VAR=VALUE set rc variable VAR to VALUE --VAR set VAR to 1 (turn on boolean options) --no-VAR set VAR to 0 (turn off boolean options) --showvars list all available rc variables --help display this help and exit --version output version information and exit --copying show copying permissions "); exit(0); }
int main (int argc, char *argv[]) { int x_state=0; int y_state=0; int foreground = 0; int opt; pid_t pid; ssize_t res; unsigned char buffer[8]; struct input_event ev[6]; struct input_event ev_button[22]; struct input_event ev_sync; conf_data conf; conf = config_parse(); while ((opt = getopt(argc, argv, "hfs:u:?")) != EOF) { switch (opt) { case 'h': usage(); break; case 'f': foreground=1; break; case 's': sprintf(conf.joystick_device, "%s", optarg); break; case 'u': sprintf(conf.uinput_device, "%s", optarg); break; default: usage(); break; } } if (!running_as_root()) { fprintf(stderr,"this program must be run as root user\n"); exit (-1); } printf("stjoy v%s ", VERSION); fflush(stdout); if (!foreground) { if ((pid = fork()) < 0) exit(1); else if (pid != 0) exit(0); /* daemon running here */ setsid(); if (chdir("/") != 0) die("Could not chdir"); umask(0); printf("forked into background\n"); } else printf("\n"); /* create pid file */ if (!create_pid_file()) exit(-1); if (foreground) { printf ("\nConfiguration data:\n"); printf ("\tjoystick_device=%s\n",conf.joystick_device); printf ("\tuinput_device=%s\n",conf.uinput_device); } // Open joystick port open_joystick_port(conf.joystick_device); // configure uinput setup_uinput_dev(conf.uinput_device); // handle signals signal_installer(); // input sync signal: memset (&ev_sync, 0, sizeof (struct input_event)); ev_sync.type = EV_SYN; ev_sync.code = 0; ev_sync.value = 0; // button press signals: memset (&ev_button, 0, sizeof (ev_button)); ev_button[0].type = EV_KEY; ev_button[0].code = BTN_A; ev_button[0].value = 0; ev_button[1].type = EV_KEY; ev_button[1].code = BTN_A; ev_button[1].value = 1; ev_button[2].type = EV_KEY; ev_button[2].code = BTN_B; ev_button[2].value = 0; ev_button[3].type = EV_KEY; ev_button[3].code = BTN_B; ev_button[3].value = 1; ev_button[4].type = EV_KEY; ev_button[4].code = BTN_X; ev_button[4].value = 0; ev_button[5].type = EV_KEY; ev_button[5].code = BTN_X; ev_button[5].value = 1; ev_button[6].type = EV_KEY; ev_button[6].code = BTN_Y; ev_button[6].value = 0; ev_button[7].type = EV_KEY; ev_button[7].code = BTN_Y; ev_button[7].value = 1; ev_button[8].type = EV_KEY; ev_button[8].code = BTN_TL; ev_button[8].value = 0; ev_button[9].type = EV_KEY; ev_button[9].code = BTN_TL; ev_button[9].value = 1; ev_button[10].type = EV_KEY; ev_button[10].code = BTN_TR; ev_button[10].value = 0; ev_button[11].type = EV_KEY; ev_button[11].code = BTN_TR; ev_button[11].value = 1; ev_button[12].type = EV_KEY; ev_button[12].code = BTN_SELECT; ev_button[12].value = 0; ev_button[13].type = EV_KEY; ev_button[13].code = BTN_SELECT; ev_button[13].value = 1; ev_button[14].type = EV_KEY; ev_button[14].code = BTN_START; ev_button[14].value = 0; ev_button[15].type = EV_KEY; ev_button[15].code = BTN_START; ev_button[15].value = 1; ev_button[16].type = EV_KEY; ev_button[16].code = BTN_MODE; ev_button[16].value = 0; ev_button[17].type = EV_KEY; ev_button[17].code = BTN_MODE; ev_button[17].value = 1; /* ev_button[18].type = EV_ABS; ev_button[18].code = ABS_RZ; ev_button[18].value = 0; ev_button[19].type = EV_ABS; ev_button[19].code = ABS_RZ; ev_button[19].value = 255; ev_button[20].type = EV_ABS; ev_button[20].code = ABS_Z; ev_button[20].value = 0; ev_button[21].type = EV_ABS; ev_button[21].code = ABS_Z; ev_button[21].value = 255; */ ev_button[18].type = EV_KEY; ev_button[18].code = BTN_THUMBL; ev_button[18].value = 0; ev_button[19].type = EV_KEY; ev_button[19].code = BTN_THUMBL; ev_button[19].value = 1; ev_button[20].type = EV_KEY; ev_button[20].code = BTN_THUMBR; ev_button[20].value = 0; ev_button[21].type = EV_KEY; ev_button[21].code = BTN_THUMBR; ev_button[21].value = 1; // load X,Y into input_events memset (ev, 0, sizeof (ev)); //resets object ev[0].type = EV_ABS; ev[0].code = ABS_HAT0X; ev[0].value = 0; ev[1].type = EV_ABS; ev[1].code = ABS_HAT0X; ev[1].value = 1; ev[2].type = EV_ABS; ev[2].code = ABS_HAT0X; ev[2].value = -1; ev[3].type = EV_ABS; ev[3].code = ABS_HAT0Y; ev[3].value = 0; ev[4].type = EV_ABS; ev[4].code = ABS_HAT0Y; ev[4].value = 1; ev[5].type = EV_ABS; ev[5].code = ABS_HAT0Y; ev[5].value = -1; while (1) { memset (buffer, 0, sizeof (buffer)); res = read (fd_joystick, &buffer, sizeof (buffer)); if (res < 0) die ("error reading from joystick port"); if (DEBUG || foreground) fprintf (stderr,"PDU: %.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7] ); // A if (buffer[6]==1 && buffer[7]==0) { if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[0], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[1], sizeof (struct input_event)) < 0) die ("error: write"); } // B if (buffer[6]==1 && buffer[7]==1) { if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[2], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[3], sizeof (struct input_event)) < 0) die ("error: write"); } // X if (buffer[6]==1 && buffer[7]==2) { if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[4], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[5], sizeof (struct input_event)) < 0) die ("error: write"); } // Y if (buffer[6]==1 && buffer[7]==3) { if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[6], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[7], sizeof (struct input_event)) < 0) die ("error: write"); } // LB <---- cheat! if (buffer[6]==1 && buffer[7]==4) { /* if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[8], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[9], sizeof (struct input_event)) < 0) die ("error: write"); */ if (buffer[4]==1 && buffer[5]==0) { // LB button press /* DP RIGHT */ // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // y/neutral if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // x/right if (write (fd_uinput, &ev[1], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(27); // y/down if (write (fd_uinput, &ev[4], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // x/right if (write (fd_uinput, &ev[1], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(27); // press Y if (write (fd_uinput, &ev_button[7], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // y/neutral if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // release Y if (write (fd_uinput, &ev_button[6], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // x/neutral x if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); /* DP LEFT */ usleep(100000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // y/neutral if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // x/left if (write (fd_uinput, &ev[2], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(27); // y/down if (write (fd_uinput, &ev[4], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // x/left if (write (fd_uinput, &ev[2], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(27); // press Y if (write (fd_uinput, &ev_button[7], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // press X (we can "piano" in the 2nd one) if (write (fd_uinput, &ev_button[5], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // y/neutral if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // release Y if (write (fd_uinput, &ev_button[6], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // release X (we can "piano" in the 2nd one) if (write (fd_uinput, &ev_button[4], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // x/neutral x if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // restore x&y state if (x_state==0) if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (x_state==1) if (write (fd_uinput, &ev[1], sizeof (struct input_event)) < 0) die ("error: write"); if (x_state==-1) if (write (fd_uinput, &ev[2], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); if (y_state==0) if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (y_state==1) if (write (fd_uinput, &ev[4], sizeof (struct input_event)) < 0) die ("error: write"); if (y_state==-1) if (write (fd_uinput, &ev[5], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); } } // RB if (buffer[6]==1 && buffer[7]==5) { if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[10], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[11], sizeof (struct input_event)) < 0) die ("error: write"); } if (buffer[6]==1 && buffer[7]==6) { if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[12], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[13], sizeof (struct input_event)) < 0) die ("error: write"); } if (buffer[6]==1 && buffer[7]==7) { if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[14], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[15], sizeof (struct input_event)) < 0) die ("error: write"); } if (buffer[6]==1 && buffer[7]==8) { if (buffer[4]==0 && buffer[5]==0) if (write (fd_uinput, &ev_button[16], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==1 && buffer[5]==0) if (write (fd_uinput, &ev_button[17], sizeof (struct input_event)) < 0) die ("error: write"); } // RT if (buffer[6]==2 && buffer[7]==5) { if (buffer[4]==1 && buffer[5]==0x80) if (write (fd_uinput, &ev_button[18], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==0xff && buffer[5]==0x7f) if (write (fd_uinput, &ev_button[19], sizeof (struct input_event)) < 0) die ("error: write"); } // LT <---- cheat! /* dragon punch */ #if 0 Event: time 1387128747.109831, type 3 (EV_ABS), code 16 (ABS_HAT0X), value 1 <---- x/right Event: time 1387128747.197553, type 3 (EV_ABS), code 16 (ABS_HAT0X), value 0 <---- x/neutral Event: time 1387128747.197580, type 3 (EV_ABS), code 17 (ABS_HAT0Y), value 1 <---- y/down Event: time 1387128747.217594, type 3 (EV_ABS), code 16 (ABS_HAT0X), value -1 <---- x/left Event: time 1387128747.277551, type 3 (EV_ABS), code 16 (ABS_HAT0X), value 0 <---- x/neutral Event: time 1387128747.293556, type 3 (EV_ABS), code 16 (ABS_HAT0X), value 1 <---- x/right Event: time 1387128747.293583, type 1 (EV_KEY), code 307 (BTN_X), value 1 <---- press X Event: time 1387128747.345564, type 3 (EV_ABS), code 17 (ABS_HAT0Y), value 0 <---- y/neutral Event: time 1387128747.365552, type 1 (EV_KEY), code 307 (BTN_X), value 0 <---- release X Event: time 1387128747.381499, type 3 (EV_ABS), code 16 (ABS_HAT0X), value 0 <---- x/neutral #endif if (buffer[6]==2 && buffer[7]==2) { /* if (buffer[4]==1 && buffer[5]==0x80) if (write (fd_uinput, &ev_button[20], sizeof (struct input_event)) < 0) die ("error: write"); if (buffer[4]==0xff && buffer[5]==0x7f) if (write (fd_uinput, &ev_button[21], sizeof (struct input_event)) < 0) die ("error: write"); */ if (buffer[4]==1 && buffer[5]==0x80) { /* DP LEFT */ // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // y/neutral if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // x/left if (write (fd_uinput, &ev[2], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(27); // y/down if (write (fd_uinput, &ev[4], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // x/left if (write (fd_uinput, &ev[2], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(27); // press X if (write (fd_uinput, &ev_button[5], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // y/neutral if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // release X if (write (fd_uinput, &ev_button[4], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // x/neutral x if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); /* DP RIGHT */ usleep(100000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // y/neutral if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // x/right if (write (fd_uinput, &ev[1], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(27); // y/down if (write (fd_uinput, &ev[4], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // x/neutral if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // x/right if (write (fd_uinput, &ev[1], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(27); // press X if (write (fd_uinput, &ev_button[5], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // press Y (we can "piano" in the 2nd one) if (write (fd_uinput, &ev_button[7], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(18000); // y/neutral if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // release X if (write (fd_uinput, &ev_button[4], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // release Y (we can "piano" in the 2nd one) if (write (fd_uinput, &ev_button[6], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(12000); // x/neutral x if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); // restore x&y state if (x_state==0) if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); if (x_state==1) if (write (fd_uinput, &ev[1], sizeof (struct input_event)) < 0) die ("error: write"); if (x_state==-1) if (write (fd_uinput, &ev[2], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); if (y_state==0) if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); if (y_state==1) if (write (fd_uinput, &ev[4], sizeof (struct input_event)) < 0) die ("error: write"); if (y_state==-1) if (write (fd_uinput, &ev[5], sizeof (struct input_event)) < 0) die ("error: write"); if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); usleep(500); } } // x-axis if (buffer[6]==2 && buffer[7]==6) { if (buffer[4]==0 && buffer[5]==0) { if (write (fd_uinput, &ev[0], sizeof (struct input_event)) < 0) die ("error: write"); x_state=0; //neutral } if (buffer[4]==0xff && buffer[5]==0x7f) { if (write (fd_uinput, &ev[1], sizeof (struct input_event)) < 0) die ("error: write"); x_state=1; // right } if (buffer[4]==1 && buffer[5]==0x80) { if (write (fd_uinput, &ev[2], sizeof (struct input_event)) < 0) die ("error: write"); x_state=-1; //left } } // y-axis if (buffer[6]==2 && buffer[7]==7) { if (buffer[4]==0 && buffer[5]==0) { if (write (fd_uinput, &ev[3], sizeof (struct input_event)) < 0) die ("error: write"); y_state=0; //neutral } if (buffer[4]==0xff && buffer[5]==0x7f) { if (write (fd_uinput, &ev[4], sizeof (struct input_event)) < 0) die ("error: write"); y_state=1; //up } if (buffer[4]==1 && buffer[5]==0x80) { if (write (fd_uinput, &ev[5], sizeof (struct input_event)) < 0) die ("error: write"); y_state=-1; // down } } // Sync if (write (fd_uinput, &ev_sync, sizeof (struct input_event)) < 0) die ("error state"); } if (ioctl (fd_uinput, UI_DEV_DESTROY) < 0) die ("error: ioctl"); close (fd_uinput); return 0; }
ws_destroy(compiler); return 0; } /********************* Static functions *********************************/ static void usage(void) { printf("Usage: %s OPTION... FILE...\n\ \n\ -a disassemble resulting byte-code and print it to the\n\ standard output\n\ -d use ws_eval_data() function instead of ws_eval_file()\n\ -h print this help message and exit successfully\n\ -l encode strings in ISO-8859/1 (ISO latin1) instead of using\n\ UTF-8\n\ -p print pragmas\n\ -s print symbolic byte-code assembler to the standard output\n\ -v print verbose progress messages\n\ \n", program); } static void pragma_meta(const WsUtf8String *property_name, const WsUtf8String *content, const WsUtf8String *scheme, void *context) { FILE *fp = stdout; char *what = (char *) context;
~CInterpreter() { lua_close(_l); E_RELEASE( engine ); $1("~CInterpreter()"); }
CInterpreter() : _l(0) { $1("CInterpreter()"); setName( "ScriptLua" ); }
A1_A07_AIO_PT6824_AI_COMBO = AI_COMBO_FUNCTION( "HI_TSEVENT" , 0 , 1 , 0_0 , 20_0 , 0 , 10_0 , 16_0 , TRUE , ALARM_RESET_B_NAME , 0 , 10_0 , 16_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_PT6824_AI_COMBO = AI_COMBO_FUNCTION( "HI_TS_TIME" , 0 , 1 , 0_0 , 20_0 , 0 , 10_0 , 16_0 , TRUE , ALARM_RESET_B_NAME , 0 , 10_0 , 16_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_PT6824_AI_COMBO = AI_COMBO_FUNCTION( "FAULT" , 0 , 1 , 0_0 , 20_0 , 0 , 10_0 , 16_0 , TRUE , ALARM_RESET_B_NAME , 0 , 10_0 , 16_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "AI_COMBO" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "LO_LATCH" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "LO_L_TIME" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "HI_LATCH" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "HI_L_TIME" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "LATCH_OR" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "LO_TSEVENT" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "LO_TS_TIME" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "HI_TSEVENT" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "HI_TS_TIME" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PT6859B_AI_COMBO = AI_COMBO_FUNCTION( "FAULT" , 0 , 1 , 0_0 , 0 , 8_0 , 40_0 , 0 , ALARM_RESET_B_NAME , 0 , 8_0 , 40_0 , 0 , *0_0 (-10_0, 10_0) , *1_0 (0_8, 1_2) , *100_0 (100_0, 150_0) ); A1_A07_AIO_PX36BMASK_AND = AND_FUNCTION( A1_A07_AIO_PT68136_LATCH_OR , *TRUE ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "AI_COMBO" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "LO_LATCH" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "LO_L_TIME" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "HI_LATCH" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "HI_L_TIME" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "LATCH_OR" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "LO_TSEVENT" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "LO_TS_TIME" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "HI_TSEVENT" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "HI_TS_TIME" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE62046_AI_COMBO = AI_COMBO_FUNCTION( "FAULT" , 0 , 0_0 , 100_0 , 0 , -12_5 , 112_5 , TRUE , ALARM_RESET_B_NAME , 0 , -12_5 , 112_5 , 0 , *1 (0, 2) , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE6232B_AI_COMBO = AI_COMBO_FUNCTION( "AI_COMBO" , 0 , 0 , -70_0 , 500_0 , 0 , -40_0 , 380_0 , 0 , ALARM_RESET_B_NAME , 0 , -40_0 , 380_0 , 0 , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE6232B_AI_COMBO = AI_COMBO_FUNCTION( "LO_LATCH" , 0 , 0 , -70_0 , 500_0 , 0 , -40_0 , 380_0 , 0 , ALARM_RESET_B_NAME , 0 , -40_0 , 380_0 , 0 , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE6232B_AI_COMBO = AI_COMBO_FUNCTION( "LO_L_TIME" , 0 , 0 , -70_0 , 500_0 , 0 , -40_0 , 380_0 , 0 , ALARM_RESET_B_NAME , 0 , -40_0 , 380_0 , 0 , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE6232B_AI_COMBO = AI_COMBO_FUNCTION( "HI_LATCH" , 0 , 0 , -70_0 , 500_0 , 0 , -40_0 , 380_0 , 0 , ALARM_RESET_B_NAME , 0 , -40_0 , 380_0 , 0 , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) ); A1_A07_AIO_TE6232B_AI_COMBO = AI_COMBO_FUNCTION( "HI_L_TIME" , 0 , 0 , -70_0 , 500_0 , 0 , -40_0 , 380_0 , 0 , ALARM_RESET_B_NAME , 0 , -40_0 , 380_0 , 0 , *0_0 (-100_0, 100_0) , *1_0 (0_8, 1_2) );
STRING kDBName = "mancala"; POSITION kBadPosition = -1; TIER BoardToTier(int* board); void SetupTierStuff(); STRING TierToString(TIER tier); TIERLIST* TierChildren(TIER tier); TIERPOSITION NumberOfTierPositions(TIER tier); int* ToTierArrayBoard(int *ArrayBoard); int* ToArrayBoard(int *TierArrayBoard, TIER tierNum); STRING kHelpGraphicInterface = ""; STRING kHelpTextInterface = "On your turn, use the numbers next to 'P1 Bin #' or 'P2 Bin #' to choose\n\ a bin from which to move your stones. Player 1 (P1) chooses from the top \n\ row, and Player 2 (P2) chooses from the bottom. The brackets [ ] represent\n\ a bin on the board. The number in the brackets represent the number of \n\ stones in that bin. The far left and far right bins are the mancalas.\n\ The far left mancala belongs to P1 and the other to P2. You cannot move \n\ from a mancala." ; STRING kHelpOnYourTurn = "Choose one of your bins. Player 1 chooses from the top, player 2 chooses\n\ from the bottom. This will disperse your stones counterclockwise around \n\ the board from that bin. The bin you choose must NOT be empty, and you \n\ CANNOT choose either mancala (the far left or right bin)." ; STRING kHelpStandardObjective = "To play until all the stones are contained in the two mancalas and no \n\ more moves are possible. The player whose mancala contains more stones wins." ;