diff --git a/desmume/src/Makefile.am b/desmume/src/Makefile.am
index 971611eea..fefbb4eff 100644
--- a/desmume/src/Makefile.am
+++ b/desmume/src/Makefile.am
@@ -95,6 +95,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_rumblepak.cpp b/desmume/src/addons/slot2_rumblepak.cpp
index e4c471900..e76c28127 100644
--- a/desmume/src/addons/slot2_rumblepak.cpp
+++ b/desmume/src/addons/slot2_rumblepak.cpp
@@ -18,8 +18,6 @@
#include "../slot2.h"
-void (*FeedbackON)(bool enable) = NULL;
-
class Slot2_RumblePak : public ISlot2Interface
{
private:
diff --git a/desmume/src/addons/slot2_slideController.cpp b/desmume/src/addons/slot2_slideController.cpp
new file mode 100644
index 000000000..5e09ea18d
--- /dev/null
+++ b/desmume/src/addons/slot2_slideController.cpp
@@ -0,0 +1,277 @@
+//Serial handling code heavily inspired by the Magic Reader code in GBE+
+//https://github.com/shonumi/gbe-plus/blob/7986317958a672d72ff54ea33f31bcca13cf8330/src/nds/slot2.cpp#L155
+
+/*
+ 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.
+
+#include "../slot2.h"
+#include "../emufile.h"
+
+static u8 delta_x;
+static u8 delta_y;
+//Product ID, Revision ID, Motion status, X delta, Y delta, Surface quality
+//Average pixel, Maximum pixel, Reserved, Reserved, Configuration, Reserved
+//Data out lower, Data out upper, Shutter lower, Shutter upper, Frame period lower, Frame period upper
+static u8 sc_regs[18] =
+{ 0x03, 0x20, 0x00, 0x00, 0x00, 0x80,
+ 0x20, 0x3F, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x64, 0x00, 0x20, 0xD1
+};
+
+class Slot2_SlideController : public ISlot2Interface
+{
+private:
+ u8 old_rumble;
+
+ struct
+ {
+ u16 in_data;
+ u16 out_data;
+ u8 counter;
+ u8 state;
+ u8 sck;
+ u8 reg_sel;
+ u8 tmp;
+ } slideCon = {};
+
+ void slideCon_reset()
+ {
+ delta_x = 0;
+ delta_y = 0;
+
+ old_rumble = 0;
+ if (FeedbackON)
+ FeedbackON(false);
+
+ slideCon.in_data = 0;
+ slideCon.out_data = 0;
+ slideCon.counter = 0;
+ slideCon.state = 0;
+ slideCon.sck = 0;
+ slideCon.reg_sel = 0;
+ slideCon.tmp = 0;
+
+ sc_regs[0x02] = 0x00; //Motion status
+ sc_regs[0x03] = 0x00; //X delta
+ sc_regs[0x04] = 0x00; //Y delta
+ sc_regs[0x0A] = 0x00; //Config bits
+ sc_regs[0x10] = 0x20; //Frame period lower
+ sc_regs[0x11] = 0xD1; //Frame period upper
+ }
+
+ void slideCon_process()
+ {
+ //Serial clock in bit 1
+ u8 new_sck = (slideCon.in_data & 0x2) >> 1;
+ //Serial data in bit 0
+ u8 sd = slideCon.in_data & 0x1;
+ //Rumble in bit 8
+ u8 rumble = (slideCon.in_data & 0x100) >> 8;
+
+ if (FeedbackON && (old_rumble != rumble))
+ {
+ old_rumble = rumble;
+ FeedbackON(rumble);
+ }
+
+ switch (slideCon.state)
+ {
+ case 0: //Reg select
+ //Build reg select byte
+ if ((slideCon.sck == 0) && (new_sck == 1) && (slideCon.counter < 8))
+ {
+ slideCon.reg_sel = (slideCon.reg_sel << 1) | sd;
+ slideCon.counter++;
+ }
+ else if (slideCon.counter == 8)
+ {
+ //Check if it's a read or a write by MSB
+ if (slideCon.reg_sel & 0x80)
+ {
+ slideCon.state = 1;
+ slideCon.reg_sel &= 0x7F;
+ slideCon.tmp = 0;
+ }
+ else
+ {
+ slideCon.state = 2;
+
+ if (slideCon.reg_sel == 0x02)
+ {
+ //Set motion flag if there has been movement
+ if (delta_x || delta_y)
+ sc_regs[0x02] |= 0x80;
+ //Freeze motion deltas
+ sc_regs[0x03] = delta_x;
+ sc_regs[0x04] = delta_y;
+ delta_x = delta_y = 0;
+ }
+ }
+ slideCon.counter = 0;
+ }
+ break;
+ case 1: //Write reg
+ if ((slideCon.sck == 0) && (new_sck == 1) && (slideCon.counter < 8))
+ {
+ slideCon.tmp = (slideCon.tmp << 1) | sd;
+ slideCon.counter++;
+ }
+ else if ((slideCon.sck == 0) && (new_sck == 0) && (slideCon.counter == 8))
+ {
+ //printf("SLIDECON WRITE REG: %02X = %02X\n", slideCon.reg_sel, slideCon.tmp);
+ slideCon.state = 0;
+ slideCon.counter = 0;
+
+ if (slideCon.reg_sel <= 0x11)
+ sc_regs[slideCon.reg_sel] = slideCon.tmp;
+ }
+ break;
+ case 2: //Read reg
+ if ((slideCon.sck == 0) && (new_sck == 1) && (slideCon.counter < 8))
+ {
+ if (slideCon.reg_sel <= 0x11)
+ slideCon.out_data = (sc_regs[slideCon.reg_sel] >> (7 - slideCon.counter)) & 1;
+ else
+ slideCon.out_data = 0;
+ slideCon.counter++;
+ }
+ else if ((slideCon.sck == 0) && (new_sck == 0) && (slideCon.counter == 8))
+ {
+ //printf("SLIDECON READ REG: %02X = %02X\n", slideCon.reg_sel, sc_regs[slideCon.reg_sel]);
+ slideCon.state = 0;
+ slideCon.counter = 0;
+
+ //Reset motion flag if reg was motion status
+ if (slideCon.reg_sel == 0x02)
+ sc_regs[0x02] &= 0x7F;
+ //Reset motion deltas if they were read
+ if ((slideCon.reg_sel == 0x03) || (slideCon.reg_sel == 0x04))
+ sc_regs[slideCon.reg_sel] = 0x00;
+ }
+ break;
+ }
+
+ slideCon.sck = new_sck;
+
+ if (sc_regs[0x0A] & 0x80) //Reset
+ {
+ slideCon_reset();
+ }
+ }
+
+public:
+
+ virtual Slot2Info const* info()
+ {
+ static Slot2InfoSimple info("Slide Controller", "Slide Controller add-on", 0x0A);
+ return &info;
+ }
+
+ virtual void connect()
+ {
+ slideCon_reset();
+ }
+
+ virtual void disconnect()
+ {
+ if (FeedbackON)
+ FeedbackON(false);
+ }
+
+ virtual void writeWord(u8 PROCNUM, u32 addr, u16 val)
+ {
+ if (addr == 0x081E0000)
+ {
+ slideCon.in_data = val;
+ slideCon_process();
+ }
+ }
+
+ virtual u8 readByte(u8 PROCNUM, u32 addr)
+ {
+ if (addr == 0x080000B2)
+ return 0x96;
+ else
+ return 0xFF;
+ }
+
+ virtual u16 readWord(u8 PROCNUM, u32 addr)
+ {
+ u16 outWord = 0xFFFF;
+
+ if (addr < 0x08000100)
+ outWord = 0xFEF0;
+ else if (addr == 0x081E0000)
+ outWord = slideCon.out_data;
+
+ return outWord;
+ }
+
+ virtual u32 readLong(u8 PROCNUM, u32 addr) { return 0xFEF0FEF0; }
+
+ virtual void savestate(EMUFILE& os)
+ {
+ s32 version = 0;
+ os.write_32LE(version);
+
+ os.write_u8(delta_x);
+ os.write_u8(delta_y);
+ for (int i = 0; i < 18; i++)
+ os.write_u8(sc_regs[i]);
+ os.write_16LE(slideCon.in_data);
+ os.write_16LE(slideCon.out_data);
+ os.write_u8(slideCon.counter);
+ os.write_u8(slideCon.state);
+ os.write_u8(slideCon.sck);
+ os.write_u8(slideCon.reg_sel);
+ os.write_u8(slideCon.tmp);
+ }
+
+ virtual void loadstate(EMUFILE& is)
+ {
+ s32 version = is.read_s32LE();
+
+ if (version == 0)
+ {
+ is.read_u8(delta_x);
+ is.read_u8(delta_y);
+ for (int i = 0; i < 18; i++)
+ sc_regs[i] = is.read_u8();
+ is.read_16LE(slideCon.in_data);
+ is.read_16LE(slideCon.out_data);
+ is.read_u8(slideCon.counter);
+ is.read_u8(slideCon.state);
+ is.read_u8(slideCon.sck);
+ is.read_u8(slideCon.reg_sel);
+ is.read_u8(slideCon.tmp);
+ }
+
+ old_rumble = 0;
+ if (FeedbackON)
+ FeedbackON(false);
+ }
+};
+
+ISlot2Interface* construct_Slot2_SlideController() { return new Slot2_SlideController(); }
+
+void slideController_updateMotion(s8 x, s8 y)
+{
+ delta_x = (u8)x;
+ delta_y = (u8)y;
+}
diff --git a/desmume/src/frontend/interface/meson.build b/desmume/src/frontend/interface/meson.build
index 04c31a2af..33ddd0c9b 100644
--- a/desmume/src/frontend/interface/meson.build
+++ b/desmume/src/frontend/interface/meson.build
@@ -116,7 +116,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 7da01eb2f..58b0e7ebe 100644
--- a/desmume/src/frontend/posix/Makefile.am
+++ b/desmume/src/frontend/posix/Makefile.am
@@ -97,7 +97,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 77e6f62c2..5adb795ff 100644
--- a/desmume/src/frontend/posix/meson.build
+++ b/desmume/src/frontend/posix/meson.build
@@ -108,7 +108,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 b3db20f51..d040ff5f2 100644
--- a/desmume/src/frontend/windows/inputdx.cpp
+++ b/desmume/src/frontend/windows/inputdx.cpp
@@ -268,6 +268,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 659c30ddc..63a1959ae 100644
--- a/desmume/src/frontend/windows/main.cpp
+++ b/desmume/src/frontend/windows/main.cpp
@@ -1580,6 +1580,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,14 @@ int _main()
exit(-1);
}
+ //Raw input for the Slide Controller add-on
+ RAWINPUTDEVICE Rid[1];
+ Rid[0].usUsagePage = 0x01;
+ Rid[0].usUsage = 0x02;
+ Rid[0].dwFlags = 0x00;
+ Rid[0].hwndTarget = MainWindow->getHWnd();
+ RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]));
+
//disable wacky stylus stuff
//TODO - we are obliged to call GlobalDeleteAtom
GlobalAddAtom(MICROSOFT_TABLETPENSERVICE_PROPERTY);
@@ -2264,6 +2273,8 @@ int _main()
break;
case NDS_SLOT2_HCV1000:
break;
+ case NDS_SLOT2_SLIDECONTROLLER:
+ break;
default:
slot2_device_type = NDS_SLOT2_NONE;
break;
@@ -2275,6 +2286,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 +4526,30 @@ DOKEYDOWN:
}
#endif
+ case WM_INPUT:
+ {
+ if (SlideController.Enabled)
+ {
+ UINT dwSize = sizeof(RAWINPUT);
+ static BYTE lpb[sizeof(RAWINPUT)];
+
+ GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER));
+
+ RAWINPUT* raw = (RAWINPUT*)lpb;
+
+ if (raw->header.dwType == RIM_TYPEMOUSE)
+ {
+ int xMotion = raw->data.mouse.lLastX;
+ int yMotion = raw->data.mouse.lLastY;
+ xMotion = max(-127, min(xMotion, 127));
+ yMotion = max(-127, min(yMotion, 127));
+ slideController_updateMotion(xMotion, -yMotion);
+ }
+ return 0;
+ }
+ }
+ break;
+
case WM_COMMAND:
if(HIWORD(wParam) == 0 || HIWORD(wParam) == 1)
{
diff --git a/desmume/src/slot2.cpp b/desmume/src/slot2.cpp
index a947fe7b6..2ab33753f 100644
--- a/desmume/src/slot2.cpp
+++ b/desmume/src/slot2.cpp
@@ -33,6 +33,8 @@ std::string CFlash_Path;
std::string GBACartridge_RomPath;
std::string GBACartridge_SRAMPath;
+void (*FeedbackON)(bool enable) = NULL;
+
ISlot2Interface* slot2_List[NDS_SLOT2_COUNT] = {0};
ISlot2Interface* slot2_device = NULL;
@@ -59,18 +61,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 +261,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__