Add input event and type classes

This commit is contained in:
JeremyStar™ 2024-07-22 15:22:34 +02:00
parent 48f910e78f
commit e754c2c248
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
6 changed files with 631 additions and 1 deletions

View file

@ -83,6 +83,20 @@ public final class GraphicsSubsystemConfiguration implements SubsystemConfigurat
*/
private boolean debug;
/**
* If enabled, will log all keys being pressed or released.
*
* @since v1-alpha2
*
* -- GETTER --
* Gets the value for {@link #debugInput}.
*
* @return variable value
* @see GraphicsSubsystemConfiguration#debugInput
* @since v1-alpha2
*/
private boolean debugInput;
/**
* If enabled, graphical errors thrown by GLFW will be printed to the log by the subsystem.
*
@ -160,6 +174,7 @@ public final class GraphicsSubsystemConfiguration implements SubsystemConfigurat
try {
switch (property) {
case "debug" -> debug = parser.getBoolean(group + property);
case "debugInput" -> debugInput = parser.getBoolean(group + property);
case "errorGraphicsError" -> errorGraphicsError = parser.getBoolean(group + property);
@ -169,7 +184,8 @@ public final class GraphicsSubsystemConfiguration implements SubsystemConfigurat
}
// Disable all debug options if 'debug' is disabled
//if (!debug) {}
if (!debug)
debugInput = false;
}
/** {@inheritDoc} */
@ -180,6 +196,7 @@ public final class GraphicsSubsystemConfiguration implements SubsystemConfigurat
/** {@inheritDoc} */
public void loadDefaultConfiguration() {
debug = false;
debugInput = false;
errorGraphicsError = true;
@ -191,6 +208,7 @@ public final class GraphicsSubsystemConfiguration implements SubsystemConfigurat
public Object getSetting(@NotNull String setting) {
switch (setting) {
case "debug" -> { return debug; }
case "debugInput" -> { return debugInput; }
case "errorGraphicsError" -> { return errorGraphicsError; }

View file

@ -0,0 +1,52 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.graphics.events.input;
import de.staropensource.sosengine.base.classes.Event;
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
import de.staropensource.sosengine.graphics.types.input.Key;
import de.staropensource.sosengine.graphics.types.input.KeyState;
import org.jetbrains.annotations.NotNull;
/**
* Called when a key is pressed.
*
* @since v1-alpha2
*/
@SuppressWarnings({ "unused" })
public class KeyInputEvent implements Event {
/**
* {@inheritDoc}
* @see #callEvent(Key, KeyState)
* @deprecated use {@link #callEvent(Key, KeyState)}
*/
@Deprecated
@Override
public void callEvent() {}
/**
* Calls the event and notifies all annotated methods.
*
* @since v1-alpha0
*/
public void callEvent(@NotNull Key key, @NotNull KeyState state) {
EventHelper.invokeAnnotatedMethods(getClass(), key, state);
}
}

View file

@ -0,0 +1,22 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.graphics.events.input;
public class MouseInputEvent {}

View file

@ -0,0 +1,492 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.graphics.types.input;
/**
* Contains a list of keys which
* can be recognized by the engine.
*
* @since v1-alpha2
*/
@SuppressWarnings({ "unused" })
public enum Key {
/**
* The {@code ALT} modifier key.
*/
ALT,
/**
* The {@code '} key.
*/
APOSTROPHE,
/**
* The {@code DOWN} arrow key.
*/
ARROW_DOWN,
/**
* The {@code LEFT} arrow key.
*/
ARROW_LEFT,
/**
* The {@code RIGHT} arrow key.
*/
ARROW_RIGHT,
/**
* The {@code UP} arrow key.
*/
ARROW_UP,
/**
* The {@code \} key.
*/
BACKSLASH,
/**
* The {@code BACKSPACE} key.
*/
BACKSPACE,
/**
* The left {@code [} key.
*/
BRACKET_LEFT,
/**
* The right {@code ]} key.
*/
BRACKET_RIGHT,
/**
* THE {@code CAPSLOCK} KEY.
*/
CAPS_LOCK,
/**
* The {@code ,} key.
*/
COMMA,
/**
* The left {@code CTRL} modifier key.
*/
CONTROL_LEFT,
/**
* The right {@code CTRL} modifier key.
*/
CONTROL_RIGHT,
/**
* The {@code DEL} key.
*/
DELETE,
/**
* The {@code END} key.
*/
END,
/**
* The {@code ENTER} key.
*/
ENTER,
/**
* The {@code =} key.
*/
EQUAL,
/**
* The {@code ESC} key.
*/
ESCAPE,
/**
* The {@code F1} key.
*/
FUNCTION_1,
/**
* The {@code F2} key.
*/
FUNCTION_2,
/**
* The {@code F3} key.
*/
FUNCTION_3,
/**
* The {@code F4} key.
*/
FUNCTION_4,
/**
* The {@code F5} key.
*/
FUNCTION_5,
/**
* The {@code F6} key.
*/
FUNCTION_6,
/**
* The {@code F7} key.
*/
FUNCTION_7,
/**
* The {@code F8} key.
*/
FUNCTION_8,
/**
* The {@code F9} key.
*/
FUNCTION_9,
/**
* The {@code F10} key.
*/
FUNCTION_10,
/**
* The {@code F11} key.
*/
FUNCTION_11,
/**
* The {@code F12} key.
*/
FUNCTION_12,
/**
* The {@code F13} key.
*/
FUNCTION_13,
/**
* The {@code F14} key.
*/
FUNCTION_14,
/**
* The {@code F15} key.
*/
FUNCTION_15,
/**
* The {@code F16} key.
*/
FUNCTION_16,
/**
* The {@code F17} key.
*/
FUNCTION_17,
/**
* The {@code F18} key.
*/
FUNCTION_18,
/**
* The {@code F19} key.
*/
FUNCTION_19,
/**
* The {@code F20} key.
*/
FUNCTION_20,
/**
* The {@code F21} key.
*/
FUNCTION_21,
/**
* The {@code F22} key.
*/
FUNCTION_22,
/**
* The {@code F23} key.
*/
FUNCTION_23,
/**
* The {@code F24} key.
*/
FUNCTION_24,
/**
* The {@code F25} key.
*/
FUNCTION_25,
/**
* The {@code `} key.
*/
GRAVE,
/**
* The {@code HOME} key.
*/
HOME,
/**
* THe {@code INS} key.
*/
INSERT,
/**
* The {@code +} key on your keypad.
*/
KEYPAD_ADD,
/**
* The {@code -} key on your keypad.
*/
KEYPAD_DECIMAL,
/**
* The {@code /} key on your keypad.
*/
KEYPAD_DIVIDE,
/**
* The {@code ENTER} key on your keypad.
*/
KEYPAD_ENTER,
/**
* The {@code =} key on your keypad.
*/
KEYPAD_EQUAL,
/**
* The {@code *} key on your keypad.
*/
KEYPAD_MULTIPLY,
/**
* The number {@code 0} key on your keypad.
*/
KEYPAD_NUMBER_0,
/**
* The number {@code 1} key on your keypad.
*/
KEYPAD_NUMBER_1,
/**
* The number {@code 2} key on your keypad.
*/
KEYPAD_NUMBER_2,
/**
* The number {@code 3} key on your keypad.
*/
KEYPAD_NUMBER_3,
/**
* The number {@code 4} key on your keypad.
*/
KEYPAD_NUMBER_4,
/**
* The number {@code 5} key on your keypad.
*/
KEYPAD_NUMBER_5,
/**
* The number {@code 6} key on your keypad.
*/
KEYPAD_NUMBER_6,
/**
* The number {@code 7} key on your keypad.
*/
KEYPAD_NUMBER_7,
/**
* The number {@code 8} key on your keypad.
*/
KEYPAD_NUMBER_8,
/**
* The number {@code 9} key on your keypad.
*/
KEYPAD_NUMBER_9,
/**
* The {@code -} key on your keypad.
*/
KEYPAD_SUBTRACT,
/**
* The letter {@code A} key.
*/
LETTER_A,
/**
* The letter {@code B} key.
*/
LETTER_B,
/**
* The letter {@code C} key.
*/
LETTER_C,
/**
* The letter {@code D} key.
*/
LETTER_D,
/**
* The letter {@code E} key.
*/
LETTER_E,
/**
* The letter {@code F} key.
*/
LETTER_F,
/**
* The letter {@code G} key.
*/
LETTER_G,
/**
* The letter {@code H} key.
*/
LETTER_H,
/**
* The letter {@code I} key.
*/
LETTER_I,
/**
* The letter {@code J} key.
*/
LETTER_J,
/**
* The letter {@code K} key.
*/
LETTER_K,
/**
* The letter {@code L} key.
*/
LETTER_L,
/**
* The letter {@code M} key.
*/
LETTER_M,
/**
* The letter {@code N} key.
*/
LETTER_N,
/**
* The letter {@code O} key.
*/
LETTER_O,
/**
* The letter {@code P} key.
*/
LETTER_P,
/**
* The letter {@code Q} key.
*/
LETTER_Q,
/**
* The letter {@code R} key.
*/
LETTER_R,
/**
* The letter {@code S} key.
*/
LETTER_S,
/**
* The letter {@code T} key.
*/
LETTER_T,
/**
* The letter {@code U} key.
*/
LETTER_U,
/**
* The letter {@code V} key.
*/
LETTER_V,
/**
* The letter {@code W} key.
*/
LETTER_W,
/**
* The letter {@code X} key.
*/
LETTER_X,
/**
* The letter {@code Y} key.
*/
LETTER_Y,
/**
* The letter {@code Z} key.
*/
LETTER_Z,
/**
* The {@code MENU} key, which brings up the right click menu.
*/
MENU,
/**
* The {@code META} key, also known as the {@code SUPER} key.
* <p>
* Windows users will recognize this key as the Windows key.
*/
META,
/**
* The {@code -} key.
*/
MINUS,
/**
* The number {@code 0}.
*/
NUMBER_0,
/**
* The number {@code 1}.
*/
NUMBER_1,
/**
* The number {@code 2}.
*/
NUMBER_2,
/**
* The number {@code 3}.
*/
NUMBER_3,
/**
* The number {@code 4}.
*/
NUMBER_4,
/**
* The number {@code 5}.
*/
NUMBER_5,
/**
* The number {@code 6}.
*/
NUMBER_6,
/**
* The number {@code 7}.
*/
NUMBER_7,
/**
* The number {@code 8}.
*/
NUMBER_8,
/**
* The number {@code 9}.
*/
NUMBER_9,
/**
* The {@code NUM} key.
*/
NUM_LOCK,
/**
* The {@code PAGE DOWN} key.
*/
PAGE_DOWN,
/**
* The {@code PAGE UP} key.
*/
PAGE_UP,
/**
* The {@code PAUSE} key.
*/
PAUSE,
/**
* The {@code .} key.
*/
PERIOD,
/**
* The {@code PRINT} key.
*/
PRINT,
/**
* The {@code SCROLL} key.
*/
SCROLL_LOCK,
/**
* The {@code ;} key.
*/
SEMICOLON,
/**
* The left {@code SHIFT} modifier key.
*/
SHIFT_LEFT,
/**
* The right {@code SHIFT} modifier key.
*/
SHIFT_RIGHT,
/**
* The {@code /} key.
*/
SLASH,
/**
* The {@code TAB} key.
*/
TAB,
}

View file

@ -0,0 +1,42 @@
/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Contributors
* Licensed under the GNU Affero General Public License v3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.staropensource.sosengine.graphics.types.input;
/**
* Indicates how a key is pressed.
*
* @since v1-alpha2
*/
@SuppressWarnings({ "unused" })
public enum KeyState {
/**
* Indicates that a key is pressed.
*
* @since v1-alpha2
*/
PRESSED,
/**
* Indicates that a key is released.
*
* @since v1-alpha2
*/
RELEASED,
}

View file

@ -15,11 +15,15 @@ module sosengine.graphics {
exports de.staropensource.sosengine.graphics;
exports de.staropensource.sosengine.graphics.classes;
exports de.staropensource.sosengine.graphics.events;
exports de.staropensource.sosengine.graphics.events.input;
exports de.staropensource.sosengine.graphics.types.input;
exports de.staropensource.sosengine.graphics.types.window;
// Reflection access
opens de.staropensource.sosengine.graphics;
opens de.staropensource.sosengine.graphics.classes;
opens de.staropensource.sosengine.graphics.events;
opens de.staropensource.sosengine.graphics.events.input;
opens de.staropensource.sosengine.graphics.types.input;
opens de.staropensource.sosengine.graphics.types.window;
}