#include "../../devicePlugIn.h"#include <string>#include <GL/glut.h>Go to the source code of this file.
Defines | |
| #define | MAXAXES 100 |
| #define | MAXBUTTONS 200 |
Functions | |
| bool | openDevice (void) |
| void | closeDevice (void) |
| bool | update (void) |
| string | name (void) |
| int | axes (void) |
| int | buttons (void) |
| long | axis (int nr) |
| bool | buttonPressed (int nr) |
| void | keyboard (unsigned char key, int x, int y) |
| void | keyboardUp (unsigned char key, int x, int y) |
| void | special (int key, int x, int y) |
| void | specialUp (int key, int x, int y) |
Variables | |
| DevicePlugIn | inputPlugIn = { openDevice, closeDevice, update, name, axes, buttons, axis, buttonPressed } |
|
Definition at line 9 of file deviceKeyboard.h.
|
Definition at line 10 of file deviceKeyboard.h.
|
Definition at line 171 of file inputDeviceJoystick.cpp.
00171 {
00172 if (isPresent) {
00173 return intAxes;
00174 } else return 0;
00175 }
|
Definition at line 203 of file inputDeviceJoystick.cpp.
00203 {
00204 if (isPresent) {
00205 if (nr < intAxes) {
00206 return (intAxis[nr]);
00207 } else {
00208 return 0;
00209 };
00210 } else {
00211 return 0;
00212 };
00213 }
|
Definition at line 225 of file inputDeviceJoystick.cpp.
00225 {
00226 if (isPresent) {
00227 if (nr < intButtons) {
00228 return intButton[nr];
00229 } else {
00230 return false;
00231 };
00232 } else {
00233 return false;
00234 };
00235 }
|
Definition at line 187 of file inputDeviceJoystick.cpp.
00187 {
00188 if (isPresent) {
00189 return intButtons;
00190 } else return 0;
00191 }
|
Definition at line 104 of file inputDeviceJoystick.cpp.
00104 {
00105 close (joyHandle);
00106 return;
00107 }
|
Definition at line 214 of file deviceKeyboard.cpp.
00214 {
00215 if (!chatmode) {
00216 intButton[0]=(key == 'f');
00217 intButton[1]=(key == 'b');
00218 intButton[2]=((key == 27) || (key == 'q') || (key == 'x'));
00219 intButton[3]=(key == '+');
00220 intButton[4]=(key == '-');
00221 } else {
00222 intAxis[2]=(long) key;
00223 keyunderway = true;
00224 };
00225 }
|
Definition at line 227 of file deviceKeyboard.cpp.
00227 {
00228 if (!chatmode) {
00229 switch (key) {
00230 case 'f' : { intButton[0] = false;
00231 break;
00232 };
00233 case 'b' : { intButton[1] = false;
00234 break;
00235 };
00236 case 27 :
00237 case 'q' :
00238 case 'x' : { intButton[2] = false;
00239 break;
00240 };
00241 case '+' : { intButton[3] = false;
00242 break;
00243 };
00244 case '-' : { intButton[4] = false;
00245 break;
00246 };
00247 default : break;
00248 };
00249 } else {
00250 intAxis[2]=0;
00251 };
00252 }
|
Definition at line 155 of file inputDeviceJoystick.cpp.
00155 {
00156 if (isPresent) {
00157 return intName;
00158 } else return "none found";
00159 }
|
Definition at line 60 of file inputDeviceJoystick.cpp.
00060 {
00061 for (int i = 1; i <= MAXAXES; i++) {
00062 intAxis[i]=0;
00063 maxAxis[i]=1;
00064 };
00065
00066 joyHandle = open ("/dev/js0", O_RDONLY | O_NONBLOCK);
00067
00068 if (joyHandle) {
00069 isPresent = true;
00070 } else {
00071 isPresent = false;
00072 return false;
00073 };
00074
00075 char tmp[128];
00076
00077 ioctl (joyHandle, JSIOCGAXES, &intAxes);
00078 ioctl (joyHandle, JSIOCGBUTTONS, &intButtons);
00079 ioctl (joyHandle, JSIOCGNAME(128), tmp);
00080
00081 intName.assign (tmp);
00082
00083 for (int i=0; i < intAxes; i++) {
00084 intAxis[i]=0;
00085 };
00086 for (int i=0; i < intButtons; i++) {
00087 intButton[i]=false;
00088 };
00089
00090 update ();
00091 return true;
00092 }
|
Definition at line 254 of file deviceKeyboard.cpp.
00254 {
00255 if (key == GLUT_KEY_UP) {
00256 intAxis[0]=32767;
00257 } else if (key == GLUT_KEY_DOWN) {
00258 intAxis[0]=-32767;
00259 } else {
00260 intAxis[0]=0;
00261 };
00262
00263 if (key == GLUT_KEY_LEFT) {
00264 intAxis[1]=32767;
00265 } else if (key == GLUT_KEY_RIGHT) {
00266 intAxis[1]=-32767;
00267 } else {
00268 intAxis[1]=0;
00269 };
00270
00271 if (key == GLUT_KEY_F1) {
00272 intButton[5]=true;
00273 chatmode = !chatmode;
00274 } else {
00275 intButton[5]=false;
00276 };
00277 }
|
Definition at line 279 of file deviceKeyboard.cpp.
00279 {
00280 switch (key) {
00281 case GLUT_KEY_UP :
00282 case GLUT_KEY_DOWN: { intAxis[0] = 0;
00283 break;
00284 };
00285 case GLUT_KEY_LEFT :
00286 case GLUT_KEY_RIGHT:{ intAxis[1] = 0;
00287 break;
00288 };
00289 case GLUT_KEY_F1 : { intButton[5] = false;
00290 break;
00291 };
00292 default : break;
00293 };
00294 }
|
Definition at line 119 of file inputDeviceJoystick.cpp.
00119 {
00120 if (isPresent) {
00121
00122 read (joyHandle, &jsEvent, sizeof (struct js_event));
00123
00124 switch (jsEvent.type) {
00125 case 1 : { if (jsEvent.value == 1) {
00126 intButton[jsEvent.number]=true;
00127 } else {
00128 intButton[jsEvent.number]=false;
00129 };
00130 break;
00131 };
00132 case 2 : { intAxis[jsEvent.number] = jsEvent.value;
00133 break;
00134 };
00135 case 129:
00136 case 130: break;
00137 default: { printf ("unhandled InputDeviceJoystick event: type=%i, number=%i, value=%i\n", jsEvent.type, jsEvent.number, jsEvent.value);
00138 break;
00139 };
00140 };
00141 return true;
00142 } else return false;
00143 }
|
Definition at line 30 of file deviceKeyboard.h.
1.1.2 written by Dimitri van Heesch,
© 1997-2000