home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Zone / VRZONE.ISO / mac / PC / PCGLOVE / GLOVE / OBJGLV.ZIP / SRC / DOSGLOVE.CPP < prev    next >
C/C++ Source or Header  |  1993-05-12  |  5KB  |  156 lines

  1. //
  2. // DOSGlove.cpp:
  3. //    "main()" function for a graphical Glove application.
  4. //    Example use of Object Glove.
  5. //
  6. // Purpose:
  7. //    Sets up the DOC glove application.
  8. //
  9. // Compatibility:
  10. //    DOS only.  See WINGLOVE.CPP for Windows version.
  11. //
  12. // Copyright 1993   Mark Thomas Pflaging
  13. //
  14. // Date:    5/15/92 - 6/4/92 (Release 1)
  15. //        8/9/92 - 9/21/92 (Release 2)
  16. //                11/20/92 (Release 2.1)
  17. //                   3/22/93 (Release 3.0)
  18. //
  19. #include <dos.h>
  20. #include <bios.h>
  21. #include <stdlib.h>
  22. #include <conio.h>
  23. #include <iostream.h>
  24. #include <string.h>
  25.  
  26. #include "smooth.hpp"
  27. #include "bgiactor.hpp"
  28. #include "ini.hpp"
  29. #include "gestsys.hpp"
  30. #include "bgigest.hpp"
  31. #include "shamless.hpp"
  32.  
  33. Boolean keyhit_quit()
  34. {
  35.     if (kbhit()) {
  36.         getch();
  37.         return True;
  38.     }
  39.     return False;
  40. }
  41.  
  42. int main()
  43. {
  44.     cout << "Edit GLOVE.INI to change startup parameters if "
  45.         "you experience trouble." << endl;
  46.     cout << "HELPME!.DOC contains important troubleshooting "
  47.         "information!" << endl;
  48.     cout << "Reading GLOVE.INI..." << endl;
  49.     InitFile * gloveIni = new InitFile("glove.ini");
  50.     if (gloveIni->getStatus() == Key::FileDidNotExist)
  51.          cout << "Cannot open \"glove.ini\".  Using defaults and creating new \"glove.ini\"." << endl;
  52.     if (gloveIni->getStatus() == Key::ErrorReadingFile)
  53.          cout << "Error in \"glove.ini\".  Using defaults and perhaps modifying \"glove.ini\"." << endl;
  54.  
  55.     cout << "Determining timing values for this machine..." << endl;
  56.  
  57.     rawGlove * GLOVE1;
  58.     GestureSystem gestSys;
  59.     BGIGestureActor gloveGesture1(*gloveIni, "1.Gestures");
  60.     BGIgraphicsActor &gloveGraph1 = *(new BGIgraphicsActor(*gloveIni, gloveGesture1));
  61.     gestSys + &gloveGraph1;
  62.     gestSys + &gloveGesture1;
  63.     cout << "Waiting for glove #1... (press any key to exit)" << endl;
  64.     if (!strcmp(gloveIni->find("1.Smoothing", "smoothingEnabled", "True"),
  65.          "True"))
  66.         GLOVE1 = new smoothGlove(*gloveIni, &gestSys, keyhit_quit);
  67.     else
  68.         GLOVE1 = new rawGlove(*gloveIni, &gestSys, keyhit_quit);
  69.     gestSys.turnOn();
  70.     GLOVE1->test();
  71.  
  72.     if (GLOVE1->driverStatus() == gloveDriver::EverythingOK) {
  73.         rawGlove * GLOVE2;
  74.         GestureSystem gestSys2;
  75.         BGIGestureActor gloveGesture2(*gloveIni, "2.Gestures");
  76.         BGIgraphicsActor &gloveGraph2 = *(new BGIgraphicsActor(*gloveIni, gloveGesture2, gloveGraph1));
  77.         gloveGraph1.turnOn();
  78.         gloveGraph2.turnOn();
  79.         gloveGesture1.turnOn();
  80.         gloveGesture2.turnOn();
  81.         gestSys2 + &gloveGraph2;
  82.         gestSys2 + &gloveGesture2;
  83.         cout << "Waiting for glove #2... (press any key to exit)"
  84.             << endl;
  85.         if (!strcmp(gloveIni->find("2.Smoothing", "smoothingEnabled", "True"),
  86.              "True"))
  87.             GLOVE2 = new smoothGlove(*gloveIni, &gestSys2, keyhit_quit);
  88.         else {
  89.             GLOVE2 = new rawGlove(*gloveIni, &gestSys2, keyhit_quit);
  90.         }
  91.         gestSys2.turnOn();
  92.  
  93.         if (GLOVE2->driverStatus() == gloveDriver::EverythingOK) {
  94.             cout << endl << endl
  95.                 << "            Press any keyboard key "
  96.                 "to begin." << endl
  97.                 << "Press the '1' key on the Glove during "
  98.                 "the demo to display help." << endl;
  99.             getch();
  100.             GLOVE1->initFunction(BGIgraphicsActor::Process, &gloveGraph1);
  101.             GLOVE2->initFunction(BGIgraphicsActor::Process, &gloveGraph2);
  102.             gloveGraph1.Setup();
  103.             gloveGraph2.Setup();
  104.             cleardevice();
  105.             GLOVE1->Start(strcmp(gloveIni->find(
  106.                 gloveDriver::getTitle(),
  107.                 "PolledOperation", "False"),
  108.                 "True") ? True : False);
  109.             gloveIni->write();
  110.             delete gloveIni;
  111.             rawGlove::run();
  112.             delete GLOVE2;
  113.             delete GLOVE1;
  114.             gloveGraph2.killAssociatedGestures();
  115.             delete &gloveGraph2;
  116.             delete &gloveGraph1;
  117.             shamelessFunc();
  118.         }
  119.         else {
  120.             delete GLOVE2;
  121.             delete &gloveGraph2;
  122.             cout << endl << endl
  123.                 << "GLOVE.INI also contains some aesthetic "
  124.                 "parameters, so READ IT!" << endl
  125.                 << "            Press any keyboard key "
  126.                 "to begin." << endl
  127.                 << "Press the '1' key on the Glove during "
  128.                 "the demo to display help." << endl;
  129.             getch();
  130.             GLOVE1->initFunction(BGIgraphicsActor::Process,
  131.                 &gloveGraph1);
  132.             gloveGraph1.Setup();
  133.             cleardevice();
  134.             GLOVE1->Start(strcmp(gloveIni->find(
  135.                 gloveDriver::getTitle(),
  136.                 "PolledOperation", "False"),
  137.                 "True") ? True : False);
  138.             gloveIni->write();
  139.             delete gloveIni;
  140.             rawGlove::run();
  141.             delete GLOVE1;
  142.             gloveGraph1.killAssociatedGestures();
  143.             delete &gloveGraph1;
  144.             shamelessFunc();
  145.         }
  146.     }
  147.     else {
  148.         cout << endl << "The program was terminated (by a "
  149.         "keystroke) before finding a glove attached." << endl;
  150.         gloveIni->write();
  151.         delete gloveIni;
  152.         delete GLOVE1;
  153.     }
  154.     return 0;
  155. }
  156.