src/sensor/windows/SDL_windowssensor.c
changeset 13844 3c44ba7a04fd
parent 13842 a09f7d0800eb
child 13918 b622185b81ce
equal deleted inserted replaced
13843:cbd001bb0b89 13844:3c44ba7a04fd
   259     BSTR bstr_name = NULL;
   259     BSTR bstr_name = NULL;
   260     char *name;
   260     char *name;
   261 
   261 
   262     hr = ISensor_GetID(sensor, &sensor_id);
   262     hr = ISensor_GetID(sensor, &sensor_id);
   263     if (FAILED(hr)) {
   263     if (FAILED(hr)) {
   264         return SDL_SetError("Couldn't get sensor ID: 0x%.4x", hr);
   264         return WIN_SetErrorFromHRESULT("Couldn't get sensor ID", hr);
   265     }
   265     }
   266 
   266 
   267     hr = ISensor_GetType(sensor, &type_id);
   267     hr = ISensor_GetType(sensor, &type_id);
   268     if (FAILED(hr)) {
   268     if (FAILED(hr)) {
   269         return SDL_SetError("Couldn't get sensor type: 0x%.4x", hr);
   269         return WIN_SetErrorFromHRESULT("Couldn't get sensor type", hr);
   270     }
   270     }
   271 
   271 
   272     if (WIN_IsEqualIID(&type_id, &SENSOR_TYPE_ACCELEROMETER_3D)) {
   272     if (WIN_IsEqualIID(&type_id, &SENSOR_TYPE_ACCELEROMETER_3D)) {
   273         type = SDL_SENSOR_ACCEL;
   273         type = SDL_SENSOR_ACCEL;
   274     } else if (WIN_IsEqualIID(&type_id, &SENSOR_TYPE_GYROMETER_3D)) {
   274     } else if (WIN_IsEqualIID(&type_id, &SENSOR_TYPE_GYROMETER_3D)) {
   349         SDL_windowscoinit = SDL_TRUE;
   349         SDL_windowscoinit = SDL_TRUE;
   350     }
   350     }
   351 
   351 
   352     hr = CoCreateInstance(&SDL_CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &SDL_IID_SensorManager, (LPVOID *) &SDL_sensor_manager);
   352     hr = CoCreateInstance(&SDL_CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &SDL_IID_SensorManager, (LPVOID *) &SDL_sensor_manager);
   353     if (FAILED(hr)) {
   353     if (FAILED(hr)) {
   354         return SDL_SetError("Couldn't create the sensor manager: 0x%.4x", hr);
   354         return WIN_SetErrorFromHRESULT("Couldn't create the sensor manager", hr);
   355     }
   355     }
   356 
   356 
   357     hr = ISensorManager_SetEventSink(SDL_sensor_manager, &sensor_manager_events);
   357     hr = ISensorManager_SetEventSink(SDL_sensor_manager, &sensor_manager_events);
   358     if (FAILED(hr)) {
   358     if (FAILED(hr)) {
   359         ISensorManager_Release(SDL_sensor_manager);
   359         ISensorManager_Release(SDL_sensor_manager);
   360         return SDL_SetError("Couldn't set the sensor manager event sink: 0x%.4x", hr);
   360         return WIN_SetErrorFromHRESULT("Couldn't set the sensor manager event sink", hr);
   361     }
   361     }
   362 
   362 
   363     hr = ISensorManager_GetSensorsByCategory(SDL_sensor_manager, &SENSOR_CATEGORY_ALL, &sensor_collection);
   363     hr = ISensorManager_GetSensorsByCategory(SDL_sensor_manager, &SENSOR_CATEGORY_ALL, &sensor_collection);
   364     if (SUCCEEDED(hr)) {
   364     if (SUCCEEDED(hr)) {
   365         ULONG i, count;
   365         ULONG i, count;