From f16311291df4cd0fa6003beee330be2b808aa360 Mon Sep 17 00:00:00 2001 From: Fabio Battaglia Date: Wed, 4 May 2011 16:48:52 +0200 Subject: N64: avoid bogus events if no controller plugged If the user has only a N64 mouse plugged in and no controllers this avoids fake clicks. --- backends/platform/n64/osys_n64.h | 2 +- backends/platform/n64/osys_n64_base.cpp | 2 +- backends/platform/n64/osys_n64_events.cpp | 15 +++++++++++---- backends/platform/n64/pad_rom.sh | 0 4 files changed, 13 insertions(+), 6 deletions(-) mode change 100644 => 100755 backends/platform/n64/pad_rom.sh (limited to 'backends/platform') diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index 7a84de0449..b9acb7c76c 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -129,7 +129,7 @@ protected: volatile int _mouseMaxX, _mouseMaxY; int _mouseHotspotX, _mouseHotspotY; - uint8 _controllerPort; + int8 _controllerPort; int8 _mousePort; bool _controllerHasRumble; // Gets enabled if rumble-pak is detected diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index 232037899b..32b2b98227 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -910,7 +910,7 @@ void OSystem_N64::detectControllers(void) { controller_data_status *ctrl_status = (controller_data_status*)memalign(8, sizeof(controller_data_status)); controller_Read_Status(ctrl_status); - _controllerPort = 0; // Use first controller as default + _controllerPort = -1; // Default no controller _mousePort = -1; // Default no mouse for (int8 ctrl_port = 3; ctrl_port >= 0; ctrl_port--) { // Found a standard pad, use this by default. diff --git a/backends/platform/n64/osys_n64_events.cpp b/backends/platform/n64/osys_n64_events.cpp index 22b9addbfb..69c854750c 100644 --- a/backends/platform/n64/osys_n64_events.cpp +++ b/backends/platform/n64/osys_n64_events.cpp @@ -94,8 +94,13 @@ void OSystem_N64::readControllerAnalogInput(void) { // Read current controller status controller_Read_Buttons(&_ctrlData); - pad_analogX = (_ctrlData.c[_controllerPort].throttle >> 8) & 0xFF; - pad_analogY = (_ctrlData.c[_controllerPort].throttle >> 0) & 0xFF; + pad_analogX = 0; + pad_analogY = 0; + + if (_controllerPort >= 0) { + pad_analogX = (_ctrlData.c[_controllerPort].throttle >> 8) & 0xFF; + pad_analogY = (_ctrlData.c[_controllerPort].throttle >> 0) & 0xFF; + } pad_mouseX = 0; pad_mouseY = 0; @@ -157,9 +162,11 @@ bool OSystem_N64::pollEvent(Common::Event &event) { static uint16 oldButtons = 0; // old button data... used for button press/release static uint16 oldMouseButtons = 0; - uint16 newButtons = _ctrlData.c[_controllerPort].buttons; // Read from controller + uint16 newButtons = 0; + if (_controllerPort >= 0) + newButtons = _ctrlData.c[_controllerPort].buttons; // Read from controller + uint16 newMouseButtons = 0; - if (_mousePort >= 0) newMouseButtons = _ctrlData.c[_mousePort].buttons; diff --git a/backends/platform/n64/pad_rom.sh b/backends/platform/n64/pad_rom.sh old mode 100644 new mode 100755 -- cgit v1.2.3