early-access version 1666

This commit is contained in:
pineappleEA 2021-05-08 21:25:29 +02:00
parent d948f410cd
commit 5e268d25d7
4 changed files with 34 additions and 8 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access
=============
This is the source code for early-access 1665.
This is the source code for early-access 1666.
## Legal Notice

View file

@ -93,9 +93,23 @@ VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, Mode perms) {
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
// Current usages of CreateFile expect to delete the contents of an existing file.
if (FS::IsFile(path)) {
FS::IOFile temp{path, FS::FileAccessMode::Write, FS::FileType::BinaryFile};
if (!temp.IsOpen()) {
return nullptr;
}
temp.Close();
return OpenFile(path, perms);
}
if (!FS::NewFile(path)) {
return nullptr;
}
return OpenFile(path, perms);
}

View file

@ -69,14 +69,18 @@ public:
SDL_GameController* game_controller)
: guid{std::move(guid_)}, port{port_}, sdl_joystick{joystick, &SDL_JoystickClose},
sdl_controller{game_controller, &SDL_GameControllerClose} {
EnableMotion();
}
if (game_controller) {
if (SDL_GameControllerHasSensor(game_controller, SDL_SENSOR_ACCEL)) {
SDL_GameControllerSetSensorEnabled(game_controller, SDL_SENSOR_ACCEL, SDL_TRUE);
void EnableMotion() {
if (sdl_controller) {
SDL_GameController* controller = sdl_controller.get();
if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_ACCEL) && !has_accel) {
SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE);
has_accel = true;
}
if (SDL_GameControllerHasSensor(game_controller, SDL_SENSOR_GYRO)) {
SDL_GameControllerSetSensorEnabled(game_controller, SDL_SENSOR_GYRO, SDL_TRUE);
if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO) && !has_gyro) {
SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_TRUE);
has_gyro = true;
}
}
@ -93,13 +97,11 @@ public:
last_motion_update = event.timestamp;
switch (event.sensor) {
case SDL_SENSOR_ACCEL: {
const Common::Vec3f acceleration = {-event.data[0], event.data[2], -event.data[1]};
motion.SetAcceleration(acceleration / 9.8f);
break;
}
case SDL_SENSOR_GYRO: {
const Common::Vec3f gyroscope = {event.data[0], -event.data[2], event.data[1]};
motion.SetGyroscope(gyroscope / (6.283f * 1.05f));
break;
@ -791,6 +793,10 @@ SDLState::SDLState() {
RegisterFactory<VibrationDevice>("sdl", vibration_factory);
RegisterFactory<MotionDevice>("sdl", motion_factory);
// Tell SDL2 to use the hidapi driver. This will allow joycons to be detected as a
// GameController and not a generic one
SDL_SetHint("SDL_JOYSTICK_HIDAPI_JOY_CONS", "1");
// If the frontend is going to manage the event loop, then we don't start one here
start_thread = SDL_WasInit(SDL_INIT_JOYSTICK) == 0;
if (start_thread && SDL_Init(SDL_INIT_JOYSTICK) < 0) {
@ -1156,6 +1162,8 @@ MotionMapping SDLState::GetMotionMappingForDevice(const Common::ParamPackage& pa
return {};
}
joystick->EnableMotion();
if (!joystick->HasGyro() && !joystick->HasAccel()) {
return {};
}

View file

@ -31,6 +31,10 @@ std::filesystem::path GetNameWithoutExtension(std::filesystem::path filename) {
InputProfiles::InputProfiles() {
const auto input_profile_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "input";
if (!FS::IsDir(input_profile_loc)) {
return;
}
FS::IterateDirEntries(
input_profile_loc,
[this](const std::filesystem::path& full_path) {