mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-10 21:00:55 -04:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e1b75801ad | |||
| facbf35343 | |||
| 7a34830dc7 | |||
| e4557efb23 | |||
| 42e12eb5ab | |||
| 16cc37ca10 | |||
| 44cb2c84ba | |||
| 8e9d4d624a | |||
| db87b91954 |
+5
-1
@@ -158,7 +158,11 @@
|
|||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_C_COMPILER": "cl",
|
"CMAKE_C_COMPILER": "cl",
|
||||||
"CMAKE_CXX_COMPILER": "cl",
|
"CMAKE_CXX_COMPILER": "cl",
|
||||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install"
|
"CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install",
|
||||||
|
"CMAKE_DISABLE_FIND_PACKAGE_PkgConfig": {
|
||||||
|
"type": "BOOL",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"vendor": {
|
"vendor": {
|
||||||
"microsoft.com/VisualStudioSettings/CMake/1.0": {
|
"microsoft.com/VisualStudioSettings/CMake/1.0": {
|
||||||
|
|||||||
Vendored
+1
-1
Submodule extern/aurora updated: f49d3c5f58...2ebe751b9b
@@ -1418,6 +1418,8 @@ set(DUSK_FILES
|
|||||||
include/dusk/scope_guard.hpp
|
include/dusk/scope_guard.hpp
|
||||||
src/dusk/dvd_asset.cpp
|
src/dusk/dvd_asset.cpp
|
||||||
src/d/actor/d_a_alink_dusk.cpp
|
src/d/actor/d_a_alink_dusk.cpp
|
||||||
|
src/dusk/android_frame_rate.hpp
|
||||||
|
src/dusk/android_frame_rate.cpp
|
||||||
src/dusk/asserts.cpp
|
src/dusk/asserts.cpp
|
||||||
src/dusk/batch.cpp
|
src/dusk/batch.cpp
|
||||||
src/dusk/batch.hpp
|
src/dusk/batch.hpp
|
||||||
|
|||||||
@@ -4556,6 +4556,7 @@ public:
|
|||||||
void handleWolfHowl();
|
void handleWolfHowl();
|
||||||
void handleQuickTransform();
|
void handleQuickTransform();
|
||||||
bool checkAimContext();
|
bool checkAimContext();
|
||||||
|
bool checkTouchAimCaptureContext();
|
||||||
|
|
||||||
void onIronBallChainInterpCallback();
|
void onIronBallChainInterpCallback();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.app.ActionBar;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -14,12 +15,16 @@ import android.provider.DocumentsContract;
|
|||||||
import android.provider.OpenableColumns;
|
import android.provider.OpenableColumns;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.Surface;
|
||||||
|
import android.view.SurfaceHolder;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
import android.view.WindowInsetsController;
|
import android.view.WindowInsetsController;
|
||||||
|
|
||||||
import org.libsdl.app.SDLActivity;
|
import org.libsdl.app.SDLActivity;
|
||||||
|
import org.libsdl.app.SDLSurface;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -27,6 +32,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class DuskActivity extends SDLActivity {
|
public class DuskActivity extends SDLActivity {
|
||||||
private static final String TAG = "DuskActivity";
|
private static final String TAG = "DuskActivity";
|
||||||
|
private static final float DEFAULT_SURFACE_FRAME_RATE = 60.0f;
|
||||||
private static final int FOLDER_DIALOG_REQUEST_CODE = 0x4455;
|
private static final int FOLDER_DIALOG_REQUEST_CODE = 0x4455;
|
||||||
private static final int MANAGE_STORAGE_REQUEST_CODE = 0x4456;
|
private static final int MANAGE_STORAGE_REQUEST_CODE = 0x4456;
|
||||||
private static final String EXTERNAL_STORAGE_AUTHORITY =
|
private static final String EXTERNAL_STORAGE_AUTHORITY =
|
||||||
@@ -88,6 +94,11 @@ public class DuskActivity extends SDLActivity {
|
|||||||
hideSystemBars();
|
hideSystemBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SDLSurface createSDLSurface(Context context) {
|
||||||
|
return new DuskSurface(context);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -139,6 +150,77 @@ public class DuskActivity extends SDLActivity {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPreferredSurfaceFrameRate(float frameRate) {
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
if (mSurface instanceof DuskSurface) {
|
||||||
|
((DuskSurface)mSurface).setPreferredFrameRate(frameRate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class DuskSurface extends SDLSurface {
|
||||||
|
private float preferredFrameRate = DEFAULT_SURFACE_FRAME_RATE;
|
||||||
|
|
||||||
|
DuskSurface(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
|
super.surfaceChanged(holder, format, width, height);
|
||||||
|
setTargetFrameRate(holder);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPreferredFrameRate(float frameRate) {
|
||||||
|
preferredFrameRate = frameRate;
|
||||||
|
setTargetFrameRate(getHolder());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTargetFrameRate(SurfaceHolder holder) {
|
||||||
|
if (!mIsSurfaceReady || Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Surface surface = holder != null ? holder.getSurface() : getHolder().getSurface();
|
||||||
|
if (surface == null || !surface.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float targetFrameRate = getMaxSupportedFrameRate();
|
||||||
|
if (preferredFrameRate > 0.0f) {
|
||||||
|
targetFrameRate = preferredFrameRate;
|
||||||
|
}
|
||||||
|
if (targetFrameRate <= 0.0f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
surface.setFrameRate(
|
||||||
|
targetFrameRate, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT);
|
||||||
|
Log.v(TAG, "Requested surface frame rate " + targetFrameRate + " fps");
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
Log.w(TAG, "Failed to request surface frame rate", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getMaxSupportedFrameRate() {
|
||||||
|
if (mDisplay == null) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float maxFrameRate = mDisplay.getRefreshRate();
|
||||||
|
Display.Mode[] modes = mDisplay.getSupportedModes();
|
||||||
|
if (modes == null) {
|
||||||
|
return maxFrameRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Display.Mode mode : modes) {
|
||||||
|
maxFrameRate = Math.max(maxFrameRate, mode.getRefreshRate());
|
||||||
|
}
|
||||||
|
return maxFrameRate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getArguments() {
|
protected String[] getArguments() {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ action-bar {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: stretch;
|
|
||||||
border: 1dp rgba(255, 255, 255, 22%);
|
border: 1dp rgba(255, 255, 255, 22%);
|
||||||
border-radius: 23dp;
|
border-radius: 23dp;
|
||||||
background-color: rgba(22, 24, 28, 48%);
|
background-color: rgba(22, 24, 28, 48%);
|
||||||
|
|||||||
@@ -175,3 +175,13 @@ bool daAlink_c::checkAimContext() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool daAlink_c::checkTouchAimCaptureContext() {
|
||||||
|
switch (mProcID) {
|
||||||
|
case PROC_HOOKSHOT_ROOF_WAIT:
|
||||||
|
case PROC_HOOKSHOT_WALL_WAIT:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return checkAimContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+9
-2
@@ -663,8 +663,15 @@ void dMeter2_c::moveLife() {
|
|||||||
draw_life = true;
|
draw_life = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLifeGaugeScale != g_drawHIO.mLifeParentScale) {
|
#if TARGET_PC
|
||||||
mLifeGaugeScale = g_drawHIO.mLifeParentScale;
|
const f32 lifeGaugeScale =
|
||||||
|
g_drawHIO.mLifeParentScale *
|
||||||
|
std::clamp(dusk::getSettings().game.hudScale.getValue(), 0.5f, 2.0f);
|
||||||
|
#else
|
||||||
|
const f32 lifeGaugeScale = g_drawHIO.mLifeParentScale;
|
||||||
|
#endif
|
||||||
|
if (mLifeGaugeScale != lifeGaugeScale) {
|
||||||
|
mLifeGaugeScale = lifeGaugeScale;
|
||||||
draw_life = true;
|
draw_life = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
#include "dusk/android_frame_rate.hpp"
|
||||||
|
|
||||||
|
#if defined(TARGET_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
|
||||||
|
#include "dusk/settings.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_system.h>
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
namespace dusk::android {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
float preferred_surface_frame_rate() {
|
||||||
|
switch (getSettings().game.enableFrameInterpolation.getValue()) {
|
||||||
|
case FrameInterpMode::Off:
|
||||||
|
return 30.0f;
|
||||||
|
case FrameInterpMode::Unlimited:
|
||||||
|
default:
|
||||||
|
return 0.0f;
|
||||||
|
case FrameInterpMode::Capped:
|
||||||
|
return static_cast<float>(getSettings().video.maxFrameRate.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool clear_pending_exception(JNIEnv* env) {
|
||||||
|
if (env == nullptr || !env->ExceptionCheck()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
env->ExceptionClear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void update_surface_frame_rate() {
|
||||||
|
auto* env = static_cast<JNIEnv*>(SDL_GetAndroidJNIEnv());
|
||||||
|
if (env == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
jobject activity = static_cast<jobject>(SDL_GetAndroidActivity());
|
||||||
|
if (activity == nullptr || clear_pending_exception(env)) {
|
||||||
|
if (activity != nullptr) {
|
||||||
|
env->DeleteLocalRef(activity);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
jclass activityClass = env->GetObjectClass(activity);
|
||||||
|
if (activityClass == nullptr || clear_pending_exception(env)) {
|
||||||
|
env->DeleteLocalRef(activity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
jmethodID setPreferredFrameRate =
|
||||||
|
env->GetMethodID(activityClass, "setPreferredSurfaceFrameRate", "(F)V");
|
||||||
|
env->DeleteLocalRef(activityClass);
|
||||||
|
if (setPreferredFrameRate == nullptr || clear_pending_exception(env)) {
|
||||||
|
env->DeleteLocalRef(activity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
jvalue args[1]{};
|
||||||
|
args[0].f = preferred_surface_frame_rate();
|
||||||
|
env->CallVoidMethodA(activity, setPreferredFrameRate, args);
|
||||||
|
env->DeleteLocalRef(activity);
|
||||||
|
clear_pending_exception(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dusk::android
|
||||||
|
#else
|
||||||
|
namespace dusk::android {
|
||||||
|
void update_surface_frame_rate() {}
|
||||||
|
} // namespace dusk::android
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace dusk::android {
|
||||||
|
|
||||||
|
void update_surface_frame_rate();
|
||||||
|
|
||||||
|
} // namespace dusk::android
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "dusk/app_info.hpp"
|
#include "dusk/app_info.hpp"
|
||||||
#include "dusk/audio/DuskAudioSystem.h"
|
#include "dusk/audio/DuskAudioSystem.h"
|
||||||
#include "dusk/audio/DuskDsp.hpp"
|
#include "dusk/audio/DuskDsp.hpp"
|
||||||
|
#include "dusk/android_frame_rate.hpp"
|
||||||
#include "dusk/config.hpp"
|
#include "dusk/config.hpp"
|
||||||
#include "dusk/hotkeys.h"
|
#include "dusk/hotkeys.h"
|
||||||
#include "dusk/data.hpp"
|
#include "dusk/data.hpp"
|
||||||
@@ -478,14 +479,19 @@ SelectButton& config_percent_select(Pane& leftPane, Pane& rightPane, ConfigVar<f
|
|||||||
|
|
||||||
SelectButton& config_int_select(Pane& leftPane, Pane& rightPane, ConfigVar<int>& var,
|
SelectButton& config_int_select(Pane& leftPane, Pane& rightPane, ConfigVar<int>& var,
|
||||||
Rml::String key, Rml::String helpText, int min, int max, int step = 5,
|
Rml::String key, Rml::String helpText, int min, int max, int step = 5,
|
||||||
std::function<bool()> isDisabled = {}, std::string suffix = "") {
|
std::function<bool()> isDisabled = {}, std::function<void(int)> onChange = {},
|
||||||
|
std::string suffix = "") {
|
||||||
auto& button = leftPane.add_child<NumberButton>(NumberButton::Props{
|
auto& button = leftPane.add_child<NumberButton>(NumberButton::Props{
|
||||||
.key = std::move(key),
|
.key = std::move(key),
|
||||||
.getValue = [&var] { return var; },
|
.getValue = [&var] { return var; },
|
||||||
.setValue =
|
.setValue =
|
||||||
[&var, min, max](int value) {
|
[&var, min, max, callback = std::move(onChange)](int value) {
|
||||||
var.setValue(std::clamp(value, min, max));
|
const int clampedValue = std::clamp(value, min, max);
|
||||||
|
var.setValue(clampedValue);
|
||||||
config::Save();
|
config::Save();
|
||||||
|
if (callback) {
|
||||||
|
callback(clampedValue);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
.isDisabled = std::move(isDisabled),
|
.isDisabled = std::move(isDisabled),
|
||||||
.isModified = [&var] { return var.getValue() != var.getDefaultValue(); },
|
.isModified = [&var] { return var.getValue() != var.getDefaultValue(); },
|
||||||
@@ -929,6 +935,7 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
|
|||||||
.on_pressed([i] {
|
.on_pressed([i] {
|
||||||
mDoAud_seStartMenu(kSoundItemChange);
|
mDoAud_seStartMenu(kSoundItemChange);
|
||||||
getSettings().game.enableFrameInterpolation.setValue(static_cast<FrameInterpMode>(i));
|
getSettings().game.enableFrameInterpolation.setValue(static_cast<FrameInterpMode>(i));
|
||||||
|
android::update_surface_frame_rate();
|
||||||
config::Save();
|
config::Save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -936,7 +943,8 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
|
|||||||
});
|
});
|
||||||
config_int_select(leftPane, rightPane, getSettings().video.maxFrameRate,
|
config_int_select(leftPane, rightPane, getSettings().video.maxFrameRate,
|
||||||
"Framerate Cap", "Limit the framerate to the specified value.", 30, 540, 1,
|
"Framerate Cap", "Limit the framerate to the specified value.", 30, 540, 1,
|
||||||
[] { return getSettings().game.enableFrameInterpolation.getValue() != FrameInterpMode::Capped; });
|
[] { return getSettings().game.enableFrameInterpolation.getValue() != FrameInterpMode::Capped; },
|
||||||
|
[](int) { android::update_surface_frame_rate(); });
|
||||||
config_bool_select(leftPane, rightPane, getSettings().game.enableMapBackground,
|
config_bool_select(leftPane, rightPane, getSettings().game.enableMapBackground,
|
||||||
{
|
{
|
||||||
.key = "Enable Mini-Map Shadows",
|
.key = "Enable Mini-Map Shadows",
|
||||||
|
|||||||
@@ -156,6 +156,11 @@ bool player_attention_locked() noexcept {
|
|||||||
return player != nullptr && (player->checkAttentionLock() || player->checkEnemyAttentionLock());
|
return player != nullptr && (player->checkAttentionLock() || player->checkEnemyAttentionLock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool touch_aim_capture_active() noexcept {
|
||||||
|
auto* player = daAlink_getAlinkActorClass();
|
||||||
|
return player != nullptr && player->checkTouchAimCaptureContext() && dCamera_c::isAimActive();
|
||||||
|
}
|
||||||
|
|
||||||
bool item_wheel_active() noexcept {
|
bool item_wheel_active() noexcept {
|
||||||
return dMeter2Info_getWindowStatus() == 2;
|
return dMeter2Info_getWindowStatus() == 2;
|
||||||
}
|
}
|
||||||
@@ -692,7 +697,7 @@ void TouchControls::sync_touch_state() noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sync_l_lock_state();
|
sync_l_lock_state();
|
||||||
const bool aimActive = dCamera_c::isAimActive();
|
const bool aimActive = touch_aim_capture_active();
|
||||||
if (aimActive && mMoveTouch.active) {
|
if (aimActive && mMoveTouch.active) {
|
||||||
if (!mCameraTouch.active) {
|
if (!mCameraTouch.active) {
|
||||||
mCameraTouch = mMoveTouch;
|
mCameraTouch = mMoveTouch;
|
||||||
@@ -1208,7 +1213,7 @@ void TouchControls::handle_touch_down(Rml::Event& event) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto id = touch_event_id(event);
|
const auto id = touch_event_id(event);
|
||||||
if (dCamera_c::isAimActive()) {
|
if (touch_aim_capture_active()) {
|
||||||
if (!mCameraTouch.active) {
|
if (!mCameraTouch.active) {
|
||||||
mCameraTouch = {
|
mCameraTouch = {
|
||||||
.id = id,
|
.id = id,
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "SSystem/SComponent/c_API.h"
|
#include "SSystem/SComponent/c_API.h"
|
||||||
|
#include "dusk/android_frame_rate.hpp"
|
||||||
#include "dusk/app_info.hpp"
|
#include "dusk/app_info.hpp"
|
||||||
#include "dusk/crash_handler.h"
|
#include "dusk/crash_handler.h"
|
||||||
#include "dusk/crash_reporting.h"
|
#include "dusk/crash_reporting.h"
|
||||||
@@ -555,6 +556,7 @@ int game_main(int argc, char* argv[]) {
|
|||||||
dusk::resetForSpeedrunMode();
|
dusk::resetForSpeedrunMode();
|
||||||
}
|
}
|
||||||
ApplyCVarOverrides(parsed_arg_options["cvar"]);
|
ApplyCVarOverrides(parsed_arg_options["cvar"]);
|
||||||
|
dusk::android::update_surface_frame_rate();
|
||||||
dusk::crash_reporting::initialize();
|
dusk::crash_reporting::initialize();
|
||||||
dusk::crash_handler::install();
|
dusk::crash_handler::install();
|
||||||
// TODO: How to handle this?
|
// TODO: How to handle this?
|
||||||
|
|||||||
Reference in New Issue
Block a user