Commits

Michael Ludwig committed 2072b85

Update tests to use new input API

Comments (0)

Files changed (2)

ferox-physics/src/test/java/com/ferox/physics/PhysicsApplicationStub.java

 package com.ferox.physics;
 
 import com.ferox.input.KeyEvent.KeyCode;
+import com.ferox.input.logic.Action;
 import com.ferox.input.logic.InputManager;
 import com.ferox.input.logic.InputState;
-import com.ferox.input.logic.KeyPressedCondition;
-import com.ferox.input.logic.Trigger;
+import com.ferox.input.logic.Predicates;
 import com.ferox.math.AxisAlignedBox;
 import com.ferox.math.Vector3;
 import com.ferox.math.bounds.QuadTree;
     
     @Override
     protected void installInputHandlers(InputManager io) {
-        io.addTrigger(new Trigger() {
+        io.on(Predicates.keyPress(KeyCode.SPACE))
+          .trigger(new Action() {
             @Override
-            public void onTrigger(InputState prev, InputState next) {
+            public void perform(InputState prev, InputState next) {
                 paused = !paused;
             }
-        }, new KeyPressedCondition(KeyCode.SPACE));
-        io.addTrigger(new Trigger() {
+        });
+        io.on(Predicates.keyPress(KeyCode.S))
+          .trigger(new Action() {
             @Override
-            public void onTrigger(InputState prev, InputState next) {
+            public void perform(InputState prev, InputState next) {
                 stepOnce = true;
             }
-        }, new KeyPressedCondition(KeyCode.S));
+        });
     }
 
     @Override

ferox-test/src/main/java/com/ferox/util/ApplicationStub.java

 package com.ferox.util;
 
 import com.ferox.input.KeyEvent.KeyCode;
+import com.ferox.input.logic.Action;
 import com.ferox.input.logic.InputManager;
 import com.ferox.input.logic.InputState;
-import com.ferox.input.logic.KeyPressedCondition;
-import com.ferox.input.logic.Trigger;
+import com.ferox.input.logic.Predicates;
 import com.ferox.math.ColorRGB;
 import com.ferox.renderer.Framework;
 import com.ferox.renderer.OnscreenSurface;
     
     public void run() {
         OnscreenSurface surface = framework.createSurface(opts);
-        InputManager io = new InputManager(surface);
-        
+        InputManager io = new InputManager();
         init(surface);
         installInputHandlers(io);
         installPrivateHandlers(io);
+        io.attach(surface);
         
         Runtime r = Runtime.getRuntime();
         CharacterSet charSet = new CharacterSet(true, false);
     protected abstract void renderFrame(OnscreenSurface surface);
     
     private void installPrivateHandlers(InputManager io) {
-        io.addTrigger(new Trigger() {
+        io.on(Predicates.keyPress(KeyCode.ESCAPE))
+          .trigger(new Action() {
             @Override
-            public void onTrigger(InputState prev, InputState next) {
+            public void perform(InputState prev, InputState next) {
                 framework.destroy();
             }
-        }, new KeyPressedCondition(KeyCode.ESCAPE));
-        io.addTrigger(new Trigger() {
+        });
+        io.on(Predicates.keyPress(KeyCode.F))
+          .trigger(new Action() {
             @Override
-            public void onTrigger(InputState prev, InputState next) {
+            public void perform(InputState prev, InputState next) {
                 showFPS = !showFPS;
             }
-        }, new KeyPressedCondition(KeyCode.F));
-        io.addTrigger(new Trigger() {
+        });
+        io.on(Predicates.keyPress(KeyCode.P))
+          .trigger(new Action() {
             @Override
-            public void onTrigger(InputState prev, InputState next) {
+            public void perform(InputState prev, InputState next) {
                 showProfiling = !showProfiling;
             }
-        }, new KeyPressedCondition(KeyCode.P));
+        });
     }
 }