Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for UWP and the Xbox platforms #11339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ CMakeLists.txt.user
/.idea/
# Ignore Visual Studio Code's working dir
/.vscode/

# Ignore UWP generated content and packages
/Source/x64/Release/DolphinUWP
/Source/packages/
/Source/Core/DolphinUWP/x64/Release
/Source/Core/DolphinUWP/Generated Files/winrt
/Source/AppPackages/DolphinUWP
/Source/Core/DolphinUWP/BundleArtifacts
/Source/Core/DolphinUWP/DolphinUWP_TemporaryKey.pfx
/Source/Core/DolphinNoGUI/DolphinNoGUI.aps
/Source/Core/DolphinUWP/Generated Files
5 changes: 5 additions & 0 deletions Source/Core/Common/WindowSystemInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum class WindowSystemType
Wayland,
FBDev,
Haiku,
UWP,
};

struct WindowSystemInfo
Expand Down Expand Up @@ -43,4 +44,8 @@ struct WindowSystemInfo

// Scale of the render surface. For hidpi systems, this will be >1.
float render_surface_scale = 1.0f;

// Renderer size for Core Windows
uint32_t render_width = 0;
uint32_t render_height = 0;
};
55 changes: 47 additions & 8 deletions Source/Core/Core/HW/GCPadEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,44 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
EmulatedController::LoadDefaults(ciface);

// Buttons
m_buttons->SetControlExpression(0, "`X`"); // A
m_buttons->SetControlExpression(1, "`Z`"); // B
m_buttons->SetControlExpression(2, "`C`"); // X
m_buttons->SetControlExpression(3, "`S`"); // Y
m_buttons->SetControlExpression(4, "`D`"); // Z
#if UWP_XBOX
// If we're running on UWP, we're likely on an Xbox. These defaults work for Xbox One & Series.
m_buttons->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Button A`"); // A
m_buttons->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Button B`"); // B
m_buttons->SetControlExpression(2, "`WGInput/0/Xbox One Game Controller:Button X`"); // X
m_buttons->SetControlExpression(3, "`WGInput/0/Xbox One Game Controller:Button Y`"); // Y
m_buttons->SetControlExpression(4, "`WGInput/0/Xbox One Game Controller:Bumper R`"); // Z
m_buttons->SetControlExpression(5, "`WGInput/0/Xbox One Game Controller:Menu`"); // Start
#else
m_buttons->SetControlExpression(0, "`Button A`"); // A
m_buttons->SetControlExpression(1, "`Button B`"); // B
m_buttons->SetControlExpression(2, "`Button X`"); // X
m_buttons->SetControlExpression(3, "`Button Y`"); // Y
m_buttons->SetControlExpression(4, "`Bumper R`"); // Z

#ifdef _WIN32
m_buttons->SetControlExpression(5, "`RETURN`"); // Start
#else
// OS X/Linux
// Start
m_buttons->SetControlExpression(5, "`Return`");
#endif
#endif

#if UWP_XBOX
// D-Pad
m_dpad->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Pad N`"); // Up
m_dpad->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Pad S`"); // Down
m_dpad->SetControlExpression(2, "`WGInput/0/Xbox One Game Controller:Pad W`"); // Left
m_dpad->SetControlExpression(3, "`WGInput/0/Xbox One Game Controller:Pad E`"); // Right

// C Stick
m_c_stick->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Right Y+`"); // Up
m_c_stick->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Right Y-`"); // Down
m_c_stick->SetControlExpression(2, "`WGInput/0/Xbox One Game Controller:Right X-`"); // Left
m_c_stick->SetControlExpression(3, "`WGInput/0/Xbox One Game Controller:Right X+`"); // Right
#else
// D-Pad
m_dpad->SetControlExpression(0, "`T`"); // Up
m_dpad->SetControlExpression(1, "`G`"); // Down
m_dpad->SetControlExpression(2, "`F`"); // Left
Expand All @@ -197,9 +221,15 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
m_c_stick->SetControlExpression(3, "`L`"); // Right
// Modifier
m_c_stick->SetControlExpression(4, "`Ctrl`");
#endif

