From 6e90d1e433811ceca4bf37473ac1c76770afdf7c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 9 Jul 2015 13:08:37 -0400 Subject: [PATCH] SI_DeviceGCController: Remedy undefined behavior regarding shifts Left shifting a negative left-hand operand is undefined behavior per section 5.8.2 of the C++11 standard. --- Source/Core/Core/HW/SI_DeviceGCController.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/SI_DeviceGCController.h b/Source/Core/Core/HW/SI_DeviceGCController.h index f738ad16fd..1a341051e4 100644 --- a/Source/Core/Core/HW/SI_DeviceGCController.h +++ b/Source/Core/Core/HW/SI_DeviceGCController.h @@ -118,7 +118,11 @@ public: virtual bool GetData(u32& _Hi, u32& _Low) override { CSIDevice_GCController::GetData(_Hi, _Low); - _Hi &= ~PAD_USE_ORIGIN << 16; + + // Unset all bits except those that represent + // A, B, X, Y, Start and the error bits, as they + // are not used. + _Hi &= ~0x20FFFFFF; return true; } };