mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
Added WIP mouse support to the free cam
This commit is contained in:
parent
a91bd6acaf
commit
9e48935186
6 changed files with 50 additions and 15 deletions
|
@ -14,25 +14,27 @@ namespace Ship {
|
||||||
Attachment = nullptr;
|
Attachment = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Event ev;
|
||||||
|
|
||||||
|
|
||||||
void Controller::Read(OSContPad* pad) {
|
void Controller::Read(OSContPad* pad) {
|
||||||
ReadFromSource();
|
ReadFromSource();
|
||||||
|
|
||||||
// Mouse Inputs
|
// Touch Inputs
|
||||||
int x, y;
|
int x, y;
|
||||||
Uint32 buttons;
|
Uint32 buttons;
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
buttons = SDL_GetMouseState(&x, &y);
|
buttons = SDL_GetMouseState(&x, &y);
|
||||||
|
|
||||||
wTouchX = x;
|
wTouchX = x;
|
||||||
wTouchY = y;
|
wTouchY = y;
|
||||||
|
|
||||||
|
// Click Inputs
|
||||||
if ((buttons & SDL_BUTTON_LMASK) != 0) {
|
if ((buttons & SDL_BUTTON_LMASK) != 0) {
|
||||||
wLeftClick = 1;
|
wLeftClick = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wLeftClick = 0;
|
wLeftClick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buttons & SDL_BUTTON_RMASK) != 0) {
|
if ((buttons & SDL_BUTTON_RMASK) != 0) {
|
||||||
wRightClick = 1;
|
wRightClick = 1;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +42,18 @@ namespace Ship {
|
||||||
wRightClick = 0;
|
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;
|
pad->button |= dwPressedButtons & 0xFFFF;
|
||||||
|
|
||||||
|
// Stick Inputs
|
||||||
if (pad->stick_x == 0) {
|
if (pad->stick_x == 0) {
|
||||||
if (dwPressedButtons & BTN_STICKLEFT) {
|
if (dwPressedButtons & BTN_STICKLEFT) {
|
||||||
pad->stick_x = -128;
|
pad->stick_x = -128;
|
||||||
|
@ -66,16 +78,23 @@ namespace Ship {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gyro
|
||||||
pad->gyro_x = wGyroX;
|
pad->gyro_x = wGyroX;
|
||||||
pad->gyro_y = wGyroY;
|
pad->gyro_y = wGyroY;
|
||||||
|
|
||||||
|
// Right Stick
|
||||||
pad->cam_x = wCamX;
|
pad->cam_x = wCamX;
|
||||||
pad->cam_y = wCamY;
|
pad->cam_y = wCamY;
|
||||||
|
|
||||||
|
// Click/Touch
|
||||||
pad->touch_x = wTouchX;
|
pad->touch_x = wTouchX;
|
||||||
pad->touch_y = wTouchY;
|
pad->touch_y = wTouchY;
|
||||||
pad->left_click = wLeftClick;
|
pad->left_click = wLeftClick;
|
||||||
pad->right_click = wRightClick;
|
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) {
|
void Controller::SetButtonMapping(const std::string& szButtonName, int32_t dwScancode) {
|
||||||
|
|
|
@ -45,7 +45,10 @@ namespace Ship {
|
||||||
|
|
||||||
float wCamX;
|
float wCamX;
|
||||||
float wCamY;
|
float wCamY;
|
||||||
|
|
||||||
|
float wMouseMoveX;
|
||||||
|
float wMouseMoveY;
|
||||||
|
|
||||||
virtual std::string GetControllerType() = 0;
|
virtual std::string GetControllerType() = 0;
|
||||||
virtual std::string GetConfSection() = 0;
|
virtual std::string GetConfSection() = 0;
|
||||||
virtual std::string GetBindingConfSection() = 0;
|
virtual std::string GetBindingConfSection() = 0;
|
||||||
|
|
|
@ -118,9 +118,11 @@ typedef struct {
|
||||||
/* 0x0B */ u8 right_click;
|
/* 0x0B */ u8 right_click;
|
||||||
/* 0x0C */ f32 touch_x;
|
/* 0x0C */ f32 touch_x;
|
||||||
/* 0x10 */ f32 touch_y;
|
/* 0x10 */ f32 touch_y;
|
||||||
/* 0x14 */ f32 cam_x;
|
/* 0x14 */ f32 mouse_move_x;
|
||||||
/* 0x18 */ f32 cam_y;
|
/* 0x18 */ f32 mouse_move_y;
|
||||||
} OSContPad; // size = 0x1C
|
/* 0x1C */ f32 cam_x;
|
||||||
|
/* 0x20 */ f32 cam_y;
|
||||||
|
} OSContPad; // size = 0x24
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ u8 rumble;
|
/* 0x00 */ u8 rumble;
|
||||||
|
|
|
@ -124,9 +124,11 @@ typedef struct {
|
||||||
/* 0x0B */ uint8_t right_click;
|
/* 0x0B */ uint8_t right_click;
|
||||||
/* 0x0C */ float touch_x;
|
/* 0x0C */ float touch_x;
|
||||||
/* 0x10 */ float touch_y;
|
/* 0x10 */ float touch_y;
|
||||||
/* 0x14 */ float cam_x;
|
/* 0x14 */ float mouse_move_x;
|
||||||
/* 0x18 */ float cam_y;
|
/* 0x18 */ float mouse_move_y;
|
||||||
} OSContPad; // size = 0x1C
|
/* 0x1C */ float cam_x;
|
||||||
|
/* 0x20 */ float cam_y;
|
||||||
|
} OSContPad; // size = 0x24
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ uint8_t rumble;
|
/* 0x00 */ uint8_t rumble;
|
||||||
|
|
|
@ -4,7 +4,7 @@ void TitleSetup_InitImpl(GameState* gameState) {
|
||||||
osSyncPrintf("ゼルダ共通データ初期化\n"); // "Zelda common data initalization"
|
osSyncPrintf("ゼルダ共通データ初期化\n"); // "Zelda common data initalization"
|
||||||
SaveContext_Init();
|
SaveContext_Init();
|
||||||
gameState->running = false;
|
gameState->running = false;
|
||||||
SET_NEXT_GAMESTATE(gameState, FileChoose_Init, TitleContext);
|
SET_NEXT_GAMESTATE(gameState, Title_Init, TitleContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleSetup_Destroy(GameState* gameState) {
|
void TitleSetup_Destroy(GameState* gameState) {
|
||||||
|
|
|
@ -1432,6 +1432,9 @@ s32 SetCameraManual(Camera* camera) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f32 lastMouseX;
|
||||||
|
f32 lastMouseY;
|
||||||
|
|
||||||
s32 Camera_Free(Camera* camera) {
|
s32 Camera_Free(Camera* camera) {
|
||||||
Normal1* norm1 = (Normal1*)camera->paramData;
|
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);
|
camera->dist = eyeAdjustment.r = Camera_LERPCeilF(150.0f, camera->dist, camSpeed / 4, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 newCamX = -D_8015BD7C->state.input[0].cur.cam_x;
|
// Mouse Free Camera
|
||||||
f32 newCamY = D_8015BD7C->state.input[0].cur.cam_y;
|
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;
|
camX += newCamX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabsf(newCamY) >= 250.0f) {
|
if (fabsf(newCamY) >= 200.0f) {
|
||||||
camY += newCamY;
|
camY += newCamY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue