From ef3fa640fd1a249be9b7d8477e887bab3e6a5694 Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Mon, 9 Feb 2026 21:29:36 +0100 Subject: [PATCH] diva: small touch controller improvements --- common/board/elo-frame.c | 11 +++++++---- games/divaio/divaio.c | 20 +++++++------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/common/board/elo-frame.c b/common/board/elo-frame.c index cf29f75..baa5f6d 100644 --- a/common/board/elo-frame.c +++ b/common/board/elo-frame.c @@ -30,6 +30,9 @@ static HRESULT elo_frame_accept(const struct iobuf *dest); /* Checksum offset to cancel out the lead byte */ #define ELO_CHECKSUM_OFFSET 0xAA +/* SmartSet frame length */ +#define ELO_FRAME_LENGTH 10 + static void elo_frame_sync(struct iobuf *src) { size_t i; @@ -46,7 +49,7 @@ static HRESULT elo_frame_accept(const struct iobuf *dest) uint8_t calc_checksum; size_t i; - if (dest->pos < 10) { + if (dest->pos < ELO_FRAME_LENGTH) { return S_FALSE; } @@ -93,7 +96,7 @@ HRESULT elo_frame_decode(struct iobuf *dest, struct iobuf *src) if (dest->pos >= dest->nbytes) { hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } else if (i == 0 && byte != 0x55) { + } else if (i == 0 && byte != ELO_FRAME_LEAD) { /* Invalid lead byte */ hr = E_FAIL; } else { @@ -135,7 +138,7 @@ HRESULT elo_frame_encode( src = ptr; /* Requires exactly 10 bytes */ - if (dest->pos + 10 > dest->nbytes) { + if (dest->pos + ELO_FRAME_LENGTH > dest->nbytes) { return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } @@ -145,7 +148,7 @@ HRESULT elo_frame_encode( checksum = ELO_CHECKSUM_OFFSET; /* Write exactly 9 bytes (lead-in + 8 data bytes) */ - for (i = 0; i < 9; i++) { + for (i = 0; i < ELO_FRAME_LENGTH-1; i++) { uint8_t b = (i < nbytes) ? src[i] : 0x00; dest->bytes[dest->pos++] = b; checksum += b; diff --git a/games/divaio/divaio.c b/games/divaio/divaio.c index e854ee4..f74b599 100644 --- a/games/divaio/divaio.c +++ b/games/divaio/divaio.c @@ -40,12 +40,16 @@ uint16_t diva_io_get_api_version(void) HRESULT diva_io_jvs_init(void) { - if (!diva_io_config_initted) { + HRESULT hr; + + if(!diva_io_config_initted) { diva_io_config_load(&diva_io_cfg, get_config_path()); diva_io_config_initted = true; } - return S_OK; + hr = diva_io_touch_config_apply(&diva_io_cfg); + + return hr; } void diva_io_jvs_poll(uint8_t *opbtn_out, uint8_t *gamebtn_out) @@ -189,16 +193,7 @@ void diva_io_led_set_leds(uint8_t board, const uint8_t *rgb) HRESULT diva_io_touch_init() { - HRESULT hr; - - if(!diva_io_config_initted) { - diva_io_config_load(&diva_io_cfg, get_config_path()); - diva_io_config_initted = true; - } - - hr = diva_io_touch_config_apply(&diva_io_cfg); - - return hr; + return S_OK; } static HRESULT diva_io_touch_config_apply( @@ -206,7 +201,6 @@ static HRESULT diva_io_touch_config_apply( ) { dprintf("Diva IO: Touch: --- Begin Configuration ---\n"); - dprintf("Diva IO: Touch: Using Elo controller\n"); if (wstr_ieq(cfg->touch_mode, L"mouse")) { dprintf("Diva IO: Touch: Mouse emulation\n");