mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
Fixes and overhaul mouse locking
This commit is contained in:
parent
54de3b689a
commit
fa8d8c9b0f
6 changed files with 22 additions and 45 deletions
|
@ -77,10 +77,6 @@ void first_person_camera_update(void) {
|
|||
} else {
|
||||
gFirstPersonCamera.yaw += sensX * (invX * m->controller->extStickX - 1.5f * mouse_x);
|
||||
}
|
||||
|
||||
gDjuiHudLockMouse = true;
|
||||
} else {
|
||||
gDjuiHudLockMouse = false;
|
||||
}
|
||||
|
||||
// fix yaw for some specific actions
|
||||
|
@ -181,8 +177,6 @@ void first_person_update(void) {
|
|||
}
|
||||
|
||||
first_person_camera_update();
|
||||
} else if (!camera_config_is_mouse_look_enabled()) {
|
||||
gDjuiHudLockMouse = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2393,7 +2393,7 @@ void change_dialog_camera_angle(void) {
|
|||
}
|
||||
|
||||
void shade_screen(void) {
|
||||
create_dl_translation_matrix(MENU_MTX_PUSH, gfx_dimensions_rect_from_left_edge(0), 240.0f, 0);
|
||||
create_dl_translation_matrix(MENU_MTX_PUSH, GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), 240.0f, 0);
|
||||
|
||||
// This is a bit weird. It reuses the dialog text box (width 130, height -80),
|
||||
// so scale to at least fit the screen.
|
||||
|
@ -2449,7 +2449,7 @@ void render_pause_red_coins(void) {
|
|||
|
||||
if (gCurrentArea->numRedCoins > 0) {
|
||||
u8 collected = gCurrentArea->numRedCoins - count_objects_with_behavior(bhvRedCoin);
|
||||
s16 x = gfx_dimensions_rect_from_left_edge(38);
|
||||
s16 x = GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(38);
|
||||
print_animated_red_coin(x - 8, 20);
|
||||
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin);
|
||||
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha);
|
||||
|
|
|
@ -11,21 +11,19 @@
|
|||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
// Analog camera movement by Pathétique (github.com/vrmiguel), y0shin and Mors
|
||||
// Contribute or communicate bugs at github.com/vrmiguel/sm64-analog-camera
|
||||
|
||||
#include <ultra64.h>
|
||||
|
||||
#include "controller_api.h"
|
||||
#include "controller_sdl.h"
|
||||
#include "controller_mouse.h"
|
||||
#include "../configfile.h"
|
||||
#include "../platform.h"
|
||||
#include "../fs/fs.h"
|
||||
#include "pc/pc_main.h"
|
||||
#include "pc/configfile.h"
|
||||
#include "pc/platform.h"
|
||||
#include "pc/fs/fs.h"
|
||||
|
||||
#include "game/level_update.h"
|
||||
#include "game/first_person_cam.h"
|
||||
#include "pc/lua/utils/smlua_misc_utils.h"
|
||||
|
||||
#include "pc/djui/djui.h"
|
||||
#include "pc/djui/djui_panel_pause.h"
|
||||
#include "pc/djui/djui_hud_utils.h"
|
||||
|
@ -170,20 +168,15 @@ static inline void update_button(const int i, const bool new) {
|
|||
}
|
||||
|
||||
extern s16 gMenuMode;
|
||||
bool ignore_lock = false;
|
||||
static void controller_sdl_read(OSContPad *pad) {
|
||||
if (!init_ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gDjuiHudLockMouse) {
|
||||
if (newcam_mouse == 1 && gMenuMode == -1 && !gDjuiInMainMenu && !gDjuiChatBoxFocus && !gDjuiConsoleFocus) {
|
||||
if ((newcam_mouse == 1 || gFirstPersonCamera.enabled || gDjuiHudLockMouse) && gMenuMode == -1 && !gDjuiInMainMenu && !gDjuiChatBoxFocus && !gDjuiConsoleFocus) {
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
ignore_lock = true;
|
||||
} else {
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
ignore_lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
u32 mouse = SDL_GetRelativeMouseState(&mouse_x, &mouse_y);
|
||||
|
@ -197,10 +190,6 @@ static void controller_sdl_read(OSContPad *pad) {
|
|||
last_mouse = (mouse_buttons ^ mouse) & mouse;
|
||||
mouse_buttons = mouse;
|
||||
|
||||
if (!ignore_lock && gMenuMode == -1 && !gDjuiInMainMenu && !gDjuiChatBoxFocus && !gDjuiConsoleFocus) {
|
||||
SDL_SetRelativeMouseMode(gDjuiHudLockMouse ? SDL_TRUE : SDL_FALSE);
|
||||
}
|
||||
|
||||
if (configBackgroundGamepad != sBackgroundGamepad) {
|
||||
sBackgroundGamepad = configBackgroundGamepad;
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, sBackgroundGamepad ? "1" : "0");
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "debuglog.h"
|
||||
#include "game/print.h"
|
||||
#include "game/hud.h"
|
||||
#include "gfx_dimensions.h"
|
||||
|
||||
static u32 sCtxDepth[CTX_MAX] = { 0 };
|
||||
|
||||
|
|
|
@ -218,15 +218,8 @@ u32 djui_hud_get_screen_width(void) {
|
|||
u32 windowWidth, windowHeight;
|
||||
wm_api->get_dimensions(&windowWidth, &windowHeight);
|
||||
|
||||
if (use_forced_4by3() && sResolution == RESOLUTION_DJUI) {
|
||||
windowWidth -= (GFX_DIMENSIONS_FROM_LEFT_EDGE(0) + GFX_DIMENSIONS_FROM_RIGHT_EDGE(0));
|
||||
}
|
||||
|
||||
if (sResolution == RESOLUTION_N64) {
|
||||
f32 aspect = use_forced_4by3()
|
||||
? (4.0f / 3.0f)
|
||||
: GFX_DIMENSIONS_ASPECT_RATIO;
|
||||
return (aspect) * SCREEN_HEIGHT;
|
||||
return (GFX_DIMENSIONS_ASPECT_RATIO) * SCREEN_HEIGHT;
|
||||
} else {
|
||||
return (windowWidth / djui_gfx_get_scale());
|
||||
}
|
||||
|
|
|
@ -217,18 +217,18 @@ void produce_interpolation_frames_and_delay(void) {
|
|||
}
|
||||
|
||||
inline static void buffer_audio(void) {
|
||||
const f32 master_mod = (f32)configMasterVolume / 127.0f;
|
||||
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * master_mod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod);
|
||||
const f32 masterMod = (f32)configMasterVolume / 127.0f;
|
||||
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * masterMod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * masterMod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * masterMod);
|
||||
|
||||
int samples_left = audio_api->buffered();
|
||||
u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
|
||||
s16 audio_buffer[SAMPLES_HIGH * 2 * 2];
|
||||
int samplesLeft = audio_api->buffered();
|
||||
u32 numAudioSamples = samplesLeft < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
|
||||
s16 audioBuffer[SAMPLES_HIGH * 2 * 2];
|
||||
for (s32 i = 0; i < 2; i++) {
|
||||
create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
|
||||
create_next_audio_buffer(audioBuffer + i * (numAudioSamples * 2), numAudioSamples);
|
||||
}
|
||||
audio_api->play((u8 *)audio_buffer, 2 * num_audio_samples * 4);
|
||||
audio_api->play((u8 *)audioBuffer, 2 * numAudioSamples * 4);
|
||||
}
|
||||
|
||||
void produce_one_frame(void) {
|
||||
|
|
Loading…
Reference in a new issue