From 69308ec1a364c50fd70cfcfbee793f032d4944c9 Mon Sep 17 00:00:00 2001 From: Daryl Borth Date: Sat, 10 Dec 2016 12:56:12 -0700 Subject: [PATCH] restore zapper fix from liuhb86 - https://github.com/dborth/fceugx/pull/347 --- source/pad.cpp | 96 ++++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/source/pad.cpp b/source/pad.cpp index 9b4c14f..c966159 100644 --- a/source/pad.cpp +++ b/source/pad.cpp @@ -464,6 +464,58 @@ static unsigned char DecodeJoy(unsigned short chan) } #endif + bool zapper_triggered = false; + // zapper enabled + if(GCSettings.Controller == CTRL_ZAPPER) + { + int z; // NES port # (0 or 1) + + if(GameInfo->type == GIT_VSUNI) + z = 0; + else + z = 1; + + myzappers[z][2] = 0; // reset trigger to not pressed + + // is trigger pressed? + if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0]) // gamecube controller + #ifdef HW_RVL + || ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) ) // wiimote + #endif + ) + { + // report trigger press + myzappers[z][2] |= 2; + zapper_triggered = true; + } + + // VS zapper games + if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1]) // gamecube controller + #ifdef HW_RVL + || ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) ) // wiimote + #endif + ) + { + FCEUI_VSUniCoin(); // insert coin for VS zapper games + zapper_triggered = true; + } + + // cursor position + int channel = 0; // by default, use wiimote 1 + #ifdef HW_RVL + if (userInput[1].wpad->ir.valid) + { + channel = 1; // if wiimote 2 is connected, use wiimote 2 as zapper + } + #endif + UpdateCursorPosition(channel); // update cursor for wiimote + myzappers[z][0] = pos_x; + myzappers[z][1] = pos_y; + + // Report changes to FCE Ultra + zapperdata[z]->Update(z,myzappers[z],0); + } + // Report pressed buttons (gamepads) int i; for (i = 0; i < MAXJP; i++) @@ -478,7 +530,7 @@ static unsigned char DecodeJoy(unsigned short chan) ) { // if zapper is on, ignore all buttons except START and SELECT - if(GCSettings.Controller != CTRL_ZAPPER || nespadmap[i] == JOY_START || nespadmap[i] == JOY_SELECT) + if (!zapper_triggered) { if(rapidAlternator && nespadmap[i] == RAPID_A) { @@ -512,48 +564,6 @@ static unsigned char DecodeJoy(unsigned short chan) } } - // zapper enabled - if(GCSettings.Controller == CTRL_ZAPPER) - { - int z; // NES port # (0 or 1) - - if(GameInfo->type == GIT_VSUNI) - z = 0; - else - z = 1; - - myzappers[z][2] = 0; // reset trigger to not pressed - - // is trigger pressed? - if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0]) // gamecube controller - #ifdef HW_RVL - || ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) ) // wiimote - #endif - ) - { - // report trigger press - myzappers[z][2] |= 2; - } - - // VS zapper games - if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1]) // gamecube controller - #ifdef HW_RVL - || ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) ) // wiimote - #endif - ) - { - FCEUI_VSUniCoin(); // insert coin for VS zapper games - } - - // cursor position - UpdateCursorPosition(0); // update cursor for wiimote 1 - myzappers[z][0] = pos_x; - myzappers[z][1] = pos_y; - - // Report changes to FCE Ultra - zapperdata[z]->Update(z,myzappers[z],0); - } - return J; }