| 28 | protected var downEvents: MutableSet<Int> = LinkedHashSet() |
| 29 | protected var upEvents: MutableSet<Int> = LinkedHashSet() |
| 30 | protected var down: MutableSet<Int> = LinkedHashSet() |
| 31 | |
| 32 | private var on: Window? = null |
| 33 | |
| 34 | fun attachToWindow(on: Window) { |
| 35 | on.addKeyboardHandler(this::state) |
| 36 | on.addMouseHandler(this::mouseState) |
| 37 | this.on = on |
| 38 | |
| 39 | val f = GLFW::class.java.declaredFields |
| 40 | for (ff in f) { |
| 41 | if (Modifier.isStatic(ff.modifiers) && ff.name.startsWith("GLFW_KEY_")) { |
| 42 | try { |
| 43 | nameMap.put(ff.name.replace("GLFW_KEY_", "").toLowerCase(), ff.getInt(null)) |
| 44 | nameMapBackwards.put(ff.getInt(null), ff.name.replace("GLFW_KEY_", "").toLowerCase()) |
| 45 | } catch (e: IllegalAccessException) { |
| 46 | e.printStackTrace() |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | nameMap.put("mouse0", -1); |
| 52 | nameMap.put("mouse1", -2); |
| 53 | nameMap.put("mouse2", -3); |
| 54 | nameMapBackwards.put(-1, "mouse0"); |
| 55 | nameMapBackwards.put(-2, "mouse1"); |
| 56 | nameMapBackwards.put(-3, "mouse2"); |
| 57 |
no test coverage detected