From 9119528a1bf1a0a84b10f8f2ab2bb91837b97567 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 7 May 2017 14:29:19 +0200 Subject: [PATCH] Renamed the sleep functions, added option to disable rumble --- ControllerPatcher.cpp | 10 ++++++++++ ControllerPatcher.hpp | 4 ++++ network/TCPServer.cpp | 4 ++-- network/UDPServer.cpp | 2 +- patcher/ControllerPatcherHID.cpp | 5 ++++- utils/CPRetainVars.cpp | 2 ++ utils/CPRetainVars.hpp | 1 + 7 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ControllerPatcher.cpp b/ControllerPatcher.cpp index 3ee6b2a..0176262 100644 --- a/ControllerPatcher.cpp +++ b/ControllerPatcher.cpp @@ -1049,3 +1049,13 @@ void ControllerPatcher::destroyConfigHelper(){ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::doSamplingForDeviceSlot(u16 device_slot){ return ControllerPatcherUtils::doSampling(device_slot,0,true); } + +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setRumbleActivated(bool value){ + gGlobalRumbleActivated = value; + return CONTROLLER_PATCHER_ERROR_NONE; +} + +bool ControllerPatcher::isRumbleActivated(){ + return gGlobalRumbleActivated; +} + diff --git a/ControllerPatcher.hpp b/ControllerPatcher.hpp index 09518f9..5e1deaa 100644 --- a/ControllerPatcher.hpp +++ b/ControllerPatcher.hpp @@ -238,6 +238,10 @@ class ControllerPatcher{ static void destroyConfigHelper(); static CONTROLLER_PATCHER_RESULT_OR_ERROR doSamplingForDeviceSlot(u16 device_slot); + + static CONTROLLER_PATCHER_RESULT_OR_ERROR setRumbleActivated(bool value); + + static bool isRumbleActivated(); }; #endif /* _CONTROLLER_PATCHER_H_ */ diff --git a/network/TCPServer.cpp b/network/TCPServer.cpp index 8f88c8b..d26efb4 100644 --- a/network/TCPServer.cpp +++ b/network/TCPServer.cpp @@ -123,7 +123,7 @@ s32 TCPServer::RunTCP(){ ret = ControllerPatcherNet::checkbyte(clientfd); if (ret < 0) { if(wiiu_errno != 6) return ret; - usleep(1000); + os_usleep(1000); continue; } //log_printf("got byte from tcp! %01X\n",ret); @@ -280,7 +280,7 @@ s32 TCPServer::RunTCP(){ void TCPServer::ErrorHandling(){ CloseSockets(); - usleep(1000*1000*2); + os_usleep(1000*1000*2); } void TCPServer::DoTCPThreadInternal(){ diff --git a/network/UDPServer.cpp b/network/UDPServer.cpp index 94ee3bb..3587e70 100644 --- a/network/UDPServer.cpp +++ b/network/UDPServer.cpp @@ -102,7 +102,7 @@ void UDPServer::DoUDPThreadInternal(){ n = recv(sockfd,buffer,MAX_UDP_SIZE,0); if (n < 0){ s32 errno_ = wiiu_errno; - usleep(2000); + os_usleep(2000); if(errno_ != 11 && errno_ != 9){ break; } diff --git a/patcher/ControllerPatcherHID.cpp b/patcher/ControllerPatcherHID.cpp index 92cfa6e..2ffab2e 100644 --- a/patcher/ControllerPatcherHID.cpp +++ b/patcher/ControllerPatcherHID.cpp @@ -101,7 +101,7 @@ void ControllerPatcherHID::myHIDReadCallback(u32 handle, s32 error, unsigned cha HIDReadCallback(handle,buf,bytes_transfered,usr); if(usr->slotdata.hidmask == gHID_LIST_DS4){ - usleep(1000*2); //DS4 is way tooo fast. sleeping to reduce lag. (need to check the other pads) + os_usleep(1000*2); //DS4 is way tooo fast. sleeping to reduce lag. (need to check the other pads) } HIDRead(handle, usr->buf, bytes_transfered, myHIDReadCallback, usr); } @@ -605,6 +605,8 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::getHIDData(u32 hidmask, void ControllerPatcherHID::HIDGCRumble(u32 handle,my_cb_user *usr){ if(usr == NULL) return; + if(!ControllerPatcher::isRumbleActivated()) return; + s32 rumblechanged = 0; for(s32 i = 0;i HID_MAX_PADS_COUNT) return; + if(!ControllerPatcher::isRumbleActivated()) return; s32 rumblechanged = 0; HID_Data * data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[pad]); diff --git a/utils/CPRetainVars.cpp b/utils/CPRetainVars.cpp index 85d48d3..96bec6f 100644 --- a/utils/CPRetainVars.cpp +++ b/utils/CPRetainVars.cpp @@ -65,6 +65,8 @@ wpad_extension_callback_t gExtensionCallback[4] __attribute__((section(".data")) wpad_sampling_callback_t gSamplingCallback __attribute__((section(".data"))) = 0; u8 gCallbackCooldown __attribute__((section(".data"))) = 0; +u8 gGlobalRumbleActivated __attribute__((section(".data"))) = 0; + u32 gUDPClientip __attribute__((section(".data"))) = 0; ControllerMappingPADInfo* gProPadInfo[4] __attribute__((section(".data"))) = {&gControllerMapping.proController[0].pad_infos[0], &gControllerMapping.proController[1].pad_infos[0], diff --git a/utils/CPRetainVars.hpp b/utils/CPRetainVars.hpp index becc9bf..4f71d4d 100644 --- a/utils/CPRetainVars.hpp +++ b/utils/CPRetainVars.hpp @@ -66,6 +66,7 @@ extern wpad_connect_callback_t gKPADConnectCallback[4]; extern wpad_extension_callback_t gExtensionCallback[4]; extern wpad_sampling_callback_t gSamplingCallback; extern u8 gCallbackCooldown; +extern u8 gGlobalRumbleActivated; extern u32 gUDPClientip; extern ControllerMappingPADInfo* gProPadInfo[4];