de7965
diff -up ./cmake/internal/SearchForStuff.cmake.enablephidget ./cmake/internal/SearchForStuff.cmake
de7965
--- ./cmake/internal/SearchForStuff.cmake.enablephidget	2011-01-08 09:28:15.974551777 -0500
de7965
+++ ./cmake/internal/SearchForStuff.cmake	2011-01-08 09:29:23.678551971 -0500
de7965
@@ -232,3 +232,41 @@ IF (PLAYER_OS_WIN)
de7965
         ${CMAKE_CURRENT_SOURCE_DIR}/cmake/internal/setdlldirectory.c)
de7965
 ENDIF (PLAYER_OS_WIN)
de7965
 
de7965
+# Check for libphidget, see if we have 2.1.7 or later
de7965
+SET (PHIDGET_INCLUDE_DIR "" CACHE STRING "Directory containing the Phidget headers")
de7965
+SET (PHIDGET_LIB_DIR "" CACHE STRING "Directory containing the Phidget libraries")
de7965
+MARK_AS_ADVANCED (PHIDGET_INCLUDE_DIR)
de7965
+MARK_AS_ADVANCED (PHIDGET_LIB_DIR)
de7965
+
de7965
+IF ("${PHIDGET_INCLUDE_DIR}" STREQUAL "")
de7965
+    SET (phidgetHeader "phidget21.h")
de7965
+    SET (phidgetCFlags "")
de7965
+ELSE ("${PHIDGET_INCLUDE_DIR}" STREQUAL "")
de7965
+    SET (phidgetHeader "${PHIDGET_INCLUDE_DIR}/phidget21.h")
de7965
+    SET (phidgetCFlags "-I${PHIDGET_INCLUDE_DIR}")
de7965
+ENDIF ("${PHIDGET_INCLUDE_DIR}" STREQUAL "")
de7965
+
de7965
+IF ("${PHIDGET_LIB_DIR}" STREQUAL "")
de7965
+    SET (phidgetLinkFlags "-lphidget21")
de7965
+ELSE ("${PHIDGET_LIB_DIR}" STREQUAL "")
de7965
+    SET (phidgetLinkFlags " -L${PHIDGET_LIB_DIR} -lphidget21")
de7965
+ENDIF ("${PHIDGET_LIB_DIR}" STREQUAL "")
de7965
+
de7965
+IF (HAVE_DNS_SD)
de7965
+   SET (phidgetLinkFlags "${phidgetLinkFlags} -ldns_sd")
de7965
+ENDIF(HAVE_DNS_SD)
de7965
+
de7965
+CHECK_INCLUDE_FILES(${phidgetHeader} HAVE_PHIDGET_H)
de7965
+IF (HAVE_PHIDGET_H)
de7965
+    INCLUDE (CheckCSourceCompiles)
de7965
+    SET(CMAKE_REQUIRED_FLAGS "${phidgetCFlags} ${phidgetLinkFlags} -lphidget21")
de7965
+    SET (CHECK_PHIDGET_SOURCE_CODE "#include <phidget21.h>\n int main () 
de7965
+    {CPhidgetInterfaceKitHandle ifk=0; int phidget_num_outputs=0;
de7965
+    CPhidgetInterfaceKit_create(&ifk;;
de7965
+    CPhidgetInterfaceKit_getOutputCount(ifk, &phidget_num_outputs); return 0; }\n")
de7965
+    CHECK_C_SOURCE_COMPILES ("${CHECK_PHIDGET_SOURCE_CODE}" HAVE_PHIDGET_2_1_7)
de7965
+ENDIF (HAVE_PHIDGET_H)
de7965
+
de7965
+IF (HAVE_PHIDGET_H)
de7965
+   SET(HAVE_PHIDGET true)
de7965
+ENDIF (HAVE_PHIDGET_H)
de7965
diff -up ./config.h.in.enablephidget ./config.h.in
de7965
--- ./config.h.in.enablephidget	2011-01-08 09:42:02.950551971 -0500
de7965
+++ ./config.h.in	2011-01-08 09:42:43.419551971 -0500
de7965
@@ -15,4 +15,5 @@
de7965
 #cmakedefine HAVE_IEEEFP_H 1
de7965
 #cmakedefine WORDS_BIGENDIAN 1
de7965
 #cmakedefine HAVE_SETDLLDIRECTORY 1
de7965
+#cmakedefine HAVE_PHIDGET_2_1_7 1
de7965
 
de7965
diff -up ./server/drivers/mixed/phidgetIFK/CMakeLists.txt.enablephidget ./server/drivers/mixed/phidgetIFK/CMakeLists.txt
de7965
--- ./server/drivers/mixed/phidgetIFK/CMakeLists.txt.enablephidget	2011-01-08 09:30:18.492552601 -0500
de7965
+++ ./server/drivers/mixed/phidgetIFK/CMakeLists.txt	2011-01-08 09:31:27.874551975 -0500
de7965
@@ -1,16 +1,10 @@
de7965
-PLAYERDRIVER_OPTION (phidgetifk build_phidgetifk ON)
de7965
-SET (PHIDGETIFK_DIR "" CACHE STRING "Directory containing the Phidget IFK headers and libraries")
de7965
-MARK_AS_ADVANCED (PHIDGETIFK_DIR)
de7965
-IF ("${PHIDGETIFK_DIR}" STREQUAL "")
de7965
-    SET (phidgetReqHeader "phidget21.h")
de7965
-    SET (phidgetExtraFlags "")
de7965
-    SET (phidgetExtraLibs "-lphidget21")
de7965
-ELSE ("${PHIDGETIFK_DIR}" STREQUAL "")
de7965
-    SET (phidgetReqHeader "${PHIDGETIFK_DIR}/phidget21.h")
de7965
-    SET (phidgetExtraFlags "-I${PHIDGETIFK_DIR}/include")
de7965
-    SET (phidgetExtraLibs "-L${PHIDGETIFK_DIR}/lib -lphidget21")
de7965
-ENDIF ("${PHIDGETIFK_DIR}" STREQUAL "")
de7965
-PLAYERDRIVER_REQUIRE_HEADER (phidgetifk build_phidgetifk ${phidgetReqHeader})
de7965
+# libphidget now discovered in SearchForStuff.cmake
de7965
+IF (HAVE_PHIDGET)
de7965
+  PLAYERDRIVER_OPTION (phidgetifk build_phidgetifk ON)
de7965
+ELSE (HAVE_PHIDGET)
de7965
+  PLAYERDRIVER_OPTION (phidgetifk build_phidgetifk OFF "Could not find libphidget")
de7965
+ENDIF (HAVE_PHIDGET)
de7965
+  
de7965
 PLAYERDRIVER_ADD_DRIVER (phidgetifk build_phidgetifk
de7965
-    LINKFLAGS ${phidgetExtraLibs} CFLAGS ${phidgetExtraFlags}
de7965
+    LINKFLAGS ${phidgetLinkFlags} CFLAGS ${phidgetCFlags}
de7965
     SOURCES phidgetIFK.cc)
de7965
diff -up ./server/drivers/mixed/phidgetIFK/phidgetIFK.cc.enablephidget ./server/drivers/mixed/phidgetIFK/phidgetIFK.cc
de7965
--- ./server/drivers/mixed/phidgetIFK/phidgetIFK.cc.enablephidget	2011-01-08 09:43:14.839551971 -0500
de7965
+++ ./server/drivers/mixed/phidgetIFK/phidgetIFK.cc	2011-01-08 09:44:01.493551971 -0500
de7965
@@ -87,7 +87,6 @@ driver
de7965
 /** @} */
de7965
 
de7965
 
de7965
-
de7965
 #include <unistd.h>
de7965
 #include <string.h>
de7965
 #include <iostream>
de7965
@@ -97,7 +96,7 @@ driver
de7965
 #include "phidget21.h"
de7965
 
de7965
 #include <libplayercore/playercore.h>
de7965
-
de7965
+#include "config.h"
de7965
 
de7965
 //For nanosleep:
de7965
 #include <time.h>
de7965
@@ -326,8 +325,11 @@ int PhidgetIFK::ProcessMessage(QueuePoin
de7965
 
de7965
         //the actual ammount of digital outputs of the widget
de7965
         int phidget_num_outputs(0);
de7965
+#ifdef HAVE_PHIDGET_2_1_7
de7965
+        CPhidgetInterfaceKit_getOutputCount(ifk, &phidget_num_outputs);
de7965
+#else
de7965
         CPhidgetInterfaceKit_getNumOutputs(ifk, &phidget_num_outputs);
de7965
-
de7965
+#endif
de7965
         if (count > static_cast<int>(max_do)) {
de7965
             PLAYER_WARN("PhidgetIFK: Received a command with a huge ammount of digital outputs. Check the value of count.\n");
de7965
             PLAYER_WARN1("PhidgetIFK: Limiting to the maximum possible value: %d\n",max_do);
de7965
@@ -379,10 +381,14 @@ int PhidgetIFK::ProcessMessage(QueuePoin
de7965
 
de7965
         //Get the size of the LCD screen
de7965
         int numcolumns(0);
de7965
-        CPhidgetTextLCD_getNumColumns(lcd,&numcolumns);
de7965
         int numrows(0);
de7965
+#ifdef HAVE_PHIDGET_2_1_7
de7965
+        CPhidgetTextLCD_getColumnCount(lcd,&numcolumns);
de7965
+        CPhidgetTextLCD_getRowCount(lcd,&numrows);
de7965
+#else
de7965
+        CPhidgetTextLCD_getNumColumns(lcd,&numcolumns);
de7965
         CPhidgetTextLCD_getNumRows(lcd,&numrows);
de7965
-
de7965
+#endif
de7965
         //Copy the text to a string for easier manipulation
de7965
         string completemessage;
de7965
         completemessage = const_cast<const char *>(cmd->string);
de7965
@@ -472,8 +478,11 @@ void PhidgetIFK::Main() {
de7965
 
de7965
         //Read from the device.
de7965
         int numsensors(0);
de7965
+#ifdef HAVE_PHIDGET_2_1_7
de7965
+        CPhidgetInterfaceKit_getSensorCount(ifk, &numsensors);
de7965
+#else
de7965
         CPhidgetInterfaceKit_getNumSensors(ifk, &numsensors);
de7965
-
de7965
+#endif
de7965
         std::vector<float> values;
de7965
         for (int i = 0 ; i != numsensors ; ++i) {
de7965
             values.push_back(0.0);
de7965
@@ -502,8 +511,11 @@ void PhidgetIFK::Main() {
de7965
         player_dio_data_t data_di;
de7965
         //need the digital inputs as a bitfield
de7965
         int num_di(0);
de7965
+#ifdef HAVE_PHIDGET_2_1_7
de7965
+        CPhidgetInterfaceKit_getInputCount(ifk, &num_di);
de7965
+#else
de7965
         CPhidgetInterfaceKit_getNumInputs(ifk, &num_di);
de7965
-
de7965
+#endif
de7965
         data_di.count=num_di;
de7965
 
de7965
         std::vector<bool> divalues;
de7965
diff -up ./server/drivers/rfid/CMakeLists.txt.enablephidget ./server/drivers/rfid/CMakeLists.txt
de7965
--- ./server/drivers/rfid/CMakeLists.txt.enablephidget	2011-01-08 09:30:27.997551861 -0500
de7965
+++ ./server/drivers/rfid/CMakeLists.txt	2011-01-08 09:31:54.667551970 -0500
de7965
@@ -10,21 +10,15 @@ PLAYERDRIVER_OPTION (skyetekM1 build_sky
de7965
 PLAYERDRIVER_REJECT_OS (skyetekM1 build_skyetekM1 PLAYER_OS_WIN)
de7965
 PLAYERDRIVER_ADD_DRIVER (skyetekM1 build_skyetekM1 SOURCES skyetekM1.cc)
de7965
 
de7965
-PLAYERDRIVER_OPTION (phidgetRFID build_phidgetRFID ON)
de7965
-SET (PHIDGETRFID_DIR "" CACHE STRING "Directory containing the Phidget RFID headers and libraries")
de7965
-MARK_AS_ADVANCED (PHIDGETRFID_DIR)
de7965
-IF ("${PHIDGETRFID_DIR}" STREQUAL "")
de7965
-    SET (phidgetReqHeader "phidget21.h")
de7965
-    SET (phidgetExtraFlags "")
de7965
-    SET (phidgetExtraLibs "-lphidget21")
de7965
-ELSE ("${PHIDGETRFID_DIR}" STREQUAL "")
de7965
-    SET (phidgetReqHeader "${PHIDGETRFID_DIR}/phidget21.h")
de7965
-    SET (phidgetExtraFlags "-I${PHIDGETRFID_DIR}/include")
de7965
-    SET (phidgetExtraLibs "-L${PHIDGETRFID_DIR}/lib -lphidget21")
de7965
-ENDIF ("${PHIDGETRFID_DIR}" STREQUAL "")
de7965
-PLAYERDRIVER_REQUIRE_HEADER (phidgetRFID build_phidgetRFID ${phidgetReqHeader})
de7965
+# libphidget now discovered in SearchForStuff.cmake
de7965
+IF (HAVE_PHIDGET)
de7965
+  PLAYERDRIVER_OPTION (phidgetAcc build_phidgetRFID ON)
de7965
+ELSE (HAVE_PHIDGET)
de7965
+  PLAYERDRIVER_OPTION (phidgetAcc build_phidgetRFID OFF "Could not find libphidget")
de7965
+ENDIF (HAVE_PHIDGET)
de7965
+
de7965
 PLAYERDRIVER_ADD_DRIVER (phidgetRFID build_phidgetRFID
de7965
-    LINKFLAGS ${phidgetExtraLibs} CFLAGS "${phidgetExtraFlags}"
de7965
+    LINKFLAGS ${phidgetLinkFlags} CFLAGS "${phidgetCFlags}"
de7965
     SOURCES phidgetRFID.cc)
de7965
 
de7965
 PLAYERDRIVER_OPTION (acr120u build_acr120u ON)
de7965
diff -up ./server/drivers/rfid/phidgetRFID.cc.enablephidget ./server/drivers/rfid/phidgetRFID.cc
de7965
--- ./server/drivers/rfid/phidgetRFID.cc.enablephidget	2011-01-08 09:43:32.178551971 -0500
de7965
+++ ./server/drivers/rfid/phidgetRFID.cc	2011-01-08 09:44:33.501551971 -0500
de7965
@@ -83,9 +83,9 @@ driver
de7965
 /** @} */
de7965
 
de7965
 
de7965
-
de7965
 #include "phidget21.h"
de7965
 #include <libplayercore/playercore.h>
de7965
+#include "config.h"
de7965
 
de7965
 #include <unistd.h>
de7965
 #include <string.h>
de7965
@@ -261,7 +261,11 @@ int Phidgetrfid::ProcessMessage(QueuePoi
de7965
 
de7965
         //the actual ammount of digital outputs of the widget
de7965
         int phidget_num_outputs(0);
de7965
+#ifdef HAVE_PHIDGET_2_1_7
de7965
+        CPhidgetRFID_getOutputCount(rfid, &phidget_num_outputs);
de7965
+#else
de7965
         CPhidgetRFID_getNumOutputs(rfid, &phidget_num_outputs);
de7965
+#endif
de7965
         printf("Num of outputs: %d\n", phidget_num_outputs);
de7965
 
de7965
         if (count > static_cast<int>(max_do)) {
de7965
diff -up ./server/drivers/wsn/CMakeLists.txt.enablephidget ./server/drivers/wsn/CMakeLists.txt
de7965
--- ./server/drivers/wsn/CMakeLists.txt.enablephidget	2011-01-08 09:30:38.161552089 -0500
de7965
+++ ./server/drivers/wsn/CMakeLists.txt	2011-01-08 09:32:14.870551971 -0500
de7965
@@ -21,19 +21,12 @@ ELSE (HAVE_STL)
de7965
 ENDIF (HAVE_STL)
de7965
 PLAYERDRIVER_ADD_DRIVER (accel_calib build_accel_calib SOURCES accel_calib.cc)
de7965
 
de7965
-PLAYERDRIVER_OPTION (phidgetAcc build_phidgetAcc ON)
de7965
-SET (PHIDGETACC_DIR "" CACHE STRING "Directory containing the Phidget Acc headers and libraries")
de7965
-MARK_AS_ADVANCED (PHIDGETACC_DIR)
de7965
-IF ("${PHIDGETACC_DIR}" STREQUAL "")
de7965
-    SET (phidgetReqHeader "phidget21.h")
de7965
-    SET (phidgetExtraFlags "")
de7965
-    SET (phidgetExtraLibs "-lphidget21")
de7965
-ELSE ("${PHIDGETACC_DIR}" STREQUAL "")
de7965
-    SET (phidgetReqHeader "${PHIDGETACC_DIR}/phidget21.h")
de7965
-    SET (phidgetExtraFlags "-I${PHIDGETACC_DIR}/include")
de7965
-    SET (phidgetExtraLibs "-L${PHIDGETACC_DIR}/lib -lphidget21")
de7965
-ENDIF ("${PHIDGETACC_DIR}" STREQUAL "")
de7965
-PLAYERDRIVER_REQUIRE_HEADER (phidgetAcc build_phidgetAcc ${phidgetReqHeader})
de7965
+# libphidget now discovered in SearchForStuff.cmake
de7965
+IF (HAVE_PHIDGET)
de7965
+  PLAYERDRIVER_OPTION (phidgetAcc build_phidgetAcc ON)
de7965
+ELSE (HAVE_PHIDGET)
de7965
+  PLAYERDRIVER_OPTION (phidgetAcc build_phidgetAcc OFF "Could not find libphidget")
de7965
+ENDIF (HAVE_PHIDGET)
de7965
 PLAYERDRIVER_ADD_DRIVER (phidgetAcc build_phidgetAcc
de7965
-    LINKFLAGS ${phidgetExtraLibs} CFLAGS ${phidgetExtraFlags}
de7965
+    LINKFLAGS ${phidgetLinkFlags} CFLAGS ${phidgetCFlags}
de7965
     SOURCES phidgetAcc.cc)
de7965
diff -up ./server/drivers/wsn/phidgetAcc.cc.enablephidget ./server/drivers/wsn/phidgetAcc.cc
de7965
--- ./server/drivers/wsn/phidgetAcc.cc.enablephidget	2011-01-08 09:43:25.513551970 -0500
de7965
+++ ./server/drivers/wsn/phidgetAcc.cc	2011-01-08 09:44:16.546551971 -0500
de7965
@@ -79,10 +79,9 @@ driver
de7965
  */
de7965
 /** @} */
de7965
 
de7965
-
de7965
-
de7965
 #include "phidget21.h"
de7965
 #include <libplayercore/playercore.h>
de7965
+#include "config.h"
de7965
 
de7965
 #include <unistd.h>
de7965
 #include <string.h>
de7965
@@ -273,7 +272,11 @@ void PhidgetAcc::Main() {
de7965
     	data.data_packet.temperature = -1;
de7965
     	data.data_packet.battery     = -1;
de7965
 	int n_axis;
de7965
+#ifdef HAVE_PHIDGET_2_1_7
de7965
+	if(CPhidgetAccelerometer_getAxisCount(accel,&n_axis)) return;
de7965
+#else
de7965
 	if(CPhidgetAccelerometer_getNumAxis(accel,&n_axis)) return;
de7965
+#endif
de7965
 	double *p_accel;
de7965
 	p_accel= new double[n_axis];
de7965
 	for (int i=0;i