ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/mintv/mintv.cpp
(Generate patch)

Comparing mintv/mintv.cpp (file contents):
Revision 1.2 by cebix, 2003-02-25T21:10:35Z vs.
Revision 1.5 by cebix, 2003-03-07T20:08:37Z

# Line 22 | Line 22
22   #include <X11/StringDefs.h>
23   #include <X11/Intrinsic.h>
24   #include <X11/Shell.h>
25 + #include <X11/cursorfont.h>
26   #include <X11/Xaw/Simple.h>
27   #include <X11/extensions/XShm.h>
28   #include <X11/extensions/Xv.h>
# Line 31 | Line 32 | static bool ntsc = false;
32  
33   const int PAL_WIDTH = 384;
34   const int PAL_HEIGHT = 288;
35 < const int NTSC_WIDTH = 320;
35 > const int NTSC_WIDTH = 360;
36   const int NTSC_HEIGHT = 240;
37  
38 < static int grab_width, grab_height;
38 > static int grab_width = -1, grab_height;
39   static int image_width, image_height;
40   static int win_width, win_height;
41  
# Line 321 | Line 322 | int main(int argc, char **argv)
322                  {"help", 0, 0, 'h'},
323                  {"ntsc", 0, 0, 'n'},
324                  {"port", 1, 0, 'p'},
325 +                {"width", 1, 0, 'w'},
326                  {NULL, 0, 0, 0}
327          };
328  
# Line 328 | Line 330 | int main(int argc, char **argv)
330          log = fopen("log", "w");
331   #endif
332  
331        // Init X11
332        XtAppContext app_context;
333        app_shell = XtAppInitialize(&app_context, "mintv", NULL, 0, &argc, argv, NULL,  NULL, 0);
334        dpy = XtDisplay(app_shell);
335        XtAppAddActions(app_context,actionTable, sizeof(actionTable) / sizeof(XtActionsRec));
336        XtOverrideTranslations(app_shell, XtParseTranslationTable(
337                "<Message>WM_PROTOCOLS: quit()\n"
338                "<Key>q: quit()\n"
339                "<Key>1: select_channel_1()\n"
340                "<Key>2: select_channel_2()\n"
341                "<Key>KP_7: inc_brightness()\n"
342                "<Key>KP_4: reset_brightness()\n"
343                "<Key>KP_1: dec_brightness()\n"
344                "<Key>KP_8: inc_contrast()\n"
345                "<Key>KP_5: reset_contrast()\n"
346                "<Key>KP_2: dec_contrast()\n"
347                "<Key>KP_9: inc_color()\n"
348                "<Key>KP_6: reset_color()\n"
349                "<Key>KP_3: dec_color()"
350        ));
351        XtAddEventHandler(app_shell, StructureNotifyMask, True, resize_event, NULL);
352        wm = XInternAtom(XtDisplay(app_shell), "WM_DELETE_WINDOW", False);
353
333          // Parse options
334          for (;;) {
335                  int c;
336 <                if ((c = getopt_long(argc, argv, "hnp:", long_opts,NULL)) == -1)
336 >                if ((c = getopt_long(argc, argv, "hnp:w:", long_opts,NULL)) == -1)
337                          break;
338  
339                  switch (c) {
# Line 366 | Line 345 | int main(int argc, char **argv)
345                          case 'p':
346                                  port = atoi(optarg);
347                                  break;
348 +                        case 'w':
349 +                                grab_width = atoi(optarg);
350 +                                break;
351                          case 'h':
352                          default:
353                                  fprintf(stderr,
354 <                                        "50/60Hz video display application\n"
354 >                                        "50/60Hz video display application\n\n"
355                                          "Options:\n"
356 <                                        "  -h | --help    this text\n"
357 <                                        "  -n | --ntsc    NTSC mode\n"
358 <                                        "  -p | --port n  Xv output port\n\n"
356 >                                        "  -h | --help     this text\n"
357 >                                        "  -n | --ntsc     NTSC mode\n"
358 >                                        "  -p | --port n   Xv output port\n"
359 >                                        "  -w | --width n  image width\n\n"
360                                          "Keyboard commands:\n"
361                                          "  q         quit\n"
362                                          "  1/2       select channel\n"
# Line 386 | Line 369 | int main(int argc, char **argv)
369                  }
370          }
371  
372 +        // Init X11
373 +        XtAppContext app_context;
374 +        app_shell = XtAppInitialize(&app_context, "mintv", NULL, 0, &argc, argv, NULL,  NULL, 0);
375 +        dpy = XtDisplay(app_shell);
376 +        XtAppAddActions(app_context,actionTable, sizeof(actionTable) / sizeof(XtActionsRec));
377 +        XtOverrideTranslations(app_shell, XtParseTranslationTable(
378 +                "<Message>WM_PROTOCOLS: quit()\n"
379 +                "<Key>q: quit()\n"
380 +                "<Key>Escape: quit()\n"
381 +                "<Key>1: select_channel_1()\n"
382 +                "<Key>2: select_channel_2()\n"
383 +                "<Key>KP_7: inc_brightness()\n"
384 +                "<Key>KP_4: reset_brightness()\n"
385 +                "<Key>KP_1: dec_brightness()\n"
386 +                "<Key>KP_8: inc_contrast()\n"
387 +                "<Key>KP_5: reset_contrast()\n"
388 +                "<Key>KP_2: dec_contrast()\n"
389 +                "<Key>KP_9: inc_color()\n"
390 +                "<Key>KP_6: reset_color()\n"
391 +                "<Key>KP_3: dec_color()"
392 +        ));
393 +        XtAddEventHandler(app_shell, StructureNotifyMask, True, resize_event, NULL);
394 +        wm = XInternAtom(XtDisplay(app_shell), "WM_DELETE_WINDOW", False);
395 +
396          // Xvideo available?
397          unsigned ver, rel, req, ev, err, val;
398          if (XvQueryExtension(dpy, &ver, &rel, &req, &ev, &err) != Success) {
# Line 431 | Line 438 | port_found:
438  
439          // Set grab and window dimensions
440          if (ntsc) {
441 <                grab_width = NTSC_WIDTH;
441 >                if (grab_width == -1)
442 >                        grab_width = NTSC_WIDTH;
443                  grab_height = NTSC_HEIGHT;
444                  fps = NTSC_FPS;
445          } else {
446 <                grab_width = PAL_WIDTH;
446 >                if (grab_width == -1)
447 >                        grab_width = PAL_WIDTH;
448                  grab_height = PAL_HEIGHT;
449                  fps = PAL_FPS;
450          }
# Line 454 | Line 463 | port_found:
463                  NULL
464          );
465          XtRealizeWidget(app_shell);
466 +        Cursor null_cursor = XCreateFontCursor(dpy, XC_left_ptr);
467 +        XDefineCursor(dpy, XtWindow(app_shell), null_cursor);
468          XtVaSetValues(app_shell,
469                  XtNtitle, "mintv",
470 +                XtNinput, True,
471                  NULL
472          );
473 <        XSetWMProtocols(XtDisplay(app_shell), XtWindow(app_shell), &wm, 1);
473 >        XSetWMProtocols(dpy, XtWindow(app_shell), &wm, 1);
474          gc = XCreateGC(dpy, XtWindow(video), 0, NULL);
475  
476          // Set image format

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines