cec: replaced a load of magic numbers
[deb_libcec.git] / src / cec-config / cec-config.cpp
index 76c91660adb27aea935d02e12277e6a116445476..c601afc3f9f573683e2dc2648ebac02dd55b998c 100644 (file)
@@ -141,9 +141,9 @@ int CecCommand(void *UNUSED(cbParam), const cec_command &command)
 
 void EnableCallbacks(ICECAdapter *adapter)
 {
-  g_callbacks.CBCecLogMessage           = &CecLogMessage;
-  g_callbacks.CBCecKeyPress             = &CecKeyPress;
-  g_callbacks.CBCecCommand              = &CecCommand;
+  g_callbacks.CBCecLogMessage = &CecLogMessage;
+  g_callbacks.CBCecKeyPress   = &CecKeyPress;
+  g_callbacks.CBCecCommand    = &CecCommand;
   adapter->EnableCallbacks(NULL, &g_callbacks);
 }
 
@@ -258,7 +258,7 @@ cec_logical_address FindPhysicalAddressBaseDevice(void)
 uint16_t FindPhysicalAddress(void)
 {
   PrintToStdOut("=== Physical Address Configuration ===\n");
-  uint16_t iAddress(0xFFFF);
+  uint16_t iAddress(CEC_INVALID_PHYSICAL_ADDRESS);
 
   PrintToStdOut("Do you want to let libCEC try to autodetect the address (y/n)?");
   string input;
@@ -280,22 +280,22 @@ uint16_t FindPhysicalAddress(void)
     else
     {
       iAddress = g_parser->GetDevicePhysicalAddress(g_primaryAddress);
-      if (iAddress == 0 || iAddress == 0xFFFF)
+      if (iAddress == 0 || iAddress == CEC_INVALID_PHYSICAL_ADDRESS)
         PrintToStdOut("Failed. Please enter the address manually, or restart this wizard and use different settings.");
     }
   }
 
-  if (iAddress == 0 || iAddress == 0xFFFF)
+  if (iAddress == 0 || iAddress == CEC_INVALID_PHYSICAL_ADDRESS)
   {
-    PrintToStdOut("Please enter the physical address (0000 - FFFF), followed by <enter>.");
+    PrintToStdOut("Please enter the physical address (0001 - FFFE), followed by <enter>.");
     getline(cin, input);
     cin.clear();
 
     int iAddressTmp;
     if (sscanf(input.c_str(), "%x", &iAddressTmp) == 1)
     {
-      if (iAddressTmp < 0 || iAddressTmp > 0xFFFF)
-        iAddressTmp = 0xFFFF;
+      if (iAddressTmp <= CEC_PHYSICAL_ADDRESS_TV || iAddressTmp > CEC_MAX_PHYSICAL_ADDRESS)
+        iAddressTmp = CEC_INVALID_PHYSICAL_ADDRESS;
       iAddress = (uint16_t)iAddressTmp;
     }
   }