// Control Stick
#ifdef _WIN32
#if UWP_XBOX
m_main_stick->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Left Y+`"); // Up
m_main_stick->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Left Y-`"); // Down
m_main_stick->SetControlExpression(2, "`WGInput/0/Xbox One Game Controller:Left X-`"); // Left
m_main_stick->SetControlExpression(3, "`WGInput/0/Xbox One Game Controller:Left X+`"); // Right
#elif _WIN32
m_main_stick->SetControlExpression(0, "`UP`"); // Up
m_main_stick->SetControlExpression(1, "`DOWN`"); // Down
m_main_stick->SetControlExpression(2, "`LEFT`"); // Left
Expand All @@ -215,16 +245,25 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
m_main_stick->SetControlExpression(2, "`Left`"); // Left
m_main_stick->SetControlExpression(3, "`Right`"); // Right
#endif

// Modifier
m_main_stick->SetControlExpression(4, "`Shift`");

// Because our defaults use keyboard input, set calibration shapes to squares.
m_c_stick->SetCalibrationFromGate(ControllerEmu::SquareStickGate(1.0));
m_main_stick->SetCalibrationFromGate(ControllerEmu::SquareStickGate(1.0));

#if UWP_XBOX
// Triggers
m_triggers->SetControlExpression(0, "`Q`"); // L
m_triggers->SetControlExpression(1, "`W`"); // R
m_triggers->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Trigger L`"); // L
m_triggers->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Trigger R`"); // R
SirMangler marked this conversation as resolved.
Show resolved Hide resolved

// Rumble
m_rumble->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Rumble 0`");
#else
m_triggers->SetControlExpression(0, "`Q`"); // L
m_triggers->SetControlExpression(1, "`W`"); // R
#endif
}

bool GCPad::GetMicButton() const
Expand Down
20 changes: 15 additions & 5 deletions Source/Core/Core/HW/WiimoteEmu/Extension/Nunchuk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,27 @@ void Nunchuk::DoState(PointerWrap& p)

void Nunchuk::LoadDefaults(const ControllerInterface& ciface)
{
#if UWP_XBOX
// Stick
m_stick->SetControlExpression(0, "W"); // up
m_stick->SetControlExpression(1, "S"); // down
m_stick->SetControlExpression(2, "A"); // left
m_stick->SetControlExpression(3, "D"); // right
m_stick->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Left Y+`"); // up
m_stick->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Left Y-`"); // down
m_stick->SetControlExpression(2, "`WGInput/0/Xbox One Game Controller:Left X-`"); // left
m_stick->SetControlExpression(3, "`WGInput/0/Xbox One Game Controller:Left X+`"); // right
#else
m_stick->SetControlExpression(0, "W"); // up
m_stick->SetControlExpression(1, "S"); // down
m_stick->SetControlExpression(2, "A"); // left
m_stick->SetControlExpression(3, "D"); // right
#endif

// Because our defaults use keyboard input, set calibration shape to a square.
m_stick->SetCalibrationFromGate(ControllerEmu::SquareStickGate(1.0));

// Buttons
#ifdef _WIN32
#if UWP_XBOX
m_buttons->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Trigger L`"); // C
m_buttons->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Trigger R`"); // Z
#elif _WIN32
m_buttons->SetControlExpression(0, "LCONTROL"); // C
m_buttons->SetControlExpression(1, "LSHIFT"); // Z
#elif __APPLE__
Expand Down
34 changes: 32 additions & 2 deletions Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,18 +666,32 @@ void Wiimote::LoadDefaults(const ControllerInterface& ciface)
m_buttons->SetControlExpression(0, "`Left Click`");
// B
m_buttons->SetControlExpression(1, "`Right Click`");
#elif UWP_XBOX
// If we're running on UWP, we're likely on an Xbox. These defaults work for Xbox One & Series.
m_buttons->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Button A`"); // A
m_buttons->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Button B`"); // B
#else
// A
m_buttons->SetControlExpression(0, "`Click 0`");
// B
m_buttons->SetControlExpression(1, "`Click 1`");
#endif

#if UWP_XBOX
m_buttons->SetControlExpression(2, "`WGInput/0/Xbox One Game Controller:Button X`");
m_buttons->SetControlExpression(3, "`WGInput/0/Xbox One Game Controller:Button Y`");
m_buttons->SetControlExpression(4, "WGInput/0/Xbox One Game Controller:View");
m_buttons->SetControlExpression(5, "WGInput/0/Xbox One Game Controller:Menu");
#else
m_buttons->SetControlExpression(2, "`1`"); // 1
m_buttons->SetControlExpression(3, "`2`"); // 2
m_buttons->SetControlExpression(4, "Q"); // -
m_buttons->SetControlExpression(5, "E"); // +
#endif

#ifdef _WIN32
#if UWP_XBOX
m_buttons->SetControlExpression(6, "WGInput/0/Xbox One Game Controller:Menu & View"); // Home
#elif _WIN32
m_buttons->SetControlExpression(6, "RETURN"); // Home
#else
// Home
Expand All @@ -692,14 +706,26 @@ void Wiimote::LoadDefaults(const ControllerInterface& ciface)
m_shake->SetControlExpression(i, "`Click 2`");
#endif

#if UWP_XBOX
// Pointing (IR)
m_ir->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Right Y+`");
m_ir->SetControlExpression(1, "`WGInput/0/Xbox One Game Controller:Right Y-`");
m_ir->SetControlExpression(2, "`WGInput/0/Xbox One Game Controller:Right X-`");
m_ir->SetControlExpression(3, "`WGInput/0/Xbox One Game Controller:Right X+`");
#else
m_ir->SetControlExpression(0, "`Cursor Y-`");
m_ir->SetControlExpression(1, "`Cursor Y+`");
m_ir->SetControlExpression(2, "`Cursor X-`");
m_ir->SetControlExpression(3, "`Cursor X+`");
#endif

// DPad
#ifdef _WIN32
#if UWP_XBOX
m_dpad->SetControlExpression(0, "WGInput/0/Xbox One Game Controller:Pad N"); // Up
m_dpad->SetControlExpression(1, "WGInput/0/Xbox One Game Controller:Pad S"); // Down
m_dpad->SetControlExpression(2, "WGInput/0/Xbox One Game Controller:Pad W"); // Left
m_dpad->SetControlExpression(3, "WGInput/0/Xbox One Game Controller:Pad E"); // Right
#elif _WIN32
m_dpad->SetControlExpression(0, "UP"); // Up
m_dpad->SetControlExpression(1, "DOWN"); // Down
m_dpad->SetControlExpression(2, "LEFT"); // Left
Expand Down Expand Up @@ -730,6 +756,10 @@ void Wiimote::LoadDefaults(const ControllerInterface& ciface)
m_imu_gyroscope->SetControlExpression(4, "`Gyro Yaw Left`");
m_imu_gyroscope->SetControlExpression(5, "`Gyro Yaw Right`");

#if UWP_XBOX
m_rumble->SetControlExpression(0, "`WGInput/0/Xbox One Game Controller:Rumble 0`");
#endif

// Enable Nunchuk:
constexpr ExtensionNumber DEFAULT_EXT = ExtensionNumber::NUNCHUK;
m_attachments->SetSelectedAttachment(DEFAULT_EXT);
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2016 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#if defined(__LIBUSB__)
#include "Core/IOS/USB/Bluetooth/BTReal.h"

#include <algorithm>
Expand Down Expand Up @@ -732,3 +733,4 @@ void BluetoothRealDevice::HandleBulkOrIntrTransfer(libusb_transfer* tr)
m_current_transfers.erase(tr);
}
} // namespace IOS::HLE
#endif
2 changes: 2 additions & 0 deletions Source/Core/Core/IOS/USB/LibusbDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#if defined(__LIBUSB__)
#include "Core/IOS/USB/LibusbDevice.h"

#include <algorithm>
Expand Down Expand Up @@ -474,3 +475,4 @@ int LibusbDevice::ReleaseAllInterfacesForCurrentConfig() const
return ReleaseAllInterfaces(config_num);
}
} // namespace IOS::HLE::USB
#endif
Loading