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 yuzu emulator early access
============= =============
This is the source code for early-access 1665. This is the source code for early-access 1666.
## Legal Notice ## 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) { VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, Mode perms) {
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); 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)) { if (!FS::NewFile(path)) {
return nullptr; return nullptr;
} }
return OpenFile(path, perms); return OpenFile(path, perms);
} }

View File

@ -69,14 +69,18 @@ public:
SDL_GameController* game_controller) SDL_GameController* game_controller)
: guid{std::move(guid_)}, port{port_}, sdl_joystick{joystick, &SDL_JoystickClose}, : guid{std::move(guid_)}, port{port_}, sdl_joystick{joystick, &SDL_JoystickClose},
sdl_controller{game_controller, &SDL_GameControllerClose} { sdl_controller{game_controller, &SDL_GameControllerClose} {
EnableMotion();
}
if (game_controller) { void EnableMotion() {
if (SDL_GameControllerHasSensor(game_controller, SDL_SENSOR_ACCEL)) { if (sdl_controller) {
SDL_GameControllerSetSensorEnabled(game_controller, SDL_SENSOR_ACCEL, SDL_TRUE); 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; has_accel = true;
} }
if (SDL_GameControllerHasSensor(game_controller, SDL_SENSOR_GYRO)) { if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO) && !has_gyro) {
SDL_GameControllerSetSensorEnabled(game_controller, SDL_SENSOR_GYRO, SDL_TRUE); SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_TRUE);
has_gyro = true; has_gyro = true;
} }
} }
@ -93,13 +97,11 @@ public:
last_motion_update = event.timestamp; last_motion_update = event.timestamp;
switch (event.sensor) { switch (event.sensor) {
case SDL_SENSOR_ACCEL: { case SDL_SENSOR_ACCEL: {
const Common::Vec3f acceleration = {-event.data[0], event.data[2], -event.data[1]}; const Common::Vec3f acceleration = {-event.data[0], event.data[2], -event.data[1]};
motion.SetAcceleration(acceleration / 9.8f); motion.SetAcceleration(acceleration / 9.8f);
break; break;
} }
case SDL_SENSOR_GYRO: { case SDL_SENSOR_GYRO: {
const Common::Vec3f gyroscope = {event.data[0], -event.data[2], event.data[1]}; const Common::Vec3f gyroscope = {event.data[0], -event.data[2], event.data[1]};
motion.SetGyroscope(gyroscope / (6.283f * 1.05f)); motion.SetGyroscope(gyroscope / (6.283f * 1.05f));
break; break;
@ -791,6 +793,10 @@ SDLState::SDLState() {
RegisterFactory<VibrationDevice>("sdl", vibration_factory); RegisterFactory<VibrationDevice>("sdl", vibration_factory);
RegisterFactory<MotionDevice>("sdl", motion_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 // 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; start_thread = SDL_WasInit(SDL_INIT_JOYSTICK) == 0;
if (start_thread && SDL_Init(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 {}; return {};
} }
joystick->EnableMotion();
if (!joystick->HasGyro() && !joystick->HasAccel()) { if (!joystick->HasGyro() && !joystick->HasAccel()) {
return {}; return {};
} }

View File

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