From fb361952ecbeade1804d35384505173c4e882471 Mon Sep 17 00:00:00 2001 From: Maschell Date: Tue, 10 Oct 2017 21:09:04 +0200 Subject: [PATCH] [WIP] Trying to implement motion controls and you the touch pad for emulating a mouse --- src/controller_patcher | 2 +- src/main.cpp | 13 ++++--- .../hid_controller_function_patcher.cpp | 35 ++++++++++++++++--- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/controller_patcher b/src/controller_patcher index 3bf0785..22775dc 160000 --- a/src/controller_patcher +++ b/src/controller_patcher @@ -1 +1 @@ -Subproject commit 3bf07857bebe4f1addf94c2e4cf2727e72d98789 +Subproject commit 22775dcbbb40c80682c6a4841eb66ebb08d457b7 diff --git a/src/main.cpp b/src/main.cpp index 634137a..135c357 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -89,6 +89,13 @@ extern "C" s32 Menu_Main(void){ ControllerPatcher::enableControllerMapping(); ControllerPatcher::startNetworkServer(); + //!******************************************************************* + //! Patching functions * + //!******************************************************************* + log_printf("Menu_Main(line %d): Patching functions\n",__LINE__); + ApplyPatches(); + + s32 result = 0; if(isInMiiMakerHBL()){ //!******************************************************************* @@ -117,11 +124,7 @@ extern "C" s32 Menu_Main(void){ } - //!******************************************************************* - //! Patching functions * - //!******************************************************************* - log_printf("Menu_Main(line %d): Patching functions\n",__LINE__); - ApplyPatches(); + if(!isInMiiMakerHBL()){ ControllerPatcher::disableWiiUEnergySetting(); diff --git a/src/patcher/hid_controller_function_patcher.cpp b/src/patcher/hid_controller_function_patcher.cpp index 13cb85a..edbbb08 100644 --- a/src/patcher/hid_controller_function_patcher.cpp +++ b/src/patcher/hid_controller_function_patcher.cpp @@ -33,11 +33,14 @@ typedef void (* WPADSamplingCallback )( s32 chan ); DECL(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, s32 scan_target){ - if(gHIDCurrentDevice & gHID_LIST_MOUSE && gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH) { - HID_Mouse_Data * mouse_data = ControllerPatcher::getMouseData(); - if(mouse_data != NULL){ - CursorDrawer::draw(mouse_data->X, mouse_data->Y); - } + if(gAppStatus == 2){ + real_GX2CopyColorBufferToScanBuffer(colorBuffer,scan_target); + return; + } + + HID_Mouse_Data * mouse_data = ControllerPatcher::getMouseData(); + if(mouse_data != (HID_Mouse_Data *)0x01){ + CursorDrawer::draw(mouse_data->X, mouse_data->Y); } real_GX2CopyColorBufferToScanBuffer(colorBuffer,scan_target); } @@ -120,6 +123,28 @@ DECL(s32, VPADRead, s32 chan, VPADData *buffer, u32 buffer_size, s32 *error) { ControllerPatcher::buttonRemapping(buffer,result); //ControllerPatcher::printVPADButtons(buffer); //Leads to random crashes on app transitions. } +/* + buffer->angle.x =0; + buffer->angle.y =0; + buffer->angle.z =0; + + buffer->dir.X.x = 1.0f; + buffer->dir.X.y = 0.0f; + buffer->dir.X.z = 0.0f; + + buffer->dir.Y.x = 0.0f;*/ + //buffer->dir.Y.y = 1.0f; + //buffer->dir.Y.z = 0.0f; + + //buffer->dir.Z.x = 0.0f; + + if(result > 0 && (buffer->btns_h & VPAD_BUTTON_R)){ + /*log_printf("VPADRead DirX: %2.2f %2.2f %2.2f DirY: %2.2f %2.2f %2.2f DirZ: %2.2f %2.2f %2.2f val: %2.2f speed: %2.2f vertical 1: %2.2f 2: %2.2f acc: x: %2.2f y: %2.2f z: %2.2f angle: x: %2.2f y: %2.2f z: %2.2f gyro x: %2.2f y: %2.2f z: %2.2f \n", + buffer->dir.X.x,buffer->dir.X.y,buffer->dir.X.z, + buffer->dir.Y.x,buffer->dir.Y.y,buffer->dir.Y.z, + buffer->dir.Z.x,buffer->dir.Z.y,buffer->dir.Z.z, + buffer->accValue,buffer->accSpeed,buffer->accVertical.x,buffer->accVertical.y,buffer->acc.x,buffer->acc.y,buffer->acc.z,buffer->angle.x,buffer->angle.y,buffer->angle.z,buffer->gyro.x,buffer->gyro.y,buffer->gyro.z);*/ + } return result; }