sdlports: fix bizarre occasional touchpad failure

This commit is contained in:
zeromus 2010-01-20 06:54:57 +00:00
parent b395a819e1
commit c3bd9cd6e4
2 changed files with 30 additions and 15 deletions

View File

@ -3639,6 +3639,9 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val)
}
return;
case REG_EXTKEYIN: //readonly
return;
case REG_POWCNT2:
{
@ -4107,12 +4110,20 @@ u16 FASTCALL _MMU_ARM7_read16(u32 adr)
return MMU.AUX_SPI_CNT;
case REG_KEYINPUT:
case REG_EXTKEYIN:
//here is an example of what not to do:
//since the arm7 polls this every frame, we shouldnt count this as an input check
//since the arm7 polls this (and EXTKEYIN) every frame, we shouldnt count this as an input check
//LagFrameFlag=0;
break;
case REG_EXTKEYIN:
{
//this is gross. we should generate this whole reg instead of poking it in ndssystem
u16 ret = MMU.ARM7_REG[0x136];
if(nds.isTouch) ret &= ~64;
else ret |= 64;
return ret;
}
case REG_POSTFLG:
return 1;
}

View File

@ -24,14 +24,13 @@
#include "saves.h"
#include "SPU.h"
#include "commandline.h"
#include "NDSSystem.h"
u16 keyboard_cfg[NB_KEYS];
u16 joypad_cfg[NB_KEYS];
u16 nbr_joy;
mouse_status mouse;
extern volatile BOOL execute;
static SDL_Joystick **open_joysticks = NULL;
/* Keypad key names */
@ -299,17 +298,22 @@ void set_mouse_coord(signed long x,signed long y)
/* Update NDS keypad */
void update_keypad(u16 keys)
{
#ifdef WORDS_BIGENDIAN
MMU.ARM9_REG[0x130] = ~keys & 0xFF;
MMU.ARM9_REG[0x131] = (~keys >> 8) & 0x3;
MMU.ARM7_REG[0x130] = ~keys & 0xFF;
MMU.ARM7_REG[0x131] = (~keys >> 8) & 0x3;
#else
((u16 *)MMU.ARM9_REG)[0x130>>1] = ~keys & 0x3FF;
((u16 *)MMU.ARM7_REG)[0x130>>1] = ~keys & 0x3FF;
#endif
/* Update X and Y buttons */
MMU.ARM7_REG[0x136] = ( ~( keys >> 10) & 0x3 ) | (MMU.ARM7_REG[0x136] & ~0x3);
NDS_beginProcessingInput();
UserButtons& input = NDS_getProcessingUserInput().buttons;
input.G = (keys>>12)&1;
input.E = (keys>>8)&1;
input.W = (keys>>9)&1;
input.X = (keys>>10)&1;
input.Y = (keys>>11)&1;
input.A = (keys>>0)&1;
input.S = (keys>>3)&1;
input.T = (keys>>2)&1;
input.U = (keys>>6)&1;
input.D = (keys>>7)&1;
input.L = (keys>>5)&1;
input.R = (keys>>4)&1;
input.F = 0;
NDS_endProcessingInput();
}
/* Retrieve current NDS keypad */