mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
Renamed hidInitializeVibrationDevice() to hidInitializeVibrationDevices(), and added support for optionally returning 2 handles + other changes.
This commit is contained in:
parent
cbaa0e359b
commit
d1cefabd12
@ -587,7 +587,7 @@ Result hidSetNpadJoyAssignmentModeSingleByDefault(HidControllerID id);
|
|||||||
/// id must be CONTROLLER_PLAYER_*.
|
/// id must be CONTROLLER_PLAYER_*.
|
||||||
Result hidSetNpadJoyAssignmentModeDual(HidControllerID id);
|
Result hidSetNpadJoyAssignmentModeDual(HidControllerID id);
|
||||||
|
|
||||||
Result hidInitializeVibrationDevice(u32 *VibrationDeviceHandle, HidControllerID id, HidControllerLayoutType type);
|
Result hidInitializeVibrationDevices(u32 *VibrationDeviceHandles, size_t total_handles, HidControllerID id, HidControllerLayoutType type);
|
||||||
|
|
||||||
Result hidSendVibrationValue(u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue);
|
Result hidSendVibrationValue(u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue);
|
||||||
|
|
||||||
|
@ -722,19 +722,49 @@ Result hidIsVibrationPermitted(bool *flag) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result hidInitializeVibrationDevice(u32 *VibrationDeviceHandle, HidControllerID id, HidControllerLayoutType type) {
|
Result hidInitializeVibrationDevices(u32 *VibrationDeviceHandles, size_t total_handles, HidControllerID id, HidControllerLayoutType type) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
Service srv;
|
Service srv;
|
||||||
|
u32 tmp_type = type & 0xff;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (total_handles == 0 || total_handles > 2)
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
|
|
||||||
|
if (tmp_type < 5) {
|
||||||
|
if (tmp_type == 4) tmp_type |= 0x010000;
|
||||||
|
tmp_type+= 3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (tmp_type == 5) tmp_type = 0x20;
|
||||||
|
if (tmp_type == 6) tmp_type = 0x21;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Is type correct?
|
//TODO: Is type correct?
|
||||||
*VibrationDeviceHandle = (type & 0xff) | (id & 0xff)<<8;
|
VibrationDeviceHandles[0] = tmp_type | (id & 0xff)<<8;
|
||||||
|
|
||||||
|
if (total_handles > 1) {
|
||||||
|
tmp_type &= 0xff;
|
||||||
|
if (tmp_type!=6 && tmp_type!=7) {
|
||||||
|
VibrationDeviceHandles[1] = VibrationDeviceHandles[0] | 0x010000;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<total_handles; i++) {
|
||||||
rc = _hidCreateActiveVibrationDeviceList(&srv);
|
rc = _hidCreateActiveVibrationDeviceList(&srv);
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc))
|
||||||
return rc;
|
break;
|
||||||
|
|
||||||
rc = _hidActivateVibrationDevice(&srv, *VibrationDeviceHandle);
|
rc = _hidActivateVibrationDevice(&srv, VibrationDeviceHandles[i]);
|
||||||
serviceClose(&srv);
|
serviceClose(&srv);
|
||||||
|
|
||||||
|
if (R_FAILED(rc))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user