From: Shamus Hammons Date: Sun, 15 Nov 2015 21:40:45 +0000 (-0600) Subject: Fix stupid button failure bug for controller #2. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=virtualjaguar;a=commitdiff_plain;h=48dd9ba5b6742935eef61cec80964afe093139ad Fix stupid button failure bug for controller #2. --- diff --git a/cross-compile b/cross-compile index 852ec95..afbca73 100755 --- a/cross-compile +++ b/cross-compile @@ -9,13 +9,13 @@ #rm makefile-qt echo "Cross compiling for Win32..." -SUFFIX=-win32 +SUFFIX=win32 export PATH=/opt/mxe-32/usr/bin:$PATH /opt/mxe-32/usr/bin/i686-w64-mingw32.static-qmake-qt5 -o makefile-qt make CROSS=i686-w64-mingw32.static- #echo "Cross compiling for Win64..." -#SUFFIX=-win64 +#SUFFIX=win64 #export PATH=/opt/mxe/usr/bin:$PATH #/opt/mxe/usr/bin/x86_64-w64-mingw32.static-qmake-qt5 -o makefile-qt #make CROSS=x86_64-w64-mingw32.static- diff --git a/src/joystick.cpp b/src/joystick.cpp index 619a751..4b25493 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -131,11 +131,12 @@ uint16_t JoystickReadWord(uint32_t offset) // Joystick data returns active low for buttons pressed, high for non- // pressed. - uint8_t offset0 = joypad0Offset[joystick_ram[1] & 0x0F] / 4; - uint8_t offset1 = joypad1Offset[(joystick_ram[1] >> 4) & 0x0F] / 4; + uint8_t offset0 = joypad0Offset[joystick_ram[1] & 0x0F]; + uint8_t offset1 = joypad1Offset[(joystick_ram[1] >> 4) & 0x0F]; if (offset0 != 0xFF) { + offset0 /= 4; // Make index 0, 1, 2, 3 instead of 0, 4, 8, 12 uint8_t mask[4][2] = { { BUTTON_A, BUTTON_PAUSE }, { BUTTON_B, -1 }, { BUTTON_C, -1 }, { BUTTON_OPTION, -1 } }; data &= (joypad0Buttons[mask[offset0][0]] ? 0xFFFD : 0xFFFF); @@ -145,6 +146,7 @@ uint16_t JoystickReadWord(uint32_t offset) if (offset1 != 0xFF) { + offset1 /= 4; // Make index 0, 1, 2, 3 instead of 0, 4, 8, 12 uint8_t mask[4][2] = { { BUTTON_A, BUTTON_PAUSE }, { BUTTON_B, -1 }, { BUTTON_C, -1 }, { BUTTON_OPTION, -1 } }; data &= (joypad1Buttons[mask[offset1][0]] ? 0xFFF7 : 0xFFFF);