From edf1b5a0a3ab4e4092b72331d84db529afee35af Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 8 Mar 2026 11:35:21 -0500 Subject: [PATCH] Technically working --- assets/init.lua | 90 ++-- cmake/targets/linux.cmake | 1 + src/dusk/display/CMakeLists.txt | 2 + src/dusk/display/display.c | 2 +- src/dusk/display/framebuffer/framebuffer.h | 6 + src/dusk/display/screen/CMakeLists.txt | 10 + src/dusk/display/spritebatch/CMakeLists.txt | 10 + src/dusk/display/spritebatch/spritebatch.c | 51 +- src/dusk/display/spritebatch/spritebatch.h | 21 +- src/dusk/display/text.c | 4 +- src/dusk/input/input.c | 59 +-- src/dusk/input/input.h | 7 +- src/dusk/input/inputbutton.c | 492 ++++++++---------- src/dusk/time/time.c | 39 +- src/dusk/time/time.h | 17 +- src/dusk/ui/ui.c | 5 +- src/duskgl/display/displaygl.c | 1 + .../display/framebuffer/framebuffergl.c | 3 +- src/duskgl/display/mesh/meshgl.h | 4 +- src/duskgl/display/texture/texturegl.c | 8 +- src/dusksdl2/CMakeLists.txt | 3 +- src/dusksdl2/display/displaysdl2.c | 17 +- src/dusksdl2/input/inputplatform.h | 1 + src/dusksdl2/input/inputsdl2.c | 42 +- src/dusksdl2/input/inputsdl2.h | 15 +- src/dusksdl2/time/CMakeLists.txt | 12 + src/dusksdl2/time/timeplatform.h | 12 + src/dusksdl2/time/timesdl2.c | 17 + src/dusksdl2/time/timesdl2.h | 24 + 29 files changed, 490 insertions(+), 485 deletions(-) create mode 100644 src/dusk/display/screen/CMakeLists.txt create mode 100644 src/dusk/display/spritebatch/CMakeLists.txt create mode 100644 src/dusksdl2/time/CMakeLists.txt create mode 100644 src/dusksdl2/time/timeplatform.h create mode 100644 src/dusksdl2/time/timesdl2.c create mode 100644 src/dusksdl2/time/timesdl2.h diff --git a/assets/init.lua b/assets/init.lua index b50800b..6f6dcd3 100644 --- a/assets/init.lua +++ b/assets/init.lua @@ -4,56 +4,56 @@ module('scene') module('locale') -- Default Input bindings. -if PLATFORM == "psp" then - inputBind("up", INPUT_ACTION_UP) - inputBind("down", INPUT_ACTION_DOWN) - inputBind("left", INPUT_ACTION_LEFT) - inputBind("right", INPUT_ACTION_RIGHT) - inputBind("circle", INPUT_ACTION_CANCEL) - inputBind("cross", INPUT_ACTION_ACCEPT) - inputBind("select", INPUT_ACTION_RAGEQUIT) - inputBind("lstick_up", INPUT_ACTION_UP) - inputBind("lstick_down", INPUT_ACTION_DOWN) - inputBind("lstick_left", INPUT_ACTION_LEFT) - inputBind("lstick_right", INPUT_ACTION_RIGHT) +-- if PLATFORM == "psp" then +-- inputBind("up", INPUT_ACTION_UP) +-- inputBind("down", INPUT_ACTION_DOWN) +-- inputBind("left", INPUT_ACTION_LEFT) +-- inputBind("right", INPUT_ACTION_RIGHT) +-- inputBind("circle", INPUT_ACTION_CANCEL) +-- inputBind("cross", INPUT_ACTION_ACCEPT) +-- inputBind("select", INPUT_ACTION_RAGEQUIT) +-- inputBind("lstick_up", INPUT_ACTION_UP) +-- inputBind("lstick_down", INPUT_ACTION_DOWN) +-- inputBind("lstick_left", INPUT_ACTION_LEFT) +-- inputBind("lstick_right", INPUT_ACTION_RIGHT) -elseif DOLPHIN then - inputBind("up", INPUT_ACTION_UP) - inputBind("down", INPUT_ACTION_DOWN) - inputBind("left", INPUT_ACTION_LEFT) - inputBind("right", INPUT_ACTION_RIGHT) - inputBind("b", INPUT_ACTION_CANCEL) - inputBind("a", INPUT_ACTION_ACCEPT) - inputBind("z", INPUT_ACTION_RAGEQUIT) - inputBind("lstick_up", INPUT_ACTION_UP) - inputBind("lstick_down", INPUT_ACTION_DOWN) - inputBind("lstick_left", INPUT_ACTION_LEFT) - inputBind("lstick_right", INPUT_ACTION_RIGHT) +-- elseif DOLPHIN then +-- inputBind("up", INPUT_ACTION_UP) +-- inputBind("down", INPUT_ACTION_DOWN) +-- inputBind("left", INPUT_ACTION_LEFT) +-- inputBind("right", INPUT_ACTION_RIGHT) +-- inputBind("b", INPUT_ACTION_CANCEL) +-- inputBind("a", INPUT_ACTION_ACCEPT) +-- inputBind("z", INPUT_ACTION_RAGEQUIT) +-- inputBind("lstick_up", INPUT_ACTION_UP) +-- inputBind("lstick_down", INPUT_ACTION_DOWN) +-- inputBind("lstick_left", INPUT_ACTION_LEFT) +-- inputBind("lstick_right", INPUT_ACTION_RIGHT) -else - if INPUT_KEYBOARD then - inputBind("w", INPUT_ACTION_UP) - inputBind("s", INPUT_ACTION_DOWN) - inputBind("a", INPUT_ACTION_LEFT) - inputBind("d", INPUT_ACTION_RIGHT) +-- else +-- if INPUT_KEYBOARD then +-- inputBind("w", INPUT_ACTION_UP) +-- inputBind("s", INPUT_ACTION_DOWN) +-- inputBind("a", INPUT_ACTION_LEFT) +-- inputBind("d", INPUT_ACTION_RIGHT) - inputBind("left", INPUT_ACTION_LEFT) - inputBind("right", INPUT_ACTION_RIGHT) - inputBind("up", INPUT_ACTION_UP) - inputBind("down", INPUT_ACTION_DOWN) +-- inputBind("left", INPUT_ACTION_LEFT) +-- inputBind("right", INPUT_ACTION_RIGHT) +-- inputBind("up", INPUT_ACTION_UP) +-- inputBind("down", INPUT_ACTION_DOWN) - inputBind("enter", INPUT_ACTION_ACCEPT) - inputBind("e", INPUT_ACTION_ACCEPT) +-- inputBind("enter", INPUT_ACTION_ACCEPT) +-- inputBind("e", INPUT_ACTION_ACCEPT) - inputBind("q", INPUT_ACTION_CANCEL) +-- inputBind("q", INPUT_ACTION_CANCEL) - inputBind("escape", INPUT_ACTION_RAGEQUIT) - end +-- inputBind("escape", INPUT_ACTION_RAGEQUIT) +-- end - if INPUT_POINTER then - inputBind("mouse_x", INPUT_ACTION_POINTERX) - inputBind("mouse_y", INPUT_ACTION_POINTERY) - end -end +-- if INPUT_POINTER then +-- inputBind("mouse_x", INPUT_ACTION_POINTERX) +-- inputBind("mouse_y", INPUT_ACTION_POINTERY) +-- end +-- end -sceneSet('scene/minesweeper.lua') \ No newline at end of file +-- sceneSet('scene/minesweeper.lua') \ No newline at end of file diff --git a/cmake/targets/linux.cmake b/cmake/targets/linux.cmake index 346a797..f747c0d 100644 --- a/cmake/targets/linux.cmake +++ b/cmake/targets/linux.cmake @@ -21,4 +21,5 @@ target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC DUSK_INPUT_KEYBOARD DUSK_INPUT_POINTER DUSK_INPUT_GAMEPAD + DUSK_TIME_DYNAMIC ) \ No newline at end of file diff --git a/src/dusk/display/CMakeLists.txt b/src/dusk/display/CMakeLists.txt index 14d41a9..99e8253 100644 --- a/src/dusk/display/CMakeLists.txt +++ b/src/dusk/display/CMakeLists.txt @@ -15,6 +15,8 @@ add_subdirectory(camera) add_subdirectory(framebuffer) add_subdirectory(mesh) add_subdirectory(texture) +add_subdirectory(spritebatch) +add_subdirectory(screen) # Color definitions dusk_run_python( diff --git a/src/dusk/display/display.c b/src/dusk/display/display.c index e7530f3..12af408 100644 --- a/src/dusk/display/display.c +++ b/src/dusk/display/display.c @@ -31,7 +31,7 @@ errorret_t displayInit(void) { errorChain(quadInit()); errorChain(frameBufferInitBackBuffer()); - spriteBatchInit(); + errorChain(spriteBatchInit()); errorChain(textInit()); // errorChain(assetLoad("main_palette.dpf", &PALETTES[0])); screenInit(); diff --git a/src/dusk/display/framebuffer/framebuffer.h b/src/dusk/display/framebuffer/framebuffer.h index cc9b15c..5e32882 100644 --- a/src/dusk/display/framebuffer/framebuffer.h +++ b/src/dusk/display/framebuffer/framebuffer.h @@ -17,6 +17,12 @@ #ifndef frameBufferPlatformBind #error "frameBufferPlatformBind not defined for this platform" #endif +#ifndef frameBufferPlatformGetWidth + #error "frameBufferPlatformGetWidth not defined for this platform" +#endif +#ifndef frameBufferPlatformGetHeight + #error "frameBufferPlatformGetHeight not defined for this platform" +#endif #define FRAMEBUFFER_CLEAR_COLOR (1 << 0) #define FRAMEBUFFER_CLEAR_DEPTH (1 << 1) diff --git a/src/dusk/display/screen/CMakeLists.txt b/src/dusk/display/screen/CMakeLists.txt new file mode 100644 index 0000000..916cdc3 --- /dev/null +++ b/src/dusk/display/screen/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Sources +target_sources(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + screen.c +) \ No newline at end of file diff --git a/src/dusk/display/spritebatch/CMakeLists.txt b/src/dusk/display/spritebatch/CMakeLists.txt new file mode 100644 index 0000000..5897115 --- /dev/null +++ b/src/dusk/display/spritebatch/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Sources +target_sources(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + spritebatch.c +) \ No newline at end of file diff --git a/src/dusk/display/spritebatch/spritebatch.c b/src/dusk/display/spritebatch/spritebatch.c index a21c6e3..b612e75 100644 --- a/src/dusk/display/spritebatch/spritebatch.c +++ b/src/dusk/display/spritebatch/spritebatch.c @@ -12,18 +12,19 @@ meshvertex_t SPRITEBATCH_VERTICES[SPRITEBATCH_VERTEX_COUNT]; spritebatch_t SPRITEBATCH; -void spriteBatchInit() { +errorret_t spriteBatchInit() { memoryZero(&SPRITEBATCH, sizeof(spritebatch_t)); - meshInit( + errorChain(meshInit( &SPRITEBATCH.mesh, - MESH_PRIMITIVE_TRIANGLES, + QUAD_PRIMITIVE_TYPE, SPRITEBATCH_VERTEX_COUNT, &SPRITEBATCH_VERTICES[0] - ); + )); + errorOk(); } -void spriteBatchPush( +errorret_t spriteBatchPush( texture_t *texture, const float_t minX, const float_t minY, @@ -35,17 +36,18 @@ void spriteBatchPush( const float_t u1, const float_t v1 ) { - return spriteBatchPush3D( + errorChain(spriteBatchPush3D( texture, (vec3){ minX, minY, 0 }, (vec3){ maxX, maxY, 0 }, color, (vec2){ u0, v0 }, (vec2){ u1, v1 } - ); + )); + errorOk(); } -void spriteBatchPush3D( +errorret_t spriteBatchPush3D( texture_t *texture, const vec3 min, const vec3 max, @@ -58,22 +60,17 @@ void spriteBatchPush3D( SPRITEBATCH.currentTexture != texture || SPRITEBATCH.spriteCount >= SPRITEBATCH_SPRITES_MAX ) { - spriteBatchFlush(); + errorChain(spriteBatchFlush()); SPRITEBATCH.currentTexture = texture; } size_t vertexOffset = SPRITEBATCH.spriteCount * QUAD_VERTEX_COUNT; - #if DOLPHIN - vertexOffset += ( - SPRITEBATCH.batchIndex * SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT - ); - #endif - quadBuffer3D( &SPRITEBATCH_VERTICES[vertexOffset], min, max, color, uv0, uv1 ); SPRITEBATCH.spriteCount++; + errorOk(); } void spriteBatchClear() { @@ -81,23 +78,17 @@ void spriteBatchClear() { SPRITEBATCH.currentTexture = NULL; } -void spriteBatchFlush() { - if(SPRITEBATCH.spriteCount == 0) return; +errorret_t spriteBatchFlush() { + if(SPRITEBATCH.spriteCount == 0) { + errorOk(); + } + textureBind(SPRITEBATCH.currentTexture); - - #if DOLPHIN - meshDraw( - &SPRITEBATCH.mesh, - QUAD_VERTEX_COUNT * SPRITEBATCH.batchIndex * SPRITEBATCH_SPRITES_MAX, - QUAD_VERTEX_COUNT * SPRITEBATCH.spriteCount - ); - SPRITEBATCH.batchIndex = ( - (SPRITEBATCH.batchIndex + 1) % SPRITEBATCH_BATCH_COUNT - ); - #else - meshDraw(&SPRITEBATCH.mesh, 0, QUAD_VERTEX_COUNT * SPRITEBATCH.spriteCount); - #endif + errorChain(meshDraw( + &SPRITEBATCH.mesh, 0, QUAD_VERTEX_COUNT * SPRITEBATCH.spriteCount + )); spriteBatchClear(); + errorOk(); } void spriteBatchDispose() { diff --git a/src/dusk/display/spritebatch/spritebatch.h b/src/dusk/display/spritebatch/spritebatch.h index 4704de2..e54865a 100644 --- a/src/dusk/display/spritebatch/spritebatch.h +++ b/src/dusk/display/spritebatch/spritebatch.h @@ -12,12 +12,6 @@ #define SPRITEBATCH_SPRITES_MAX 128 #define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT) -#if DOLPHIN - #define SPRITEBATCH_SPRITES_MAX 16 - #define SPRITEBATCH_BATCH_COUNT 16 - #define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT * SPRITEBATCH_BATCH_COUNT) -#endif - typedef struct { mesh_t mesh; @@ -37,8 +31,9 @@ extern spritebatch_t SPRITEBATCH; * Initializes a sprite batch. * * @param spriteBatch The sprite batch to initialize. + * @return An error code indicating success or failure. */ -void spriteBatchInit(); +errorret_t spriteBatchInit(); /** * Pushes a sprite to the batch. This basically "queues" it to render (well @@ -58,8 +53,9 @@ void spriteBatchInit(); * @param v0 The texture coordinate for the top-left corner of the sprite. * @param u1 The texture coordinate for the bottom-right corner of the sprite. * @param v1 The texture coordinate for the bottom-right corner of the sprite. + * @return An error code indicating success or failure. */ -void spriteBatchPush( +errorret_t spriteBatchPush( texture_t *texture, const float_t minX, const float_t minY, @@ -81,9 +77,10 @@ void spriteBatchPush( * @param max The maximum (x,y,z) coordinate of the sprite. * @param color The color to tint the sprite with. * @param uvMin The texture coordinate for the top-left corner of the sprite. - * @param uvMax The texture coordinate for the bottom-right corner of the sprite. + * @param uvMax The texture coordinate for the bottom-right corner of the sprite + * @return An error code indicating success or failure. */ -void spriteBatchPush3D( +errorret_t spriteBatchPush3D( texture_t *texture, const vec3 min, const vec3 max, @@ -99,8 +96,10 @@ void spriteBatchClear(); /** * Flushes the sprite batch, rendering all queued sprites. + * + * @return An error code indicating success or failure. */ -void spriteBatchFlush(); +errorret_t spriteBatchFlush(); /** * Disposes of the sprite batch, freeing any allocated resources. diff --git a/src/dusk/display/text.c b/src/dusk/display/text.c index 5e30c0c..75a11eb 100644 --- a/src/dusk/display/text.c +++ b/src/dusk/display/text.c @@ -15,8 +15,8 @@ texture_t DEFAULT_FONT_TEXTURE; tileset_t DEFAULT_FONT_TILESET; errorret_t textInit(void) { - errorChain(assetLoad("ui/minogram.dpt", &DEFAULT_FONT_TEXTURE)); - errorChain(assetLoad("ui/minogram.dtf", &DEFAULT_FONT_TILESET)); + // errorChain(assetLoad("ui/minogram.dpt", &DEFAULT_FONT_TEXTURE)); + // errorChain(assetLoad("ui/minogram.dtf", &DEFAULT_FONT_TILESET)); errorOk(); } diff --git a/src/dusk/input/input.c b/src/dusk/input/input.c index fc625f7..76f627c 100644 --- a/src/dusk/input/input.c +++ b/src/dusk/input/input.c @@ -25,12 +25,12 @@ void inputInit(void) { INPUT.actions[i].currentValue = 0.0f; } - #if INPUT_GAMEPAD == 1 + #ifdef DUSK_INPUT_GAMEPAD INPUT.deadzone = 0.2f; #endif - #if DOLPHIN - PAD_Init(); + #ifdef inputInitPlatform + inputInitPlatform(); #endif eventInit( @@ -42,51 +42,14 @@ void inputInit(void) { } void inputUpdate(void) { - #if INPUT_SDL2 == 1 - #if INPUT_GAMEPAD == 1 - INPUT.controller = NULL; - - for(int32_t i = 0; i < SDL_NumJoysticks(); i++) { - if(!SDL_IsGameController(i)) continue; - INPUT.controller = SDL_GameControllerOpen(i); - if(INPUT.controller) break; - } - #endif - - #if INPUT_KEYBOARD == 1 - INPUT.keyboardState = SDL_GetKeyboardState(NULL); - #endif - - #if INPUT_POINTER == 1 - int pointerX, pointerY; - SDL_GetMouseState(&pointerX, &pointerY); - - int windowWidth, windowHeight; - SDL_GetWindowSize(DISPLAY.window, &windowWidth, &windowHeight); - - INPUT.mouseX = (float_t)pointerX / (float_t)windowWidth; - INPUT.mouseY = (float_t)pointerY / (float_t)windowHeight; - #endif - - #elif DOLPHIN - PAD_ScanPads(); - - for(uint8_t i = 0; i < INPUT_PAD_COUNT; i++) { - INPUT.padState[i] = PAD_ButtonsDown(i); - INPUT.pads[i][INPUT_GAMEPAD_AXIS_LEFT_X] = INPUT_AXIS_FLOAT(PAD_StickX(i)); - INPUT.pads[i][INPUT_GAMEPAD_AXIS_LEFT_Y] = INPUT_AXIS_FLOAT(PAD_StickY(i)); - INPUT.pads[i][INPUT_GAMEPAD_AXIS_C_X] = INPUT_AXIS_FLOAT(PAD_SubStickX(i)); - INPUT.pads[i][INPUT_GAMEPAD_AXIS_C_Y] = INPUT_AXIS_FLOAT(PAD_SubStickY(i)); - INPUT.pads[i][INPUT_GAMEPAD_AXIS_TRIGGER_LEFT] = INPUT_AXIS_FLOAT(PAD_TriggerL(i)); - INPUT.pads[i][INPUT_GAMEPAD_AXIS_TRIGGER_RIGHT] = INPUT_AXIS_FLOAT(PAD_TriggerR(i)); - } - + #ifdef inputUpdatePlatform + inputUpdatePlatform(); #endif // Reset all actions inputactiondata_t *action = &INPUT.actions[0]; do { - #if TIME_FIXED == 0 + #ifdef DUSK_TIME_DYNAMIC action->lastDynamicValue = action->currentDynamicValue; action->currentDynamicValue = 0.0f; if(!TIME.dynamicUpdate) { @@ -113,7 +76,7 @@ void inputUpdate(void) { } // Update current val. - #if TIME_FIXED == 0 + #ifdef DUSK_TIME_DYNAMIC INPUT.actions[cur->action].currentDynamicValue = mathMax( cur->curVal, INPUT.actions[cur->action].currentDynamicValue ); @@ -132,7 +95,7 @@ void inputUpdate(void) { } // Do we need to fire off events? - #if TIME_FIXED == 0 + #ifdef DUSK_TIME_DYNAMIC if(TIME.dynamicUpdate) return; #endif @@ -160,7 +123,7 @@ void inputUpdate(void) { } float_t inputGetCurrentValue(const inputaction_t action) { - #if TIME_FIXED == 0 + #ifdef DUSK_TIME_DYNAMIC if(TIME.dynamicUpdate) return inputGetCurrentValueDynamic(action); #endif @@ -169,7 +132,7 @@ float_t inputGetCurrentValue(const inputaction_t action) { } float_t inputGetLastValue(const inputaction_t action) { - #if TIME_FIXED == 0 + #ifdef DUSK_TIME_DYNAMIC if(TIME.dynamicUpdate) return inputGetLastValueDynamic(action); #endif @@ -177,7 +140,7 @@ float_t inputGetLastValue(const inputaction_t action) { return INPUT.actions[action].lastValue; } -#if TIME_FIXED == 0 +#ifdef DUSK_TIME_DYNAMIC float_t inputGetCurrentValueDynamic(const inputaction_t action) { assertTrue(action < INPUT_ACTION_COUNT, "Input action out of bounds"); return INPUT.actions[action].currentDynamicValue; diff --git a/src/dusk/input/input.h b/src/dusk/input/input.h index 3201aea..345486f 100644 --- a/src/dusk/input/input.h +++ b/src/dusk/input/input.h @@ -10,11 +10,6 @@ #include "inputaction.h" #include "event/event.h" -#if DOLPHIN - #define INPUT_PAD_COUNT PAD_CHANMAX - #define INPUT_AXIS_FLOAT(value) ((float_t)(value) / 128.0f) -#endif - #define INPUT_LISTENER_PRESSED_MAX 16 #define INPUT_LISTENER_RELEASED_MAX INPUT_LISTENER_PRESSED_MAX @@ -65,7 +60,7 @@ float_t inputGetCurrentValue(const inputaction_t action); */ float_t inputGetLastValue(const inputaction_t action); -#if TIME_FIXED == 0 +#ifdef DUSK_TIME_DYNAMIC /** * Gets the current value of a specific input action (dynamic timestep). * diff --git a/src/dusk/input/inputbutton.c b/src/dusk/input/inputbutton.c index 7949850..1f00e8b 100644 --- a/src/dusk/input/inputbutton.c +++ b/src/dusk/input/inputbutton.c @@ -11,228 +11,228 @@ #include "util/string.h" inputbuttondata_t INPUT_BUTTON_DATA[] = { - #if INPUT_SDL2 == 1 - #if INPUT_GAMEPAD == 1 - #if PSP - { .name = "triangle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } }, - { .name = "cross", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } }, - { .name = "circle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } }, - { .name = "square", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } }, - { .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } }, - { .name = "select", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } }, - { .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } }, - { .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } }, - { .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } }, - { .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } }, - { .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } }, - { .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } }, +// #if INPUT_SDL2 == 1 +// #if INPUT_GAMEPAD == 1 +// #if PSP +// { .name = "triangle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } }, +// { .name = "cross", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } }, +// { .name = "circle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } }, +// { .name = "square", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } }, +// { .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } }, +// { .name = "select", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } }, +// { .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } }, +// { .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } }, +// { .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } }, +// { .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } }, +// { .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } }, +// { .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } }, - { .name = "lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } }, - { .name = "lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } }, - { .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } }, - { .name = "lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } }, - #else - { .name = "a", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } }, - { .name = "b", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } }, - { .name = "x", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } }, - { .name = "y", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } }, - { .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } }, - { .name = "back", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } }, - { .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } }, - { .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } }, - { .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } }, - { .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } }, - { .name = "l1", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } }, - { .name = "r1", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } }, - { .name = "l3", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSTICK } }, - { .name = "r3", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSTICK } }, - { .name = "lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } }, - { .name = "lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } }, - { .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } }, - { .name = "lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } }, - { .name = "rstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTY, .positive = true } } }, - { .name = "rstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTY, .positive = false } } }, - { .name = "rstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTX, .positive = true } } }, - { .name = "rstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTX, .positive = false } } }, - { .name = "l2", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_TRIGGERLEFT, .positive = true } } }, - { .name = "r2", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT, .positive = true } } }, - #endif - #endif +// { .name = "lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } }, +// { .name = "lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } }, +// { .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } }, +// { .name = "lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } }, +// #else +// { .name = "a", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } }, +// { .name = "b", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } }, +// { .name = "x", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } }, +// { .name = "y", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } }, +// { .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } }, +// { .name = "back", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } }, +// { .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } }, +// { .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } }, +// { .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } }, +// { .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } }, +// { .name = "l1", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } }, +// { .name = "r1", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } }, +// { .name = "l3", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSTICK } }, +// { .name = "r3", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSTICK } }, +// { .name = "lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } }, +// { .name = "lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } }, +// { .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } }, +// { .name = "lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } }, +// { .name = "rstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTY, .positive = true } } }, +// { .name = "rstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTY, .positive = false } } }, +// { .name = "rstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTX, .positive = true } } }, +// { .name = "rstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTX, .positive = false } } }, +// { .name = "l2", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_TRIGGERLEFT, .positive = true } } }, +// { .name = "r2", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT, .positive = true } } }, +// #endif +// #endif - #if INPUT_POINTER == 1 - { .name = "mouse_x", { .type = INPUT_BUTTON_TYPE_POINTER, .pointerAxis = INPUT_POINTER_AXIS_X } }, - { .name = "mouse_y", { .type = INPUT_BUTTON_TYPE_POINTER, .pointerAxis = INPUT_POINTER_AXIS_Y } }, - // { .name = "mouse_wheel_x", { .type = INPUT_BUTTON_TYPE_POINTER, .pointerAxis = INPUT_POINTER_AXIS_WHEEL_X } }, - // { .name = "mouse_wheel_y", { .type = INPUT_BUTTON_TYPE_POINTER, .pointerAxis = INPUT_POINTER_AXIS_WHEEL_Y } }, - #endif +// #if INPUT_POINTER == 1 +// { .name = "mouse_x", { .type = INPUT_BUTTON_TYPE_POINTER, .pointerAxis = INPUT_POINTER_AXIS_X } }, +// { .name = "mouse_y", { .type = INPUT_BUTTON_TYPE_POINTER, .pointerAxis = INPUT_POINTER_AXIS_Y } }, +// // { .name = "mouse_wheel_x", { .type = INPUT_BUTTON_TYPE_POINTER, .pointerAxis = INPUT_POINTER_AXIS_WHEEL_X } }, +// // { .name = "mouse_wheel_y", { .type = INPUT_BUTTON_TYPE_POINTER, .pointerAxis = INPUT_POINTER_AXIS_WHEEL_Y } }, +// #endif - #if INPUT_KEYBOARD == 1 - { .name = "a", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_A } }, - { .name = "b", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_B } }, - { .name = "c", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_C } }, - { .name = "d", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_D } }, - { .name = "e", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_E } }, - { .name = "f", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F } }, - { .name = "g", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_G } }, - { .name = "h", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_H } }, - { .name = "i", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_I } }, - { .name = "j", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_J } }, - { .name = "k", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_K } }, - { .name = "l", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_L } }, - { .name = "m", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_M } }, - { .name = "n", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_N } }, - { .name = "o", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_O } }, - { .name = "p", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_P } }, - { .name = "q", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Q } }, - { .name = "r", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_R } }, - { .name = "s", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_S } }, - { .name = "t", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_T } }, - { .name = "u", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_U } }, - { .name = "v", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_V } }, - { .name = "w", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_W } }, - { .name = "x", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_X } }, - { .name = "y", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Y } }, - { .name = "z", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Z } }, +// #if INPUT_KEYBOARD == 1 +// { .name = "a", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_A } }, +// { .name = "b", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_B } }, +// { .name = "c", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_C } }, +// { .name = "d", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_D } }, +// { .name = "e", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_E } }, +// { .name = "f", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F } }, +// { .name = "g", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_G } }, +// { .name = "h", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_H } }, +// { .name = "i", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_I } }, +// { .name = "j", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_J } }, +// { .name = "k", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_K } }, +// { .name = "l", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_L } }, +// { .name = "m", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_M } }, +// { .name = "n", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_N } }, +// { .name = "o", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_O } }, +// { .name = "p", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_P } }, +// { .name = "q", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Q } }, +// { .name = "r", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_R } }, +// { .name = "s", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_S } }, +// { .name = "t", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_T } }, +// { .name = "u", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_U } }, +// { .name = "v", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_V } }, +// { .name = "w", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_W } }, +// { .name = "x", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_X } }, +// { .name = "y", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Y } }, +// { .name = "z", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Z } }, - { .name = "0", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_0 } }, - { .name = "1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_1 } }, - { .name = "2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_2 } }, - { .name = "3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_3 } }, - { .name = "4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_4 } }, - { .name = "5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_5 } }, - { .name = "6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_6 } }, - { .name = "7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_7 } }, - { .name = "8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_8 } }, - { .name = "9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_9 } }, +// { .name = "0", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_0 } }, +// { .name = "1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_1 } }, +// { .name = "2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_2 } }, +// { .name = "3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_3 } }, +// { .name = "4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_4 } }, +// { .name = "5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_5 } }, +// { .name = "6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_6 } }, +// { .name = "7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_7 } }, +// { .name = "8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_8 } }, +// { .name = "9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_9 } }, - { .name = "space", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SPACE } }, - { .name = "shift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LSHIFT } }, - { .name = "lshift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LSHIFT } }, - { .name = "rshift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RSHIFT } }, - { .name = "lctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LCTRL } }, - { .name = "rctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RCTRL } }, - { .name = "ctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LCTRL } }, - { .name = "lalt", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LALT } }, - { .name = "ralt", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RALT } }, - { .name = "tab", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_TAB } }, - { .name = "enter", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RETURN } }, - { .name = "backspace", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSPACE } }, - { .name = "escape", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_ESCAPE } }, - { .name = "esc", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_ESCAPE } }, - { .name = "up", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_UP } }, - { .name = "down", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_DOWN } }, - { .name = "left", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFT } }, - { .name = "right", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHT } }, - { .name = "pageup", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PAGEUP } }, - { .name = "pagedown", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PAGEDOWN } }, - { .name = "home", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_HOME } }, - { .name = "end", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_END } }, - { .name = "insert", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_INSERT } }, - { .name = "delete", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_DELETE } }, +// { .name = "space", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SPACE } }, +// { .name = "shift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LSHIFT } }, +// { .name = "lshift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LSHIFT } }, +// { .name = "rshift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RSHIFT } }, +// { .name = "lctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LCTRL } }, +// { .name = "rctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RCTRL } }, +// { .name = "ctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LCTRL } }, +// { .name = "lalt", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LALT } }, +// { .name = "ralt", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RALT } }, +// { .name = "tab", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_TAB } }, +// { .name = "enter", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RETURN } }, +// { .name = "backspace", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSPACE } }, +// { .name = "escape", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_ESCAPE } }, +// { .name = "esc", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_ESCAPE } }, +// { .name = "up", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_UP } }, +// { .name = "down", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_DOWN } }, +// { .name = "left", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFT } }, +// { .name = "right", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHT } }, +// { .name = "pageup", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PAGEUP } }, +// { .name = "pagedown", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PAGEDOWN } }, +// { .name = "home", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_HOME } }, +// { .name = "end", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_END } }, +// { .name = "insert", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_INSERT } }, +// { .name = "delete", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_DELETE } }, - { .name = "f1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F1 } }, - { .name = "f2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F2 } }, - { .name = "f3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F3 } }, - { .name = "f4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F4 } }, - { .name = "f5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F5 } }, - { .name = "f6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F6 } }, - { .name = "f7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F7 } }, - { .name = "f8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F8 } }, - { .name = "f9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F9 } }, - { .name = "f10", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F10 } }, - { .name = "f11", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F11 } }, - { .name = "f12", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F12 } }, - { .name = "f13", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F13 } }, - { .name = "f14", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F14 } }, - { .name = "f15", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F15 } }, - { .name = "f16", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F16 } }, - { .name = "f17", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F17 } }, - { .name = "f18", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F18 } }, - { .name = "f19", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F19 } }, - { .name = "f20", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F20 } }, - { .name = "f21", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F21 } }, - { .name = "f22", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F22 } }, - { .name = "f23", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F23 } }, - { .name = "f24", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F24 } }, +// { .name = "f1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F1 } }, +// { .name = "f2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F2 } }, +// { .name = "f3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F3 } }, +// { .name = "f4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F4 } }, +// { .name = "f5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F5 } }, +// { .name = "f6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F6 } }, +// { .name = "f7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F7 } }, +// { .name = "f8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F8 } }, +// { .name = "f9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F9 } }, +// { .name = "f10", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F10 } }, +// { .name = "f11", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F11 } }, +// { .name = "f12", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F12 } }, +// { .name = "f13", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F13 } }, +// { .name = "f14", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F14 } }, +// { .name = "f15", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F15 } }, +// { .name = "f16", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F16 } }, +// { .name = "f17", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F17 } }, +// { .name = "f18", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F18 } }, +// { .name = "f19", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F19 } }, +// { .name = "f20", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F20 } }, +// { .name = "f21", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F21 } }, +// { .name = "f22", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F22 } }, +// { .name = "f23", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F23 } }, +// { .name = "f24", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F24 } }, - { .name = "minus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_MINUS } }, - { .name = "equals", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_EQUALS } }, - { .name = "leftbracket", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFTBRACKET } }, - { .name = "rightbracket", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHTBRACKET } }, - { .name = "backslash", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSLASH } }, - { .name = "semicolon", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SEMICOLON } }, - { .name = "apostrophe", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_APOSTROPHE } }, - { .name = "grave", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_GRAVE } }, - { .name = "comma", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_COMMA } }, - { .name = "period", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PERIOD } }, - { .name = "slash", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SLASH } }, +// { .name = "minus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_MINUS } }, +// { .name = "equals", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_EQUALS } }, +// { .name = "leftbracket", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFTBRACKET } }, +// { .name = "rightbracket", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHTBRACKET } }, +// { .name = "backslash", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSLASH } }, +// { .name = "semicolon", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SEMICOLON } }, +// { .name = "apostrophe", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_APOSTROPHE } }, +// { .name = "grave", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_GRAVE } }, +// { .name = "comma", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_COMMA } }, +// { .name = "period", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PERIOD } }, +// { .name = "slash", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SLASH } }, - { .name = "caps", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_CAPSLOCK } }, - { .name = "capslock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_CAPSLOCK } }, - { .name = "numlock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_NUMLOCKCLEAR } }, - { .name = "scrollock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SCROLLLOCK } }, +// { .name = "caps", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_CAPSLOCK } }, +// { .name = "capslock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_CAPSLOCK } }, +// { .name = "numlock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_NUMLOCKCLEAR } }, +// { .name = "scrollock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SCROLLLOCK } }, - { .name = "-", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_MINUS } }, - { .name = "=", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_EQUALS } }, - { .name = "[", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFTBRACKET } }, - { .name = "]", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHTBRACKET } }, - { .name = "\\", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSLASH } }, - { .name = ";", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SEMICOLON } }, - { .name = "'", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_APOSTROPHE } }, - { .name = "`", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_GRAVE } }, - { .name = ",", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_COMMA } }, - { .name = ".", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PERIOD } }, - { .name = "/", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SLASH } }, +// { .name = "-", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_MINUS } }, +// { .name = "=", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_EQUALS } }, +// { .name = "[", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFTBRACKET } }, +// { .name = "]", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHTBRACKET } }, +// { .name = "\\", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSLASH } }, +// { .name = ";", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SEMICOLON } }, +// { .name = "'", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_APOSTROPHE } }, +// { .name = "`", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_GRAVE } }, +// { .name = ",", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_COMMA } }, +// { .name = ".", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PERIOD } }, +// { .name = "/", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SLASH } }, - { .name = "kp_0", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_0 } }, - { .name = "kp_1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_1 } }, - { .name = "kp_2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_2 } }, - { .name = "kp_3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_3 } }, - { .name = "kp_4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_4 } }, - { .name = "kp_5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_5 } }, - { .name = "kp_6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_6 } }, - { .name = "kp_7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_7 } }, - { .name = "kp_8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_8 } }, - { .name = "kp_9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_9 } }, - { .name = "kp_period", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_PERIOD } }, - { .name = "kp_divide", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_DIVIDE } }, - { .name = "kp_multiply", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_MULTIPLY } }, - { .name = "kp_minus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_MINUS } }, - { .name = "kp_plus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_PLUS } }, - { .name = "kp_enter", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_ENTER } }, - { .name = "kp_equals", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_EQUALS } }, - #endif +// { .name = "kp_0", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_0 } }, +// { .name = "kp_1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_1 } }, +// { .name = "kp_2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_2 } }, +// { .name = "kp_3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_3 } }, +// { .name = "kp_4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_4 } }, +// { .name = "kp_5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_5 } }, +// { .name = "kp_6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_6 } }, +// { .name = "kp_7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_7 } }, +// { .name = "kp_8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_8 } }, +// { .name = "kp_9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_9 } }, +// { .name = "kp_period", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_PERIOD } }, +// { .name = "kp_divide", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_DIVIDE } }, +// { .name = "kp_multiply", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_MULTIPLY } }, +// { .name = "kp_minus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_MINUS } }, +// { .name = "kp_plus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_PLUS } }, +// { .name = "kp_enter", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_ENTER } }, +// { .name = "kp_equals", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_EQUALS } }, +// #endif - #elif DOLPHIN - #if INPUT_GAMEPAD == 1 - { .name = "a", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_A } }, - { .name = "b", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_B } }, - { .name = "x", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_X } }, - { .name = "y", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_Y } }, - { .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_START } }, - { .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_UP } }, - { .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_DOWN } }, - { .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_LEFT } }, - { .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_RIGHT } }, - { .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_L } }, - { .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_R } }, - { .name = "z", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_Z } }, - { .name = "menu", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_MENU } }, - { .name = "lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = true } } }, - { .name = "lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = false } } }, - { .name = "lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = true } } }, - { .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = false } } }, - { .name = "rstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = true } } }, - { .name = "rstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = false } } }, - { .name = "rstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = true } } }, - { .name = "rstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = false } } }, - { .name = "ltrigger", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_TRIGGER_LEFT, .positive = true } } }, - { .name = "rtrigger", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_TRIGGER_RIGHT, .positive = true } } }, - #endif - #endif +// #elif DOLPHIN +// #if INPUT_GAMEPAD == 1 +// { .name = "a", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_A } }, +// { .name = "b", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_B } }, +// { .name = "x", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_X } }, +// { .name = "y", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_Y } }, +// { .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_START } }, +// { .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_UP } }, +// { .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_DOWN } }, +// { .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_LEFT } }, +// { .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_RIGHT } }, +// { .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_L } }, +// { .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_R } }, +// { .name = "z", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_TRIGGER_Z } }, +// { .name = "menu", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = PAD_BUTTON_MENU } }, +// { .name = "lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = true } } }, +// { .name = "lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_X, .positive = false } } }, +// { .name = "lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = true } } }, +// { .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_LEFT_Y, .positive = false } } }, +// { .name = "rstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = true } } }, +// { .name = "rstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_X, .positive = false } } }, +// { .name = "rstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = true } } }, +// { .name = "rstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_C_Y, .positive = false } } }, +// { .name = "ltrigger", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_TRIGGER_LEFT, .positive = true } } }, +// { .name = "rtrigger", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = INPUT_GAMEPAD_AXIS_TRIGGER_RIGHT, .positive = true } } }, +// #endif +// #endif - { .name = NULL } +// { .name = NULL } }; inputbutton_t inputButtonGetByName(const char_t *name) { @@ -247,78 +247,4 @@ inputbutton_t inputButtonGetByName(const char_t *name) { } return (inputbutton_t){ .type = INPUT_BUTTON_TYPE_NONE }; -} - -float_t inputButtonGetValue(const inputbutton_t button) { - switch(button.type) { - #if INPUT_KEYBOARD == 1 - case INPUT_BUTTON_TYPE_KEYBOARD: { - #if INPUT_SDL2 == 1 - return INPUT.keyboardState[button.scancode] ? 1.0f : 0.0f; - #endif - - return 0.0f; - } - #endif - - #if INPUT_POINTER == 1 - case INPUT_BUTTON_TYPE_POINTER: { - switch(button.pointerAxis) { - case INPUT_POINTER_AXIS_X: - #if INPUT_SDL2 == 1 - return INPUT.mouseX; - #endif - return 0.0f; - - case INPUT_POINTER_AXIS_Y: - #if INPUT_SDL2 == 1 - return INPUT.mouseY; - #endif - return 0.0f; - - default: { - assertUnreachable("Unknown pointer axis"); - return 0.0f; - } - } - } - #endif - - #if INPUT_GAMEPAD == 1 - case INPUT_BUTTON_TYPE_GAMEPAD: { - #if INPUT_SDL2 == 1 - if(SDL_GameControllerGetButton(INPUT.controller, button.gpButton)) { - return 1.0f; - } - #elif DOLPHIN - if(INPUT.padState[0] & button.gpButton) return 1.0f; - - #endif - - return 0.0f; - } - - case INPUT_BUTTON_TYPE_GAMEPAD_AXIS: { - float_t value = 0.0f; - - #if INPUT_SDL2 == 1 - Sint16 axis = SDL_GameControllerGetAxis(INPUT.controller, button.gpAxis.axis); - value = (float_t)axis / 32767.0f; - - #elif DOLPHIN - value = INPUT.pads[0][button.gpAxis.axis]; - - #endif - - if(!button.gpAxis.positive) value = -value; - if(value >= INPUT.deadzone) return value; - return 0.0f; - } - #endif - - default: { - assertUnreachable("Unknown input button type"); - return 0.0f; - } - } } \ No newline at end of file diff --git a/src/dusk/time/time.c b/src/dusk/time/time.c index 15a150c..2b672a3 100644 --- a/src/dusk/time/time.c +++ b/src/dusk/time/time.c @@ -9,50 +9,41 @@ #include "util/memory.h" #include "assert/assert.h" -#if TIME_SDL2 - #include -#endif - dusktime_t TIME; void timeInit(void) { memoryZero(&TIME, sizeof(TIME)); // Set these to something non-zero. - TIME.time = TIME_STEP; - TIME.delta = TIME_STEP; + TIME.time = DUSK_TIME_STEP; + TIME.delta = DUSK_TIME_STEP; - #if TIME_FIXED == 0 - TIME.dynamicTime = TIME_STEP; - TIME.dynamicDelta = TIME_STEP; + #ifdef DUSK_TIME_DYNAMIC + TIME.dynamicTime = DUSK_TIME_STEP; + TIME.dynamicDelta = DUSK_TIME_STEP; TIME.dynamicUpdate = false; TIME.lastNonDynamic = TIME.dynamicTime; #endif } void timeUpdate(void) { - - #if TIME_FIXED == 0 - #if TIME_SDL2 - float_t msElapsed = ((float_t)SDL_GetTicks64() / 1000.0f) + TIME_STEP; - TIME.dynamicDelta = msElapsed - TIME.dynamicTime; - TIME.dynamicTime = msElapsed; - TIME.dynamicUpdate = true; - #else - #error "No time platform defined" - #endif + #ifdef DUSK_TIME_DYNAMIC + timeTickPlatform(); + TIME.dynamicDelta = timeGetDeltaPlatform(); + TIME.dynamicTime += TIME.dynamicDelta; + TIME.dynamicUpdate = true; assertTrue(TIME.dynamicDelta >= 0.0f, "Time delta is negative"); // Is within 1ms of a full step? - if(TIME.dynamicTime - TIME.lastNonDynamic >= TIME_STEP * 0.999f) { + if(TIME.dynamicTime - TIME.lastNonDynamic >= DUSK_TIME_STEP * 0.999f) { TIME.dynamicUpdate = false; TIME.lastNonDynamic = TIME.dynamicTime; - TIME.delta = TIME_STEP; - TIME.time += TIME_STEP; + TIME.delta = DUSK_TIME_STEP; + TIME.time += DUSK_TIME_STEP; } #else - TIME.delta = TIME_STEP; - TIME.time += TIME_STEP; + TIME.delta = DUSK_TIME_STEP; + TIME.time += DUSK_TIME_STEP; #endif } \ No newline at end of file diff --git a/src/dusk/time/time.h b/src/dusk/time/time.h index 52bfc1b..a6a18fa 100644 --- a/src/dusk/time/time.h +++ b/src/dusk/time/time.h @@ -7,17 +7,26 @@ #pragma once #include "dusk.h" +#include "time/timeplatform.h" -#define TIME_STEP (16.0f / 1000.0f) -#ifndef TIME_FIXED - #define TIME_FIXED 0 +#ifndef DUSK_TIME_STEP + #define DUSK_TIME_STEP (16.0f / 1000.0f) +#endif + +#ifdef DUSK_TIME_DYNAMIC + #ifndef timeTickPlatform + #error "DUSK_TIME_DYNAMIC needs tick method defined" + #endif + #ifndef timeGetDeltaPlatform + #error "DUSK_TIME_DYNAMIC needs delta method defined" + #endif #endif typedef struct { float_t delta; float_t time; - #if TIME_FIXED == 0 + #ifdef DUSK_TIME_DYNAMIC float_t lastNonDynamic; bool_t dynamicUpdate; float_t dynamicDelta; diff --git a/src/dusk/ui/ui.c b/src/dusk/ui/ui.c index f602b22..1872049 100644 --- a/src/dusk/ui/ui.c +++ b/src/dusk/ui/ui.c @@ -8,9 +8,8 @@ #include "ui.h" #include "util/memory.h" #include "assert/assert.h" -#include "display/spritebatch.h" -#include "display/screen.h" - +#include "display/spritebatch/spritebatch.h" +#include "display/screen/screen.h" #include "debug/debug.h" ui_t UI; diff --git a/src/duskgl/display/displaygl.c b/src/duskgl/display/displaygl.c index 212accc..c5d9cd5 100644 --- a/src/duskgl/display/displaygl.c +++ b/src/duskgl/display/displaygl.c @@ -28,4 +28,5 @@ errorret_t displayOpenGLInit(void) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); errorChain(errorGLCheck()); + errorOk(); } \ No newline at end of file diff --git a/src/duskgl/display/framebuffer/framebuffergl.c b/src/duskgl/display/framebuffer/framebuffergl.c index 3f47b7c..9564e01 100644 --- a/src/duskgl/display/framebuffer/framebuffergl.c +++ b/src/duskgl/display/framebuffer/framebuffergl.c @@ -8,12 +8,13 @@ #include "display/display.h" #include "display/framebuffer/framebuffer.h" #include "assert/assert.h" +#include "util/memory.h" errorret_t frameBufferGLInitBackBuffer(void) { errorOk(); } -uint32_t frameBufferGetWidth(const framebuffer_t *framebuffer) { +uint32_t frameBufferGLGetWidth(const framebuffer_t *framebuffer) { if(framebuffer == NULL) { return 0; } diff --git a/src/duskgl/display/mesh/meshgl.h b/src/duskgl/display/mesh/meshgl.h index 59936c1..8acc6c3 100644 --- a/src/duskgl/display/mesh/meshgl.h +++ b/src/duskgl/display/mesh/meshgl.h @@ -16,7 +16,9 @@ typedef enum { } meshprimitivetypegl_t; typedef struct { - + const meshvertex_t *vertices; + int32_t vertexCount; + meshprimitivetypegl_t primitiveType; } meshgl_t; /** diff --git a/src/duskgl/display/texture/texturegl.c b/src/duskgl/display/texture/texturegl.c index 6a7ff46..1c7108a 100644 --- a/src/duskgl/display/texture/texturegl.c +++ b/src/duskgl/display/texture/texturegl.c @@ -39,10 +39,10 @@ errorret_t textureInitGL( ); errorChain(errorGLCheck()); - glColorTableEXT( - GL_TEXTURE_2D, GL_RGBA, data.palette.palette->colorCount, GL_RGBA, - GL_UNSIGNED_BYTE, (const void*)data.palette.palette->colors - ); + // glColorTableEXT( + // GL_TEXTURE_2D, GL_RGBA, data.palette.palette->colorCount, GL_RGBA, + // GL_UNSIGNED_BYTE, (const void*)data.palette.palette->colors + // ); break; default: diff --git a/src/dusksdl2/CMakeLists.txt b/src/dusksdl2/CMakeLists.txt index 3e86b70..69f5232 100644 --- a/src/dusksdl2/CMakeLists.txt +++ b/src/dusksdl2/CMakeLists.txt @@ -11,4 +11,5 @@ target_include_directories(${DUSK_LIBRARY_TARGET_NAME} # Subdirs add_subdirectory(display) -add_subdirectory(input) \ No newline at end of file +add_subdirectory(input) +add_subdirectory(time) \ No newline at end of file diff --git a/src/dusksdl2/display/displaysdl2.c b/src/dusksdl2/display/displaysdl2.c index 2d9ff5e..f5e5473 100644 --- a/src/dusksdl2/display/displaysdl2.c +++ b/src/dusksdl2/display/displaysdl2.c @@ -8,10 +8,11 @@ #include "display/display.h" #include "engine/engine.h" #include "display/displaygl.h" +#include "error/errorgl.h" -erroret_t displaySDL2Init(void) { +errorret_t displaySDL2Init(void) { uint32_t flags = SDL_INIT_VIDEO; - #if INPUT_GAMEPAD == 1 + #ifdef DUSK_INPUT_GAMEPAD flags |= SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK; #endif if(SDL_Init(flags) != 0) { @@ -26,8 +27,8 @@ erroret_t displaySDL2Init(void) { "Dusk", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - DUSK_WINDOW_WIDTH_DEFAULT, - DUSK_WINDOW_HEIGHT_DEFAULT, + DUSK_DISPLAY_WIDTH_DEFAULT, + DUSK_DISPLAY_HEIGHT_DEFAULT, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL ); @@ -48,12 +49,12 @@ erroret_t displaySDL2Init(void) { errorChain(displayOpenGLInit()); - // #if DUSK_PSP // errorChain(displayPSPInit()); // #endif errorChain(errorGLCheck()); + errorOk(); } errorret_t displaySDL2Update(void) { @@ -90,11 +91,7 @@ errorret_t displaySDL2Update(void) { errorret_t displaySDL2Swap(void) { SDL_GL_SwapWindow(DISPLAY.window); - - GLenum err; - while((err = glGetError()) != GL_NO_ERROR) { - debugPrint("GL Error: %d\n", err); - } + errorChain(errorGLCheck()); errorOk(); } diff --git a/src/dusksdl2/input/inputplatform.h b/src/dusksdl2/input/inputplatform.h index b6a852c..c71c3d1 100644 --- a/src/dusksdl2/input/inputplatform.h +++ b/src/dusksdl2/input/inputplatform.h @@ -21,6 +21,7 @@ typedef inputpointeraxissdl2_t inputpointeraxisplatform_t; #endif +#define inputUpdatePlatform inputUpdateSDL2 #define inputButtonGetValuePlatform inputButtonGetValueSDL2 typedef inputsdl2_t inputplatform_t; \ No newline at end of file diff --git a/src/dusksdl2/input/inputsdl2.c b/src/dusksdl2/input/inputsdl2.c index dabb1ae..0863434 100644 --- a/src/dusksdl2/input/inputsdl2.c +++ b/src/dusksdl2/input/inputsdl2.c @@ -6,12 +6,40 @@ */ #include "input/input.h" +#include "assert/assert.h" + +void inputUpdateSDL2(void) { + #if INPUT_GAMEPAD == 1 + INPUT.controller = NULL; + + for(int32_t i = 0; i < SDL_NumJoysticks(); i++) { + if(!SDL_IsGameController(i)) continue; + INPUT.controller = SDL_GameControllerOpen(i); + if(INPUT.controller) break; + } + #endif + + #if INPUT_KEYBOARD == 1 + INPUT.keyboardState = SDL_GetKeyboardState(NULL); + #endif + + #if INPUT_POINTER == 1 + int pointerX, pointerY; + SDL_GetMouseState(&pointerX, &pointerY); + + int windowWidth, windowHeight; + SDL_GetWindowSize(DISPLAY.window, &windowWidth, &windowHeight); + + INPUT.mouseX = (float_t)pointerX / (float_t)windowWidth; + INPUT.mouseY = (float_t)pointerY / (float_t)windowHeight; + #endif +} float_t inputButtonGetValue(const inputbutton_t button) { switch(button.type) { #ifdef DUSK_INPUT_KEYBOARD case INPUT_BUTTON_TYPE_KEYBOARD: { - return INPUT.keyboardState[button.scancode] ? 1.0f : 0.0f; + return INPUT.platform.keyboardState[button.scancode] ? 1.0f : 0.0f; } #endif @@ -19,10 +47,10 @@ float_t inputButtonGetValue(const inputbutton_t button) { case INPUT_BUTTON_TYPE_POINTER: { switch(button.pointerAxis) { case INPUT_POINTER_AXIS_X: - return INPUT.mouseX; + return INPUT.platform.mouseX; case INPUT_POINTER_AXIS_Y: - return INPUT.mouseY; + return INPUT.platform.mouseY; default: assertUnreachable("Unknown pointer axis"); @@ -33,7 +61,9 @@ float_t inputButtonGetValue(const inputbutton_t button) { #ifdef DUSK_INPUT_GAMEPAD case INPUT_BUTTON_TYPE_GAMEPAD: { - if(SDL_GameControllerGetButton(INPUT.controller, button.gpButton)) { + if(SDL_GameControllerGetButton( + INPUT.platform.controller, button.gpButton + )) { return 1.0f; } return 0.0f; @@ -42,7 +72,9 @@ float_t inputButtonGetValue(const inputbutton_t button) { case INPUT_BUTTON_TYPE_GAMEPAD_AXIS: { float_t value = 0.0f; - Sint16 axis = SDL_GameControllerGetAxis(INPUT.controller, button.gpAxis.axis); + Sint16 axis = SDL_GameControllerGetAxis( + INPUT.platform.controller, button.gpAxis.axis + ); value = (float_t)axis / 32767.0f; if(!button.gpAxis.positive) value = -value; diff --git a/src/dusksdl2/input/inputsdl2.h b/src/dusksdl2/input/inputsdl2.h index f529325..54de60a 100644 --- a/src/dusksdl2/input/inputsdl2.h +++ b/src/dusksdl2/input/inputsdl2.h @@ -30,21 +30,24 @@ typedef struct inputbutton_s inputbutton_t; #endif typedef struct { - #if INPUT_GAMEPAD == 1 + #ifdef DUSK_INPUT_GAMEPAD SDL_GameController *controller; #endif - #if INPUT_KEYBOARD == 1 + #ifdef DUSK_INPUT_KEYBOARD const uint8_t *keyboardState; #endif - #if INPUT_POINTER == 1 - #if INPUT_SDL2 == 1 - float_t mouseX, mouseY; - #endif + #ifdef DUSK_INPUT_POINTER + float_t mouseX, mouseY; #endif } inputsdl2_t; +/** + * Updates the input state for SDL2. + */ +void inputUpdateSDL2(void); + /** * Returns the input value (between 0 and 1) of the given button. * diff --git a/src/dusksdl2/time/CMakeLists.txt b/src/dusksdl2/time/CMakeLists.txt new file mode 100644 index 0000000..79fb745 --- /dev/null +++ b/src/dusksdl2/time/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) 2026 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +# Sources +target_sources(${DUSK_LIBRARY_TARGET_NAME} + PUBLIC + timesdl2.c +) + +# Subdirs \ No newline at end of file diff --git a/src/dusksdl2/time/timeplatform.h b/src/dusksdl2/time/timeplatform.h new file mode 100644 index 0000000..b5e7814 --- /dev/null +++ b/src/dusksdl2/time/timeplatform.h @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "timesdl2.h" + +#define timeTickPlatform timeTickSDL2 +#define timeGetDeltaPlatform timeGetDeltaSDL2 \ No newline at end of file diff --git a/src/dusksdl2/time/timesdl2.c b/src/dusksdl2/time/timesdl2.c new file mode 100644 index 0000000..688672f --- /dev/null +++ b/src/dusksdl2/time/timesdl2.c @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "timesdl2.h" + +void timeTickSDL2(void) { + TIME_TICKS_LAST_SDL2 = TIME_TICKS_SDL2; + TIME_TICKS_SDL2 = SDL_GetTicks64(); +} + +float_t timeGetDeltaSDL2(void) { + return (float_t)(TIME_TICKS_SDL2 - TIME_TICKS_LAST_SDL2) / 1000.0f; +} \ No newline at end of file diff --git a/src/dusksdl2/time/timesdl2.h b/src/dusksdl2/time/timesdl2.h new file mode 100644 index 0000000..42a93c4 --- /dev/null +++ b/src/dusksdl2/time/timesdl2.h @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2026 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "dusk.h" + +static uint64_t TIME_TICKS_SDL2 = 0; +static uint64_t TIME_TICKS_LAST_SDL2 = 0; + +/** + * Requests SDL2 to update its internal game ticks. + */ +void timeTickSDL2(void); + +/** + * Gets the time delta for this tick in seconds. + * + * @return The time delta for this tick in seconds. + */ +float_t timeGetDeltaSDL2(void); \ No newline at end of file