diff --git a/libultraship/libultraship/Controller.cpp b/libultraship/libultraship/Controller.cpp index d6459b8b2..26151ab91 100644 --- a/libultraship/libultraship/Controller.cpp +++ b/libultraship/libultraship/Controller.cpp @@ -14,25 +14,27 @@ namespace Ship { Attachment = nullptr; } + SDL_Event ev; + + void Controller::Read(OSContPad* pad) { ReadFromSource(); - // Mouse Inputs + // Touch Inputs int x, y; Uint32 buttons; SDL_PumpEvents(); buttons = SDL_GetMouseState(&x, &y); - wTouchX = x; wTouchY = y; + // Click Inputs if ((buttons & SDL_BUTTON_LMASK) != 0) { wLeftClick = 1; } else { wLeftClick = 0; } - if ((buttons & SDL_BUTTON_RMASK) != 0) { wRightClick = 1; } @@ -40,8 +42,18 @@ namespace Ship { wRightClick = 0; } + // Mouse Inputs + int x2, y2; + Uint32 buttons2; + SDL_PumpEvents(); + buttons2 = SDL_GetRelativeMouseState(&x2, &y2); + wMouseMoveX = x2; + wMouseMoveY = y2; + + // Button Inputs pad->button |= dwPressedButtons & 0xFFFF; + // Stick Inputs if (pad->stick_x == 0) { if (dwPressedButtons & BTN_STICKLEFT) { pad->stick_x = -128; @@ -66,16 +78,23 @@ namespace Ship { } } + // Gyro pad->gyro_x = wGyroX; pad->gyro_y = wGyroY; + // Right Stick pad->cam_x = wCamX; pad->cam_y = wCamY; + // Click/Touch pad->touch_x = wTouchX; pad->touch_y = wTouchY; pad->left_click = wLeftClick; pad->right_click = wRightClick; + + // Mouse + pad->mouse_move_x = wMouseMoveX; + pad->mouse_move_y = wMouseMoveY; } void Controller::SetButtonMapping(const std::string& szButtonName, int32_t dwScancode) { diff --git a/libultraship/libultraship/Controller.h b/libultraship/libultraship/Controller.h index 1257b76e7..ac3b706bd 100644 --- a/libultraship/libultraship/Controller.h +++ b/libultraship/libultraship/Controller.h @@ -45,7 +45,10 @@ namespace Ship { float wCamX; float wCamY; - + + float wMouseMoveX; + float wMouseMoveY; + virtual std::string GetControllerType() = 0; virtual std::string GetConfSection() = 0; virtual std::string GetBindingConfSection() = 0; diff --git a/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/controller.h b/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/controller.h index 670362a29..81a12da68 100644 --- a/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/controller.h +++ b/libultraship/libultraship/Lib/Fast3D/U64/PR/ultra64/controller.h @@ -118,9 +118,11 @@ typedef struct { /* 0x0B */ u8 right_click; /* 0x0C */ f32 touch_x; /* 0x10 */ f32 touch_y; - /* 0x14 */ f32 cam_x; - /* 0x18 */ f32 cam_y; -} OSContPad; // size = 0x1C + /* 0x14 */ f32 mouse_move_x; + /* 0x18 */ f32 mouse_move_y; + /* 0x1C */ f32 cam_x; + /* 0x20 */ f32 cam_y; +} OSContPad; // size = 0x24 typedef struct { /* 0x00 */ u8 rumble; diff --git a/libultraship/libultraship/UltraController.h b/libultraship/libultraship/UltraController.h index b58fecd62..08764b0f2 100644 --- a/libultraship/libultraship/UltraController.h +++ b/libultraship/libultraship/UltraController.h @@ -124,9 +124,11 @@ typedef struct { /* 0x0B */ uint8_t right_click; /* 0x0C */ float touch_x; /* 0x10 */ float touch_y; - /* 0x14 */ float cam_x; - /* 0x18 */ float cam_y; -} OSContPad; // size = 0x1C + /* 0x14 */ float mouse_move_x; + /* 0x18 */ float mouse_move_y; + /* 0x1C */ float cam_x; + /* 0x20 */ float cam_y; +} OSContPad; // size = 0x24 typedef struct { /* 0x00 */ uint8_t rumble; diff --git a/soh/src/code/title_setup.c b/soh/src/code/title_setup.c index 131c97627..1e709dc12 100644 --- a/soh/src/code/title_setup.c +++ b/soh/src/code/title_setup.c @@ -4,7 +4,7 @@ void TitleSetup_InitImpl(GameState* gameState) { osSyncPrintf("ゼルダ共通データ初期化\n"); // "Zelda common data initalization" SaveContext_Init(); gameState->running = false; - SET_NEXT_GAMESTATE(gameState, FileChoose_Init, TitleContext); + SET_NEXT_GAMESTATE(gameState, Title_Init, TitleContext); } void TitleSetup_Destroy(GameState* gameState) { diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 33aacd121..8eb1ae579 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -1432,6 +1432,9 @@ s32 SetCameraManual(Camera* camera) { return 0; } +f32 lastMouseX; +f32 lastMouseY; + s32 Camera_Free(Camera* camera) { Normal1* norm1 = (Normal1*)camera->paramData; @@ -1501,14 +1504,20 @@ s32 Camera_Free(Camera* camera) { camera->dist = eyeAdjustment.r = Camera_LERPCeilF(150.0f, camera->dist, camSpeed / 4, 1.0f); } - f32 newCamX = -D_8015BD7C->state.input[0].cur.cam_x; - f32 newCamY = D_8015BD7C->state.input[0].cur.cam_y; + // Mouse Free Camera + f32 mouseX = D_8015BD7C->state.input[0].cur.touch_x - lastMouseX; + lastMouseX = D_8015BD7C->state.input[0].cur.touch_x; + f32 mouseY = D_8015BD7C->state.input[0].cur.touch_y - lastMouseY; + lastMouseY = D_8015BD7C->state.input[0].cur.touch_y; - if (fabsf(newCamX) >= 250.0f) { + f32 newCamX = -D_8015BD7C->state.input[0].cur.cam_x + -(mouseX * 40.0f); + f32 newCamY = D_8015BD7C->state.input[0].cur.cam_y + (mouseY * 40.0f); + + if (fabsf(newCamX) >= 200.0f) { camX += newCamX; } - if (fabsf(newCamY) >= 250.0f) { + if (fabsf(newCamY) >= 200.0f) { camY += newCamY; }