+
+int ConnectProfileToDevice(int deviceNum)
+{
+// bool found1 = false;
+// bool found2 = false;
+ int numberFoundForController1 = 0;
+ int numberFoundForController2 = 0;
+
+ for(int i=0; i<numberOfProfiles; i++)
+ {
+ // Skip profile if it's not our device
+ if (profile[i].device != deviceNum)
+ continue;
+
+ if (profile[i].preferredController & CONTROLLER1)
+ {
+ controller1Profile = i;
+// found1 = true;
+ numberFoundForController1++;
+ }
+
+ if (profile[i].preferredController & CONTROLLER2)
+ {
+ controller2Profile = i;
+// found2 = true;
+ numberFoundForController2++;
+ }
+ }
+
+// return found;
+ return numberFoundForController1 + numberFoundForController2;
+}
+
+/*
+int FindProfileForDevice(int deviceNum)
+{
+ for(int i=0; i<numberOfProfiles; i++)
+ {
+ // Skip profile if it's not our device
+ if (profile[i].device != deviceNum)
+ continue;
+
+ return i;
+ }
+
+ return -1;
+}
+*/
+
+int FindProfileForDevice(int deviceNum, int preferred, int * found)
+{
+ int numFound = 0;
+
+ for(int i=0; i<numberOfProfiles; i++)
+ {
+ // Return the profile only if it matches the passed in device and
+ // matches the passed in prefence...
+ if ((profile[i].device == deviceNum) && (profile[i].preferredController == preferred))
+ found[numFound++] = i;
+ }
+
+ return numFound;
+}
+