From 3341cc386567c7713aaa3ccab67677635293ba29 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 22 Feb 2017 16:44:16 -0800 Subject: [PATCH] DS I/O: Add extended key input --- src/ds/io.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ds/io.c b/src/ds/io.c index 0aabbc9bf..a3dcb0748 100644 --- a/src/ds/io.c +++ b/src/ds/io.c @@ -193,8 +193,20 @@ uint32_t DSIOWrite32(struct DSCommon* dscore, uint32_t address, uint32_t value) return value; } +static uint16_t DSIOReadExKeyInput(struct DS* ds) { + uint16_t input = 0; + if (ds->keyCallback) { + input = ds->keyCallback->readKeys(ds->keyCallback); + } else if (ds->keySource) { + input = *ds->keySource; + } + input = ~(input >> 10) & 0x3; + input |= 0x3C; + return input; +} + static uint16_t DSIOReadKeyInput(struct DS* ds) { - uint16_t input = 0x3FF; + uint16_t input = 0; if (ds->keyCallback) { input = ds->keyCallback->readKeys(ds->keyCallback); } else if (ds->keySource) { @@ -212,7 +224,7 @@ static uint16_t DSIOReadKeyInput(struct DS* ds) { input |= ud; } }*/ - return 0x3FF ^ input; + return ~input & 0x3FF; } static void DSIOUpdateTimer(struct DSCommon* dscore, uint32_t address) { @@ -327,6 +339,8 @@ uint16_t DS7IORead(struct DS* ds, uint32_t address) { break; case DS_REG_KEYINPUT: return DSIOReadKeyInput(ds); + case DS7_REG_EXTKEYIN: + return DSIOReadExKeyInput(ds); case DS_REG_DMA0FILL_LO: case DS_REG_DMA0FILL_HI: case DS_REG_DMA1FILL_LO: