forked from etc/pineapple-src
early-access version 3364
This commit is contained in:
parent
fc8996e542
commit
e83a64940e
7 changed files with 77 additions and 67 deletions
|
@ -1,7 +1,7 @@
|
|||
yuzu emulator early access
|
||||
=============
|
||||
|
||||
This is the source code for early-access 3363.
|
||||
This is the source code for early-access 3364.
|
||||
|
||||
## Legal Notice
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ public:
|
|||
explicit Value(u8 value) noexcept;
|
||||
explicit Value(u16 value) noexcept;
|
||||
explicit Value(u32 value) noexcept;
|
||||
explicit Value(s32 value) noexcept;
|
||||
explicit Value(f32 value) noexcept;
|
||||
explicit Value(u64 value) noexcept;
|
||||
explicit Value(f64 value) noexcept;
|
||||
|
@ -66,7 +65,6 @@ public:
|
|||
[[nodiscard]] u8 U8() const;
|
||||
[[nodiscard]] u16 U16() const;
|
||||
[[nodiscard]] u32 U32() const;
|
||||
[[nodiscard]] s32 S32() const;
|
||||
[[nodiscard]] f32 F32() const;
|
||||
[[nodiscard]] u64 U64() const;
|
||||
[[nodiscard]] f64 F64() const;
|
||||
|
@ -86,7 +84,6 @@ private:
|
|||
u8 imm_u8;
|
||||
u16 imm_u16;
|
||||
u32 imm_u32;
|
||||
s32 imm_s32;
|
||||
f32 imm_f32;
|
||||
u64 imm_u64;
|
||||
f64 imm_f64;
|
||||
|
@ -378,14 +375,6 @@ inline u32 Value::U32() const {
|
|||
return imm_u32;
|
||||
}
|
||||
|
||||
inline s32 Value::S32() const {
|
||||
if (IsIdentity()) {
|
||||
return inst->Arg(0).S32();
|
||||
}
|
||||
DEBUG_ASSERT(type == Type::S32);
|
||||
return imm_s32;
|
||||
}
|
||||
|
||||
inline f32 Value::F32() const {
|
||||
if (IsIdentity()) {
|
||||
return inst->Arg(0).F32();
|
||||
|
|
|
@ -176,6 +176,9 @@ void Config::ReadValues() {
|
|||
Settings::values.debug_pad_analogs[i] = default_param;
|
||||
}
|
||||
|
||||
ReadSetting("ControlsGeneral", Settings::values.enable_raw_input);
|
||||
ReadSetting("ControlsGeneral", Settings::values.enable_joycon_driver);
|
||||
ReadSetting("ControlsGeneral", Settings::values.emulate_analog_keyboard);
|
||||
ReadSetting("ControlsGeneral", Settings::values.vibration_enabled);
|
||||
ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations);
|
||||
ReadSetting("ControlsGeneral", Settings::values.motion_enabled);
|
||||
|
|
|
@ -14,6 +14,7 @@ const char* sdl2_config_file =
|
|||
# Escape characters $0 (for ':'), $1 (for ',') and $2 (for '$') can be used in values
|
||||
|
||||
# Indicates if this player should be connected at boot
|
||||
# 0 (default): Disabled, 1: Enabled
|
||||
connected=
|
||||
|
||||
# for button input, the following devices are available:
|
||||
|
@ -94,6 +95,18 @@ motionright=
|
|||
# 0 (default): Disabled, 1: Enabled
|
||||
debug_pad_enabled =
|
||||
|
||||
# Enable sdl raw input. Allows to configure up to 8 xinput controllers.
|
||||
# 0 (default): Disabled, 1: Enabled
|
||||
enable_raw_input =
|
||||
|
||||
# Enable yuzu joycon driver instead of SDL drive.
|
||||
# 0: Disabled, 1 (default): Enabled
|
||||
enable_joycon_driver =
|
||||
|
||||
# Emulates an analog input from buttons. Allowing to dial any angle.
|
||||
# 0 (default): Disabled, 1: Enabled
|
||||
emulate_analog_keyboard =
|
||||
|
||||
# Whether to enable or disable vibration
|
||||
# 0: Disabled, 1 (default): Enabled
|
||||
vibration_enabled=
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
|
||||
EmuWindow_SDL2::EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_)
|
||||
: input_subsystem{input_subsystem_}, system{system_} {
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
||||
input_subsystem->Initialize();
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) {
|
||||
LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");
|
||||
exit(1);
|
||||
}
|
||||
input_subsystem->Initialize();
|
||||
SDL_SetMainReady();
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,6 @@ EmuWindow_SDL2::~EmuWindow_SDL2() {
|
|||
SDL_Quit();
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
|
||||
input_subsystem->GetMouse()->MouseMove(x, y, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) const {
|
||||
switch (button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
|
@ -53,44 +49,36 @@ InputCommon::MouseButton EmuWindow_SDL2::SDLButtonToMouseButton(u32 button) cons
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<float, float> EmuWindow_SDL2::MouseToTouchPos(s32 touch_x, s32 touch_y) const {
|
||||
int w, h;
|
||||
SDL_GetWindowSize(render_window, &w, &h);
|
||||
const float fx = static_cast<float>(touch_x) / w;
|
||||
const float fy = static_cast<float>(touch_y) / h;
|
||||
|
||||
return {std::clamp<float>(fx, 0.0f, 1.0f), std::clamp<float>(fy, 0.0f, 1.0f)};
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::OnMouseButton(u32 button, u8 state, s32 x, s32 y) {
|
||||
const auto mouse_button = SDLButtonToMouseButton(button);
|
||||
if (state == SDL_PRESSED) {
|
||||
input_subsystem->GetMouse()->PressButton(x, y, 0, 0, mouse_button);
|
||||
const auto [touch_x, touch_y] = MouseToTouchPos(x, y);
|
||||
input_subsystem->GetMouse()->PressButton(x, y, touch_x, touch_y, mouse_button);
|
||||
} else {
|
||||
input_subsystem->GetMouse()->ReleaseButton(mouse_button);
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> EmuWindow_SDL2::TouchToPixelPos(float touch_x, float touch_y) const {
|
||||
int w, h;
|
||||
SDL_GetWindowSize(render_window, &w, &h);
|
||||
|
||||
touch_x *= w;
|
||||
touch_y *= h;
|
||||
|
||||
return {static_cast<unsigned>(std::max(std::round(touch_x), 0.0f)),
|
||||
static_cast<unsigned>(std::max(std::round(touch_y), 0.0f))};
|
||||
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
|
||||
const auto [touch_x, touch_y] = MouseToTouchPos(x, y);
|
||||
input_subsystem->GetMouse()->MouseMove(x, y, touch_x, touch_y, 0, 0);
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::OnFingerDown(float x, float y, std::size_t id) {
|
||||
int width, height;
|
||||
SDL_GetWindowSize(render_window, &width, &height);
|
||||
const auto [px, py] = TouchToPixelPos(x, y);
|
||||
const float fx = px * 1.0f / width;
|
||||
const float fy = py * 1.0f / height;
|
||||
|
||||
input_subsystem->GetTouchScreen()->TouchPressed(fx, fy, id);
|
||||
input_subsystem->GetTouchScreen()->TouchPressed(x, y, id);
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::OnFingerMotion(float x, float y, std::size_t id) {
|
||||
int width, height;
|
||||
SDL_GetWindowSize(render_window, &width, &height);
|
||||
const auto [px, py] = TouchToPixelPos(x, y);
|
||||
const float fx = px * 1.0f / width;
|
||||
const float fy = py * 1.0f / height;
|
||||
|
||||
input_subsystem->GetTouchScreen()->TouchMoved(fx, fy, id);
|
||||
input_subsystem->GetTouchScreen()->TouchMoved(x, y, id);
|
||||
}
|
||||
|
||||
void EmuWindow_SDL2::OnFingerUp() {
|
||||
|
|
|
@ -38,17 +38,17 @@ protected:
|
|||
/// Called by WaitEvent when a key is pressed or released.
|
||||
void OnKeyEvent(int key, u8 state);
|
||||
|
||||
/// Called by WaitEvent when the mouse moves.
|
||||
void OnMouseMotion(s32 x, s32 y);
|
||||
|
||||
/// Converts a SDL mouse button into MouseInput mouse button
|
||||
InputCommon::MouseButton SDLButtonToMouseButton(u32 button) const;
|
||||
|
||||
/// Translates pixel position to float position
|
||||
std::pair<float, float> MouseToTouchPos(s32 touch_x, s32 touch_y) const;
|
||||
|
||||
/// Called by WaitEvent when a mouse button is pressed or released
|
||||
void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
|
||||
|
||||
/// Translates pixel position (0..1) to pixel positions
|
||||
std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const;
|
||||
/// Called by WaitEvent when the mouse moves.
|
||||
void OnMouseMotion(s32 x, s32 y);
|
||||
|
||||
/// Called by WaitEvent when a finger starts touching the touchscreen
|
||||
void OnFingerDown(float x, float y, std::size_t id);
|
||||
|
|
|
@ -62,13 +62,15 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
|||
static void PrintHelp(const char* argv0) {
|
||||
std::cout << "Usage: " << argv0
|
||||
<< " [options] <filename>\n"
|
||||
"-c, --config Load the specified configuration file\n"
|
||||
"-f, --fullscreen Start in fullscreen mode\n"
|
||||
"-g, --game File path of the game to load\n"
|
||||
"-h, --help Display this help and exit\n"
|
||||
"-m, --multiplayer=nick:password@address:port"
|
||||
" Nickname, password, address and port for multiplayer\n"
|
||||
"-f, --fullscreen Start in fullscreen mode\n"
|
||||
"-h, --help Display this help and exit\n"
|
||||
"-v, --version Output version information and exit\n"
|
||||
"-p, --program Pass following string as arguments to executable\n"
|
||||
"-c, --config Load the specified configuration file\n";
|
||||
"-u, --user Select a specific user profile from 0 to 7\n"
|
||||
"-v, --version Output version information and exit\n";
|
||||
}
|
||||
|
||||
static void PrintVersion() {
|
||||
|
@ -199,6 +201,7 @@ int main(int argc, char** argv) {
|
|||
std::string filepath;
|
||||
std::optional<std::string> config_path;
|
||||
std::string program_args;
|
||||
std::optional<int> selected_user;
|
||||
|
||||
bool use_multiplayer = false;
|
||||
bool fullscreen = false;
|
||||
|
@ -209,12 +212,14 @@ int main(int argc, char** argv) {
|
|||
|
||||
static struct option long_options[] = {
|
||||
// clang-format off
|
||||
{"multiplayer", required_argument, 0, 'm'},
|
||||
{"config", required_argument, 0, 'c'},
|
||||
{"fullscreen", no_argument, 0, 'f'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"game", required_argument, 0, 'g'},
|
||||
{"multiplayer", required_argument, 0, 'm'},
|
||||
{"program", optional_argument, 0, 'p'},
|
||||
{"config", required_argument, 0, 'c'},
|
||||
{"user", required_argument, 0, 'u'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{0, 0, 0, 0},
|
||||
// clang-format on
|
||||
};
|
||||
|
@ -223,6 +228,21 @@ int main(int argc, char** argv) {
|
|||
int arg = getopt_long(argc, argv, "g:fhvp::c:", long_options, &option_index);
|
||||
if (arg != -1) {
|
||||
switch (static_cast<char>(arg)) {
|
||||
case 'c':
|
||||
config_path = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
fullscreen = true;
|
||||
LOG_INFO(Frontend, "Starting in fullscreen mode...");
|
||||
break;
|
||||
case 'h':
|
||||
PrintHelp(argv[0]);
|
||||
return 0;
|
||||
case 'g': {
|
||||
const std::string str_arg(optarg);
|
||||
filepath = str_arg;
|
||||
break;
|
||||
}
|
||||
case 'm': {
|
||||
use_multiplayer = true;
|
||||
const std::string str_arg(optarg);
|
||||
|
@ -255,23 +275,16 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
fullscreen = true;
|
||||
LOG_INFO(Frontend, "Starting in fullscreen mode...");
|
||||
break;
|
||||
case 'h':
|
||||
PrintHelp(argv[0]);
|
||||
return 0;
|
||||
case 'v':
|
||||
PrintVersion();
|
||||
return 0;
|
||||
case 'p':
|
||||
program_args = argv[optind];
|
||||
++optind;
|
||||
break;
|
||||
case 'c':
|
||||
config_path = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
selected_user = atoi(optarg);
|
||||
return 0;
|
||||
case 'v':
|
||||
PrintVersion();
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
|
@ -295,6 +308,10 @@ int main(int argc, char** argv) {
|
|||
Settings::values.program_args = program_args;
|
||||
}
|
||||
|
||||
if (selected_user.has_value()) {
|
||||
Settings::values.current_user = std::clamp(*selected_user, 0, 7);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
LocalFree(argv_w);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue