diff Renderer/Engine/Pad.cc @ 539:3bc98f6d31ff draft

Reorganization..
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 09:39:35 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/Pad.cc	Mon Oct 12 09:39:35 2009 +0900
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include "Keyboard.h"
+#include "Joystick.h"
+
+/**
+ * Joystick があればそれを使い、
+ * 無ければキーボードを返す
+ */
+Pad*
+create_controller(void)
+{
+    if (SDL_NumJoysticks()) {
+		SDL_Joystick *joy = SDL_JoystickOpen(0);
+		if (!joy) {
+			printf("%s: failed to open joystick", __FUNCTION__);
+			printf("Instead use Keyboard\n");
+			return new Keyboard;
+		} else {
+			printf("Use Joystick\n");
+			return new Joystick(joy);
+		}
+    } else {
+		printf("Use Keyboard\n");
+		return new Keyboard;
+    }
+}