diff --git a/board/led15093.c b/board/led15093.c index cb3cd2e..606ce27 100644 --- a/board/led15093.c +++ b/board/led15093.c @@ -239,15 +239,25 @@ static HRESULT led15093_handle_irp_locked(int board, struct irp *irp) if (irp->op == IRP_OP_OPEN) { 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) { - dprintf("LED 15093: Backend error, LED board disconnected: " - "%d\n", - res); + return E_FAIL; + } + */ + 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); diff --git a/board/led15093.h b/board/led15093.h index ff2f612..869a11b 100644 --- a/board/led15093.h +++ b/board/led15093.h @@ -16,7 +16,7 @@ struct led15093_config { 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); HRESULT led15093_hook_init(const struct led15093_config *cfg, io_led_init_t _led_init, diff --git a/chunihook/chuni-dll.h b/chunihook/chuni-dll.h index 034b204..8341b48 100644 --- a/chunihook/chuni-dll.h +++ b/chunihook/chuni-dll.h @@ -13,7 +13,7 @@ struct chuni_dll { void (*slider_start)(chuni_io_slider_callback_t callback); void (*slider_stop)(void); 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); }; diff --git a/chuniio/chuniio.c b/chuniio/chuniio.c index 32481f1..95a52d7 100644 --- a/chuniio/chuniio.c +++ b/chuniio/chuniio.c @@ -166,7 +166,7 @@ static unsigned int __stdcall chuni_io_slider_thread_proc(void *ctx) return 0; } -int chuni_io_led_init() +HRESULT chuni_io_led_init(void) { return led_output_init(&chuni_io_cfg); } diff --git a/chuniio/chuniio.h b/chuniio/chuniio.h index 5fc7ebe..1ecba4a 100644 --- a/chuniio/chuniio.h +++ b/chuniio/chuniio.h @@ -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 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 bytes. The majority of these are for the marquee display, but the final diff --git a/chuniio/ledoutput.c b/chuniio/ledoutput.c index 84509bc..ab0187f 100644 --- a/chuniio/ledoutput.c +++ b/chuniio/ledoutput.c @@ -19,18 +19,18 @@ static bool any_outputs_enabled; 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); if (dwWaitResult == WAIT_FAILED) { - // return HRESULT_FROM_WIN32(GetLastError()); - return 1; + return HRESULT_FROM_WIN32(GetLastError()); + // return 1; } else if (dwWaitResult != WAIT_OBJECT_0) { - // return E_FAIL; - return 1; + return E_FAIL; + // return 1; } if (!led_output_is_init) @@ -65,8 +65,8 @@ int led_output_init(struct chuni_io_config* const cfg) led_output_is_init = true; ReleaseMutex(led_init_mutex); - // return S_OK; - return 0; + return S_OK; + // return 0; } struct _chuni_led_data_buf_t* escape_led_data(struct _chuni_led_data_buf_t* unescaped) diff --git a/chuniio/ledoutput.h b/chuniio/ledoutput.h index 82e54b1..33a4180 100644 --- a/chuniio/ledoutput.h +++ b/chuniio/ledoutput.h @@ -15,5 +15,5 @@ #include "chuniio/config.h" 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); diff --git a/chusanhook/chuni-dll.h b/chusanhook/chuni-dll.h index 034b204..8341b48 100644 --- a/chusanhook/chuni-dll.h +++ b/chusanhook/chuni-dll.h @@ -13,7 +13,7 @@ struct chuni_dll { void (*slider_start)(chuni_io_slider_callback_t callback); void (*slider_stop)(void); 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); }; diff --git a/fgohook/fgo-dll.h b/fgohook/fgo-dll.h index 05dd997..22bf02d 100644 --- a/fgohook/fgo-dll.h +++ b/fgohook/fgo-dll.h @@ -11,7 +11,7 @@ struct fgo_dll { void (*get_opbtns)(uint8_t *opbtn); void (*get_gamebtns)(uint8_t *gamebtn); 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); }; diff --git a/fgoio/fgoio.c b/fgoio/fgoio.c index 5ffbd72..95c86d9 100644 --- a/fgoio/fgoio.c +++ b/fgoio/fgoio.c @@ -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) diff --git a/fgoio/fgoio.h b/fgoio/fgoio.h index 6e526f5..5a815a7 100644 --- a/fgoio/fgoio.h +++ b/fgoio/fgoio.h @@ -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 your responsibility. */ -int fgo_io_led_init(); +HRESULT fgo_io_led_init(void); /* Update the RGB LEDs.