mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-03 02:53:08 -04:00
Touch controls (#2053)
* WIP touch controls * Action icons * Updates * Don't mutate freeCamera config; allow switching between touch and controller cam * Wow * Fix build & add Skip button * Fix build & add settings * RCSS cleanup * Dpad and fishing, might redo * Add menu mouse controls * More pointer & fix icons * Optimizations & introduce layout system * Update aurora * Implement touch controls layout editor * Cleanup & fixes * Allow disabling mouse/touch in menus * More fixes
This commit is contained in:
+42
-7
@@ -34,6 +34,7 @@
|
||||
#include "dusk/action_bindings.h"
|
||||
#include "dusk/mouse.h"
|
||||
#include "dusk/settings.h"
|
||||
#include "dusk/touch_camera.h"
|
||||
#include "imgui.h"
|
||||
#endif
|
||||
|
||||
@@ -7499,6 +7500,15 @@ static constexpr s16 FLYCAM_ROLL_SPEED = 256;
|
||||
static ImVec2 sFlyCamLastMousePos = {-1.f, -1.f};
|
||||
|
||||
#if TARGET_PC
|
||||
static constexpr f32 TOUCH_CAMERA_CSTICK_EXIT_THRESHOLD = 0.05f;
|
||||
static bool sTouchFreeCameraActive = false;
|
||||
|
||||
bool dCamera_c::isAimActive() {
|
||||
auto* link = daAlink_getAlinkActorClass();
|
||||
return link != nullptr && link->checkAimContext() &&
|
||||
dComIfGp_checkCameraAttentionStatus(link->field_0x317c, 0x10);
|
||||
}
|
||||
|
||||
bool dCamera_c::executeDebugFlyCam() {
|
||||
if (!dusk::getSettings().game.debugFlyCam) {
|
||||
if (mDebugFlyCam.initialized) {
|
||||
@@ -7640,16 +7650,30 @@ void dCamera_c::deactivateDebugFlyCam() {
|
||||
mDebugFlyCam.initialized = false;
|
||||
}
|
||||
|
||||
bool dCamera_c::canUseFreeCam() {
|
||||
return dusk::getSettings().game.freeCamera || dusk::getSettings().game.enableMouseCamera;
|
||||
}
|
||||
|
||||
bool dCamera_c::freeCamera() {
|
||||
if (canUseFreeCam() && mGear == 1) {
|
||||
f32 touchYawDp = 0.0f;
|
||||
f32 touchPitchDp = 0.0f;
|
||||
bool touchCameraMoved = false;
|
||||
const bool touchControlsEnabled = dusk::getSettings().game.enableTouchControls;
|
||||
if (touchControlsEnabled && !isAimActive()) {
|
||||
touchCameraMoved = dusk::touch_camera::consume_delta(touchYawDp, touchPitchDp);
|
||||
}
|
||||
if (!touchControlsEnabled ||
|
||||
mPadInfo.mCStick.mLastValue > TOUCH_CAMERA_CSTICK_EXIT_THRESHOLD)
|
||||
{
|
||||
sTouchFreeCameraActive = false;
|
||||
}
|
||||
if (touchCameraMoved) {
|
||||
sTouchFreeCameraActive = true;
|
||||
}
|
||||
|
||||
const bool useFreeCamera = dusk::getSettings().game.freeCamera ||
|
||||
dusk::getSettings().game.enableMouseCamera || sTouchFreeCameraActive;
|
||||
if (useFreeCamera && mGear == 1) {
|
||||
mGear = 0;
|
||||
}
|
||||
|
||||
if (!canUseFreeCam() || mCamStyle == 70)
|
||||
if (!useFreeCamera || mCamStyle == 70)
|
||||
{
|
||||
mCamParam.mManualMode = 0;
|
||||
return false;
|
||||
@@ -7660,6 +7684,17 @@ bool dCamera_c::freeCamera() {
|
||||
mCamParam.freeYAngle = mViewCache.mDirection.mInclination.Degree();
|
||||
}
|
||||
|
||||
if (touchCameraMoved) {
|
||||
mCamParam.mManualMode = 1;
|
||||
const f32 yawInput = dusk::getSettings().game.invertCameraXAxis ? -touchYawDp : touchYawDp;
|
||||
const f32 pitchInput =
|
||||
touchPitchDp * (dusk::getSettings().game.invertCameraYAxis ? -1.0f : 1.0f);
|
||||
mCamParam.freeXAngle += yawInput * dusk::getSettings().game.touchCameraXSensitivity *
|
||||
dusk::touch_camera::YAW_DEGREES_PER_DP;
|
||||
mCamParam.freeYAngle += pitchInput * dusk::getSettings().game.touchCameraYSensitivity *
|
||||
dusk::touch_camera::PITCH_DEGREES_PER_DP;
|
||||
}
|
||||
|
||||
cXyz camMovement = {mPadInfo.mCStick.mLastPosX, mPadInfo.mCStick.mLastPosY, 0.0f};
|
||||
f32 magnitude = sqrt(mPadInfo.mCStick.mLastPosX * mPadInfo.mCStick.mLastPosX + mPadInfo.mCStick.mLastPosY * mPadInfo.mCStick.mLastPosY);
|
||||
|
||||
@@ -11359,7 +11394,7 @@ static int camera_execute(camera_process_class* i_this) {
|
||||
const auto target = get_target_trim_height(i_this);
|
||||
const auto step = dusk::frame_interp::get_interpolation_step();
|
||||
const auto cur = camera->TrimHeight();
|
||||
const auto prev = (4.0f * cur - target) / 3.0f;
|
||||
const auto prev = (4.0f * cur - target) / 3.0f;
|
||||
const auto trim_height = prev + (cur - prev) * step;
|
||||
|
||||
widezoom_correction(i_this, trim_height);
|
||||
|
||||
Reference in New Issue
Block a user