From 1d7516982a62e07b63c2713d0f33f9df953de947 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 11 Mar 2026 08:11:49 -0500 Subject: [PATCH] Fixed dolphin input --- assets/scene/minesweeper.lua | 1 + cmake/targets/dolphin.cmake | 1 + src/duskdolphin/debug/debug.c | 84 ++++++++++++++-------------- src/duskdolphin/input/inputdolphin.c | 8 +-- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/assets/scene/minesweeper.lua b/assets/scene/minesweeper.lua index bcafd1e..31dc201 100644 --- a/assets/scene/minesweeper.lua +++ b/assets/scene/minesweeper.lua @@ -187,6 +187,7 @@ function sceneUpdate() end if inputIsDown(INPUT_ACTION_DOWN) then + print("down") y = y + 1 end diff --git a/cmake/targets/dolphin.cmake b/cmake/targets/dolphin.cmake index e1648c8..2f10c8d 100644 --- a/cmake/targets/dolphin.cmake +++ b/cmake/targets/dolphin.cmake @@ -1,6 +1,7 @@ # Target definitions target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC DUSK_DOLPHIN + DUSK_INPUT_GAMEPAD DUSK_DISPLAY_WIDTH=640 DUSK_DISPLAY_HEIGHT=480 ) diff --git a/src/duskdolphin/debug/debug.c b/src/duskdolphin/debug/debug.c index 70d4566..d1a11f0 100644 --- a/src/duskdolphin/debug/debug.c +++ b/src/duskdolphin/debug/debug.c @@ -25,57 +25,55 @@ void debugPrint(const char_t *message, ...) { fflush(stdout); // Append to buffer - vsnprintf( - DEBUG_ERROR_BUFFER + start, - sizeof(DEBUG_ERROR_BUFFER) - start, - message, - args - ); - - va_end(args); + // vsnprintf( + // DEBUG_ERROR_BUFFER + start, + // sizeof(DEBUG_ERROR_BUFFER) - start, + // message, + // args + // ); } void debugFlush() { fflush(stdout); // Either create graphics, or hijack the displays' graphics. - void *xfb = NULL; - GXRModeObj *rmode = NULL; - void *framebuffer; + // void *xfb = NULL; + // GXRModeObj *rmode = NULL; + // void *framebuffer; - if(DISPLAY.frameBuffer[0]) { - console_init( - DISPLAY.frameBuffer[0], - 20, - 20, - DISPLAY.screenMode->fbWidth, - DISPLAY.screenMode->xfbHeight, - DISPLAY.screenMode->fbWidth * VI_DISPLAY_PIX_SZ - ); - } else { - VIDEO_Init(); - rmode = VIDEO_GetPreferredMode(NULL); - framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); - console_init( - framebuffer, - 20, - 20, - rmode->fbWidth, - rmode->xfbHeight, - rmode->fbWidth*VI_DISPLAY_PIX_SZ - ); - VIDEO_Configure(rmode); - VIDEO_SetNextFramebuffer(framebuffer); - VIDEO_SetBlack(FALSE); - VIDEO_Flush(); - VIDEO_WaitVSync(); - if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); - } + // if(DISPLAY.frameBuffer[0]) { + // console_init( + // DISPLAY.frameBuffer[0], + // 20, + // 20, + // DISPLAY.screenMode->fbWidth, + // DISPLAY.screenMode->xfbHeight, + // DISPLAY.screenMode->fbWidth * VI_DISPLAY_PIX_SZ + // ); + // } else { + // VIDEO_Init(); + // rmode = VIDEO_GetPreferredMode(NULL); + // framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); + // console_init( + // framebuffer, + // 20, + // 20, + // rmode->fbWidth, + // rmode->xfbHeight, + // rmode->fbWidth*VI_DISPLAY_PIX_SZ + // ); + // VIDEO_Configure(rmode); + // VIDEO_SetNextFramebuffer(framebuffer); + // VIDEO_SetBlack(FALSE); + // VIDEO_Flush(); + // VIDEO_WaitVSync(); + // if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); + // } - // Printf - printf("SOB\n"); - printf(DEBUG_ERROR_BUFFER); - printf("\nEOB."); + // // Printf + // printf("SOB\n"); + // printf(DEBUG_ERROR_BUFFER); + // printf("\nEOB."); while(SYS_MainLoop()) { VIDEO_WaitVSync(); diff --git a/src/duskdolphin/input/inputdolphin.c b/src/duskdolphin/input/inputdolphin.c index 2e3b90b..2a1f9ef 100644 --- a/src/duskdolphin/input/inputdolphin.c +++ b/src/duskdolphin/input/inputdolphin.c @@ -49,8 +49,8 @@ void inputUpdateDolphin(void) { PAD_ScanPads(); #ifdef DUSK_INPUT_GAMEPAD - for(uint8_t i = 0; i < INPUT_PAD_COUNT; i++) { - INPUT.platform.padState[i] = PAD_ButtonsDown(i); + for(uint8_t i = 0; i < INPUT_DOLPHIN_PAD_COUNT; i++) { + INPUT.platform.padState[i] = PAD_ButtonsHeld(i); INPUT.platform.pads[i][INPUT_GAMEPAD_AXIS_LEFT_X] = ( INPUT_DOLPHIN_AXIS(PAD_StickX(i)) @@ -83,12 +83,12 @@ float_t inputButtonGetValueDolphin(const inputbutton_t button) { switch(button.type) { #ifdef DUSK_INPUT_GAMEPAD case INPUT_BUTTON_TYPE_GAMEPAD: { - if(INPUT.padState[0] & button.gpButton) return 1.0f; + if(INPUT.platform.padState[0] & button.gpButton) return 1.0f; return 0.0f; } case INPUT_BUTTON_TYPE_GAMEPAD_AXIS: { - float_t value = INPUT.pads[0][button.gpAxis.axis]; + float_t value = INPUT.platform.pads[0][button.gpAxis.axis]; if(!button.gpAxis.positive) value = -value; if(value >= INPUT.deadzone) return value; return 0.0f;