Skip to content
Permalink
Browse files

Proper device type detection for UWP

implement proper device type detection instead of relying on architecture.
  • Loading branch information...
driver1998 committed May 13, 2019
1 parent 0e9f53c commit 1804b88454a5eaf096eab23bec9858bc8ebaa37d
Showing with 25 additions and 15 deletions.
  1. +15 −9 UWP/App.cpp
  2. +10 −6 UWP/PPSSPP_UWPMain.cpp
@@ -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) {
@@ -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;
}

0 comments on commit 1804b88

Please sign in to comment.
You can’t perform that action at this time.