1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-03-18 18:19:39 +01:00

fix free camera control

fix RB/LB for Switch
This commit is contained in:
XProger 2020-01-31 21:11:20 +03:00
parent c3ed37af34
commit c6d409f860
5 changed files with 18 additions and 12 deletions

View File

@ -418,7 +418,7 @@ struct Camera : ICamera {
float d = 3.0f * Core::deltaTime;
vec2 L = Input::joy[cameraIndex].L;
if (L.length() < JOY_DEAD_ZONE) L = vec2(0.0f);
L = L.normal() * max(0.0f, L.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK);
lookAngle.x += L.y * d;
lookAngle.y += L.x * d;
@ -539,7 +539,7 @@ struct Camera : ICamera {
viewTarget = NULL;
}
Input::Joystick &specJoy = Input::joy[cameraIndex];
Input::Joystick &specJoy = Input::joy[Core::settings.controls[cameraIndex].joyIndex];
if (specJoy.down[jkL] && specJoy.down[jkR]) {
specTimer += Core::deltaTime;
@ -564,6 +564,11 @@ struct Camera : ICamera {
float U = specJoy.RT;
float D = specJoy.LT;
L = L.normal() * max(0.0f, L.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK);
R = R.normal() * max(0.0f, R.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK);
U = max(0.0f, U - INPUT_JOY_DZ_TRIGGER) / (1.0f - INPUT_JOY_DZ_TRIGGER);
D = max(0.0f, D - INPUT_JOY_DZ_TRIGGER) / (1.0f - INPUT_JOY_DZ_TRIGGER);
// apply dead zone
if (L.length() < 0.05f) L = vec2(0.0f);
if (R.length() < 0.05f) R = vec2(0.0f);
@ -591,16 +596,15 @@ struct Camera : ICamera {
mViewInv.rotateX(specRotSmooth.x);
mViewInv.rotateZ(specRotSmooth.z);
level->getSector(specRoom, specPos);
/*
for (int i = 0; i < level->roomsCount; i++) {
TR::Room &room = level->rooms[i];
if (room.contains(specPos)) {
eye.room = i;
specRoom = i;
break;
}
}
*/
level->getSector(specRoom, specPos);
}
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR)

View File

@ -1244,7 +1244,7 @@ namespace GAPI {
support.VAO = GLES3 || extSupport(ext, "_vertex_array_object");
support.depthTexture = GLES3 || extSupport(ext, "_depth_texture");
support.shadowSampler = _GL_EXT_shadow_samplers || _GL_ARB_shadow;
support.discardFrame = extSupport(ext, "_discard_framebuffer") && (glDiscardFramebufferEXT != NULL);
support.discardFrame = extSupport(ext, "_discard_framebuffer");
support.texNPOT = GLES3 || extSupport(ext, "_texture_npot") || extSupport(ext, "_texture_non_power_of_two");
support.texRG = GLES3 || extSupport(ext, "_texture_rg "); // hope that isn't last extension in string ;)
support.texMaxLevel = GLES3 || extSupport(ext, "_texture_max_level");

View File

@ -4,9 +4,11 @@
#include "core.h"
#include "utils.h"
#define INPUT_JOY_COUNT 4
#define MAX_PLAYERS COUNT(Core::settings.controls)
#define JOY_DEAD_ZONE 0.3f
#define MAX_PLAYERS COUNT(Core::settings.controls)
#define INPUT_JOY_COUNT 4
#define INPUT_JOY_DZ_STICK 0.2f
#define INPUT_JOY_DZ_TRIGGER 0.01f
namespace Input {
InputKey lastKey;

View File

@ -3109,7 +3109,7 @@ struct Lara : Character {
vec2 L = joy.L;
if (L.length() < JOY_DEAD_ZONE) L = vec2(0.0f); // dead zone
if (L.length() < INPUT_JOY_DZ_STICK) L = vec2(0.0f); // dead zone
if (!((state == STATE_STOP || state == STATE_SURF_TREAD || state == STATE_HANG) && fabsf(L.x) < 0.5f && fabsf(L.y) < 0.5f)) {
bool moving = state == STATE_RUN || state == STATE_WALK || state == STATE_BACK || state == STATE_FAST_BACK || state == STATE_SURF_SWIM || state == STATE_SURF_BACK || state == STATE_FORWARD_JUMP;

View File

@ -211,7 +211,7 @@ void joyInit() {
void joyUpdate() {
const static u64 keys[jkMAX] = { 0,
KEY_B, KEY_A, KEY_Y, KEY_X, KEY_L, KEY_R, KEY_PLUS, KEY_MINUS,
0, 0, KEY_ZL, KEY_ZR,
KEY_LSTICK, KEY_RSTICK, KEY_ZL, KEY_ZR,
KEY_DLEFT, KEY_DRIGHT, KEY_DUP, KEY_DDOWN,
};