make slot2 addons more realistic, and add xinput rumble support

This commit is contained in:
zeromus 2010-08-10 01:55:43 +00:00
parent cc38aeeef8
commit 9248e9454b
6 changed files with 49 additions and 64 deletions

View File

@ -1,5 +1,4 @@
/* Copyright (C) 2009 CrazyMax /* Copyright (C) 2009-2010 DeSmuME team
Copyright (C) 2009 DeSmuME team
This file is part of DeSmuME This file is part of DeSmuME
@ -38,20 +37,18 @@ static u8 guitarGrip_read08(u32 adr)
{ {
//INFO("GuitarGrip: read 08 at 0x%08X\n", adr); //INFO("GuitarGrip: read 08 at 0x%08X\n", adr);
if (adr == 0x0A000000) return (~guitarKeyStatus); if (adr == 0x0A000000) return (~guitarKeyStatus);
return (0xFF); else if(adr&1) return 0xFF;
else return 0xF9;
} }
static u16 guitarGrip_read16(u32 adr) static u16 guitarGrip_read16(u32 adr)
{ {
//INFO("GuitarGrip: read 16 at 0x%08X\n", adr); //INFO("GuitarGrip: read 16 at 0x%08X\n", adr);
if (adr == 0x080000BE) return (0xF9FF); return 0xF9FF;
if (adr == 0x0801FFFE) return (0xF9FF);
return (0xFFFF);
} }
static u32 guitarGrip_read32(u32 adr) static u32 guitarGrip_read32(u32 adr)
{ {
//INFO("GuitarGrip: read 32 at 0x%08X\n", adr); //INFO("GuitarGrip: read 32 at 0x%08X\n", adr);
return (0xFFFFFFFF); return (0xF9FFF9FF);
} }
static void guitarGrip_info(char *info) { strcpy(info, "Guitar Grip for Guitar Hero games"); } static void guitarGrip_info(char *info) { strcpy(info, "Guitar Grip for Guitar Hero games"); }

View File

@ -1,4 +1,5 @@
/* Copyright (C) 2009-2010 DeSmuME team /* Copyright (C) 2009 CrazyMax
Copyright (C) 2009 DeSmuME team
This file is part of DeSmuME This file is part of DeSmuME
@ -17,9 +18,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <string.h>
#include "../addons.h" #include "../addons.h"
#include "../NDSSystem.h" #include <string.h>
static BOOL None_init(void) { return (TRUE); } static BOOL None_init(void) { return (TRUE); }
static void None_reset(void) {} static void None_reset(void) {}
@ -28,40 +28,9 @@ static void None_config(void) {}
static void None_write08(u32 adr, u8 val) {} static void None_write08(u32 adr, u8 val) {}
static void None_write16(u32 adr, u16 val) {} static void None_write16(u32 adr, u16 val) {}
static void None_write32(u32 adr, u32 val) {} static void None_write32(u32 adr, u32 val) {}
static u8 None_read08(u32 adr) static u8 None_read08(u32 adr){ return (0xFF); }
{ static u16 None_read16(u32 adr){ return (0xFFFF); }
if (adr > 0x09FFFFFF) static u32 None_read32(u32 adr){ return (0xFFFFFFFF); }
{
if ((adr & 0x0000FFFF) > MMU_new.backupDevice.data.size()) return 0xFF;
return MMU_new.backupDevice.data[adr & 0x0000FFFF];
}
if ((adr - 0x08000000) > gameInfo.romsize) return 0xFF;
return T1ReadByte((u8*)gameInfo.romdata, adr - 0x08000000);
}
static u16 None_read16(u32 adr)
{
if (adr > 0x09FFFFFF)
{
if ((adr & 0x0000FFFF) > MMU_new.backupDevice.data.size()) return 0xFFFF;
return (u16)MMU_new.backupDevice.data[adr & 0x0000FFFF];
}
if ((adr - 0x08000000) > gameInfo.romsize) return 0xFFFF;
return T1ReadWord((u8*)gameInfo.romdata, adr - 0x08000000);
}
static u32 None_read32(u32 adr)
{
if (adr > 0x09FFFFFF)
{
if ((adr & 0x0000FFFF) > MMU_new.backupDevice.data.size()) return 0xFFFFFFFF;
return (u32)MMU_new.backupDevice.data[adr & 0x0000FFFF];
}
if ((adr - 0x08000000) > gameInfo.romsize) return 0xFFFFFFFF;
return T1ReadLong((u8*)gameInfo.romdata, adr - 0x08000000);
}
static void None_info(char *info) { strcpy(info, "Nothing in GBA slot"); } static void None_info(char *info) { strcpy(info, "Nothing in GBA slot"); }
ADDONINTERFACE addonNone = { ADDONINTERFACE addonNone = {

View File

@ -46,7 +46,7 @@ static void piano_write32(u32 adr, u32 val)
extern int currFrameCounter; extern int currFrameCounter;
static u8 piano_read08(u32 adr) static u8 piano_read08(u32 adr)
{ {
//INFO("piano: read 08 at 0x%08X\n", adr); //printf("piano: read 08 at 0x%08X\n", adr);
//the actual keyboard output //the actual keyboard output
@ -75,22 +75,18 @@ static u8 piano_read08(u32 adr)
if(adr == 0x09FFFFFE) return ~(pianoKeyStatus&0xFF); if(adr == 0x09FFFFFE) return ~(pianoKeyStatus&0xFF);
if(adr == 0x09FFFFFF) return ~((pianoKeyStatus>>8)&0xFF); if(adr == 0x09FFFFFF) return ~((pianoKeyStatus>>8)&0xFF);
return (0xFF); if(adr&1) return 0x07;
else return 0x00;
} }
static u16 piano_read16(u32 adr) static u16 piano_read16(u32 adr)
{ {
//LOG("piano: read 16 at 0x%08X\n", adr); //printf("piano: read 16 at 0x%08X\n", adr);
return 0x07FF;
//sufficient for the device to be identified
if(adr == 0x080000BE) return (0x07FF);
if(adr == 0x0801FFFE) return (0x07FF);
return (0xFFFF);
} }
static u32 piano_read32(u32 adr) static u32 piano_read32(u32 adr)
{ {
//LOG("piano: read 32 at 0x%08X\n", adr); //printf("piano: read 32 at 0x%08X\n", adr);
return (0xFFFFFFFF); return 0x07FF07FF;
} }
static void piano_info(char *info) { strcpy(info, "Piano for EasyPiano"); } static void piano_info(char *info) { strcpy(info, "Piano for EasyPiano"); }

View File

@ -1,5 +1,4 @@
/* Copyright (C) 2009 CrazyMax /* Copyright (C) 2009-2010 DeSmuME team
Copyright (C) 2009 DeSmuME team
This file is part of DeSmuME This file is part of DeSmuME
@ -65,20 +64,18 @@ static void RumblePak_write32(u32 adr, u32 val)
static u8 RumblePak_read08(u32 adr) static u8 RumblePak_read08(u32 adr)
{ {
return (0xFF); if(adr&1) return 0xFF;
else return 0xFD;
} }
static u16 RumblePak_read16(u32 adr) static u16 RumblePak_read16(u32 adr)
{ {
u16 val = ( (adr & 0x1FFFF) >> 1 ) & 0xFFFD; return 0xFFFD;
if (adr == 0x0801FFFE) val = 0x005D; // hack!!! anybody have docs for RumblePak?
return ((u16)val);
} }
static u32 RumblePak_read32(u32 adr) static u32 RumblePak_read32(u32 adr)
{ {
return (0xFFFFFFFF); return 0xFFFDFFFD;
} }
static void RumblePak_info(char *info) static void RumblePak_info(char *info)

View File

@ -2444,6 +2444,8 @@ void S9xWinScanJoypads ()
////#endif ////#endif
//} //}
#include "directx/xinput.h"
void input_feedback(BOOL enable) void input_feedback(BOOL enable)
{ {
@ -2459,6 +2461,30 @@ void input_feedback(BOOL enable)
else else
JoystickF[C].pEffect->Stop(); JoystickF[C].pEffect->Stop();
} }
//use xinput if it is available!!
//but try lazy initializing xinput so that the dll is not required
{
static DWORD ( WINAPI *_XInputSetState)(DWORD,XINPUT_VIBRATION*) = NULL;
static bool xinput_tried = false;
if(!xinput_tried)
{
xinput_tried = true;
HMODULE lib = LoadLibrary("xinput1_3.dll");
if(lib)
{
_XInputSetState = (DWORD (WINAPI *)(DWORD,XINPUT_VIBRATION*))GetProcAddress(lib,"XInputSetState");
}
}
if(_XInputSetState)
{
XINPUT_VIBRATION vib;
vib.wLeftMotorSpeed = enable?65535:0;
vib.wRightMotorSpeed = enable?65535:0;
for(int i=0;i<4;i++)
_XInputSetState(0,&vib);
}
}
} }