int8_t FindPhysicalAddressPortNumber(void)
{
- PrintToStdOut("Enter the HDMI port number to which you connected your CEC adapter, followed by <enter>. Only port 1, 2, 3 or 4 are supported. Anything else will cancel this wizard.");
+ PrintToStdOut("Enter the HDMI port number to which you connected your CEC adapter, followed by <enter>. Valid ports are in the range 1-15. Anything else will cancel this wizard.");
string input;
getline(cin, input);
cin.clear();
- if (input.empty() || (input != "1" && input != "2" && input != "3" && input != "4"))
+ if (input.empty())
return -1;
- return (int8_t)atoi(input.c_str());
+
+ int8_t hdmiport = atoi(input.c_str());
+ if (hdmiport < 1 || hdmiport > 15)
+ return -1;
+
+ return hdmiport;
}
cec_logical_address FindPhysicalAddressBaseDevice(void)
{
if (argc >= iArgPtr + 2)
{
- g_config.iHDMIPort = (int8_t)atoi(argv[iArgPtr + 1]);
+ uint8_t hdmiport = (int8_t)atoi(argv[iArgPtr + 1]);
+ if (hdmiport < 1)
+ hdmiport = 1;
+ if (hdmiport > 15)
+ hdmiport = 15;
+ g_config.iHDMIPort = hdmiport;
cout << "using HDMI port '" << (int)g_config.iHDMIPort << "'" << endl;
++iArgPtr;
}