mirror of
https://github.com/amwatson/CitraVR.git
synced 2024-09-20 03:11:40 +02:00
Merge branch 'master' into lubos_immersive_mode
This commit is contained in:
commit
0719680a45
8 changed files with 48 additions and 18 deletions
|
@ -587,6 +587,17 @@ public class EmulationActivity extends AppCompatActivity {
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_UP) {
|
||||
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, NativeLibrary.ButtonType.DPAD_UP, action);
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN) {
|
||||
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, NativeLibrary.ButtonType.DPAD_DOWN, action);
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
|
||||
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, NativeLibrary.ButtonType.DPAD_LEFT, action);
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) {
|
||||
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, NativeLibrary.ButtonType.DPAD_RIGHT, action);
|
||||
}
|
||||
|
||||
InputDevice input = event.getDevice();
|
||||
|
||||
if (input == null) {
|
||||
|
|
|
@ -435,7 +435,7 @@ public final class SettingsFragmentPresenter {
|
|||
Setting vrImmersiveMode = vrSection.getSetting(SettingsFile.KEY_VR_IMMERSIVE_MODE);
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_VR_ENVIRONMENT, Settings.SECTION_VR, R.string.vr_background, 0, R.array.vrBackgroundNames, R.array.vrBackgroundValues, VRUtils.getHMDType() == VRUtils.HMDType.QUEST3.getValue() ? 1 : 2, vrEnvironment));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_VR_EXTRA_PERFORMANCE_MODE, Settings.SECTION_VR, R.string.vr_extra_performance_mode, R.string.vr_extra_performance_mode_description, false, vrExtraPerformanceMode));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_VR_CPU_LEVEL, Settings.SECTION_VR, R.string.vr_cpu_level, R.string.vr_cpu_level_description, R.array.vrCpuLevelNames, R.array.vrCpuLevelValues, 4, vrCpuLevel));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_VR_IMMERSIVE_MODE, Settings.SECTION_VR, R.string.vr_immersive_mode_title, R.string.vr_immersive_mode_description, false, vrImmersiveMode, false, true, mView));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_VR_CPU_LEVEL, Settings.SECTION_VR, R.string.vr_cpu_level, R.string.vr_cpu_level_description, R.array.vrCpuLevelNames, R.array.vrCpuLevelValues, 3, vrCpuLevel));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_VR_IMMERSIVE_MODE, Settings.SECTION_VR, R.string.vr_immersive_mode_title, R.string.vr_immersive_mode_description, false, vrImmersiveMode, false, true, mView));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.TreeMap;
|
|||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Contains static methods for interacting with .ini files in which settings are stored.
|
||||
* Contains static methods for interacting with .ini.vr0 files in which settings are stored.
|
||||
*/
|
||||
public final class SettingsFile {
|
||||
public static final String FILE_NAME_CONFIG = "config";
|
||||
|
@ -245,7 +245,7 @@ public final class SettingsFile {
|
|||
outputStream.flush();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.error("[SettingsFile] File not found: " + fileName + ".ini: " + e.getMessage());
|
||||
Log.error("[SettingsFile] File not found: " + fileName + ".ini.vr0 " + e.getMessage());
|
||||
if (view != null) {
|
||||
view.showToastMessage(CitraApplication.getAppContext().getString(R.string.error_saving, fileName, e.getMessage()), false);
|
||||
}
|
||||
|
@ -288,13 +288,13 @@ public final class SettingsFile {
|
|||
public static DocumentFile getSettingsFile(String fileName) {
|
||||
DocumentFile root = DocumentFile.fromTreeUri(CitraApplication.getAppContext(), Uri.parse(DirectoryInitialization.getUserDirectory()));
|
||||
DocumentFile configDirectory = root.findFile("config");
|
||||
return configDirectory.findFile(fileName + ".ini");
|
||||
return configDirectory.findFile(fileName + ".ini.vr0");
|
||||
}
|
||||
|
||||
private static DocumentFile getCustomGameSettingsFile(String gameId) {
|
||||
DocumentFile root = DocumentFile.fromTreeUri(CitraApplication.getAppContext(), Uri.parse(DirectoryInitialization.getUserDirectory()));
|
||||
DocumentFile configDirectory = root.findFile("GameSettings");
|
||||
return configDirectory.findFile(gameId + ".ini");
|
||||
return configDirectory.findFile(gameId + ".ini.vr0");
|
||||
}
|
||||
|
||||
private static SettingSection sectionFromLine(String line, boolean isCustomGame) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
Config::Config() {
|
||||
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
||||
sdl2_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "config.ini";
|
||||
sdl2_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "config.ini.vr0";
|
||||
std::string ini_buffer;
|
||||
FileUtil::ReadFileToString(true, sdl2_config_loc, ini_buffer);
|
||||
if (!ini_buffer.empty()) {
|
||||
|
@ -304,7 +304,7 @@ void Config::ReadValues() {
|
|||
VRSettings::values.cpu_level =
|
||||
VRSettings::values.extra_performance_mode_enabled ? XR_HIGHEST_CPU_PERF_LEVEL
|
||||
: VRSettings::CPUPrefToPerfSettingsLevel(sdl2_config->GetInteger(
|
||||
"VR", "vr_cpu_level", XR_HIGHEST_CPU_PREFERENCE));
|
||||
"VR", "vr_cpu_level", 3));
|
||||
Settings::values.vr_use_immersive_mode = sdl2_config->GetBoolean(
|
||||
"VR", "vr_immersive_mode", false);
|
||||
|
||||
|
|
|
@ -100,6 +100,9 @@ InputStateStatic::InputStateStatic(const XrInstance& instance, const XrSession&
|
|||
mThumbClickAction = CreateAction(mActionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "thumb_click",
|
||||
nullptr, 2, handSubactionPaths);
|
||||
|
||||
mThumbRestTouchAction = CreateAction(mActionSet, XR_ACTION_TYPE_BOOLEAN_INPUT, "thumbresttouch",
|
||||
nullptr, 2, handSubactionPaths);
|
||||
|
||||
mSqueezeTriggerAction = CreateAction(mActionSet, XR_ACTION_TYPE_BOOLEAN_INPUT,
|
||||
"squeeze_trigger", nullptr, 2, handSubactionPaths);
|
||||
|
||||
|
@ -141,6 +144,11 @@ InputStateStatic::InputStateStatic(const XrInstance& instance, const XrSession&
|
|||
bindings.push_back(ActionSuggestedBinding(instance, mThumbClickAction,
|
||||
"/user/hand/left/input/thumbstick/click"));
|
||||
|
||||
bindings.push_back(ActionSuggestedBinding(instance, mThumbRestTouchAction,
|
||||
"/user/hand/left/input/thumbrest/touch"));
|
||||
bindings.push_back(ActionSuggestedBinding(instance, mThumbRestTouchAction,
|
||||
"/user/hand/right/input/thumbrest/touch"));
|
||||
|
||||
bindings.push_back(ActionSuggestedBinding(instance, mSqueezeTriggerAction,
|
||||
"/user/hand/right/input/squeeze/value"));
|
||||
bindings.push_back(ActionSuggestedBinding(instance, mSqueezeTriggerAction,
|
||||
|
@ -176,6 +184,7 @@ InputStateStatic::~InputStateStatic() {
|
|||
OXR(xrDestroyAction(mHandPoseAction));
|
||||
OXR(xrDestroyAction(mThumbStickAction));
|
||||
OXR(xrDestroyAction(mThumbClickAction));
|
||||
OXR(xrDestroyAction(mThumbRestTouchAction));
|
||||
OXR(xrDestroyAction(mSqueezeTriggerAction));
|
||||
|
||||
if (mLeftHandSpace != XR_NULL_HANDLE) {
|
||||
|
@ -248,6 +257,12 @@ void InputStateFrame::SyncButtonsAndThumbSticks(
|
|||
mThumbStickClickState[RIGHT_CONTROLLER] = SyncButtonState(
|
||||
session, staticState->mThumbClickAction, staticState->mRightHandSubactionPath);
|
||||
|
||||
// Sync thumbrest touch states
|
||||
mThumbrestTouchState[LEFT_CONTROLLER] = SyncButtonState(
|
||||
session, staticState->mThumbRestTouchAction, staticState->mLeftHandSubactionPath);
|
||||
mThumbrestTouchState[RIGHT_CONTROLLER] = SyncButtonState(
|
||||
session, staticState->mThumbRestTouchAction, staticState->mRightHandSubactionPath);
|
||||
|
||||
// Sync index trigger states
|
||||
mIndexTriggerState[LEFT_CONTROLLER] = SyncButtonState(
|
||||
session, staticState->mLeftHandIndexTriggerAction, staticState->mLeftHandSubactionPath);
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
XrAction mHandPoseAction = XR_NULL_HANDLE;
|
||||
XrAction mThumbClickAction = XR_NULL_HANDLE;
|
||||
XrAction mSqueezeTriggerAction = XR_NULL_HANDLE;
|
||||
XrAction mThumbRestTouchAction = XR_NULL_HANDLE;
|
||||
};
|
||||
|
||||
struct InputStateFrame {
|
||||
|
@ -64,6 +65,7 @@ struct InputStateFrame {
|
|||
|
||||
XrActionStateVector2f mThumbStickState[NUM_CONTROLLERS];
|
||||
XrActionStateBoolean mThumbStickClickState[NUM_CONTROLLERS];
|
||||
XrActionStateBoolean mThumbrestTouchState[NUM_CONTROLLERS];
|
||||
XrActionStateBoolean mIndexTriggerState[NUM_CONTROLLERS];
|
||||
XrActionStateBoolean mSqueezeTriggerState[NUM_CONTROLLERS];
|
||||
|
||||
|
|
|
@ -329,14 +329,16 @@ private:
|
|||
const auto leftStickHand = InputStateFrame::LEFT_CONTROLLER;
|
||||
const auto cStickHand = InputStateFrame::RIGHT_CONTROLLER;
|
||||
|
||||
const auto& leftThumbstickClickState =
|
||||
mInputStateFrame.mThumbStickClickState[InputStateFrame::LEFT_CONTROLLER];
|
||||
const auto& rightThumbstickClickState =
|
||||
mInputStateFrame.mThumbStickClickState[InputStateFrame::RIGHT_CONTROLLER];
|
||||
const int dpadHand =
|
||||
leftThumbstickClickState.currentState ? InputStateFrame::LEFT_CONTROLLER
|
||||
: rightThumbstickClickState.currentState ? InputStateFrame::RIGHT_CONTROLLER
|
||||
: InputStateFrame::NUM_CONTROLLERS;
|
||||
const auto& leftThumbrestTouchState =
|
||||
mInputStateFrame.mThumbrestTouchState[InputStateFrame::LEFT_CONTROLLER];
|
||||
const auto& rightThumbrestTouchState =
|
||||
mInputStateFrame.mThumbrestTouchState[InputStateFrame::RIGHT_CONTROLLER];
|
||||
const int dpadHand = leftThumbrestTouchState.currentState
|
||||
? InputStateFrame::RIGHT_CONTROLLER
|
||||
: rightThumbrestTouchState.currentState
|
||||
? InputStateFrame::LEFT_CONTROLLER
|
||||
: InputStateFrame::NUM_CONTROLLERS;
|
||||
|
||||
{
|
||||
static constexpr float kThumbStickDirectionThreshold = 0.5f;
|
||||
// Doing it this way helps ensure we don't leave the dpad
|
||||
|
|
|
@ -37,12 +37,12 @@ std::string GetHMDTypeStr();
|
|||
HMDType HmdTypeFromStr(const std::string& hmdType);
|
||||
|
||||
struct Values {
|
||||
XrPerfSettingsLevelEXT cpu_level = XR_HIGHEST_CPU_PERF_LEVEL;
|
||||
XrPerfSettingsLevelEXT cpu_level = XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT;
|
||||
HMDType hmd_type = HMDType::UNKNOWN;
|
||||
uint32_t resolution_factor = 0;
|
||||
int32_t vr_environment = 0;
|
||||
bool extra_performance_mode_enabled = false;
|
||||
int32_t vr_immersive_mode = 0;
|
||||
bool extra_performance_mode_enabled = false;
|
||||
} extern values;
|
||||
|
||||
} // namespace VRSettings
|
||||
|
|
Loading…
Reference in a new issue