539
|
1 #include <stdio.h>
|
|
2 #include "Keyboard.h"
|
|
3 #include "Joystick.h"
|
|
4
|
|
5 /**
|
|
6 * Joystick があればそれを使い、
|
|
7 * 無ければキーボードを返す
|
|
8 */
|
|
9 Pad*
|
|
10 create_controller(void)
|
|
11 {
|
|
12 if (SDL_NumJoysticks()) {
|
|
13 SDL_Joystick *joy = SDL_JoystickOpen(0);
|
|
14 if (!joy) {
|
|
15 printf("%s: failed to open joystick", __FUNCTION__);
|
|
16 printf("Instead use Keyboard\n");
|
|
17 return new Keyboard;
|
|
18 } else {
|
|
19 printf("Use Joystick\n");
|
|
20 return new Joystick(joy);
|
|
21 }
|
|
22 } else {
|
|
23 printf("Use Keyboard\n");
|
|
24 return new Keyboard;
|
|
25 }
|
|
26 }
|