From b8a40675421e8224820807364433d969e217c3a1 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 7 Dec 2009 01:19:52 +0000 Subject: [PATCH] sdl: dont allow --inputcfg gamepad0 and gamepad5 etc. as there arent actually that many gamepads --- src/drivers/sdl/input.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/drivers/sdl/input.cpp b/src/drivers/sdl/input.cpp index 46a3d58c..46bdebf8 100644 --- a/src/drivers/sdl/input.cpp +++ b/src/drivers/sdl/input.cpp @@ -1453,9 +1453,19 @@ void InputCfg(const std::string &text) { if(text.find("gamepad") != std::string::npos) { - ConfigDevice(FCFGD_GAMEPAD, (text[strlen("gamepad")] - '1') & 3); + int device = (text[strlen("gamepad")] - '1'); + if(device<0 || device>3) { + FCEUD_PrintError("Invalid gamepad device specified; must be one of gamepad1 through gamepad4"); + exit(-1); + } + ConfigDevice(FCFGD_GAMEPAD, device); } else if(text.find("powerpad") != std::string::npos) { - ConfigDevice(FCFGD_POWERPAD, (text[strlen("powerpad")] - '1') & 1); + int device = (text[strlen("powerpad")] - '1'); + if(device<0 || device>1) { + FCEUD_PrintError("Invalid powerpad device specified; must be powerpad1 or powerpad2"); + exit(-1); + } + ConfigDevice(FCFGD_POWERPAD, device); } else if(text.find("hypershot") != std::string::npos) { ConfigDevice(FCFGD_HYPERSHOT, 0); } else if(text.find("quizking") != std::string::npos) {