forked from Dniel97/segatools
chuniio 0x0101: Fix IR beam mapping
This commit is contained in:
parent
01cfc4e48f
commit
7b71b944e1
@ -31,7 +31,8 @@ static const struct io3_ops chunithm_jvs_io3_ops = {
|
||||
.read_coin_counter = chunithm_jvs_read_coin_counter,
|
||||
};
|
||||
|
||||
static const struct chunithm_jvs_ir_mask chunithm_jvs_ir_masks[] = {
|
||||
// Incorrect IR beam mappings retained for backward compatibility
|
||||
static const struct chunithm_jvs_ir_mask chunithm_jvs_ir_masks_v1[] = {
|
||||
{ 0x0000, 0x0020 },
|
||||
{ 0x0020, 0x0000 },
|
||||
{ 0x0000, 0x0010 },
|
||||
@ -40,6 +41,15 @@ static const struct chunithm_jvs_ir_mask chunithm_jvs_ir_masks[] = {
|
||||
{ 0x0008, 0x0000 },
|
||||
};
|
||||
|
||||
static const struct chunithm_jvs_ir_mask chunithm_jvs_ir_masks[] = {
|
||||
{ 0x0020, 0x0000 },
|
||||
{ 0x0000, 0x0020 },
|
||||
{ 0x0010, 0x0000 },
|
||||
{ 0x0000, 0x0010 },
|
||||
{ 0x0008, 0x0000 },
|
||||
{ 0x0000, 0x0008 },
|
||||
};
|
||||
|
||||
static struct io3 chunithm_jvs_io3;
|
||||
|
||||
HRESULT chunithm_jvs_init(struct jvs_node **out)
|
||||
@ -66,6 +76,7 @@ HRESULT chunithm_jvs_init(struct jvs_node **out)
|
||||
|
||||
static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out)
|
||||
{
|
||||
const struct chunithm_jvs_ir_mask *masks;
|
||||
uint8_t opbtn;
|
||||
uint8_t beams;
|
||||
size_t i;
|
||||
@ -73,6 +84,14 @@ static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out)
|
||||
assert(out != NULL);
|
||||
assert(chuni_dll.jvs_poll != NULL);
|
||||
|
||||
if (chuni_dll.api_version >= 0x0101) {
|
||||
// Use correct mapping
|
||||
masks = chunithm_jvs_ir_masks;
|
||||
} else {
|
||||
// Use backwards-compatible incorrect mapping
|
||||
masks = chunithm_jvs_ir_masks_v1;
|
||||
}
|
||||
|
||||
opbtn = 0;
|
||||
beams = 0;
|
||||
|
||||
@ -95,8 +114,8 @@ static void chunithm_jvs_read_switches(void *ctx, struct io3_switch_state *out)
|
||||
for (i = 0 ; i < 6 ; i++) {
|
||||
/* Beam "press" is active-low hence the ~ */
|
||||
if (~beams & (1 << i)) {
|
||||
out->p1 |= chunithm_jvs_ir_masks[i].p1;
|
||||
out->p2 |= chunithm_jvs_ir_masks[i].p2;
|
||||
out->p1 |= masks[i].p1;
|
||||
out->p2 |= masks[i].p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ static struct chuni_io_config chuni_io_cfg;
|
||||
|
||||
uint16_t chuni_io_get_api_version(void)
|
||||
{
|
||||
return 0x0100;
|
||||
return 0x0101;
|
||||
}
|
||||
|
||||
HRESULT chuni_io_jvs_init(void)
|
||||
|
@ -1,5 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
CHUNITHM CUSTOM IO API
|
||||
|
||||
Changelog:
|
||||
|
||||
- 0x0100: Initial API version (assumed if chuni_io_get_api_version is not
|
||||
exported)
|
||||
- 0x0101: Fix IR beam mappings
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
@ -10,7 +20,7 @@
|
||||
the major version and the low byte is the minor version (as defined by the
|
||||
Semantic Versioning standard).
|
||||
|
||||
The latest API version as of this writing is 0x0100. */
|
||||
The latest API version as of this writing is 0x0101. */
|
||||
|
||||
uint16_t chuni_io_get_api_version(void);
|
||||
|
||||
@ -41,7 +51,12 @@ HRESULT chuni_io_jvs_init(void);
|
||||
a gradual raising and lowering of the hands. Consult the proof-of-concept
|
||||
implementation for details.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
NOTE: Previous releases of Segatools mapped the IR beam inputs incorrectly.
|
||||
Please ensure that you advertise an API version of at least 0x0101 so that
|
||||
the correct mapping can be used.
|
||||
|
||||
Minimum API version: 0x0100
|
||||
Latest API version: 0x0101 */
|
||||
|
||||
void chuni_io_jvs_poll(uint8_t *opbtn, uint8_t *beams);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user