3DS: Don't always force vsync, and try to tie joystick movement to framerate

This commit is contained in:
UnknownShadow200 2023-08-17 20:48:01 +10:00
parent 8b53b9eb9d
commit 6d1ec70de1
2 changed files with 10 additions and 7 deletions

View File

@ -119,6 +119,7 @@ void Gfx_Create(void) {
Gfx.MaxTexWidth = 512; Gfx.MaxTexWidth = 512;
Gfx.MaxTexHeight = 512; Gfx.MaxTexHeight = 512;
Gfx.Created = true; Gfx.Created = true;
gfx_vsync = true;
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8); target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
@ -326,10 +327,11 @@ void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
} }
void Gfx_BeginFrame(void) { void Gfx_BeginFrame(void) {
C3D_FrameBegin(C3D_FRAME_SYNCDRAW); int flags = gfx_vsync ? C3D_FRAME_SYNCDRAW : 0;
C3D_FrameBegin(flags);
} }
void Gfx_Clear(void) { void Gfx_Clear(void) {
//Platform_Log1("CLEAR: %i", &clear_color);
C3D_RenderTargetClear(target, C3D_CLEAR_ALL, clear_color, 0); C3D_RenderTargetClear(target, C3D_CLEAR_ALL, clear_color, 0);
C3D_FrameDrawOn(target); C3D_FrameDrawOn(target);
} }

View File

@ -106,12 +106,14 @@ static void HandleButtons_Launcher(u32 mods) {
Input_SetNonRepeatable(CCPAD_DOWN, mods & KEY_DDOWN); Input_SetNonRepeatable(CCPAD_DOWN, mods & KEY_DDOWN);
} }
static void ProcessJoystickInput(circlePosition* pos) { static void ProcessJoystickInput(circlePosition* pos, double delta) {
float scale = (delta * 60.0) / 8.0f;
// May not be exactly 0 on actual hardware // May not be exactly 0 on actual hardware
if (Math_AbsI(pos->dx) <= 4) pos->dx = 0; if (Math_AbsI(pos->dx) <= 4) pos->dx = 0;
if (Math_AbsI(pos->dy) <= 4) pos->dy = 0; if (Math_AbsI(pos->dy) <= 4) pos->dy = 0;
Event_RaiseRawMove(&PointerEvents.RawMoved, pos->dx / 8.0f, -pos->dy / 8.0f); Event_RaiseRawMove(&PointerEvents.RawMoved, pos->dx * scale, -pos->dy * scale);
} }
void Window_ProcessEvents(double delta) { void Window_ProcessEvents(double delta) {
@ -156,14 +158,14 @@ void Window_ProcessEvents(double delta) {
if (Input.RawMode) { if (Input.RawMode) {
circlePosition pos; circlePosition pos;
hidCircleRead(&pos); hidCircleRead(&pos);
ProcessJoystickInput(&pos); ProcessJoystickInput(&pos, delta);
} }
if (Input.RawMode && irrst_result == 0) { if (Input.RawMode && irrst_result == 0) {
circlePosition pos; circlePosition pos;
irrstScanInput(); irrstScanInput();
irrstCstickRead(&pos); irrstCstickRead(&pos);
ProcessJoystickInput(&pos); ProcessJoystickInput(&pos, delta);
} }
} }
@ -285,7 +287,6 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
} }
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) { cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED; return ERR_NOT_SUPPORTED;
} }
#endif #endif