chuniio: use HRESULT instead of int for chuni_io_led_init()

This commit is contained in:
Dniel97 2023-12-21 00:45:41 +01:00
parent ac9b889d71
commit d4372fa5c2
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
11 changed files with 35 additions and 24 deletions

View File

@ -239,15 +239,25 @@ static HRESULT led15093_handle_irp_locked(int board, struct irp *irp)
if (irp->op == IRP_OP_OPEN) { if (irp->op == IRP_OP_OPEN) {
dprintf("LED 15093: Starting backend DLL\n"); dprintf("LED 15093: Starting backend DLL\n");
int res = led_init(); // int res = led_init();
hr = led_init();
/*
if (res != 0) {
dprintf("LED 15093: Backend error, LED board disconnected: "
"%d\n",
res);
if (res != 0) { return E_FAIL;
dprintf("LED 15093: Backend error, LED board disconnected: " }
"%d\n", */
res); if (FAILED(hr)) {
dprintf("LED 15093: Backend error, LED board disconnected: "
"%x\n",
(int) hr);
return E_FAIL; return hr;
} }
} }
hr = uart_handle_irp(boarduart, irp); hr = uart_handle_irp(boarduart, irp);

View File

@ -16,7 +16,7 @@ struct led15093_config {
uint16_t fw_sum; uint16_t fw_sum;
}; };
typedef int (*io_led_init_t)(); typedef HRESULT (*io_led_init_t)(void);
typedef void (*io_led_set_leds_t)(uint8_t board, uint8_t *rgb); typedef void (*io_led_set_leds_t)(uint8_t board, uint8_t *rgb);
HRESULT led15093_hook_init(const struct led15093_config *cfg, io_led_init_t _led_init, HRESULT led15093_hook_init(const struct led15093_config *cfg, io_led_init_t _led_init,

View File

@ -13,7 +13,7 @@ struct chuni_dll {
void (*slider_start)(chuni_io_slider_callback_t callback); void (*slider_start)(chuni_io_slider_callback_t callback);
void (*slider_stop)(void); void (*slider_stop)(void);
void (*slider_set_leds)(const uint8_t *rgb); void (*slider_set_leds)(const uint8_t *rgb);
int (*led_init)(); HRESULT (*led_init)(void);
void (*led_set_leds)(uint8_t board, uint8_t *rgb); void (*led_set_leds)(uint8_t board, uint8_t *rgb);
}; };

View File

@ -166,7 +166,7 @@ static unsigned int __stdcall chuni_io_slider_thread_proc(void *ctx)
return 0; return 0;
} }
int chuni_io_led_init() HRESULT chuni_io_led_init(void)
{ {
return led_output_init(&chuni_io_cfg); return led_output_init(&chuni_io_cfg);
} }

View File

@ -153,7 +153,7 @@ void chuni_io_slider_set_leds(const uint8_t *rgb);
overlap with each other. Ensuring synchronization inside your IO DLL is overlap with each other. Ensuring synchronization inside your IO DLL is
your responsibility. */ your responsibility. */
int chuni_io_led_init(); HRESULT chuni_io_led_init(void);
/* Update the RGB LEDs. rgb is a pointer to an array of 66 * 3 = 198 /* Update the RGB LEDs. rgb is a pointer to an array of 66 * 3 = 198
bytes. The majority of these are for the marquee display, but the final bytes. The majority of these are for the marquee display, but the final

View File

@ -19,18 +19,18 @@ static bool any_outputs_enabled;
HANDLE led_init_mutex; HANDLE led_init_mutex;
int led_output_init(struct chuni_io_config* const cfg) HRESULT led_output_init(struct chuni_io_config* const cfg)
{ {
DWORD dwWaitResult = WaitForSingleObject(led_init_mutex, INFINITE); DWORD dwWaitResult = WaitForSingleObject(led_init_mutex, INFINITE);
if (dwWaitResult == WAIT_FAILED) if (dwWaitResult == WAIT_FAILED)
{ {
// return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
return 1; // return 1;
} }
else if (dwWaitResult != WAIT_OBJECT_0) else if (dwWaitResult != WAIT_OBJECT_0)
{ {
// return E_FAIL; return E_FAIL;
return 1; // return 1;
} }
if (!led_output_is_init) if (!led_output_is_init)
@ -65,8 +65,8 @@ int led_output_init(struct chuni_io_config* const cfg)
led_output_is_init = true; led_output_is_init = true;
ReleaseMutex(led_init_mutex); ReleaseMutex(led_init_mutex);
// return S_OK; return S_OK;
return 0; // return 0;
} }
struct _chuni_led_data_buf_t* escape_led_data(struct _chuni_led_data_buf_t* unescaped) struct _chuni_led_data_buf_t* escape_led_data(struct _chuni_led_data_buf_t* unescaped)

View File

@ -15,5 +15,5 @@
#include "chuniio/config.h" #include "chuniio/config.h"
extern HANDLE led_init_mutex; extern HANDLE led_init_mutex;
int led_output_init(struct chuni_io_config* const cfg); HRESULT led_output_init(struct chuni_io_config* const cfg);
void led_output_update(uint8_t board, const byte* rgb); void led_output_update(uint8_t board, const byte* rgb);

View File

@ -13,7 +13,7 @@ struct chuni_dll {
void (*slider_start)(chuni_io_slider_callback_t callback); void (*slider_start)(chuni_io_slider_callback_t callback);
void (*slider_stop)(void); void (*slider_stop)(void);
void (*slider_set_leds)(const uint8_t *rgb); void (*slider_set_leds)(const uint8_t *rgb);
int (*led_init)(); HRESULT (*led_init)(void);
void (*led_set_leds)(uint8_t board, uint8_t *rgb); void (*led_set_leds)(uint8_t board, uint8_t *rgb);
}; };

View File

@ -11,7 +11,7 @@ struct fgo_dll {
void (*get_opbtns)(uint8_t *opbtn); void (*get_opbtns)(uint8_t *opbtn);
void (*get_gamebtns)(uint8_t *gamebtn); void (*get_gamebtns)(uint8_t *gamebtn);
void (*get_analogs)(int16_t *stick_x, int16_t *stick_y); void (*get_analogs)(int16_t *stick_x, int16_t *stick_y);
int (*led_init)(); HRESULT (*led_init)();
void (*led_set_leds)(uint8_t board, uint8_t *rgb); void (*led_set_leds)(uint8_t board, uint8_t *rgb);
}; };

View File

@ -140,9 +140,10 @@ void fgo_io_get_analogs(int16_t *stick_x, int16_t *stick_y)
} }
} }
int fgo_io_led_init() HRESULT fgo_io_led_init(void)
{ {
return 0; // return 0;
return S_OK;
} }
void fgo_io_led_set_leds(uint8_t board, uint8_t *rgb) void fgo_io_led_set_leds(uint8_t board, uint8_t *rgb)

View File

@ -77,7 +77,7 @@ void fgo_io_get_analogs(int16_t *stick_x, int16_t *stick_y);
overlap with each other. Ensuring synchronization inside your IO DLL is overlap with each other. Ensuring synchronization inside your IO DLL is
your responsibility. */ your responsibility. */
int fgo_io_led_init(); HRESULT fgo_io_led_init(void);
/* Update the RGB LEDs. /* Update the RGB LEDs.