File: joy.cpp

package info (click to toggle)
pinball 0.3.20201218-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,452 kB
  • sloc: cpp: 15,230; makefile: 840; sh: 381; xml: 24
file content (42 lines) | stat: -rw-r--r-- 887 bytes parent folder | download | duplicates (8)
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
/***************************************************************************
 Joystick test
 ***************************************************************************/

#include <iostream>

#include "Private.h"
#include "Engine.h"
#include "Keyboard.h"

/** Main */
int main(int argc, char *argv[]) {
#if EM_USE_SDL
	cerr << "Joystick test" << endl;
	Engine* engine = new Engine(argc, argv);
	
	int njoystick = SDL_NumJoysticks();
	cerr << njoystick << " joysticks were found." << endl;
	
	if (njoystick != 0) {
		cerr << "The names of the joysticks are:" << endl;
		for(int a=0; a<njoystick; a++ ) {
			cerr << "  " << SDL_JoystickName(a) << endl;
		}
	}

	while (!Keyboard::isKeyDown(SDLK_ESCAPE)) {
		engine->tick();
		engine->render();
		engine->swap();
	}	

	delete(engine);
#else
#warning "this is sdl specific test"
#endif
	return 0;
}

#if EM_USE_ALLEGRO
END_OF_MAIN();
#endif