hid: Fixed vibration, toggling vibration-enable off->on is no longer needed. Properly closes #148.

This commit is contained in:
yellows8 2020-01-12 12:25:16 -05:00
parent cbe9fae600
commit 583d6bb92d
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43

View File

@ -11,6 +11,7 @@
static Service g_hidSrv; static Service g_hidSrv;
static Service g_hidIAppletResource; static Service g_hidIAppletResource;
static Service g_hidIActiveVibrationDeviceList;
static SharedMemory g_hidSharedmem; static SharedMemory g_hidSharedmem;
static HidTouchScreenEntry g_touchEntry; static HidTouchScreenEntry g_touchEntry;
@ -103,6 +104,8 @@ Result _hidInitialize(void) {
} }
void _hidCleanup(void) { void _hidCleanup(void) {
serviceClose(&g_hidIActiveVibrationDeviceList);
hidFinalizeSevenSixAxisSensor(); hidFinalizeSevenSixAxisSensor();
hidSetNpadJoyHoldType(HidJoyHoldType_Default); hidSetNpadJoyHoldType(HidJoyHoldType_Default);
@ -1098,19 +1101,20 @@ static Result _hidGetDeviceHandles(u32 devicetype, u32 *DeviceHandles, s32 total
Result hidInitializeVibrationDevices(u32 *VibrationDeviceHandles, s32 total_handles, HidControllerID id, HidControllerType type) { Result hidInitializeVibrationDevices(u32 *VibrationDeviceHandles, s32 total_handles, HidControllerID id, HidControllerType type) {
Result rc=0; Result rc=0;
Service srv;
s32 i; s32 i;
rc = _hidGetDeviceHandles(0, VibrationDeviceHandles, total_handles, id, type); rc = _hidGetDeviceHandles(0, VibrationDeviceHandles, total_handles, id, type);
if (R_FAILED(rc)) return rc; if (R_FAILED(rc)) return rc;
for (i=0; i<total_handles; i++) { rwlockWriteLock(&g_hidLock);
rc = _hidCreateActiveVibrationDeviceList(&srv); if (!serviceIsActive(&g_hidIActiveVibrationDeviceList)) {
if (R_FAILED(rc)) rc = _hidCreateActiveVibrationDeviceList(&g_hidIActiveVibrationDeviceList);
break; if (R_FAILED(rc)) return rc;
}
rwlockWriteUnlock(&g_hidLock);
rc = _hidActivateVibrationDevice(&srv, VibrationDeviceHandles[i]); for (i=0; i<total_handles; i++) {
serviceClose(&srv); rc = _hidActivateVibrationDevice(&g_hidIActiveVibrationDeviceList, VibrationDeviceHandles[i]);
if (R_FAILED(rc)) if (R_FAILED(rc))
break; break;