OSDN Git Service

ran gdx-tools HeaderFixer tool
[mikumikustudio/libgdx-mikumikustudio.git] / backends / gdx-backend-jglfw / src / com / badlogic / gdx / backends / jglfw / JglfwInput.java
index 839834f..d92656d 100644 (file)
@@ -1,13 +1,23 @@
+/*******************************************************************************\r
+ * Copyright 2011 See AUTHORS file.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *   http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ ******************************************************************************/
 
 package com.badlogic.gdx.backends.jglfw;
 
 import static com.badlogic.jglfw.Glfw.*;
 
-import com.badlogic.gdx.Input;
-import com.badlogic.gdx.InputProcessor;
-import com.badlogic.gdx.InputProcessorQueue;
-import com.badlogic.jglfw.GlfwCallbackAdapter;
-
 import java.awt.Color;
 import java.awt.FlowLayout;
 import java.awt.event.WindowEvent;
@@ -24,6 +34,11 @@ import javax.swing.border.EmptyBorder;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 
+import com.badlogic.gdx.Input;
+import com.badlogic.gdx.InputProcessor;
+import com.badlogic.gdx.InputProcessorQueue;
+import com.badlogic.jglfw.GlfwCallbackAdapter;
+
 /** An implementation of the {@link Input} interface hooking GLFW panel for input.
  * @author mzechner
  * @author Nathan Sweet */
@@ -175,6 +190,8 @@ public class JglfwInput implements Input {
 
        public boolean isKeyPressed (int key) {
                if (key == Input.Keys.ANY_KEY) return pressedKeys > 0;
+               if (key == Input.Keys.SYM)
+                       return glfwGetKey(app.graphics.window, GLFW_KEY_LEFT_SUPER) || glfwGetKey(app.graphics.window, GLFW_KEY_RIGHT_SUPER);
                return glfwGetKey(app.graphics.window, getJglfwKeyCode(key));
        }
 
@@ -361,6 +378,10 @@ public class JglfwInput implements Input {
                case GLFW_KEY_KP_DIVIDE:
                        return Input.Keys.SLASH;
                case GLFW_KEY_MENU:
+                       return Input.Keys.MENU;
+               case GLFW_KEY_RIGHT_SUPER:
+                       return Input.Keys.SYM;
+               case GLFW_KEY_LEFT_SUPER:
                        return Input.Keys.SYM;
                case GLFW_KEY_KP_EQUAL:
                        return Input.Keys.EQUALS;
@@ -521,25 +542,25 @@ public class JglfwInput implements Input {
                case GLFW_KEY_F12:
                        return Input.Keys.F12;
                case GLFW_KEY_KP_0:
-                       return Input.Keys.NUM_0;
+                       return Input.Keys.NUMPAD_0;
                case GLFW_KEY_KP_1:
-                       return Input.Keys.NUM_1;
+                       return Input.Keys.NUMPAD_1;
                case GLFW_KEY_KP_2:
-                       return Input.Keys.NUM_2;
+                       return Input.Keys.NUMPAD_2;
                case GLFW_KEY_KP_3:
-                       return Input.Keys.NUM_3;
+                       return Input.Keys.NUMPAD_3;
                case GLFW_KEY_KP_4:
-                       return Input.Keys.NUM_4;
+                       return Input.Keys.NUMPAD_4;
                case GLFW_KEY_KP_5:
-                       return Input.Keys.NUM_5;
+                       return Input.Keys.NUMPAD_5;
                case GLFW_KEY_KP_6:
-                       return Input.Keys.NUM_6;
+                       return Input.Keys.NUMPAD_6;
                case GLFW_KEY_KP_7:
-                       return Input.Keys.NUM_7;
+                       return Input.Keys.NUMPAD_7;
                case GLFW_KEY_KP_8:
-                       return Input.Keys.NUM_8;
+                       return Input.Keys.NUMPAD_8;
                case GLFW_KEY_KP_9:
-                       return Input.Keys.NUM_9;
+                       return Input.Keys.NUMPAD_9;
                default:
                        return Input.Keys.UNKNOWN;
                }
@@ -559,8 +580,10 @@ public class JglfwInput implements Input {
                        return GLFW_KEY_NUM_LOCK;
                case Input.Keys.EQUALS:
                        return GLFW_KEY_MENU;
-               case Input.Keys.SYM:
+               case Input.Keys.MENU:
                        return GLFW_KEY_MENU;
+               case Input.Keys.SYM:
+                       return GLFW_KEY_LEFT_SUPER;
                case Input.Keys.NUM_0:
                        return GLFW_KEY_0;
                case Input.Keys.NUM_1:
@@ -705,6 +728,26 @@ public class JglfwInput implements Input {
                        return GLFW_KEY_F11;
                case Input.Keys.F12:
                        return GLFW_KEY_F12;
+               case Input.Keys.NUMPAD_0:
+                       return GLFW_KEY_KP_0;
+               case Input.Keys.NUMPAD_1:
+                       return GLFW_KEY_KP_1;
+               case Input.Keys.NUMPAD_2:
+                       return GLFW_KEY_KP_2;
+               case Input.Keys.NUMPAD_3:
+                       return GLFW_KEY_KP_3;
+               case Input.Keys.NUMPAD_4:
+                       return GLFW_KEY_KP_4;
+               case Input.Keys.NUMPAD_5:
+                       return GLFW_KEY_KP_5;
+               case Input.Keys.NUMPAD_6:
+                       return GLFW_KEY_KP_6;
+               case Input.Keys.NUMPAD_7:
+                       return GLFW_KEY_KP_7;
+               case Input.Keys.NUMPAD_8:
+                       return GLFW_KEY_KP_8;
+               case Input.Keys.NUMPAD_9:
+                       return GLFW_KEY_KP_9;                   
                default:
                        return 0;
                }
@@ -725,6 +768,7 @@ public class JglfwInput implements Input {
                public void key (long window, int key, int action) {
                        switch (action) {
                        case GLFW_PRESS:
+
                                key = getGdxKeyCode(key);
                                processor.keyDown(key);
 
@@ -757,7 +801,7 @@ public class JglfwInput implements Input {
                                mousePressed++;
                                processor.touchDown(mouseX, mouseY, 0, button);
                        } else {
-                               mousePressed--;
+                               mousePressed = Math.max(0, mousePressed - 1);
                                processor.touchUp(mouseX, mouseY, 0, button);
                        }
                }
@@ -771,4 +815,4 @@ public class JglfwInput implements Input {
                                processor.mouseMoved(x, y);
                }
        }
-}
+}
\ No newline at end of file