Slot2: Slide Controller - add rumble

Must be explicitly enabled by frontent
This commit is contained in:
windwakr 2023-10-11 22:14:58 -04:00
parent 3f708ff53f
commit 4add68c92e
5 changed files with 39 additions and 3 deletions

View File

@ -18,8 +18,6 @@
#include "../slot2.h"
void (*FeedbackON)(bool enable) = NULL;
class Slot2_RumblePak : public ISlot2Interface
{
private:

View File

@ -18,12 +18,14 @@
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
//Absolute barebones implementation of the Slide Controller add-on. Rumble is not implemented.
//Absolute barebones implementation of the Slide Controller add-on.
//The game does a bunch of mystery reads of various sizes which have not been investigated at all.
#include "../slot2.h"
#include "../emufile.h"
static bool rumbleEnable = false;
static u8 xDelta;
static u8 yDelta;
//Product ID, Revision ID, Motion status, X delta, Y delta, Surface quality
@ -38,6 +40,8 @@ static u8 scRegs[18] =
class Slot2_SlideController : public ISlot2Interface
{
private:
u8 old_rumble;
struct slideControllerSerial
{
u16 in_data;
@ -51,6 +55,10 @@ private:
void slideCon_reset()
{
old_rumble = 0;
if (FeedbackON)
FeedbackON(false);
xDelta = 0;
yDelta = 0;
@ -76,6 +84,14 @@ private:
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 && rumbleEnable && (old_rumble != rumble))
{
old_rumble = rumble;
FeedbackON(rumble);
}
switch (slideCon.state)
{
@ -175,6 +191,12 @@ public:
slideCon_reset();
}
virtual void disconnect()
{
if (FeedbackON)
FeedbackON(false);
}
virtual void writeWord(u8 PROCNUM, u32 addr, u16 val)
{
if (addr == 0x081E0000)
@ -240,6 +262,10 @@ public:
is.read_u8(slideCon.reg_sel);
is.read_u8(slideCon.tmp);
}
old_rumble = 0;
if (FeedbackON)
FeedbackON(false);
}
};
@ -253,3 +279,10 @@ void slideController_updateMotion(s8 x, s8 y)
yDelta = (u8)y;
}
}
void slideController_rumbleEnable(bool enable)
{
rumbleEnable = enable;
if (FeedbackON && (enable == false))
FeedbackON(false);
}

View File

@ -2211,6 +2211,8 @@ int _main()
slot2_HCV1000_barcode = GetPrivateProfileStdString("Slot2.HCV1000", "barcode", "").substr(0, 16);
HCV1000_setBarcode(slot2_HCV1000_barcode);
slideController_rumbleEnable(GetPrivateProfileBool("Slot2.SlideController", "rumble", false, IniName));
cmdline.process_addonCommands();
WIN_InstallCFlash();
WIN_InstallGBACartridge();

View File

@ -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;

View File

@ -162,4 +162,5 @@ extern void piano_setKey(bool c, bool cs, bool d, bool ds, bool e, bool f, bool
extern void HCV1000_setReady();
extern void HCV1000_setBarcode(std::string barcode);
extern void slideController_updateMotion(s8 x, s8 y);
extern void slideController_rumbleEnable(bool enable);
#endif //__SLOT_H__