| 1117 | } |
| 1118 | |
| 1119 | HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bExclusive) |
| 1120 | { |
| 1121 | LOGV( "hid_open_path( %s )", path ); |
| 1122 | |
| 1123 | hid_device_ref< CHIDDevice > pDevice; |
| 1124 | { |
| 1125 | hid_mutex_guard r( &g_DevicesRefCountMutex ); |
| 1126 | hid_mutex_guard l( &g_DevicesMutex ); |
| 1127 | for ( hid_device_ref<CHIDDevice> pCurr = g_Devices; pCurr; pCurr = pCurr->next ) |
| 1128 | { |
| 1129 | if ( SDL_strcmp( pCurr->GetDeviceInfo()->path, path ) == 0 ) |
| 1130 | { |
| 1131 | hid_device *pValue = pCurr->GetDevice(); |
| 1132 | if ( pValue ) |
| 1133 | { |
| 1134 | ++pValue->m_nDeviceRefCount; |
| 1135 | LOGD("Incrementing device %d (%p), refCount = %d\n", pValue->m_nId, pValue, pValue->m_nDeviceRefCount); |
| 1136 | return pValue; |
| 1137 | } |
| 1138 | |
| 1139 | // Hold a shared pointer to the controller for the duration |
| 1140 | pDevice = pCurr; |
| 1141 | break; |
| 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | if ( pDevice && pDevice->BOpen() ) |
| 1146 | { |
| 1147 | return pDevice->GetDevice(); |
| 1148 | } |
| 1149 | return NULL; |
| 1150 | } |
| 1151 | |
| 1152 | int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length) |
| 1153 | { |