This commit is contained in:
ineedhelpbad 2023-10-30 11:31:28 -05:00 committed by GitHub
commit b74088e699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 26 deletions

View File

@ -24,6 +24,16 @@
#include "config.h"
#include "gfx_dimensions.h"
#ifdef BETTERCAMERA
#include "pc/controller/controller_mouse.h"
#include "pc/configfile.h"
static bool mouseControl = FALSE;
static int oldMouse_x;
static int oldMouse_y;
#endif
#define MAX_GD_DLS 1000
#define OS_MESG_SI_COMPLETE 0x33333333
@ -2442,20 +2452,43 @@ void parse_p1_controller(void) {
// deadzone checks?
if (ABS(gdctrl->stickX) >= 6) {
gdctrl->csrX += gdctrl->stickX * 0.1; //? 0.1f
#ifdef BETTERCAMERA
mouseControl = FALSE;
#endif
}
if (ABS(gdctrl->stickY) >= 6) {
gdctrl->csrY -= gdctrl->stickY * 0.1; //? 0.1f
#ifdef BETTERCAMERA
mouseControl = FALSE;
#endif
}
#ifdef BETTERCAMERA
if (mouse_x - oldMouse_x != 0 || mouse_y - oldMouse_y != 0)
mouseControl = true;
if (mouseControl) {
float screenScale = (float) gfx_current_dimensions.height / (float)SCREEN_HEIGHT;
if (configCameraMouse) {
gdctrl->csrX = (mouse_x - (gfx_current_dimensions.width - (screenScale * (float)SCREEN_WIDTH))/ 2)/ screenScale;
gdctrl->csrY = mouse_y / screenScale;
}
}
oldMouse_x = mouse_x;
oldMouse_y = mouse_y;
if (!mouseControl) {
#endif
// border checks? is this for the cursor finger movement?
if ((f32) gdctrl->csrX < (sScreenView2->parent->upperLeft.x + (16.0f/aspect))) {
gdctrl->csrX = (s32)(sScreenView2->parent->upperLeft.x + (16.0f/aspect));
if ((f32) gdctrl->csrX < (sScreenView2->parent->upperLeft.x + (16.0f / aspect))) {
gdctrl->csrX = (s32)(sScreenView2->parent->upperLeft.x + (16.0f / aspect));
}
if ((f32) gdctrl->csrX
> (sScreenView2->parent->upperLeft.x + sScreenView2->parent->lowerRight.x - (48.0/aspect))) {
gdctrl->csrX =
(s32)(sScreenView2->parent->upperLeft.x + sScreenView2->parent->lowerRight.x - (48.0/aspect));
> (sScreenView2->parent->upperLeft.x + sScreenView2->parent->lowerRight.x - (48.0 / aspect))) {
gdctrl->csrX = (s32)(sScreenView2->parent->upperLeft.x + sScreenView2->parent->lowerRight.x
- (48.0 / aspect));
}
if ((f32) gdctrl->csrY < (sScreenView2->parent->upperLeft.y + 16.0f)) {
@ -2471,8 +2504,11 @@ void parse_p1_controller(void) {
for (i = 0; i < sizeof(OSContPad); i++) {
((u8 *) p1contPrev)[i] = ((u8 *) p1cont)[i];
}
}
#ifdef BETTERCAMERA
}
#endif
}
/* 251A1C -> 251AC4 */
void Unknown801A324C(f32 arg0) {
return;

View File

@ -21,6 +21,16 @@
#include "sm64.h"
#include "text_strings.h"
#ifdef BETTERCAMERA
#include "pc/controller/controller_mouse.h"
#include "pc/configfile.h"
static bool mouseControl = FALSE;
static int oldMouse_x;
static int oldMouse_y;
#endif
#include "eu_translation.h"
#ifdef VERSION_EU
#undef LANGUAGE_FUNCTION
@ -75,7 +85,12 @@ static u8 sYesNoColor[2];
#ifdef VERSION_EU
static s16 sCenteredX;
#endif
struct GfxDimensions {
uint32_t width, height;
float aspect_ratio;
};
extern struct GfxDimensions gfx_current_dimensions;
// The button that is selected when it is clicked.
static s8 sSelectedButtonID = MENU_BUTTON_NONE;
@ -133,7 +148,7 @@ static s8 sAllFilesExist = FALSE;
// Defines the value of the save slot selected in the menu.
// Mario A: 1 | Mario B: 2 | Mario C: 3 | Mario D: 4
static s8 sSelectedFileNum = 0;
s8 sSelectedFileNum = 0;
// Which coin score mode to use when scoring files. 0 for local
// coin high score, 1 for high score across all files.
@ -1607,34 +1622,64 @@ void handle_controller_cursor_input(void) {
if (rawStickY > -2 && rawStickY < 2) {
rawStickY = 0;
}
#ifdef BETTERCAMERA
else
{
mouseControl = 0;
}
#endif
if (rawStickX > -2 && rawStickX < 2) {
rawStickX = 0;
}
#ifdef BETTERCAMERA
else
{
mouseControl = 0;
}
#endif
// Move cursor
sCursorPos[0] += rawStickX / 8;
sCursorPos[1] += rawStickY / 8;
// Stop cursor from going offscreen
if (sCursorPos[0] > 132.0f) {
sCursorPos[0] = 132.0f;
}
if (sCursorPos[0] < -132.0f) {
sCursorPos[0] = -132.0f;
}
#ifdef BETTERCAMERA
static float screenScale;
screenScale = (float) gfx_current_dimensions.height / SCREEN_HEIGHT;
if (mouse_x - oldMouse_x != 0 || mouse_y - oldMouse_y != 0)
mouseControl = 1;
if (mouseControl && configCameraMouse) {
sCursorPos[0] =
((mouse_x - (gfx_current_dimensions.width - (screenScale * 320)) / 2) / screenScale)
- 160.0f;
sCursorPos[1] = (mouse_y / screenScale - 120.0f) * -1;
}
oldMouse_x = mouse_x;
oldMouse_y = mouse_y;
if (sCursorPos[1] > 90.0f) {
sCursorPos[1] = 90.0f;
}
if (sCursorPos[1] < -90.0f) {
sCursorPos[1] = -90.0f;
}
if (!mouseControl) {
#endif
// Stop cursor from going offscreen
if (sCursorPos[0] > 132.0f) {
sCursorPos[0] = 132.0f;
}
if (sCursorPos[0] < -132.0f) {
sCursorPos[0] = -132.0f;
}
if (sCursorPos[1] > 90.0f) {
sCursorPos[1] = 90.0f;
}
if (sCursorPos[1] < -90.0f) {
sCursorPos[1] = -90.0f;
}
# ifdef BETTERCAMERA
}
#endif
if (sCursorClickingTimer == 0) {
handle_cursor_button_input();
}
}
/**
* Prints the cursor (Mario Hand, different to the one in the Mario screen)
* and loads it's controller inputs in handle_controller_cursor_input

View File

@ -20,6 +20,7 @@
#include "game/level_update.h"
// mouse buttons are also in the controller namespace (why), just offset 0x100
#define VK_OFS_SDL_MOUSE 0x0100
#define VK_BASE_SDL_MOUSE (VK_BASE_SDL_GAMEPAD + VK_OFS_SDL_MOUSE)
@ -33,6 +34,7 @@ int mouse_y;
#ifdef BETTERCAMERA
extern u8 newcam_mouse;
extern s8 sSelectedFileNum;
#endif
static bool init_ok;
@ -152,13 +154,16 @@ static void controller_sdl_read(OSContPad *pad) {
}
#ifdef BETTERCAMERA
if (newcam_mouse == 1 && sCurrPlayMode != 2)
u32 mouse;
if (newcam_mouse == 1 && sCurrPlayMode != 2 && sSelectedFileNum !=0){
SDL_SetRelativeMouseMode(SDL_TRUE);
else
mouse = SDL_GetRelativeMouseState(&mouse_x, &mouse_y);
}
else{
SDL_SetRelativeMouseMode(SDL_FALSE);
u32 mouse = SDL_GetRelativeMouseState(&mouse_x, &mouse_y);
mouse = SDL_GetMouseState(&mouse_x, &mouse_y);
}
for (u32 i = 0; i < num_mouse_binds; ++i)
if (mouse & SDL_BUTTON(mouse_binds[i][0]))
pad->button |= mouse_binds[i][1];