From f425e865dd67acceec2bf5acc49c186d7c90b480 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 14 Sep 2024 23:15:04 +1000 Subject: [PATCH] Wii: Untested USB mouse support --- src/Window_GCWii.c | 35 +++++++++++++++++++++++++++++++++- third_party/dsiwifi/.gitignore | 2 -- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Window_GCWii.c b/src/Window_GCWii.c index 2aba6de8e..f276040c0 100644 --- a/src/Window_GCWii.c +++ b/src/Window_GCWii.c @@ -14,12 +14,14 @@ #include "VirtualKeyboard.h" #include #if defined HW_RVL +#include #include #include #endif static cc_bool needsFBUpdate; static cc_bool launcherMode; +static int mouseSupported; #include "VirtualCursor.h" static void* xfb; static GXRModeObj* rmode; @@ -86,6 +88,7 @@ void Window_Init(void) { #if defined HW_RVL KEYBOARD_Init(NULL); + mouseSupported = MOUSE_Init() >= 0; #endif } @@ -168,7 +171,7 @@ static void ProcessPADInputs(float delta) { /*########################################################################################################################* -*--------------------------------------------------Kebyaord processing----------------------------------------------------* +*--------------------------------------------------Keyboard processing----------------------------------------------------* *#########################################################################################################################*/ #if defined HW_RVL static const cc_uint8 key_map[] = { @@ -231,6 +234,35 @@ static void ProcessKeyboardInput(void) { #endif +/*########################################################################################################################* +*---------------------------------------------------Mouse processing------------------------------------------------------* +*#########################################################################################################################*/ +#if defined HW_RVL +static void ProcessMouseInput(float delta) { + if (!mouseSupported) return; + if (!MOUSE_IsConnected()) return; + + mouse_event event; + if (MOUSE_GetEvent(&event) == 0) return; + + Input_SetNonRepeatable(CCMOUSE_L, event.button & 4); + Input_SetNonRepeatable(CCMOUSE_R, event.button & 1); + Input_SetNonRepeatable(CCMOUSE_M, event.button & 2); + Mouse_ScrollVWheel(event.rz * 0.5f); + + if (!vc_hooked) { + Pointer_SetPosition(0, Window_Main.Width / 2, Window_Main.Height / 2); + } + VirtualCursor_SetPosition(Pointers[0].x + event.rx, Pointers[0].y + event.ry); + + if (!Input.RawMode) return; + float scale = (delta * 60.0) / 2.0f; + Event_RaiseRawMove(&PointerEvents.RawMoved, + event.rx * scale, event.ry * scale); +} +#endif + + /*########################################################################################################################* *----------------------------------------------------Input processing-----------------------------------------------------* *#########################################################################################################################*/ @@ -241,6 +273,7 @@ static cc_bool dragActive; void Window_ProcessEvents(float delta) { ProcessKeyboardInput(); + ProcessMouseInput(delta); } static void GetIRPos(int res, int* x, int* y) { diff --git a/third_party/dsiwifi/.gitignore b/third_party/dsiwifi/.gitignore index 25d39aacc..eba9a04a4 100644 --- a/third_party/dsiwifi/.gitignore +++ b/third_party/dsiwifi/.gitignore @@ -2,7 +2,5 @@ arm_iop/debug arm_iop/release arm_host/debug arm_host/release -include/dswifi_version.h -include/dsiwifi_version.h lib *.bz2