Skip to content

Commit 1f1e404

Browse files
committed
Minor cleanup
1 parent b58c019 commit 1f1e404

File tree

3 files changed

+56
-54
lines changed

3 files changed

+56
-54
lines changed

include/game_structs.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ enum WeaponType : uint32_t {
413413
UnknownWeapon = 0x5,
414414
};
415415

416-
enum class EquipType {
416+
enum class EquipType {
417417
None = 0,
418418
Melee = 1,
419419
Shield = 2,
@@ -424,14 +424,14 @@ enum WeaponType : uint32_t {
424424
ThrowableObject = 7
425425
};
426426

427-
enum class RumbleType {
428-
Fixed,
429-
Raising,
430-
Falling,
431-
OscillationSmooth,
432-
OscillationFallingSawtoothWave,
433-
OscillationRaisingSawtoothWave
434-
};
427+
enum class RumbleType {
428+
Fixed,
429+
Raising,
430+
Falling,
431+
OscillationSmooth,
432+
OscillationFallingSawtoothWave,
433+
OscillationRaisingSawtoothWave
434+
};
435435

436436
struct RumbleParameters {
437437
bool prioritizeThisRumble = false;
@@ -444,7 +444,7 @@ enum WeaponType : uint32_t {
444444
float amplitude = 0.0f;
445445
};
446446

447-
enum class Direction {
447+
enum class Direction {
448448
Up,
449449
Right,
450450
Down,

src/hooking/controls.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ void handleLeftHandInGameInput(
203203
) {
204204
constexpr std::chrono::milliseconds INPUT_DELAY(400);
205205

206-
static const RumbleParameters leftRumbleRaise = { true, 0, RumbleType::Raising, 0.5f, false, 0.2, 1.0f, 1.0f };
207-
static const RumbleParameters leftRumbleFall = { true, 0, RumbleType::Falling, 0.5f, false, 0.3, 0.1f, 0.75f };
208-
static const RumbleParameters RuneRumble = { true, 0, RumbleType::OscillationSmooth, 1.0f, false, 1.0, 0.25f, 0.25f };
206+
constexpr RumbleParameters leftRumbleRaise = { true, 0, RumbleType::Raising, 0.5f, false, 0.2, 1.0f, 1.0f };
207+
constexpr RumbleParameters leftRumbleFall = { true, 0, RumbleType::Falling, 0.5f, false, 0.3, 0.1f, 0.75f };
208+
constexpr RumbleParameters RuneRumble = { true, 0, RumbleType::OscillationSmooth, 1.0f, false, 1.0, 0.25f, 0.25f };
209209

210210
auto* rumbleMgr = VRManager::instance().XR->GetRumbleManager();
211211
bool isGrabPressed = inputs.inGame.grabState[0].lastEvent == ButtonState::Event::ShortPress;
@@ -374,8 +374,8 @@ void handleRightHandInGameInput(
374374
) {
375375
constexpr std::chrono::milliseconds INPUT_DELAY(400);
376376

377-
static const RumbleParameters rightRumbleFall = { true, 1, RumbleType::Falling, 0.5f, false, 0.3, 0.1f, 0.75f };
378-
static const RumbleParameters rightRumbleInfiniteRaise = { true, 1, RumbleType::Raising, 0.5f, true, 1.0, 0.25f, 0.25f };
377+
constexpr RumbleParameters rightRumbleFall = { true, 1, RumbleType::Falling, 0.5f, false, 0.3, 0.1f, 0.75f };
378+
constexpr RumbleParameters rightRumbleInfiniteRaise = { true, 1, RumbleType::Raising, 0.5f, true, 1.0, 0.25f, 0.25f };
379379

380380
auto* rumbleMgr = VRManager::instance().XR->GetRumbleManager();
381381
bool isGrabPressedShort = inputs.inGame.grabState[1].lastEvent == ButtonState::Event::ShortPress;
@@ -535,12 +535,12 @@ void handleLeftTriggerBindings(
535535
return;
536536
}
537537

538-
static const RumbleParameters raiseRumble = { true, 0, RumbleType::Raising, 0.5f, false, 0.25, 0.3f, 0.3f };
539-
static const RumbleParameters fallRumble = { true, 0, RumbleType::Falling, 0.5f, false, 0.25, 0.3f, 0.3f };
538+
constexpr RumbleParameters raiseRumble = { true, 0, RumbleType::Raising, 0.5f, false, 0.25, 0.3f, 0.3f };
539+
constexpr RumbleParameters fallRumble = { true, 0, RumbleType::Falling, 0.5f, false, 0.25, 0.3f, 0.3f };
540540

541541
auto* rumbleMgr = VRManager::instance().XR->GetRumbleManager();
542542

543-
//Guard + lock on
543+
// Guard + lock on
544544
// Reset the guard state to trigger again the lock on camera
545545
if (!gameState.is_locking_on_target && gameState.previous_button_hold & VPAD_BUTTON_ZL) {
546546
// cancel rune use to let the shield guard happen
@@ -576,11 +576,11 @@ void handleRightTriggerBindings(
576576
return;
577577
}
578578

579-
const static RumbleParameters rightRumbleFixed = { true, 1, RumbleType::Fixed, 0.5f, false, 0.25, 0.3f, 0.3f };
580-
const static RumbleParameters leftRumbleFixed = { true, 0, RumbleType::Fixed, 0.5f, false, 0.25, 0.3f, 0.3f };
581-
static const RumbleParameters rightRumbleInfiniteRaiseBow = { true, 1, RumbleType::Raising, 0.5f, true, 1.0, 0.25f, 0.25f };
582-
static const RumbleParameters rightRumbleInfiniteRaiseWeaponThrow = { true, 1, RumbleType::Raising, 0.5f, true, 1.0, 0.25f, 0.25f };
583-
static const RumbleParameters rightRumbleFiniteRaise = { true, 1, RumbleType::Raising, 0.5f, false, 0.25, 1.0f, 1.0f };
579+
constexpr RumbleParameters rightRumbleFixed = { true, 1, RumbleType::Fixed, 0.5f, false, 0.25, 0.3f, 0.3f };
580+
constexpr RumbleParameters leftRumbleFixed = { true, 0, RumbleType::Fixed, 0.5f, false, 0.25, 0.3f, 0.3f };
581+
constexpr RumbleParameters rightRumbleInfiniteRaiseBow = { true, 1, RumbleType::Raising, 0.5f, true, 1.0, 0.25f, 0.25f };
582+
constexpr RumbleParameters rightRumbleInfiniteRaiseWeaponThrow = { true, 1, RumbleType::Raising, 0.5f, true, 1.0, 0.25f, 0.25f };
583+
constexpr RumbleParameters rightRumbleFiniteRaise = { true, 1, RumbleType::Raising, 0.5f, false, 0.25, 1.0f, 1.0f };
584584

585585

586586
if (gameState.has_something_in_hand) {
@@ -673,6 +673,8 @@ void CemuHooks::hook_InjectXRInput(PPCInterpreter_t* hCPU) {
673673
readMemory(vpadStatusOffset, &vpadStatus);
674674
}
675675

676+
auto* rumbleMgr = VRManager::instance().XR->GetRumbleManager();
677+
676678
// fetch input state
677679
OpenXR::InputState inputs = VRManager::instance().XR->m_input.load();
678680
inputs.inGame.drop_weapon[0] = inputs.inGame.drop_weapon[1] = false;
@@ -736,7 +738,7 @@ void CemuHooks::hook_InjectXRInput(PPCInterpreter_t* hCPU) {
736738
rightGesture = calculateHandGesture(gameState, rightHandPos, headsetMtx, headsetPos, gameState.right_hand_position_stored, gameState.stored_right_hand_position);
737739
}
738740

739-
//dpad menu toggle
741+
// dpad menu toggle
740742
if (gameState.dpad_menu_open)
741743
{
742744
switch (gameState.last_dpad_menu_open) {
@@ -805,11 +807,11 @@ void CemuHooks::hook_InjectXRInput(PPCInterpreter_t* hCPU) {
805807
else
806808
newXRBtnHold |= mapXRButtonToVpad(inputs.inGame.run_interact_cancel, VPAD_BUTTON_A);
807809
}
808-
809-
// Wistle gesture
810+
811+
// Whistle gesture
810812
if (isHandOverMouthSlot(leftGesture) && isHandOverMouthSlot(rightGesture)) {
811813
if (inputs.inGame.grabState[0].wasDownLastFrame && inputs.inGame.grabState[1].wasDownLastFrame) {
812-
static const RumbleParameters rumble = { true, 0, RumbleType::OscillationRaisingSawtoothWave, 1.0f, false, 0.25, 0.2f, 0.2f };
814+
rumbleMgr->enqueueInputsRumbleCommand({ true, 0, RumbleType::OscillationRaisingSawtoothWave, 1.0f, false, 0.25, 0.2f, 0.2f });
813815
VRManager::instance().XR->GetRumbleManager()->enqueueInputsRumbleCommand(rumble);
814816
newXRBtnHold |= VPAD_BUTTON_DOWN;
815817
}
@@ -829,7 +831,7 @@ void CemuHooks::hook_InjectXRInput(PPCInterpreter_t* hCPU) {
829831
//if (inputs.inGame.leftTrigger.currentState &&
830832
// gameState.left_equip_type == EquipType::Rune) {
831833
// RumbleParameters rumble = { true, 1, 0.5f, false, 0.25, 0.3f, 0.3f };
832-
// VRManager::instance().XR->GetRumbleManager()->enqueueInputsRumbleCommand(rumble);
834+
// rumbleMgr->enqueueInputsRumbleCommand(rumble);
833835
// newXRBtnHold |= VPAD_BUTTON_B;
834836
//}
835837
}
@@ -838,7 +840,7 @@ void CemuHooks::hook_InjectXRInput(PPCInterpreter_t* hCPU) {
838840
}
839841

840842
// Update rumble/haptics
841-
VRManager::instance().XR->GetRumbleManager()->updateHaptics();
843+
rumbleMgr->updateHaptics();
842844

843845

844846

src/rendering/openxr.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,30 @@ class OpenXR {
2525
} m_capabilities = {};
2626

2727
union InputState {
28+
struct ButtonState {
29+
enum class Event {
30+
None,
31+
ShortPress,
32+
LongPress,
33+
//DoublePress
34+
};
35+
36+
bool wasDownLastFrame = false;
37+
bool longFired = false;
38+
bool waitingForSecond = false;
39+
std::chrono::steady_clock::time_point pressStartTime;
40+
std::chrono::steady_clock::time_point lastReleaseTime;
41+
42+
Event lastEvent = Event::None;
43+
44+
void resetFrameFlags() { lastEvent = Event::None; }
45+
void resetButtonState() {
46+
wasDownLastFrame = false;
47+
longFired = false;
48+
waitingForSecond = false;
49+
}
50+
};
51+
2852
struct InGame {
2953
bool in_game = true;
3054
XrTime inputTime;
@@ -55,30 +79,6 @@ class OpenXR {
5579

5680
std::array<bool, 2> drop_weapon; // LEFT/RIGHT
5781

58-
struct ButtonState {
59-
enum class Event {
60-
None,
61-
ShortPress,
62-
LongPress,
63-
//DoublePress
64-
};
65-
66-
bool wasDownLastFrame = false;
67-
bool longFired = false;
68-
bool waitingForSecond = false;
69-
std::chrono::steady_clock::time_point pressStartTime;
70-
std::chrono::steady_clock::time_point lastReleaseTime;
71-
72-
Event lastEvent = Event::None;
73-
74-
void resetFrameFlags() { lastEvent = Event::None; }
75-
void resetButtonState() {
76-
wasDownLastFrame = false;
77-
longFired = false;
78-
waitingForSecond = false;
79-
}
80-
};
81-
8282
std::array<ButtonState, 2> grabState; // LEFT/RIGHT
8383
ButtonState runState;
8484
ButtonState map_scopeState;
@@ -258,7 +258,7 @@ class OpenXR {
258258
PFN_xrCreateDebugUtilsMessengerEXT func_xrCreateDebugUtilsMessengerEXT = nullptr;
259259
PFN_xrDestroyDebugUtilsMessengerEXT func_xrDestroyDebugUtilsMessengerEXT = nullptr;
260260
};
261-
using ButtonState = OpenXR::InputState::InGame::ButtonState;
261+
using ButtonState = OpenXR::InputState::ButtonState;
262262
using EyeSide = OpenXR::EyeSide;
263263

264264
template <>

0 commit comments

Comments
 (0)