MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / makeCallback

Method makeCallback

src/main/java/field/graphics/Window.java:854–986  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

852 @Override
853 public void scroll(long window, double scrollX, double scrollY) {
854 if (window == Window.this.window) {
855 MouseState next = mouseState.withScroll(scrollX, scrollY);
856 next.keyboardState = keyboardState;
857 fireMouseTransitionNoMods(mouseState, next);
858 next = mouseState.withScroll(0, 0);
859 mouseState = next;
860 next.keyboardState = keyboardState;
861 }
862 }
863
864 @Override
865 public void cursorPos(long window, double x, double y) {
866 if (window == Window.this.window) {
867 MouseState next = mouseState.withPosition(x, y);
868 fireMouseTransition(mouseState, next);
869 mouseState = next;
870 }
871 }
872
873 @Override
874 public void key(long window, int key, int scancode, int action, int mods) {
875 if (window == Window.this.window && RunLoop.tick > windowOpenedAt + 10) { // we ignore keyboard events from the first couple of updates; they can refer to key downs
876 // that we'll never receive
877
878// System.out.println("key> " + key + "/" + scancode + "/" + action);
879
880 KeyboardState next = keyboardState.withKey(key, action != GLFW_RELEASE);
881
882 next.windowsScancodes.addAll(keyboardState.windowsScancodes);
883 if (action == GLFW_RELEASE)
884 next.windowsScancodes.removeIf((p) -> p == scancode);
885 else if (!next.windowsScancodes.contains(scancode)) next.windowsScancodes.add(scancode);
886
887 modifiers.event(key, scancode, action, mods, next.keysDown);
888
889// next = modifiers.cleanModifiers(next);
890 next = next.clean(window);
891
892
893 fireKeyboardTransition(keyboardState, next);
894 keyboardState = next;
895 }
896 }
897
898 @Override
899 public void character(long window, int character) {
900 if (window == Window.this.window) {
901 KeyboardState next = keyboardState.withChar((char) character, true);
902
903 boolean shift = ((glfwGetKey(window, GLFW_KEY_LEFT_SHIFT)) | (glfwGetKey(window,
904 GLFW_KEY_RIGHT_SHIFT))) != 0;
905 boolean alt = ((glfwGetKey(window, GLFW_KEY_LEFT_ALT)) | (glfwGetKey(window,
906 GLFW_KEY_RIGHT_ALT))) != 0;
907 boolean meta = ((glfwGetKey(window, GLFW_KEY_LEFT_SUPER)) | (glfwGetKey(window,
908 GLFW_KEY_RIGHT_SUPER))) != 0;
909 boolean ctrl = ((glfwGetKey(window, GLFW_KEY_LEFT_CONTROL)) | (glfwGetKey(window,
910 GLFW_KEY_RIGHT_CONTROL))) != 0;
911

Callers 1

WindowMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected