Proper device type detection for UWP

implement proper device type detection instead of relying on architecture.
This commit is contained in:
driver1998 2019-05-13 15:38:04 +08:00
parent 0e9f53c8b4
commit 1804b88454
2 changed files with 25 additions and 15 deletions

View File

@ -95,6 +95,9 @@ void App::SetWindow(CoreWindow^ window) {
if (Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) {
m_hardwareButtons.insert(HardwareButton::BACK);
}
if (Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily == "Windows.Mobile") {
m_isPhone = true;
}
@ -107,7 +110,10 @@ void App::SetWindow(CoreWindow^ window) {
}
bool App::HasBackButton() {
return m_isPhone;
if (m_hardwareButtons.count(HardwareButton::BACK) != 0)
return true;
else
return false;
}
void App::App_BackRequested(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ e) {
@ -151,9 +157,9 @@ void App::OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::C
float Y = args->CurrentPoint->Position.Y;
int64_t timestamp = args->CurrentPoint->Timestamp;
m_main->OnTouchEvent(TOUCH_DOWN|TOUCH_MOVE, pointerId, X, Y, timestamp);
#if !PPSSPP_ARCH(ARM)
if (!m_isPhone) {
sender->SetPointerCapture();
#endif
}
}
void App::OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) {
@ -164,9 +170,9 @@ void App::OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::
float Y = args->CurrentPoint->Position.Y;
int64_t timestamp = args->CurrentPoint->Timestamp;
m_main->OnTouchEvent(TOUCH_UP|TOUCH_MOVE, pointerId, X, Y, timestamp);
#if !PPSSPP_ARCH(ARM)
sender->ReleasePointerCapture();
#endif
if (!m_isPhone) {
sender->ReleasePointerCapture();
}
}
void App::OnPointerCaptureLost(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args) {
@ -211,9 +217,9 @@ void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^
// Run() won't start until the CoreWindow is activated.
CoreWindow::GetForCurrentThread()->Activate();
// On mobile, we force-enter fullscreen mode.
#ifdef _ARM
Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->TryEnterFullScreenMode();
#endif
if (m_isPhone) {
Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->TryEnterFullScreenMode();
}
}
void App::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args) {

View File

@ -368,12 +368,16 @@ int System_GetPropertyInt(SystemProperty prop) {
case SYSPROP_DISPLAY_REFRESH_RATE:
return 60000;
case SYSPROP_DEVICE_TYPE:
// TODO: Detect touch screen instead.
#ifdef _M_ARM
return DEVICE_TYPE_MOBILE;
#else
return DEVICE_TYPE_DESKTOP;
#endif
{
auto ver = Windows::System::Profile::AnalyticsInfo::VersionInfo;
if (ver->DeviceFamily == "Windows.Mobile") {
return DEVICE_TYPE_MOBILE;
} else if (ver->DeviceFamily == "Windows.Xbox") {
return DEVICE_TYPE_TV;
} else {
return DEVICE_TYPE_DESKTOP;
}
}
default:
return -1;
}