mirror of
https://github.com/Pixelplanet/Pixel-VR-Player.git
synced 2026-10-26 11:01:40 +01:00
Add settings toggles and strength control for laser hover rumble
This commit is contained in:
1 parent
e5f1f733e7
commit
05f13ddfc2
3 files changed
+58
-8
No files matched your search
+16
-6
@@ -1733,12 +1733,13 @@ int App::run() {
|
||||
const int pH = renderer_.pointerHand();
|
||||
const int activeH = (pH >= 0 && pH <= 1) ? pH : 1;
|
||||
|
||||
if ((curBrowserHov != lastBrowserHov && curBrowserHov >= 0) ||
|
||||
(curPageBtnHov != lastPageBtnHov && curPageBtnHov >= 0) ||
|
||||
(curSidebarHov != lastSidebarHov && curSidebarHov >= 0) ||
|
||||
(curSettingsHov != lastSettingsHov && curSettingsHov >= 0) ||
|
||||
(curCtrlBtnHov != lastCtrlBtnHov && curCtrlBtnHov >= 0)) {
|
||||
xr_.triggerHaptic(activeH, 0.008f, 0.0f, 0.15f);
|
||||
if (settings_.hoverHapticsEnabled() &&
|
||||
((curBrowserHov != lastBrowserHov && curBrowserHov >= 0) ||
|
||||
(curPageBtnHov != lastPageBtnHov && curPageBtnHov >= 0) ||
|
||||
(curSidebarHov != lastSidebarHov && curSidebarHov >= 0) ||
|
||||
(curSettingsHov != lastSettingsHov && curSettingsHov >= 0) ||
|
||||
(curCtrlBtnHov != lastCtrlBtnHov && curCtrlBtnHov >= 0))) {
|
||||
xr_.triggerHaptic(activeH, 0.008f, 0.0f, settings_.hoverHapticsStrength());
|
||||
}
|
||||
lastBrowserHov = curBrowserHov;
|
||||
lastPageBtnHov = curPageBtnHov;
|
||||
@@ -2273,6 +2274,15 @@ int App::run() {
|
||||
switchTracks(true);
|
||||
}
|
||||
#endif
|
||||
else if (act == SettingsMenu::Action::ToggleHoverHaptics) {
|
||||
const int pH = renderer_.pointerHand();
|
||||
const int activeH = (pH >= 0 && pH <= 1) ? pH : 1;
|
||||
xr_.triggerHaptic(activeH, 0.020f, 0.0f, settings_.hoverHapticsEnabled() ? settings_.hoverHapticsStrength() : 0.2f);
|
||||
} else if (act == SettingsMenu::Action::CycleHoverHapticsStrength) {
|
||||
const int pH = renderer_.pointerHand();
|
||||
const int activeH = (pH >= 0 && pH <= 1) ? pH : 1;
|
||||
xr_.triggerHaptic(activeH, 0.025f, 0.0f, settings_.hoverHapticsStrength());
|
||||
}
|
||||
}
|
||||
if (in.recenter && in.headValid) {
|
||||
renderer_.recenterScreen(in.headPos, in.headForward);
|
||||
|
||||
@@ -56,6 +56,11 @@ const char* kUiDistanceNames[] = {"Near (1.5 m)", "Comfort (1.9 m)",
|
||||
const float kUiDistanceValues[] = {1.5f, 1.9f, 2.3f, 2.8f};
|
||||
constexpr int kUiDistanceCount = 4;
|
||||
|
||||
const char* kHoverHapticsStrengthNames[] = {
|
||||
"Subtle (25%)", "Medium (50%)", "Strong (75%)", "Maximum (100%)"};
|
||||
const float kHoverHapticsStrengthValues[] = {0.08f, 0.15f, 0.28f, 0.50f};
|
||||
constexpr int kHoverHapticsStrengthCount = 4;
|
||||
|
||||
std::string getConfigPath() {
|
||||
#ifdef _WIN32
|
||||
const char* appData = std::getenv("APPDATA");
|
||||
@@ -198,9 +203,12 @@ void SettingsMenu::refresh() {
|
||||
Action::ListenRecenter});
|
||||
rows_.push_back({"Bookmarks Shortcut", btnLabel(4, bindQuickPathBtn_),
|
||||
Action::ListenQuickPath});
|
||||
rows_.push_back({"Select / Click", "Trigger", Action::None});
|
||||
rows_.push_back({"Controller Models", drawModels_ ? "On" : "Off",
|
||||
rows_.push_back({"Controller Models", drawModels_ ? "ON" : "OFF",
|
||||
Action::ToggleModels});
|
||||
rows_.push_back({"Laser Hover Rumble", hoverHapticsEnabled_ ? "ON" : "OFF",
|
||||
Action::ToggleHoverHaptics});
|
||||
rows_.push_back({"Rumble Strength", hoverHapticsStrengthStr(),
|
||||
Action::CycleHoverHapticsStrength, hoverHapticsEnabled_});
|
||||
} else if (section_ == 4) {
|
||||
title_ = "Settings > Vault & Privacy";
|
||||
rows_.push_back({"Auto-Lock on Headset Removal",
|
||||
@@ -378,6 +386,16 @@ SettingsMenu::Action SettingsMenu::activate() {
|
||||
saveConfig();
|
||||
refresh();
|
||||
break;
|
||||
case Action::ToggleHoverHaptics:
|
||||
hoverHapticsEnabled_ = !hoverHapticsEnabled_;
|
||||
saveConfig();
|
||||
refresh();
|
||||
break;
|
||||
case Action::CycleHoverHapticsStrength:
|
||||
hoverHapticsStrengthIdx_ = (hoverHapticsStrengthIdx_ + 1) % kHoverHapticsStrengthCount;
|
||||
saveConfig();
|
||||
refresh();
|
||||
break;
|
||||
case Action::ListenQuickPath:
|
||||
listeningFunc_ = 4;
|
||||
status_ = "Press a controller button for Bookmarks shortcut";
|
||||
@@ -558,6 +576,14 @@ float SettingsMenu::uiDistance() const {
|
||||
return kUiDistanceValues[uiDistanceIdx_ % kUiDistanceCount];
|
||||
}
|
||||
|
||||
float SettingsMenu::hoverHapticsStrength() const {
|
||||
return kHoverHapticsStrengthValues[hoverHapticsStrengthIdx_ % kHoverHapticsStrengthCount];
|
||||
}
|
||||
|
||||
const char* SettingsMenu::hoverHapticsStrengthStr() const {
|
||||
return kHoverHapticsStrengthNames[hoverHapticsStrengthIdx_ % kHoverHapticsStrengthCount];
|
||||
}
|
||||
|
||||
void SettingsMenu::loadConfig() {
|
||||
const std::string path = getConfigPath();
|
||||
std::ifstream file(path);
|
||||
@@ -599,6 +625,8 @@ void SettingsMenu::loadConfig() {
|
||||
else if (key == "list_show_size") listShowSize_ = (val == "1" || val == "true");
|
||||
else if (key == "list_show_dur") listShowDuration_ = (val == "1" || val == "true");
|
||||
else if (key == "quick_path") quickPath_ = val;
|
||||
else if (key == "hover_haptics") hoverHapticsEnabled_ = (val == "1" || val == "true");
|
||||
else if (key == "hover_haptics_strength") hoverHapticsStrengthIdx_ = std::clamp(std::stoi(val), 0, kHoverHapticsStrengthCount - 1);
|
||||
}
|
||||
PIXELVR_LOG_INFO("Loaded settings from %s", path.c_str());
|
||||
}
|
||||
@@ -635,6 +663,8 @@ void SettingsMenu::saveConfig() const {
|
||||
file << "list_show_res=" << (listShowRes_ ? 1 : 0) << "\n";
|
||||
file << "list_show_size=" << (listShowSize_ ? 1 : 0) << "\n";
|
||||
file << "list_show_dur=" << (listShowDuration_ ? 1 : 0) << "\n";
|
||||
file << "hover_haptics=" << (hoverHapticsEnabled_ ? 1 : 0) << "\n";
|
||||
file << "hover_haptics_strength=" << hoverHapticsStrengthIdx_ << "\n";
|
||||
if (!quickPath_.empty()) {
|
||||
file << "quick_path=" << quickPath_ << "\n";
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ public:
|
||||
ToggleListColRes,
|
||||
ToggleListColSize,
|
||||
ToggleListColDuration,
|
||||
ToggleHoverHaptics,
|
||||
CycleHoverHapticsStrength,
|
||||
BackToUI,
|
||||
Close
|
||||
};
|
||||
@@ -137,6 +139,12 @@ public:
|
||||
bool listShowSize() const { return listShowSize_; }
|
||||
bool listShowDuration() const { return listShowDuration_; }
|
||||
|
||||
bool hoverHapticsEnabled() const { return hoverHapticsEnabled_; }
|
||||
void setHoverHapticsEnabled(bool e) { hoverHapticsEnabled_ = e; saveConfig(); refresh(); }
|
||||
int hoverHapticsStrengthIdx() const { return hoverHapticsStrengthIdx_; }
|
||||
float hoverHapticsStrength() const;
|
||||
const char* hoverHapticsStrengthStr() const;
|
||||
|
||||
void onKeyboardSubmit(const std::string& text) { (void)text; }
|
||||
void onKeyboardCancel() {}
|
||||
|
||||
@@ -173,6 +181,8 @@ private:
|
||||
bool listShowSize_ = true;
|
||||
bool listShowDuration_ = true;
|
||||
std::string quickPath_;
|
||||
bool hoverHapticsEnabled_ = true;
|
||||
int hoverHapticsStrengthIdx_ = 1;
|
||||
|
||||
int section_ = 0; // 0=Display, 1=UI, 2=Audio, 3=Controls, 4=Vault; 10..12=sub-lists
|
||||
std::vector<std::pair<int, std::string>> videoStreams_; // (index, label)
|
||||
|
||||
Reference in new issue
Block a user