Fix Dolphin crash

This commit is contained in:
2026-03-11 07:27:06 -05:00
parent 9b87dfa1a9
commit 5bd43a4643
9 changed files with 27 additions and 8 deletions

View File

@@ -16,7 +16,6 @@
#include "ui/ui.h"
#include "map/map.h"
#include "script/scriptmanager.h"
#include "debug/debug.h"
#include "item/backpack.h"
#include "assert/assert.h"
@@ -30,7 +29,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
// Init systems. Order is important.
timeInit();
inputInit();
errorChain(inputInit());
errorChain(assetInit());
errorChain(localeManagerInit());
errorChain(scriptManagerInit());

View File

@@ -15,7 +15,7 @@
input_t INPUT;
void inputInit(void) {
errorret_t inputInit(void) {
memoryZero(&INPUT, sizeof(input_t));
for(uint8_t i = 0; i < INPUT_ACTION_COUNT; i++) {
@@ -29,7 +29,7 @@ void inputInit(void) {
#endif
#ifdef inputInitPlatform
inputInitPlatform();
errorChain(inputInitPlatform());
#endif
eventInit(
@@ -38,6 +38,8 @@ void inputInit(void) {
eventInit(
&INPUT.eventReleased, INPUT.releasedListeners, INPUT_LISTENER_RELEASED_MAX
);
errorOk();
}
void inputUpdate(void) {

View File

@@ -6,6 +6,7 @@
*/
#pragma once
#include "error/error.h"
#include "inputbutton.h"
#include "inputaction.h"
#include "event/event.h"
@@ -36,8 +37,10 @@ extern input_t INPUT;
/**
* Initialize the input system.
*
* @return An error code if initialization fails.
*/
void inputInit(void);
errorret_t inputInit(void);
/**
* Updates the input state.

View File

@@ -33,8 +33,6 @@ void timeUpdate(void) {
TIME.dynamicTime += TIME.dynamicDelta;
TIME.dynamicUpdate = true;
printf("Time delta: %f\n", TIME.dynamicDelta);
assertTrue(TIME.dynamicDelta >= 0.0f, "Time delta is negative");
// Is within 1ms of a full step?

View File

@@ -22,6 +22,7 @@ void debugPrint(const char_t *message, ...) {
va_copy(copy, args);
vfprintf(stdout, message, copy);
va_end(copy);
fflush(stdout);
// Append to buffer
vsnprintf(

View File

@@ -7,6 +7,7 @@
#include "input/input.h"
#include "assert/assert.h"
#include "debug/debug.h"
inputbuttondata_t INPUT_BUTTON_DATA[] = {
#ifdef DUSK_INPUT_GAMEPAD
@@ -38,6 +39,12 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
{ .name = NULL }
};
errorret_t inputInitDolphin(void) {
PAD_Init();
errorOk();
}
void inputUpdateDolphin(void) {
PAD_ScanPads();

View File

@@ -7,6 +7,7 @@
#pragma once
#include "dusk.h"
#include "error/error.h"
#define INPUT_DOLPHIN_PAD_COUNT PAD_CHANMAX
#define INPUT_DOLPHIN_AXIS(value) ((float_t)(value) / 128.0f)
@@ -44,6 +45,13 @@ typedef struct {
#endif
} inputdolphin_t;
/**
* Initializes the input system for Dolphin.
*
* @return An error code if initialization fails.
*/
errorret_t inputInitDolphin(void);
/**
* Updates the input state for Dolphin.
*/

View File

@@ -15,5 +15,6 @@
typedef inputdolphin_t inputplatform_t;
#define inputInitPlatform inputInitDolphin
#define inputUpdatePlatform inputUpdateDolphin
#define inputButtonGetValuePlatform inputButtonGetValueDolphin

View File

@@ -61,7 +61,7 @@ errorret_t assetInitLinux(void) {
ASSET.zip = zip_open(searchPath, ZIP_RDONLY, &error);
if(ASSET.zip == NULL) continue;
if(error != 0) {
printf("Warning: Opened asset file with non-zero error code: %d\n", error);
printf("Opened asset file with non-zero error code: %d\n", error);
ASSET.zip = NULL;
continue;
}