From 3a1c9e2035c28ced266fa018e5a73c027d514e35 Mon Sep 17 00:00:00 2001
From: windwakr <284886+windwakr@users.noreply.github.com>
Date: Tue, 10 Oct 2023 22:27:29 -0400
Subject: [PATCH] Slot2: Add Slide Controller
---
desmume/src/Makefile.am | 1 +
desmume/src/addons/slot2_slideController.cpp | 264 ++++++++++++++++++
desmume/src/frontend/interface/meson.build | 2 +-
.../windows/DeSmuME_Interface.vcxproj | 1 +
.../windows/DeSmuME_Interface.vcxproj.filters | 3 +
desmume/src/frontend/posix/Makefile.am | 2 +-
desmume/src/frontend/posix/meson.build | 2 +-
desmume/src/frontend/windows/DeSmuME.vcxproj | 1 +
.../frontend/windows/DeSmuME.vcxproj.filters | 3 +
.../src/frontend/windows/gbaslot_config.cpp | 17 +-
desmume/src/frontend/windows/inputdx.cpp | 2 +
desmume/src/frontend/windows/inputdx.h | 5 +
desmume/src/frontend/windows/main.cpp | 34 +++
desmume/src/slot2.cpp | 25 +-
desmume/src/slot2.h | 26 +-
15 files changed, 356 insertions(+), 32 deletions(-)
create mode 100644 desmume/src/addons/slot2_slideController.cpp
diff --git a/desmume/src/Makefile.am b/desmume/src/Makefile.am
index b17d4df7f..1db6c6fa0 100644
--- a/desmume/src/Makefile.am
+++ b/desmume/src/Makefile.am
@@ -96,6 +96,7 @@ libdesmume_a_SOURCES = \
addons/slot2_rumblepak.cpp \
addons/slot2_guitarGrip.cpp \
addons/slot2_hcv1000.cpp \
+ addons/slot2_slideController.cpp \
addons/slot2_expMemory.cpp \
addons/slot2_piano.cpp \
addons/slot2_passme.cpp \
diff --git a/desmume/src/addons/slot2_slideController.cpp b/desmume/src/addons/slot2_slideController.cpp
new file mode 100644
index 000000000..b75cae51c
--- /dev/null
+++ b/desmume/src/addons/slot2_slideController.cpp
@@ -0,0 +1,264 @@
+/*
+ Copyright (C) 2023 DeSmuME team
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the this software. If not, see .
+*/
+
+//Absolute barebones implementation of the Slide Controller add-on. Rumble is not implemented.
+//The game does a bunch of mystery reads of various sizes which have not been investigated at all.
+
+#include "../slot2.h"
+#include "../emufile.h"
+
+#define SC_BITIN(X, Y) \
+do { \
+ X = (X << 1) | (Y & 1); \
+ bitsWritten++; \
+} while (0)
+
+#define SC_BITOUT(X, Y) \
+do { \
+ X = ((Y >> 7 - bitsRead) & 1); \
+ bitsRead++; \
+} while(0)
+
+u8 motionStatus;
+u8 xMotion;
+u8 yMotion;
+
+class Slot2_SlideController : public ISlot2Interface
+{
+private:
+ u8 prevClock;
+ u8 bitsWritten;
+ u8 bitsRead;
+ u8 inByte;
+ u16 regSel;
+
+ u8 configBits;
+ u8 framePeriodLower;
+ u8 framePeriodUpper;
+public:
+
+ virtual Slot2Info const* info()
+ {
+ static Slot2InfoSimple info("Slide Controller", "Slide Controller add-on", 0x0A);
+ return &info;
+ }
+
+ virtual void connect()
+ {
+ prevClock = 0;
+ bitsWritten = 0;
+ bitsRead = 0;
+ inByte = 0;
+ regSel = 0xFFFF;
+
+ motionStatus = 0;
+ xMotion = 0;
+ yMotion = 0;
+ configBits = 0;
+ framePeriodLower = 0x20;
+ framePeriodUpper = 0xD1;
+ }
+
+ virtual void writeWord(u8 PROCNUM, u32 addr, u16 val)
+ {
+ if (addr == 0x081E0000)
+ {
+ if ((prevClock == 0) && (val & 0x2) && (val & 0x8))
+ {
+ SC_BITIN(inByte, val);
+ if (bitsWritten == 8)
+ {
+ bitsWritten = 0;
+ if (regSel == 0xFFFF) //First byte written
+ {
+ regSel = inByte;
+ }
+ else //Second byte written
+ {
+ //printf("WRITE TO REG: %02X = %02X\n", regSel & 0x7F , inByte);
+ switch (regSel & 0x7F)
+ {
+ case 0x0A: //Config bits
+ configBits = inByte;
+ break;
+ case 0x10: //Frame period (lower)
+ framePeriodLower = inByte;
+ break;
+ case 0x11: //Frame period(upper)
+ framePeriodUpper = inByte;
+ break;
+ }
+ regSel = 0xFFFF;
+ }
+ }
+ }
+ prevClock = (val & 0x2) >> 1;
+ }
+
+ if (configBits & 0x80) //Reset
+ {
+ motionStatus = 0;
+ xMotion = 0;
+ yMotion = 0;
+ configBits = 0;
+ framePeriodLower = 0x20;
+ framePeriodUpper = 0xD1;
+
+ prevClock = 0;
+ bitsWritten = 0;
+ bitsRead = 0;
+ inByte = 0;
+ regSel = 0xFFFF;
+ }
+ }
+
+ virtual u8 readByte(u8 PROCNUM, u32 addr)
+ {
+ if (addr == 0x080000B2)
+ {
+ return 0x96;
+ }
+ return 0xFF;
+ }
+
+ virtual u16 readWord(u8 PROCNUM, u32 addr)
+ {
+ u16 outWord = 0;
+
+ if (addr < 0x08000100)
+ {
+ outWord = 0xFEF0;
+ }
+
+ if (addr == 0x081E0000)
+ {
+ switch (regSel)
+ {
+ case 0x00: //Product ID
+ SC_BITOUT(outWord, 0x3);
+ break;
+ case 0x01: //Revision ID
+ SC_BITOUT(outWord, 0x20); //Is this correct?
+ break;
+ case 0x02: //Motion status
+ SC_BITOUT(outWord, motionStatus);
+ if (bitsRead == 8) motionStatus = 0;
+ break;
+ case 0x03: //X motion delta
+ SC_BITOUT(outWord, xMotion);
+ if (bitsRead == 8) xMotion = 0;
+ break;
+ case 0x04: //Y motion delta
+ SC_BITOUT(outWord, yMotion);
+ if (bitsRead == 8) yMotion = 0;
+ break;
+ case 0x05: //Surface quality
+ SC_BITOUT(outWord, 128);
+ break;
+ case 0x06: //Average pixel
+ SC_BITOUT(outWord, 32);
+ break;
+ case 0x07: //Maximum pixel
+ SC_BITOUT(outWord, 63);
+ break;
+ case 0x0A: //Configuration bits
+ SC_BITOUT(outWord, configBits);
+ break;
+ case 0x0C: //Data out (lower)
+ SC_BITOUT(outWord, 0);
+ break;
+ case 0x0D: //Data out (upper)
+ SC_BITOUT(outWord, 0);
+ break;
+ case 0x0E: //Shutter value (lower)
+ SC_BITOUT(outWord, 64);
+ break;
+ case 0x0F: //Shutter value (upper)
+ SC_BITOUT(outWord, 0);
+ break;
+ case 0x10: //Frame period (lower)
+ SC_BITOUT(outWord, framePeriodLower);
+ break;
+ case 0x11: //Frame period (upper)
+ SC_BITOUT(outWord, framePeriodUpper);
+ break;
+ }
+
+ if (bitsRead == 8)
+ {
+ bitsRead = 0;
+ //printf("READ FROM REG: %02X\n", regSel);
+ regSel = 0xFFFF;
+ }
+ }
+
+ return outWord;
+ }
+
+ virtual void savestate(EMUFILE& os)
+ {
+ s32 version = 0;
+ os.write_32LE(version);
+
+ os.write_u8(prevClock);
+ os.write_u8(bitsWritten);
+ os.write_u8(bitsRead);
+ os.write_u8(inByte);
+ os.write_16LE(regSel);
+
+ os.write_u8(configBits);
+ os.write_u8(framePeriodLower);
+ os.write_u8(framePeriodUpper);
+ os.write_u8(motionStatus);
+ os.write_u8(xMotion);
+ os.write_u8(yMotion);
+ }
+
+ virtual void loadstate(EMUFILE& is)
+ {
+ s32 version = is.read_s32LE();
+
+ if (version == 0)
+ {
+ is.read_u8(prevClock);
+ is.read_u8(bitsWritten);
+ is.read_u8(bitsRead);
+ is.read_u8(inByte);
+ is.read_16LE(regSel);
+
+ is.read_u8(configBits);
+ is.read_u8(framePeriodLower);
+ is.read_u8(framePeriodUpper);
+ is.read_u8(motionStatus);
+ is.read_u8(xMotion);
+ is.read_u8(yMotion);
+ }
+ }
+};
+
+ISlot2Interface* construct_Slot2_SlideController() { return new Slot2_SlideController(); }
+
+void slideController_updateMotion(s8 x, s8 y)
+{
+ xMotion = (u8)x;
+ yMotion = (u8)y;
+ if (xMotion || yMotion)
+ motionStatus = 0x80;
+}
+
+#undef SC_BITIN
+#undef SC_BITOUT
diff --git a/desmume/src/frontend/interface/meson.build b/desmume/src/frontend/interface/meson.build
index 6a62fbb2e..70693ce42 100644
--- a/desmume/src/frontend/interface/meson.build
+++ b/desmume/src/frontend/interface/meson.build
@@ -109,7 +109,7 @@ libdesmume_src += [
'../../utils/tinyxml/tinyxmlerror.cpp',
'../../utils/tinyxml/tinyxmlparser.cpp',
'../../utils/colorspacehandler/colorspacehandler.cpp',
- '../../addons/slot2_auto.cpp', '../../addons/slot2_mpcf.cpp', '../../addons/slot2_paddle.cpp', '../../addons/slot2_gbagame.cpp', '../../addons/slot2_none.cpp', '../../addons/slot2_rumblepak.cpp', '../../addons/slot2_guitarGrip.cpp', '../../addons/slot2_hcv1000.cpp', '../../addons/slot2_expMemory.cpp', '../../addons/slot2_piano.cpp', '../../addons/slot2_passme.cpp', '../../addons/slot1_none.cpp', '../../addons/slot1_r4.cpp', '../../addons/slot1_retail_nand.cpp', '../../addons/slot1_retail_auto.cpp', '../../addons/slot1_retail_mcrom.cpp', '../../addons/slot1_retail_mcrom_debug.cpp', '../../addons/slot1comp_mc.cpp', '../../addons/slot1comp_rom.cpp', '../../addons/slot1comp_protocol.cpp',
+ '../../addons/slot2_auto.cpp', '../../addons/slot2_mpcf.cpp', '../../addons/slot2_paddle.cpp', '../../addons/slot2_gbagame.cpp', '../../addons/slot2_none.cpp', '../../addons/slot2_rumblepak.cpp', '../../addons/slot2_guitarGrip.cpp', '../../addons/slot2_hcv1000.cpp', '../../addons/slot2_slideController.cpp', '../../addons/slot2_expMemory.cpp', '../../addons/slot2_piano.cpp', '../../addons/slot2_passme.cpp', '../../addons/slot1_none.cpp', '../../addons/slot1_r4.cpp', '../../addons/slot1_retail_nand.cpp', '../../addons/slot1_retail_auto.cpp', '../../addons/slot1_retail_mcrom.cpp', '../../addons/slot1_retail_mcrom_debug.cpp', '../../addons/slot1comp_mc.cpp', '../../addons/slot1comp_rom.cpp', '../../addons/slot1comp_protocol.cpp',
'../../cheatSystem.cpp',
'../../texcache.cpp', '../../rasterize.cpp',
'../../metaspu/metaspu.cpp',
diff --git a/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj b/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj
index ab87e284e..33e7243a5 100644
--- a/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj
+++ b/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj
@@ -269,6 +269,7 @@
+
diff --git a/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj.filters b/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj.filters
index cb3248c43..64101c1a3 100755
--- a/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj.filters
+++ b/desmume/src/frontend/interface/windows/DeSmuME_Interface.vcxproj.filters
@@ -135,6 +135,9 @@
addons
+
+ addons
+
addons
diff --git a/desmume/src/frontend/posix/Makefile.am b/desmume/src/frontend/posix/Makefile.am
index 4329a89e7..68a63e774 100644
--- a/desmume/src/frontend/posix/Makefile.am
+++ b/desmume/src/frontend/posix/Makefile.am
@@ -98,7 +98,7 @@ libdesmume_a_SOURCES = \
../../utils/tinyxml/tinyxmlparser.cpp \
../../utils/glcorearb.h \
../../utils/colorspacehandler/colorspacehandler.cpp ../../utils/colorspacehandler/colorspacehandler.h \
- ../../addons/slot2_auto.cpp ../../addons/slot2_mpcf.cpp ../../addons/slot2_paddle.cpp ../../addons/slot2_gbagame.cpp ../../addons/slot2_none.cpp ../../addons/slot2_rumblepak.cpp ../../addons/slot2_guitarGrip.cpp ../../addons/slot2_hcv1000.cpp ../../addons/slot2_expMemory.cpp ../../addons/slot2_piano.cpp ../../addons/slot2_passme.cpp ../../addons/slot1_none.cpp ../../addons/slot1_r4.cpp ../../addons/slot1_retail_nand.cpp ../../addons/slot1_retail_auto.cpp ../../addons/slot1_retail_mcrom.cpp ../../addons/slot1_retail_mcrom_debug.cpp ../../addons/slot1comp_mc.cpp ../../addons/slot1comp_mc.h ../../addons/slot1comp_rom.h ../../addons/slot1comp_rom.cpp ../../addons/slot1comp_protocol.h ../../addons/slot1comp_protocol.cpp \
+ ../../addons/slot2_auto.cpp ../../addons/slot2_mpcf.cpp ../../addons/slot2_paddle.cpp ../../addons/slot2_gbagame.cpp ../../addons/slot2_none.cpp ../../addons/slot2_rumblepak.cpp ../../addons/slot2_guitarGrip.cpp ../../addons/slot2_hcv1000.cpp ../../addons/slot2_slideController.cpp ../../addons/slot2_expMemory.cpp ../../addons/slot2_piano.cpp ../../addons/slot2_passme.cpp ../../addons/slot1_none.cpp ../../addons/slot1_r4.cpp ../../addons/slot1_retail_nand.cpp ../../addons/slot1_retail_auto.cpp ../../addons/slot1_retail_mcrom.cpp ../../addons/slot1_retail_mcrom_debug.cpp ../../addons/slot1comp_mc.cpp ../../addons/slot1comp_mc.h ../../addons/slot1comp_rom.h ../../addons/slot1comp_rom.cpp ../../addons/slot1comp_protocol.h ../../addons/slot1comp_protocol.cpp \
../../cheatSystem.cpp ../../cheatSystem.h \
../../texcache.cpp ../../texcache.h ../../rasterize.cpp ../../rasterize.h \
../../metaspu/metaspu.cpp ../../metaspu/metaspu.h \
diff --git a/desmume/src/frontend/posix/meson.build b/desmume/src/frontend/posix/meson.build
index 89e0e4bef..59e93afba 100644
--- a/desmume/src/frontend/posix/meson.build
+++ b/desmume/src/frontend/posix/meson.build
@@ -104,7 +104,7 @@ libdesmume_src = [
'../../utils/tinyxml/tinyxmlerror.cpp',
'../../utils/tinyxml/tinyxmlparser.cpp',
'../../utils/colorspacehandler/colorspacehandler.cpp',
- '../../addons/slot2_auto.cpp', '../../addons/slot2_mpcf.cpp', '../../addons/slot2_paddle.cpp', '../../addons/slot2_gbagame.cpp', '../../addons/slot2_none.cpp', '../../addons/slot2_rumblepak.cpp', '../../addons/slot2_guitarGrip.cpp', '../../addons/slot2_hcv1000.cpp', '../../addons/slot2_expMemory.cpp', '../../addons/slot2_piano.cpp', '../../addons/slot2_passme.cpp', '../../addons/slot1_none.cpp', '../../addons/slot1_r4.cpp', '../../addons/slot1_retail_nand.cpp', '../../addons/slot1_retail_auto.cpp', '../../addons/slot1_retail_mcrom.cpp', '../../addons/slot1_retail_mcrom_debug.cpp', '../../addons/slot1comp_mc.cpp', '../../addons/slot1comp_rom.cpp', '../../addons/slot1comp_protocol.cpp',
+ '../../addons/slot2_auto.cpp', '../../addons/slot2_mpcf.cpp', '../../addons/slot2_paddle.cpp', '../../addons/slot2_gbagame.cpp', '../../addons/slot2_none.cpp', '../../addons/slot2_rumblepak.cpp', '../../addons/slot2_guitarGrip.cpp', '../../addons/slot2_hcv1000.cpp', '../../addons/slot2_slideController.cpp', '../../addons/slot2_expMemory.cpp', '../../addons/slot2_piano.cpp', '../../addons/slot2_passme.cpp', '../../addons/slot1_none.cpp', '../../addons/slot1_r4.cpp', '../../addons/slot1_retail_nand.cpp', '../../addons/slot1_retail_auto.cpp', '../../addons/slot1_retail_mcrom.cpp', '../../addons/slot1_retail_mcrom_debug.cpp', '../../addons/slot1comp_mc.cpp', '../../addons/slot1comp_rom.cpp', '../../addons/slot1comp_protocol.cpp',
'../../cheatSystem.cpp',
'../../texcache.cpp', '../../rasterize.cpp',
'../../metaspu/metaspu.cpp',
diff --git a/desmume/src/frontend/windows/DeSmuME.vcxproj b/desmume/src/frontend/windows/DeSmuME.vcxproj
index bd4484362..5bd3c3ac1 100644
--- a/desmume/src/frontend/windows/DeSmuME.vcxproj
+++ b/desmume/src/frontend/windows/DeSmuME.vcxproj
@@ -73,6 +73,7 @@
+
diff --git a/desmume/src/frontend/windows/DeSmuME.vcxproj.filters b/desmume/src/frontend/windows/DeSmuME.vcxproj.filters
index 3e18bf156..35e1d4720 100644
--- a/desmume/src/frontend/windows/DeSmuME.vcxproj.filters
+++ b/desmume/src/frontend/windows/DeSmuME.vcxproj.filters
@@ -933,6 +933,9 @@
addons
+
+ addons
+
diff --git a/desmume/src/frontend/windows/gbaslot_config.cpp b/desmume/src/frontend/windows/gbaslot_config.cpp
index 9109eba18..5df2b0cc4 100644
--- a/desmume/src/frontend/windows/gbaslot_config.cpp
+++ b/desmume/src/frontend/windows/gbaslot_config.cpp
@@ -526,11 +526,12 @@ u32 GBAslot_IDDs[NDS_SLOT2_COUNT] = {
IDD_GBASLOT_RUMBLEPAK,
IDD_GBASLOT_GBAGAME,
IDD_GBASLOT_GUITARGRIP,
- IDD_GBASLOT_NONE, //expmem
+ IDD_GBASLOT_NONE, //expmem
IDD_GBASLOT_PIANO,
- IDD_GBASLOT_PADDLE, //paddle
- IDD_GBASLOT_NONE, //PassME
- IDD_GBASLOT_HCV1000, //HCV-1000
+ IDD_GBASLOT_PADDLE, //paddle
+ IDD_GBASLOT_NONE, //PassME
+ IDD_GBASLOT_HCV1000, //HCV-1000
+ IDD_GBASLOT_NONE, //Slide Controller
};
DLGPROC GBAslot_Procs[NDS_SLOT2_COUNT] = {
@@ -540,11 +541,12 @@ DLGPROC GBAslot_Procs[NDS_SLOT2_COUNT] = {
GbaSlotRumblePak,
GbaSlotGBAgame,
GbaSlotGuitarGrip,
- GbaSlotNone, //expmem
+ GbaSlotNone, //expmem
GbaSlotPiano,
GbaSlotPaddle,
- GbaSlotNone, // PassME
+ GbaSlotNone, // PassME
GbaSlotHCV1000, //HCV-1000
+ GbaSlotNone, //Slide Controller
};
@@ -696,6 +698,8 @@ void GBAslotDialog(HWND hwnd)
WritePrivateProfileString("Slot2.HCV1000", "barcode", tmp_hcv1000_barcode, IniName);
WritePrivateProfileInt("Slot2.HCV1000", "scankey", HCV1000.SCANKEY, IniName);
break;
+ case NDS_SLOT2_SLIDECONTROLLER:
+ break;
default:
return;
}
@@ -708,6 +712,7 @@ void GBAslotDialog(HWND hwnd)
Piano.Enabled = (slot2_GetCurrentType() == NDS_SLOT2_EASYPIANO)?true:false;
Paddle.Enabled = (slot2_GetCurrentType() == NDS_SLOT2_PADDLE)?true:false;
HCV1000.Enabled = (slot2_GetCurrentType() == NDS_SLOT2_HCV1000)?true:false;
+ SlideController.Enabled = (slot2_GetCurrentType() == NDS_SLOT2_SLIDECONTROLLER)?true:false;
}
}
diff --git a/desmume/src/frontend/windows/inputdx.cpp b/desmume/src/frontend/windows/inputdx.cpp
index c6a6b40a9..ecdbbcc48 100644
--- a/desmume/src/frontend/windows/inputdx.cpp
+++ b/desmume/src/frontend/windows/inputdx.cpp
@@ -261,6 +261,8 @@ SPaddle DefaultPaddle = { false, 'K', 'L' };
SHCV1000 HCV1000;
SHCV1000 DefaultHCV1000 = { false, 'L'};
+SSLIDECONTROLLER SlideController;
+
bool killStylusTopScreen = false;
bool killStylusOffScreen = false;
bool allowUpAndDown = false;
diff --git a/desmume/src/frontend/windows/inputdx.h b/desmume/src/frontend/windows/inputdx.h
index 5b23b2c3f..50611250d 100644
--- a/desmume/src/frontend/windows/inputdx.h
+++ b/desmume/src/frontend/windows/inputdx.h
@@ -158,10 +158,15 @@ struct SHCV1000 {
WORD SCANKEY;
};
+struct SSLIDECONTROLLER {
+ BOOL Enabled;
+};
+
extern SGuitar Guitar;
extern SPiano Piano;
extern SPaddle Paddle;
extern SHCV1000 HCV1000;
+extern SSLIDECONTROLLER SlideController;
#endif
diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp
index 5588ace62..be90abb41 100644
--- a/desmume/src/frontend/windows/main.cpp
+++ b/desmume/src/frontend/windows/main.cpp
@@ -1581,6 +1581,7 @@ static BOOL LoadROM(const char * filename, const char * physicalName, const char
Piano.Enabled = (selectedSlot2Type == NDS_SLOT2_EASYPIANO)?true:false;
Paddle.Enabled = (selectedSlot2Type == NDS_SLOT2_PADDLE)?true:false;
HCV1000.Enabled = (selectedSlot2Type == NDS_SLOT2_HCV1000)?true:false;
+ SlideController.Enabled = (selectedSlot2Type == NDS_SLOT2_SLIDECONTROLLER)?true:false;
LoadSaveStateInfo();
lagframecounter=0;
@@ -2132,6 +2133,13 @@ int _main()
exit(-1);
}
+ RAWINPUTDEVICE rid = {};
+ rid.usUsagePage = 0x01;
+ rid.usUsage = 0x02;
+ rid.dwFlags = 0;
+ rid.hwndTarget = MainWindow->getHWnd();
+ RegisterRawInputDevices(&rid, 1, sizeof(rid));
+
//disable wacky stylus stuff
//TODO - we are obliged to call GlobalDeleteAtom
GlobalAddAtom(MICROSOFT_TABLETPENSERVICE_PROPERTY);
@@ -2264,6 +2272,8 @@ int _main()
break;
case NDS_SLOT2_HCV1000:
break;
+ case NDS_SLOT2_SLIDECONTROLLER:
+ break;
default:
slot2_device_type = NDS_SLOT2_NONE;
break;
@@ -2275,6 +2285,7 @@ int _main()
Piano.Enabled = (slot2_device_type == NDS_SLOT2_EASYPIANO)?true:false;
Paddle.Enabled = (slot2_device_type == NDS_SLOT2_PADDLE)?true:false;
HCV1000.Enabled = (slot2_device_type == NDS_SLOT2_HCV1000)?true:false;
+ SlideController.Enabled = (slot2_device_type == NDS_SLOT2_SLIDECONTROLLER)?true:false;
CommonSettings.WifiBridgeDeviceID = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName);
@@ -4514,6 +4525,29 @@ DOKEYDOWN:
}
#endif
+ case WM_INPUT:
+ {
+ if (SlideController.Enabled)
+ {
+ UINT dataSize;
+ GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dataSize, sizeof(RAWINPUTHEADER));
+ LPBYTE rawdata = new BYTE[dataSize];
+ if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawdata, &dataSize, sizeof(RAWINPUTHEADER)) == dataSize)
+ {
+ RAWINPUT* raw = (RAWINPUT*)rawdata;
+ if (raw->header.dwType == RIM_TYPEMOUSE)
+ {
+ LONG xMotion = raw->data.mouse.lLastX;
+ LONG yMotion = raw->data.mouse.lLastY;
+ xMotion = max((LONG)-127, min(xMotion, (LONG)127));
+ yMotion = max((LONG)-127, min(yMotion, (LONG)127));
+ slideController_updateMotion(xMotion, -yMotion);
+ }
+ }
+ }
+ }
+ return 0;
+
case WM_COMMAND:
if(HIWORD(wParam) == 0 || HIWORD(wParam) == 1)
{
diff --git a/desmume/src/slot2.cpp b/desmume/src/slot2.cpp
index a947fe7b6..dd361aa08 100644
--- a/desmume/src/slot2.cpp
+++ b/desmume/src/slot2.cpp
@@ -59,18 +59,20 @@ void slot2_Init()
extern TISlot2InterfaceConstructor construct_Slot2_Paddle;
extern TISlot2InterfaceConstructor construct_Slot2_PassME;
extern TISlot2InterfaceConstructor construct_Slot2_HCV1000;
+ extern TISlot2InterfaceConstructor construct_Slot2_SlideController;
- slot2_List[NDS_SLOT2_NONE] = construct_Slot2_None();
- slot2_List[NDS_SLOT2_AUTO] = construct_Slot2_Auto();
- slot2_List[NDS_SLOT2_CFLASH] = construct_Slot2_CFlash();
- slot2_List[NDS_SLOT2_RUMBLEPAK] = construct_Slot2_RumblePak();
- slot2_List[NDS_SLOT2_GBACART] = construct_Slot2_GbaCart();
- slot2_List[NDS_SLOT2_GUITARGRIP] = construct_Slot2_GuitarGrip();
- slot2_List[NDS_SLOT2_EXPMEMORY] = construct_Slot2_ExpansionPak();
- slot2_List[NDS_SLOT2_EASYPIANO] = construct_Slot2_EasyPiano();
- slot2_List[NDS_SLOT2_PADDLE] = construct_Slot2_Paddle();
- slot2_List[NDS_SLOT2_PASSME] = construct_Slot2_PassME();
- slot2_List[NDS_SLOT2_HCV1000] = construct_Slot2_HCV1000();
+ slot2_List[NDS_SLOT2_NONE] = construct_Slot2_None();
+ slot2_List[NDS_SLOT2_AUTO] = construct_Slot2_Auto();
+ slot2_List[NDS_SLOT2_CFLASH] = construct_Slot2_CFlash();
+ slot2_List[NDS_SLOT2_RUMBLEPAK] = construct_Slot2_RumblePak();
+ slot2_List[NDS_SLOT2_GBACART] = construct_Slot2_GbaCart();
+ slot2_List[NDS_SLOT2_GUITARGRIP] = construct_Slot2_GuitarGrip();
+ slot2_List[NDS_SLOT2_EXPMEMORY] = construct_Slot2_ExpansionPak();
+ slot2_List[NDS_SLOT2_EASYPIANO] = construct_Slot2_EasyPiano();
+ slot2_List[NDS_SLOT2_PADDLE] = construct_Slot2_Paddle();
+ slot2_List[NDS_SLOT2_PASSME] = construct_Slot2_PassME();
+ slot2_List[NDS_SLOT2_HCV1000] = construct_Slot2_HCV1000();
+ slot2_List[NDS_SLOT2_SLIDECONTROLLER] = construct_Slot2_SlideController();
}
@@ -257,6 +259,7 @@ NDS_SLOT2_TYPE slot2_DetermineTypeByGameCode(const char *theGameCode)
{"C4A", NDS_SLOT2_HCV1000}, // Card de Asobu! Hajimete no DS
{"A6I", NDS_SLOT2_HCV1000}, // Kouchuu Ouja: Mushi King Super Collection
{"ALB", NDS_SLOT2_HCV1000}, // Oshare Majo Berry and Love
+ {"AGU", NDS_SLOT2_SLIDECONTROLLER}, // Slide Adventure MAGKID
};
for(size_t i = 0; i < ARRAY_SIZE(gameCodeDeviceTypes); i++)
diff --git a/desmume/src/slot2.h b/desmume/src/slot2.h
index 66f84f708..634c4048a 100644
--- a/desmume/src/slot2.h
+++ b/desmume/src/slot2.h
@@ -87,18 +87,19 @@ typedef ISlot2Interface* TISlot2InterfaceConstructor();
enum NDS_SLOT2_TYPE
{
- NDS_SLOT2_NONE, // 0xFF
- NDS_SLOT2_AUTO, // 0xFE - Auto-select
- NDS_SLOT2_CFLASH, // 0x01 - Compact flash
- NDS_SLOT2_RUMBLEPAK, // 0x02 - RumblePak
- NDS_SLOT2_GBACART, // 0x03 - GBA cartrindge in slot
- NDS_SLOT2_GUITARGRIP, // 0x04 - Guitar Grip
- NDS_SLOT2_EXPMEMORY, // 0x05 - Memory Expansion Pak
- NDS_SLOT2_EASYPIANO, // 0x06 - Easy Piano
- NDS_SLOT2_PADDLE, // 0x07 - Arkanoids DS paddle
- NDS_SLOT2_PASSME, // 0x08 - PassME/Homebrew
- NDS_SLOT2_HCV1000, // 0x09 - HCV-1000 Sega Card Reader
- NDS_SLOT2_COUNT // use for counter addons - MUST TO BE LAST!!!
+ NDS_SLOT2_NONE, // 0xFF
+ NDS_SLOT2_AUTO, // 0xFE - Auto-select
+ NDS_SLOT2_CFLASH, // 0x01 - Compact flash
+ NDS_SLOT2_RUMBLEPAK, // 0x02 - RumblePak
+ NDS_SLOT2_GBACART, // 0x03 - GBA cartrindge in slot
+ NDS_SLOT2_GUITARGRIP, // 0x04 - Guitar Grip
+ NDS_SLOT2_EXPMEMORY, // 0x05 - Memory Expansion Pak
+ NDS_SLOT2_EASYPIANO, // 0x06 - Easy Piano
+ NDS_SLOT2_PADDLE, // 0x07 - Arkanoids DS paddle
+ NDS_SLOT2_PASSME, // 0x08 - PassME/Homebrew
+ NDS_SLOT2_HCV1000, // 0x09 - HCV-1000 Sega Card Reader
+ NDS_SLOT2_SLIDECONTROLLER, // 0x0A - Slide Controller
+ NDS_SLOT2_COUNT // use for counter addons - MUST TO BE LAST!!!
};
extern ISlot2Interface* slot2_device; //the current slot2 device instance
@@ -160,4 +161,5 @@ extern void guitarGrip_setKey(bool green, bool red, bool yellow, bool blue); //
extern void piano_setKey(bool c, bool cs, bool d, bool ds, bool e, bool f, bool fs, bool g, bool gs, bool a, bool as, bool b, bool hic); //piano keys
extern void HCV1000_setReady();
extern void HCV1000_setBarcode(std::string barcode);
+extern void slideController_updateMotion(s8 x, s8 y);
#endif //__SLOT_H__