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.
This commit is contained in:
Fabio Battaglia 2011-05-04 16:48:52 +02:00
parent 9f1dacd72b
commit f16311291d
4 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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.

View File

@ -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;

0
backends/platform/n64/pad_rom.sh Normal file → Executable file
View File