From bd5933dd680da30271d20a360bc1fe207d8ff06c Mon Sep 17 00:00:00 2001 From: ugetab Date: Thu, 13 May 2010 21:08:37 +0000 Subject: [PATCH] Further optimization, now that I know the code functions and have something to fall back to if I mess up. --- src/drivers/win/input.cpp | 54 +++++++++++++++++++++++++++++++++- src/drivers/win/input.h | 1 + src/drivers/win/keyboard.cpp | 56 ------------------------------------ src/fceu.cpp | 3 -- src/video.cpp | 14 +++++++-- 5 files changed, 65 insertions(+), 63 deletions(-) diff --git a/src/drivers/win/input.cpp b/src/drivers/win/input.cpp index effef0dc..b6a2d1aa 100644 --- a/src/drivers/win/input.cpp +++ b/src/drivers/win/input.cpp @@ -170,6 +170,59 @@ int GetAutoFireDesynch() return DesynchAutoFire; } +// Test button state using current keyboard data. +// Clone of DTestButton, but uses local variables. +int DTestButtonImmediate(ButtConfig *bc) +{ + uint32 x;//mbg merge 7/17/06 changed to uint + + static unsigned int *keys_im=GetKeyboard_nr(); + + for(x=0;xNumC;x++) + { + if(bc->ButtType[x]==BUTTC_KEYBOARD) + { + if(keys_im[bc->ButtonNum[x]]) + { + return(1); + } + } + } + if(DTestButtonJoy(bc)) return(1); // Needs joystick.h. Tested with PPJoy mapped with Print Screen + return(0); +} + +uint32 GetGamepadPressedImmediate() +{ + // Get selected joypad buttons, ignoring NES polling + // Basically checks for immediate gamepad input. + //extern ButtConfig GamePadConfig[4][10]; + //extern int allowUDLR; + + uint32 JSButtons=0; + int x; + int wg; + + for(wg=0;wg<4;wg++) + { + + for(x=0;x<8;x++) + if(DTestButtonImmediate(&GamePadConfig[wg][x])) + JSButtons|=(1<NumC;x++) - { - if(bc->ButtType[x]==BUTTC_KEYBOARD) - { - if(keys_nr[bc->ButtonNum[x]]) - { - return(1); - } - } - } - if(DTestButtonJoy(bc)) return(1); // Needs joystick.h. Tested with PPJoy mapped with Print Screen - return(0); -} - -uint32 GetGamepadPressedImmediate() -{ - // Get selected joypad buttons, ignoring NES polling - // Basically checks for immediate gamepad input. - extern ButtConfig GamePadConfig[4][10]; - extern int allowUDLR; - - uint32 JSButtons=0; - int x; - int wg; - - for(wg=0;wg<4;wg++) - { - - for(x=0;x<8;x++) - if(DTestButtonImmediate(&GamePadConfig[wg][x])) - JSButtons|=(1<> (controller * 8); - extern uint32 JSImmediate; - // This doesn't work in anything except windows for now. // It doesn't get set anywhere in other ports. - ci = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0:JSImmediate >> (controller * 8); +#ifdef WIN32 + ci = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0:GetGamepadPressedImmediate() >> (controller * 8); +#else + // Put other port info here + ci = 0; +#endif c &= 255; ci &= 255;