void FCEUD_UpdateInput() { bool joy=false,mouse=false; EMOVIEMODE FCEUMOVState = FCEUMOV_Mode(); UpdateRawInputAndHotkeys(); { for(int x=0;x<2;x++) switch(InputType[x]) { case SI_GAMEPAD: joy=true; break; case SI_SNES: UpdateGamepad(true); break; case SI_MOUSE: mouse=true; break; case SI_SNES_MOUSE: mouse=true; break; case SI_ARKANOID: mouse=true; break; case SI_ZAPPER: mouse=true; break; case SI_POWERPADA: case SI_POWERPADB: powerpadbuf[x]=UpdatePPadData(x); break; } switch(InputType[2]) { case SIFC_ARKANOID: mouse=true; break; case SIFC_SHADOW: mouse=true; break; case SIFC_FKB: if(cidisabled) UpdateFKB(); break; case SIFC_PEC586KB: case SIFC_SUBORKB: if(cidisabled) UpdateSuborKB(); break; case SIFC_HYPERSHOT: UpdateHyperShot();break; case SIFC_MAHJONG: UpdateMahjong();break; case SIFC_QUIZKING: UpdateQuizKing();break; case SIFC_FTRAINERB: case SIFC_FTRAINERA: UpdateFTrainer();break; case SIFC_TOPRIDER: UpdateTopRider();break; case SIFC_OEKAKIDS: mouse=true; break; } if(joy) UpdateGamepad(false); if(mouse) if(FCEUMOVState != MOVIEMODE_PLAY) //FatRatKnight: Moved this if out of the function GetMouseData(MouseData); //A more concise fix may be desired. } }
void FCEU_FDSInsert(void) { if (FCEUI_EmulationPaused()) EmulationPaused |= 2; if (FCEUMOV_Mode(MOVIEMODE_RECORD)) FCEUMOV_AddCommand(FCEUNPCMD_FDSINSERT); if (TotalSides == 0) { FCEU_DispMessage("Not FDS; can't eject disk.", 0); return; } if (InDisk == 255) { FCEU_DispMessage("Disk %d Side %s Inserted", 0, SelectDisk >> 1, (SelectDisk & 1) ? "B" : "A"); InDisk = SelectDisk; } else {
void FCEU_PutImage(void) { if(dosnapsave==2) //Save screenshot as, currently only flagged & run by the Win32 build. //TODO SDL: implement this? { char nameo[512]; strcpy(nameo,FCEUI_GetSnapshotAsName().c_str()); if (nameo[0]) { SaveSnapshot(nameo); FCEU_DispMessage("Snapshot Saved.",0); } dosnapsave=0; } if(GameInfo->type==GIT_NSF) { DrawNSF(XBuf); //Save snapshot after NSF screen is drawn. Why would we want to do it before? if(dosnapsave==1) { ReallySnap(); dosnapsave=0; } } else { //Save backbuffer before overlay stuff is written. if(!FCEUI_EmulationPaused()) memcpy(XBackBuf, XBuf, 256*256); //Some messages need to be displayed before the avi is dumped DrawMessage(true); #ifdef _S9XLUA_H // Lua gui should draw before the avi is dumped. FCEU_LuaGui(XBuf); #endif //Save snapshot if(dosnapsave==1) { ReallySnap(); dosnapsave=0; } if (!FCEUI_AviEnableHUDrecording()) snapAVI(); if(GameInfo->type==GIT_VSUNI) FCEU_VSUniDraw(XBuf); FCEU_DrawSaveStates(XBuf); FCEU_DrawMovies(XBuf); FCEU_DrawLagCounter(XBuf); FCEU_DrawNTSCControlBars(XBuf); FCEU_DrawRecordingStatus(XBuf); ShowFPS(); } if(FCEUD_ShouldDrawInputAids()) FCEU_DrawInput(XBuf); //Fancy input display code if(input_display) { extern uint32 JSAutoHeld; uint32 held; int controller, c, ci, color; int i, j; uint32 on = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0x90:0xA7; //Standard, or Gray depending on movie mode uint32 oni = 0xA0; //Color for immediate keyboard buttons uint32 blend = 0xB6; //Blend of immiate and last held buttons uint32 ahold = 0x87; //Auto hold uint32 off = 0xCF; uint8 *t = XBuf+(FSettings.LastSLine-9)*256 + 20; //mbg merge 7/17/06 changed t to uint8* if(input_display > 4) input_display = 4; for(controller = 0; controller < input_display; controller++, t += 56) { for(i = 0; i < 34;i++) for(j = 0; j <9 ; j++) t[i+j*256] = (t[i+j*256] & 0x30) | 0xC1; for(i = 3; i < 6; i++) for(j = 3; j< 6; j++) t[i+j*256] = 0xCF; c = cur_input_display >> (controller * 8); // This doesn't work in anything except windows for now. // It doesn't get set anywhere in other ports. #if defined(WIN32) && !defined(DINGUX) if (!oldInputDisplay) ci = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0:GetGamepadPressedImmediate() >> (controller * 8); else ci = 0; if (!oldInputDisplay && !FCEUMOV_Mode(MOVIEMODE_PLAY)) held = (JSAutoHeld >> (controller * 8)); else held = 0; #else // Put other port info here ci = 0; held = 0; #endif //adelikat: I apologize to anyone who ever sifts through this color assignment //A if (held&1) { //If auto-hold if (!(ci&1) ) color = ahold; else color = (c&1) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&1) color = (ci&1) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&1) ? oni : off; } for(i=0; i < 4; i++) { for(j = 0; j < 4; j++) { if(i%3==0 && j %3 == 0) continue; t[30+4*256+i+j*256] = color; } } //B if (held&2) { //If auto-hold if (!(ci&2) ) color = ahold; else color = (c&2) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&2) color = (ci&2) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&2) ? oni : off; } for(i=0; i < 4; i++) { for(j = 0; j < 4; j++) { if(i%3==0 && j %3 == 0) continue; t[24+4*256+i+j*256] = color; } } //Select if (held&4) { //If auto-hold if (!(ci&4) ) color = ahold; else color = (c&4) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&4) color = (ci&4) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&4) ? oni : off; } for(i = 0; i < 4; i++) { t[11+5*256+i] = color; t[11+6*256+i] = color; } //Start if (held&8) { //If auto-hold if (!(ci&8) ) color = ahold; else color = (c&8) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&8) color = (ci&8) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&8) ? oni : off; } for(i = 0; i < 4; i++) { t[17+5*256+i] = color; t[17+6*256+i] = color; } //Up if (held&16) { //If auto-hold if (!(ci&16) ) color = ahold; else color = (c&16) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&16) color = (ci&16) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&16) ? oni : off; } for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { t[3+i+256*j] = color; } } //Down if (held&32) { //If auto-hold if (!(ci&32) ) color = ahold; else color = (c&32) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&32) color = (ci&32) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&32) ? oni : off; } for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { t[3+i+256*j+6*256] = color; } } //Left if (held&64) { //If auto-hold if (!(ci&64) ) color = ahold; else color = (c&64) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&64) color = (ci&64) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&64) ? oni : off; } for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { t[3*256+i+256*j] = color; } } //Right if (held&128) { //If auto-hold if (!(ci&128) ) color = ahold; else color = (c&128) ? on : off; //If the button is pressed down (immediate) that negates auto hold, however it is only off if the previous frame the button wasn't pressed! } else { if (c&128) color = (ci&128) ? blend : on; //If immedaite buttons are pressed and they match the previous frame, blend the colors else color = (ci&128) ? oni : off; } for(i = 0; i < 3; i++) { for(j = 0; j < 3; j++) { t[6+3*256+i+256*j] = color; } } }
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; }