static void UpdateGamepad(void) { static int rapid = 0; uint32 JS = 0; int x; int wg; rapid = (rapid + 1) & 3; for (wg = 0; wg < 4; wg++) { for (x = 0; x < 8; x++) if (DTestButton(&GamePadConfig[wg][x])) JS |= (1 << x) << (wg << 3); if (rapid & 2) for (x = 0; x < 2; x++) if (DTestButton(&GamePadConfig[wg][8 + x])) JS |= (1 << x) << (wg << 3); } for (x = 0; x < 32; x += 8) { /* Now, test to see if anything weird(up+down at same time) is happening, and correct */ if ((JS & (0xC0 << x)) == (0xC0 << x)) JS &= ~(0xC0 << x); if ((JS & (0x30 << x)) == (0x30 << x)) JS &= ~(0x30 << x); } JSreturn = JS; }
static void UpdateGamepad(void) { if(FCEUI_IsMovieActive()<0) return; static int rapid=0; uint32 JS=0; int x; int wg; rapid^=1; for(wg=0;wg<4;wg++) { for(x=0;x<8;x++) if(DTestButton(&GamePadConfig[wg][x])) JS|=(1<<x)<<(wg<<3); if(rapid) for(x=0;x<2;x++) if(DTestButton(&GamePadConfig[wg][8+x])) JS|=(1<<x)<<(wg<<3); } // for(x=0;x<32;x+=8) /* Now, test to see if anything weird(up+down at same time) // is happening, and correct */ // { // if((JS & (0xC0<<x) ) == (0xC0<<x) ) JS&=~(0xC0<<x); // if((JS & (0x30<<x) ) == (0x30<<x) ) JS&=~(0x30<<x); // } JSreturn=JS; }
static void UpdateTopRider(void) { int x; TopRiderData = 0; for (x = 0; x < 8; x++) if (DTestButton(&TopRiderButtons[x])) TopRiderData |= 1 << x; }
static void UpdateGamepad(void) { static int rapid=0; uint32 JS=0; // WHAT THE F**K does js stand for? A bitvector that holds the states of all buttons on all controllers (4 controllers x 8 buttons) int x; int wg; // WHAT THE F**K DOES WG STAND FOR?? (I think it stands for "which gamepad." Yeah that's obvious.) rapid ^= 1; for(wg=0; wg<4; wg++) // 4 controllers { for(x=0; x<8; x++) // 8 buttons per controller { if(DTestButton(&GamePadConfig[wg][x])) // Test each button on each controller { JS |= (1<<x) << (wg<<3); // A bitvector that holds the states of all buttons on all controllers (4 controllers x 8 buttons) } } if(rapid) { for(x=0; x<2; x++) { if(DTestButton(&GamePadConfig[wg][8+x])) { JS |= (1<<x) << (wg<<3); } } } } for(x=0; x<32; x+=8) // Test to see if anything weird (up+down at same time) is happening, and correct { if( (JS&(0xC0<<x)) == 0xC0<<x ) { JS &=~ (0xC0<<x); } if( (JS&(0x30<<x)) == 0x30<<x ) { JS &=~ (0x30<<x); } } JSreturn = JS; // Don't return, just manipulate the global }
static void UpdateMahjong(void) { int x; MahjongData = 0; for (x = 0; x < 21; x++) { if (DTestButton(&MahjongButtons[x])) MahjongData |= 1 << x; } }
static void UpdateHyperShot(void) { int x; HyperShotData = 0; for (x = 0; x < 0x4; x++) { if (DTestButton(&HyperShotButtons[x])) HyperShotData |= 1 << x; } }
static void UpdateFTrainer(void) { int x; FTrainerData = 0; for (x = 0; x < 12; x++) { if (DTestButton(&FTrainerButtons[x])) FTrainerData |= 1 << x; } }
static void UpdateQuizKing(void) { int x; QuizKingData = 0; for (x = 0; x < 6; x++) { if (DTestButton(&QuizKingButtons[x])) QuizKingData |= 1 << x; } }
static void UpdateSuborKB(void) { int x; for (x = 0; x < sizeof(suborkbkeys); x++) { suborkbkeys[x] = 0; if (DTestButton(&suborkbmap[x])) suborkbkeys[x] = 1; } }
static void UpdateFKB(void) { int x; for (x = 0; x < sizeof(fkbkeys); x++) { fkbkeys[x] = 0; if (DTestButton(&fkbmap[x])) fkbkeys[x] = 1; } }
static uint32 UpdatePPadData(int w) { uint32 r = 0; ButtConfig *ppadtsc = powerpadsc[w]; int x; for (x = 0; x < 12; x++) if (DTestButton(&ppadtsc[x])) r |= 1 << x; return r; }
static uint32 UpdatePPadData(int w) { if(FCEUI_IsMovieActive()<0) return; uint32 r=0; ButtConfig *ppadtsc=powerpadsc[w]; int x; for(x=0;x<12;x++) if(DTestButton(&ppadtsc[x])) r|=1<<x; return r; }
void UpdateGamepad(bool snes) { if(FCEUMOV_Mode(MOVIEMODE_PLAY)) return; int JS=0; if(FCEUMOV_Mode(MOVIEMODE_RECORD)) AutoFire(); for(int wg=0;wg<4;wg++) { int wgs = wg; if(snes) { JS = 0; wgs = 0; for(int x=0;x<12;x++) if(DTestButton(&GamePadConfig[wg][x])) JS|=(1<<x)<<(wgs<<3); //printf("%d %d\n",wg,JS); //useful debugging } else { for(int x=0;x<8;x++) if(DTestButton(&GamePadConfig[wg][x])) JS|=(1<<x)<<(wgs<<3); } // Check if U+D/L+R is disabled //TODO: how does this affect snes pads? if(!allowUDLR) { for(int x=0;x<32;x+=8) { if((JS & (0xC0<<x) ) == (0xC0<<x) ) JS&=~(0xC0<<x); if((JS & (0x30<<x) ) == (0x30<<x) ) JS&=~(0x30<<x); } } // if(rapidAlternator) if(!snes) { for(int x=0;x<2;x++) if(DTestButton(&GamePadConfig[wg][8+x])) JS|=((1<<x)<<(wgs<<3))*(rapidAlternator^(x*DesynchAutoFire)); } if(snes) { snespad_return[wg] = JS; //printf("%d %d\n",wg,JS); } } if(autoHoldOn) { if(autoHoldRefire) { autoHoldRefire--; if(!autoHoldRefire) JSAutoHeldAffected = 0; } for(int wg=0;wg<4;wg++) for(int x=0;x<8;x++) if(DTestButton(&GamePadConfig[wg][x])) { if(!autoHoldRefire || !(JSAutoHeldAffected&(1<<x)<<(wg<<3))) { JSAutoHeld^=(1<<x)<<(wg<<3); JSAutoHeldAffected|=(1<<x)<<(wg<<3); autoHoldRefire = 192; } } char inputstr [41]; int disppos=38; { uint32 c = JSAutoHeld; sprintf(inputstr, "1%c%c%c%c%c%c%c%c 2%c%c%c%c%c%c%c%c\n3%c%c%c%c%c%c%c%c 4%c%c%c%c%c%c%c%c", (c&0x40)?'<':' ', (c&0x10)?'^':' ', (c&0x80)?'>':' ', (c&0x20)?'v':' ', (c&0x01)?'A':' ', (c&0x02)?'B':' ', (c&0x08)?'S':' ', (c&0x04)?'s':' ', (c&0x4000)?'<':' ', (c&0x1000)?'^':' ', (c&0x8000)?'>':' ', (c&0x2000)?'v':' ', (c&0x0100)?'A':' ', (c&0x0200)?'B':' ', (c&0x0800)?'S':' ', (c&0x0400)?'s':' ', (c&0x400000)?'<':' ', (c&0x100000)?'^':' ', (c&0x800000)?'>':' ', (c&0x200000)?'v':' ', (c&0x010000)?'A':' ', (c&0x020000)?'B':' ', (c&0x080000)?'S':' ', (c&0x040000)?'s':' ', (c&0x40000000)?'<':' ', (c&0x10000000)?'^':' ', (c&0x80000000)?'>':' ', (c&0x20000000)?'v':' ', (c&0x01000000)?'A':' ', (c&0x02000000)?'B':' ', (c&0x08000000)?'S':' ', (c&0x04000000)?'s':' '); if(!(c&0xffffff00)) { inputstr[9] = '\0'; disppos = 30; } else if(!(c&0xffff0000)) { inputstr[19] = '\0'; disppos = 30; } else if(!(c&0xff000000)) { inputstr[30] = '\0'; } } FCEU_DispMessage("Held:\n%s", disppos, inputstr); } else { JSAutoHeldAffected = 0; autoHoldRefire = 0; } if(autoHoldReset) { FCEU_DispMessage("Held: ",30); JSAutoHeld = 0; JSAutoHeldAffected = 0; autoHoldRefire = 0; } // apply auto-hold if(JSAutoHeld) JS ^= JSAutoHeld; if(!snes) JSreturn=JS; }