home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Zone
/
VRZONE.ISO
/
mac
/
PC
/
PCGLOVE
/
GLOVE
/
OBJGLV.ZIP
/
SRC
/
SIMPLE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-12
|
4KB
|
156 lines
//
// Simple.cpp:
// Exercises Object Glove functions in a simple way.
// Example use of Object Glove.
//
// Compatibility:
// DOS and Windows.
//
// Copyright 1992, 1993 Mark Thomas Pflaging
//
// Date: 11/20/92 (Release 2.1)
// 3/22/93 (Release 3.0)
//
#include <dos.h>
#include <bios.h>
#include <stdlib.h>
#include <conio.h>
#include <strstream.h>
#include <iomanip.h>
#include <string.h>
#include "smooth.hpp"
#include "ini.hpp"
#include "gesture.hpp"
#include "shamless.hpp"
#pragma argsused
void simpleOutput(gloveDriver & gd, void * sysarg)
{
#ifndef _Windows
gotoxy(1,1 + gd.whichGlove());
ostrstream temp;
temp <<
#else
cout <<
#endif
setw(8) << gd.getFingers()
<< setw(8) << gd.getRotation()
<< setw(8) << gd.getX()
<< setw(8) << gd.getY()
<< setw(8) << gd.getZ()
<< setw(8) << gd.getKeys()
#ifndef _Windows
<< '\0';
char * byebye;
cprintf(byebye = temp.str());
free(byebye);
#else
<< endl;
#endif
}
Boolean keyhit_quit()
{
if (kbhit()) {
getch();
return True;
}
return False;
}
int main()
{
cout << "Edit GLOVE.INI to change startup parameters if "
"you experience trouble." << endl;
cout << "HELPME!.DOC contains important troubleshooting "
"information!" << endl;
cout << "Reading GLOVE.INI..." << endl;
InitFile * gloveIni = new InitFile("glove.ini");
#ifndef _Windows
cout << "Determining timing values for this machine..." << endl;
#endif
gloveDriver * GLOVE1;
cout << "Looking for glove #1...(Press any key to quit.)" << endl;
if (!strcmp(gloveIni->find("1.Smoothing", "smoothingEnabled", "True"),
"True"))
GLOVE1 = new smoothGlove(*gloveIni, NULL, keyhit_quit);
else
GLOVE1 = new rawGlove(*gloveIni, NULL, keyhit_quit);
GLOVE1->test();
if (GLOVE1->driverStatus() == gloveDriver::EverythingOK) {
((rawGlove *)GLOVE1)->initFunction(simpleOutput);
gloveDriver * GLOVE2;
cout << "Looking for glove #2...(Press any key to proceed with one glove.)" << endl;
if (!strcmp(gloveIni->find("2.Smoothing", "smoothingEnabled", "True"),
"True"))
GLOVE2 = new smoothGlove(*gloveIni, NULL, keyhit_quit);
else
GLOVE2 = new rawGlove(*gloveIni, NULL, keyhit_quit);
if (GLOVE2->driverStatus() == gloveDriver::EverythingOK) {
cout << endl << endl
<< " Press any keyboard key to begin." << endl
<< endl;
getch();
#ifndef _Windows
clrscr();
#endif
((rawGlove *)GLOVE2)->initFunction(simpleOutput);
GLOVE1->Start(strcmp(gloveIni->find(
gloveDriver::getTitle(),
"PolledOperation", "False"),
"True") ? True : False);
gloveIni->write();
delete gloveIni;
rawGlove::run();
#ifndef _Windows
clrscr();
#endif
delete GLOVE2;
delete GLOVE1;
shamelessFunc();
}
else {
cout << endl << endl
<< " Press any keyboard key to begin." << endl
<< endl;
getch();
#ifndef _Windows
clrscr();
#endif
delete GLOVE2;
GLOVE1->Start(strcmp(gloveIni->find(
gloveDriver::getTitle(),
"PolledOperation", "False"),
"True") ? True : False);
gloveIni->write();
delete gloveIni;
rawGlove::run();
#ifndef _Windows
clrscr();
#endif
delete GLOVE1;
shamelessFunc();
}
}
else {
if (GLOVE1->driverStatus() == gloveDriver::WindowsParametersMissing)
cout << "Delay values are not specified in \"glove.ini\"." << endl
<< "Please EXIT WINDOWS and run \"INITGLOV.EXE\"" << endl
<< "while you are in the same directory as GLOVE.INI." << endl;
else
cout << "You pressed a key to end the program." << endl;
gloveIni->write();
delete gloveIni;
delete GLOVE1;
}
return 0;
}