Renamed the sleep functions, added option to disable rumble

This commit is contained in:
Maschell 2017-05-07 14:29:19 +02:00
parent 5c7be021d0
commit 9119528a1b
7 changed files with 24 additions and 4 deletions

View File

@ -1049,3 +1049,13 @@ void ControllerPatcher::destroyConfigHelper(){
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::doSamplingForDeviceSlot(u16 device_slot){ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::doSamplingForDeviceSlot(u16 device_slot){
return ControllerPatcherUtils::doSampling(device_slot,0,true); 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;
}

View File

@ -238,6 +238,10 @@ class ControllerPatcher{
static void destroyConfigHelper(); static void destroyConfigHelper();
static CONTROLLER_PATCHER_RESULT_OR_ERROR doSamplingForDeviceSlot(u16 device_slot); 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_ */ #endif /* _CONTROLLER_PATCHER_H_ */

View File

@ -123,7 +123,7 @@ s32 TCPServer::RunTCP(){
ret = ControllerPatcherNet::checkbyte(clientfd); ret = ControllerPatcherNet::checkbyte(clientfd);
if (ret < 0) { if (ret < 0) {
if(wiiu_errno != 6) return ret; if(wiiu_errno != 6) return ret;
usleep(1000); os_usleep(1000);
continue; continue;
} }
//log_printf("got byte from tcp! %01X\n",ret); //log_printf("got byte from tcp! %01X\n",ret);
@ -280,7 +280,7 @@ s32 TCPServer::RunTCP(){
void TCPServer::ErrorHandling(){ void TCPServer::ErrorHandling(){
CloseSockets(); CloseSockets();
usleep(1000*1000*2); os_usleep(1000*1000*2);
} }
void TCPServer::DoTCPThreadInternal(){ void TCPServer::DoTCPThreadInternal(){

View File

@ -102,7 +102,7 @@ void UDPServer::DoUDPThreadInternal(){
n = recv(sockfd,buffer,MAX_UDP_SIZE,0); n = recv(sockfd,buffer,MAX_UDP_SIZE,0);
if (n < 0){ if (n < 0){
s32 errno_ = wiiu_errno; s32 errno_ = wiiu_errno;
usleep(2000); os_usleep(2000);
if(errno_ != 11 && errno_ != 9){ if(errno_ != 11 && errno_ != 9){
break; break;
} }

View File

@ -101,7 +101,7 @@ void ControllerPatcherHID::myHIDReadCallback(u32 handle, s32 error, unsigned cha
HIDReadCallback(handle,buf,bytes_transfered,usr); HIDReadCallback(handle,buf,bytes_transfered,usr);
if(usr->slotdata.hidmask == gHID_LIST_DS4){ 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); 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){ void ControllerPatcherHID::HIDGCRumble(u32 handle,my_cb_user *usr){
if(usr == NULL) return; if(usr == NULL) return;
if(!ControllerPatcher::isRumbleActivated()) return;
s32 rumblechanged = 0; s32 rumblechanged = 0;
for(s32 i = 0;i<HID_GC_PAD_COUNT;i++){ for(s32 i = 0;i<HID_GC_PAD_COUNT;i++){
@ -625,6 +627,7 @@ void ControllerPatcherHID::HIDGCRumble(u32 handle,my_cb_user *usr){
void ControllerPatcherHID::HIDRumble(u32 handle,my_cb_user *usr,u32 pad){ void ControllerPatcherHID::HIDRumble(u32 handle,my_cb_user *usr,u32 pad){
if(usr == NULL || pad > HID_MAX_PADS_COUNT) return; if(usr == NULL || pad > HID_MAX_PADS_COUNT) return;
if(!ControllerPatcher::isRumbleActivated()) return;
s32 rumblechanged = 0; s32 rumblechanged = 0;
HID_Data * data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[pad]); HID_Data * data_ptr = &(gHID_Devices[usr->slotdata.deviceslot].pad_data[pad]);

View File

@ -65,6 +65,8 @@ wpad_extension_callback_t gExtensionCallback[4] __attribute__((section(".data"))
wpad_sampling_callback_t gSamplingCallback __attribute__((section(".data"))) = 0; wpad_sampling_callback_t gSamplingCallback __attribute__((section(".data"))) = 0;
u8 gCallbackCooldown __attribute__((section(".data"))) = 0; u8 gCallbackCooldown __attribute__((section(".data"))) = 0;
u8 gGlobalRumbleActivated __attribute__((section(".data"))) = 0;
u32 gUDPClientip __attribute__((section(".data"))) = 0; u32 gUDPClientip __attribute__((section(".data"))) = 0;
ControllerMappingPADInfo* gProPadInfo[4] __attribute__((section(".data"))) = {&gControllerMapping.proController[0].pad_infos[0], ControllerMappingPADInfo* gProPadInfo[4] __attribute__((section(".data"))) = {&gControllerMapping.proController[0].pad_infos[0],
&gControllerMapping.proController[1].pad_infos[0], &gControllerMapping.proController[1].pad_infos[0],

View File

@ -66,6 +66,7 @@ extern wpad_connect_callback_t gKPADConnectCallback[4];
extern wpad_extension_callback_t gExtensionCallback[4]; extern wpad_extension_callback_t gExtensionCallback[4];
extern wpad_sampling_callback_t gSamplingCallback; extern wpad_sampling_callback_t gSamplingCallback;
extern u8 gCallbackCooldown; extern u8 gCallbackCooldown;
extern u8 gGlobalRumbleActivated;
extern u32 gUDPClientip; extern u32 gUDPClientip;
extern ControllerMappingPADInfo* gProPadInfo[4]; extern ControllerMappingPADInfo* gProPadInfo[4];