diff mde/events.d @ 25:2c28ee04a4ed

Some minor and some futile efforts. Played around with init functions, had problems, gave up and put them back. Removed idea for multiple init stages; it's not good for performance or simplicity. Adjusted exception messages. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 03 Apr 2008 17:26:52 +0100
parents 32eff0e01c05
children 611f7b9063c6
line wrap: on
line diff
--- a/mde/events.d	Thu Mar 27 16:15:21 2008 +0000
+++ b/mde/events.d	Thu Apr 03 17:26:52 2008 +0100
@@ -16,15 +16,15 @@
 /// Handles all events from SDL_PollEvent.
 module mde.events;
 
-import mde.scheduler.InitStage;
-import mde.scheduler.runTime;
-
 import global = mde.global;
 static import mde.SDL;
 
 import mde.input.input;
 import mde.input.exception;
 
+import mde.scheduler.InitFunctions;
+import mde.scheduler.runTime;
+
 import derelict.sdl.events;
 
 import tango.util.log.Log : Log, Logger;
@@ -32,23 +32,26 @@
 private Logger logger;
 static this() {
     logger = Log.getLogger ("mde.events");
+    
+    init.addFunc (&initInput);
 
-    init2.addFunc (&initInput);
-    
-    Scheduler.perFrame (&pollEvents);
+    Scheduler.perFrame (&mde.events.pollEvents);
 }
 
-void initInput () { // init2 func
-    debug logger.trace ("init2: initInput() started");
-    
+void initInput () { // init func
     try {
         global.input = new Input();
         global.input.loadConfig ();         // (may also create instance)
-    } catch (Exception e) {
-        setInitFailure ();                // must clean up properly
+    
+        global.input.addButtonCallback (cast(Input.inputID) 0x0u, delegate void(Input.inputID i, bool b) {
+            if (b) {
+                logger.info ("Quiting...");
+                global.run = false;
+            }
+        } );
+    } catch (Exception) {
+        setInitFailure;
     }
-    
-    debug logger.trace ("init2: initInput() finished");
 }
 
 void pollEvents (double) {