aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/n64
diff options
context:
space:
mode:
authorFabio Battaglia2011-05-04 16:48:52 +0200
committerFabio Battaglia2011-05-04 16:48:52 +0200
commitf16311291df4cd0fa6003beee330be2b808aa360 (patch)
tree656cb9c6820108803a4eaf7dae6dfb8636e71df3 /backends/platform/n64
parent9f1dacd72bd633ff162eb4f385f0f4505a59e522 (diff)
downloadscummvm-rg350-f16311291df4cd0fa6003beee330be2b808aa360.tar.gz
scummvm-rg350-f16311291df4cd0fa6003beee330be2b808aa360.tar.bz2
scummvm-rg350-f16311291df4cd0fa6003beee330be2b808aa360.zip
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.
Diffstat (limited to 'backends/platform/n64')
-rw-r--r--backends/platform/n64/osys_n64.h2
-rw-r--r--backends/platform/n64/osys_n64_base.cpp2
-rw-r--r--backends/platform/n64/osys_n64_events.cpp15
-rwxr-xr-x[-rw-r--r--]backends/platform/n64/pad_rom.sh0
4 files changed, 13 insertions, 6 deletions
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
index 085203306f..085203306f 100644..100755
--- a/backends/platform/n64/pad_rom.sh
+++ b/backends/platform/n64/pad_rom.sh