• Main Page
  • Modules
  • Classes
  • Files
  • File List

tbtcheck_ascii.cpp

00001 /*  Time Based Text - .tbt file checker
00002  *
00003  *  (C) Copyright 2006 Denis Rojo <jaromil@dyne.org>
00004  *
00005  * This source code is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Public License as published 
00007  * by the Free Software Foundation; either version 2 of the License,
00008  * or (at your option) any later version.
00009  *
00010  * This source code is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00013  * Please refer to the GNU Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Public License along with
00016  * this source code; if not, write to:
00017  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *
00019  */
00020 
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <unistd.h>
00024 
00025 #include <getopt.h>
00026 
00027 #include <assert.h>
00028 
00029 #include <tbt.h>
00030 #include <keycodes.h>
00031 
00032 #include <jutils.h>
00033 
00034 // Time Based Text object
00035 TBT tbt;
00036 
00037 int main(int argc, char **argv) {
00038   int c, len;
00039 
00040   len = tbt.load_ascii( argv[1] );
00041   if(!len) {
00042     fprintf(stderr,"no entries found in file %s\n",argv[1]);
00043     exit(1);
00044   }
00045 
00046   TBTEntry *stroke;
00047   char keyname[256];
00048 
00049   for(c=1; c<len+1; c++) {
00050     // this is a blocking call
00051     // tbt.getkey will wait N time before returning
00052     stroke =  (TBTEntry*) tbt.buffer->pick(c);
00053     switch(stroke->key) {
00054       case KEY_ENTER:   sprintf(keyname,"ENTER"); break;
00055       case KEY_UP:      sprintf(keyname,"UP");    break;
00056       case KEY_DOWN:    sprintf(keyname,"DOWN");  break;
00057       case KEY_LEFT:    sprintf(keyname,"LEFT");  break;
00058       case KEY_RIGHT:   sprintf(keyname,"RIGHT"); break;
00059       default: sprintf(keyname, "%c", (int)stroke->key);
00060     }
00061     act("[ %s ] - %lu", keyname, (unsigned long)stroke->msec);
00062     
00063     
00064   }
00065 
00066   exit(0);
00067 
00068 }
00069 
00070 
00071 
00072 

Generated on Mon Apr 9 2012 15:29:22 for TimeBasedText_code_doc by  doxygen 1.7.1