-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoystick_testing.cpp
77 lines (61 loc) · 1.35 KB
/
joystick_testing.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string>
#include <math.h>
#include <vector>
#include <GL/glut.h>
#include <GL/glu.h>
#include <iostream>
void mainglutInit( int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(100, 100);
glutInitWindowPosition(100, 100);
glutCreateWindow("Bringing the Joy");
}
void secondInit(void)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 100, 0, 100);
glMatrixMode(GL_MODELVIEW);
}
void keyboard( unsigned char key, int x, int y )
{
//Quit
if ( key == 'q' || key == 'Q') exit(0);
}
void joystick(unsigned int buttonMask, int x, int y, int z)
{
for(int i = 0; i < 32; i++)
{
if(buttonMask & 1)
printf("1 ");
else
printf("0 ");
buttonMask = buttonMask >> 1;
}
printf("\njoystick axes (x, y, z) = (%d, %d, %d)\n", x, y, z);
}
void display()
{
// Load identity for drawing the white background.
glLoadIdentity();
//Make everything black first. This affects everything in window.
glClear(GL_COLOR_BUFFER_BIT);
//Change color to white.
//Go to pipeline.
//Pipeline();
glColor3f(1.0, 1.0, 1.0);
//glutSwapBuffers();
}
int main(int argc, char** argv){
mainglutInit(argc, argv);
secondInit();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutJoystickFunc(joystick,1);
glutMainLoop();
}