Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

deviceMouse.cpp File Reference

#include "deviceMouse.h"
#include <string.h>
#include <iostream>
#include <iomanip>

Go to the source code of this file.

Functions

DevicePlugInGetDevicePlugIn (void)
bool openDevice ()
void closeDevice ()
bool update ()
string name ()
int axes ()
int buttons ()
long axis (int nr)
bool buttonPressed (int nr)
void mouse (int button, int state, int x, int y)
void motion (int x, int y)

Variables

bool isPresent
int intAxes
int intButtons
long intAxis [MAXAXES]
bool intButton [MAXBUTTONS]
string intName
int intX
int intY


Function Documentation

DevicePlugIn * GetDevicePlugIn ( void)

Definition at line 40 of file deviceMouse.cpp.

00040 {
00041     return &inputPlugIn;
00042 }

int axes ( void)

Definition at line 159 of file deviceMouse.cpp.

00159 {
00160     if (isPresent) {
00161         return intAxes;
00162     } else return 0;
00163 }

long axis ( int nr)

Definition at line 191 of file deviceMouse.cpp.

00191 {
00192     if (isPresent) {
00193         if (nr < intAxes) {
00194             return (intAxis[nr]);
00195         } else {
00196             return 0;
00197         };
00198     } else {
00199         return 0;
00200     };
00201 }

bool buttonPressed ( int nr)

Definition at line 213 of file deviceMouse.cpp.

00213 {
00214     if (isPresent) {
00215     if (nr < intButtons) {
00216         return intButton[nr];
00217     } else {
00218         return false;
00219     };
00220     } else {
00221         return false;
00222     };
00223 }

int buttons ( void)

Definition at line 175 of file deviceMouse.cpp.

00175 {
00176     if (isPresent) {
00177         return intButtons;
00178     } else return 0;
00179 }

void closeDevice ( void)

Definition at line 85 of file deviceMouse.cpp.

00085 {
00086     return;
00087 }

void motion ( int x,
int y)

Definition at line 234 of file deviceMouse.cpp.

00234 {
00235     intX = x;
00236     intY = y;
00237 }

void mouse ( int button,
int state,
int x,
int y)

Definition at line 226 of file deviceMouse.cpp.

00226 {
00227     if (state == GLUT_DOWN) {
00228         intButton[button]=true;
00229     } else {
00230         intButton[button]=false;
00231     };
00232 }

string name ( void)

Definition at line 143 of file deviceMouse.cpp.

00143 {
00144     if (isPresent) {
00145         return intName;
00146     } else return "none found";
00147 }

bool openDevice ( void)

Definition at line 54 of file deviceMouse.cpp.

00054 {
00055     intAxes   =2;
00056     intButtons=3;
00057     intName   ="glut-mouse";
00058     isPresent =true;
00059 
00060     for (int i=0; i < intAxes; i++) {
00061         intAxis[i]=0;
00062     };
00063     for (int i=0; i < intButtons; i++) {
00064         intButton[i]=false;
00065     };
00066 
00067     glutMouseFunc (mouse);
00068     glutPassiveMotionFunc (motion);
00069 
00070     update ();
00071 
00072     return true;
00073 }

bool update ( void)

Definition at line 99 of file deviceMouse.cpp.

00099 {
00100     if (isPresent) {
00101         int WindowHeight = glutGet ((GLenum)GLUT_WINDOW_HEIGHT);
00102         int WindowWidth  = glutGet ((GLenum)GLUT_WINDOW_WIDTH);
00103 
00104         intAxis[0]= ( ( WindowHeight  / 2) - intY) * 100;
00105         intAxis[1]= (  ( WindowWidth / 2) - intX) * 100;
00106 
00107         if ( intY > ( WindowHeight - 1 ) )
00108             {
00109             intY = WindowHeight - 1;
00110             glutWarpPointer ( intX, intY );
00111             }
00112         else if ( intY < 0 )
00113             {
00114             intY = 1;
00115             glutWarpPointer ( intX, intY );
00116             }
00117 
00118         if ( intX > ( WindowWidth - 1 ) )
00119             {
00120             intX = WindowWidth - 1;
00121             glutWarpPointer ( intX, intY );
00122             }
00123         else if ( intX < 0 )
00124             {
00125             intX = 1;
00126             glutWarpPointer ( intX, intY );
00127             }
00128 
00129         return true;
00130     } else return false;
00131 }

Variable Documentation

int intAxes

Definition at line 21 of file deviceMouse.cpp.

long intAxis[MAXAXES]

Definition at line 23 of file deviceMouse.cpp.

bool intButton[MAXBUTTONS]

Definition at line 24 of file deviceMouse.cpp.

int intButtons

Definition at line 22 of file deviceMouse.cpp.

string intName

Definition at line 25 of file deviceMouse.cpp.

int intX

Definition at line 26 of file deviceMouse.cpp.

int intY

Definition at line 26 of file deviceMouse.cpp.

bool isPresent

Definition at line 20 of file deviceMouse.cpp.


Generated at Sat May 13 13:50:19 2000 for 3Dsia by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000