From fdc169468972edf6fc3e39dc2f2e4df00d0db504 Mon Sep 17 00:00:00 2001 From: Anton Fedchin Date: Wed, 4 Apr 2018 09:10:02 +0300 Subject: [win10] powermanagement: move implementation to platform folder --- cmake/treedata/windowsstore/subdirs.txt | 28 +++---- xbmc/platform/win10/powermanagement/CMakeLists.txt | 6 ++ .../win10/powermanagement/Win10PowerSyscall.cpp | 97 ++++++++++++++++++++++ .../win10/powermanagement/Win10PowerSyscall.h | 47 +++++++++++ .../win10/powermanagement/WinIdleTimer.cpp | 49 +++++++++++ xbmc/powermanagement/win10/CMakeLists.txt | 6 -- xbmc/powermanagement/win10/Win10PowerSyscall.cpp | 97 ---------------------- xbmc/powermanagement/win10/Win10PowerSyscall.h | 47 ----------- xbmc/powermanagement/win10/WinIdleTimer.cpp | 49 ----------- xbmc/windowing/win10/WinSystemWin10.cpp | 2 +- 10 files changed, 214 insertions(+), 214 deletions(-) create mode 100644 xbmc/platform/win10/powermanagement/CMakeLists.txt create mode 100644 xbmc/platform/win10/powermanagement/Win10PowerSyscall.cpp create mode 100644 xbmc/platform/win10/powermanagement/Win10PowerSyscall.h create mode 100644 xbmc/platform/win10/powermanagement/WinIdleTimer.cpp delete mode 100644 xbmc/powermanagement/win10/CMakeLists.txt delete mode 100644 xbmc/powermanagement/win10/Win10PowerSyscall.cpp delete mode 100644 xbmc/powermanagement/win10/Win10PowerSyscall.h delete mode 100644 xbmc/powermanagement/win10/WinIdleTimer.cpp diff --git a/cmake/treedata/windowsstore/subdirs.txt b/cmake/treedata/windowsstore/subdirs.txt index 82d49b1f71..1084447281 100644 --- a/cmake/treedata/windowsstore/subdirs.txt +++ b/cmake/treedata/windowsstore/subdirs.txt @@ -1,15 +1,15 @@ -xbmc/platform/win10 platform/win10 -xbmc/platform/win10/filesystem platform/win10/filesystem -xbmc/platform/win10/network platform/win10/network -xbmc/platform/win10/peripherals platform/win10/peripherals -xbmc/platform/win10/storage platfrom/win10/storage -xbmc/platform/win32/filesystem platform/win32/filesystem -xbmc/input/touch input/touch -xbmc/input/touch/generic input/touch/generic -xbmc/network/mdns network/mdns -xbmc/powermanagement/win10 powermanagement/win10 -xbmc/utils/win32 utils/win32 -xbmc/rendering/dx rendering/dx -xbmc/threads/platform/win threads/win -xbmc/windowing/win10 windowing/win10 +xbmc/platform/win10 platform/win10 +xbmc/platform/win10/filesystem platform/win10/filesystem +xbmc/platform/win10/network platform/win10/network +xbmc/platform/win10/peripherals platform/win10/peripherals +xbmc/platform/win10/powermanagement platfrom/win10/powermanagement +xbmc/platform/win10/storage platfrom/win10/storage +xbmc/platform/win32/filesystem platform/win32/filesystem +xbmc/input/touch input/touch +xbmc/input/touch/generic input/touch/generic +xbmc/network/mdns network/mdns +xbmc/utils/win32 utils/win32 +xbmc/rendering/dx rendering/dx +xbmc/threads/platform/win threads/win +xbmc/windowing/win10 windowing/win10 xbmc/cores/VideoPlayer/Process/windows cores/VideoPlayer/Process/windows diff --git a/xbmc/platform/win10/powermanagement/CMakeLists.txt b/xbmc/platform/win10/powermanagement/CMakeLists.txt new file mode 100644 index 0000000000..2b80d3736a --- /dev/null +++ b/xbmc/platform/win10/powermanagement/CMakeLists.txt @@ -0,0 +1,6 @@ +set(SOURCES Win10PowerSyscall.cpp + WinIdleTimer.cpp) + +set(HEADERS Win10PowerSyscall.h) + +core_add_library(platform_win10_powermanagement) diff --git a/xbmc/platform/win10/powermanagement/Win10PowerSyscall.cpp b/xbmc/platform/win10/powermanagement/Win10PowerSyscall.cpp new file mode 100644 index 0000000000..8755f503f6 --- /dev/null +++ b/xbmc/platform/win10/powermanagement/Win10PowerSyscall.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include "Win10PowerSyscall.h" + +using namespace Windows::Devices::Power; + +IPowerSyscall* CPowerSyscall::CreateInstance() +{ + return new CPowerSyscall(); +} + +void CPowerSyscall::Register() +{ + IPowerSyscall::RegisterPowerSyscall(CPowerSyscall::CreateInstance); +} + +CPowerSyscall::CPowerSyscall() = default; + +CPowerSyscall::~CPowerSyscall() = default; + +bool CPowerSyscall::Powerdown() +{ + return false; +} +bool CPowerSyscall::Suspend() +{ + return false; +} +bool CPowerSyscall::Hibernate() +{ + return false; +} +bool CPowerSyscall::Reboot() +{ + return false; +} + +bool CPowerSyscall::CanPowerdown() +{ + return false; +} +bool CPowerSyscall::CanSuspend() +{ + return false; +} +bool CPowerSyscall::CanHibernate() +{ + return false; +} +bool CPowerSyscall::CanReboot() +{ + return false; +} + +int CPowerSyscall::BatteryLevel() +{ + int result = 0; + auto aggBattery = Battery::AggregateBattery; + auto report = aggBattery->GetReport(); + + int remaining = 0; + if (report->RemainingCapacityInMilliwattHours) + remaining = report->RemainingCapacityInMilliwattHours->Value; + int full = 0; + if (report->FullChargeCapacityInMilliwattHours) + full = report->FullChargeCapacityInMilliwattHours->Value; + + if (full != 0 && remaining != 0) + { + float percent = static_cast(remaining) / static_cast(full); + result = static_cast (percent * 100.0f); + } + return result; +} + +bool CPowerSyscall::PumpPowerEvents(IPowerEventsCallback *callback) +{ + return true; +} diff --git a/xbmc/platform/win10/powermanagement/Win10PowerSyscall.h b/xbmc/platform/win10/powermanagement/Win10PowerSyscall.h new file mode 100644 index 0000000000..289e15b34b --- /dev/null +++ b/xbmc/platform/win10/powermanagement/Win10PowerSyscall.h @@ -0,0 +1,47 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Kodi; see the file COPYING. If not, see + * . + * + */ + +#include "powermanagement/IPowerSyscall.h" +#include "powermanagement/PowerManager.h" + +class CPowerSyscall : public CAbstractPowerSyscall +{ +public: + CPowerSyscall(); + ~CPowerSyscall(); + + static IPowerSyscall* CreateInstance(); + static void Register(); + + bool Powerdown() override; + bool Suspend() override; + bool Hibernate() override; + bool Reboot() override; + + bool CanPowerdown() override; + bool CanSuspend() override; + bool CanHibernate() override; + bool CanReboot() override; + int BatteryLevel() override; + + bool PumpPowerEvents(IPowerEventsCallback *callback) override; +}; diff --git a/xbmc/platform/win10/powermanagement/WinIdleTimer.cpp b/xbmc/platform/win10/powermanagement/WinIdleTimer.cpp new file mode 100644 index 0000000000..b39441646f --- /dev/null +++ b/xbmc/platform/win10/powermanagement/WinIdleTimer.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ +#include "powermanagement/WinIdleTimer.h" +#include "Application.h" + +using namespace Windows::ApplicationModel::Core; +using namespace Windows::Foundation; +using namespace Windows::System::Display; +using namespace Windows::System::Threading; +using namespace Windows::UI::Core; + +void CWinIdleTimer::StartZero() +{ + if (!g_application.IsDPMSActive()) + { + auto workItem = ref new DispatchedHandler([]() + { + try + { + auto displayRequest = ref new DisplayRequest(); + // this couple of calls activate and deactivate a display-required + // request in other words they reset display idle timer + displayRequest->RequestActive(); + displayRequest->RequestRelease(); + } + catch (Platform::Exception^ ex) { } + }); + CoreWindow^ window = CoreApplication::MainView->CoreWindow; + window->Dispatcher->RunAsync(CoreDispatcherPriority::High, workItem); + } + CStopWatch::StartZero(); +} diff --git a/xbmc/powermanagement/win10/CMakeLists.txt b/xbmc/powermanagement/win10/CMakeLists.txt deleted file mode 100644 index 1f33c27207..0000000000 --- a/xbmc/powermanagement/win10/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set(SOURCES Win10PowerSyscall.cpp - WinIdleTimer.cpp) - -set(HEADERS Win10PowerSyscall.h) - -core_add_library(powermanagement_win10) diff --git a/xbmc/powermanagement/win10/Win10PowerSyscall.cpp b/xbmc/powermanagement/win10/Win10PowerSyscall.cpp deleted file mode 100644 index 8755f503f6..0000000000 --- a/xbmc/powermanagement/win10/Win10PowerSyscall.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ - -#include "Win10PowerSyscall.h" - -using namespace Windows::Devices::Power; - -IPowerSyscall* CPowerSyscall::CreateInstance() -{ - return new CPowerSyscall(); -} - -void CPowerSyscall::Register() -{ - IPowerSyscall::RegisterPowerSyscall(CPowerSyscall::CreateInstance); -} - -CPowerSyscall::CPowerSyscall() = default; - -CPowerSyscall::~CPowerSyscall() = default; - -bool CPowerSyscall::Powerdown() -{ - return false; -} -bool CPowerSyscall::Suspend() -{ - return false; -} -bool CPowerSyscall::Hibernate() -{ - return false; -} -bool CPowerSyscall::Reboot() -{ - return false; -} - -bool CPowerSyscall::CanPowerdown() -{ - return false; -} -bool CPowerSyscall::CanSuspend() -{ - return false; -} -bool CPowerSyscall::CanHibernate() -{ - return false; -} -bool CPowerSyscall::CanReboot() -{ - return false; -} - -int CPowerSyscall::BatteryLevel() -{ - int result = 0; - auto aggBattery = Battery::AggregateBattery; - auto report = aggBattery->GetReport(); - - int remaining = 0; - if (report->RemainingCapacityInMilliwattHours) - remaining = report->RemainingCapacityInMilliwattHours->Value; - int full = 0; - if (report->FullChargeCapacityInMilliwattHours) - full = report->FullChargeCapacityInMilliwattHours->Value; - - if (full != 0 && remaining != 0) - { - float percent = static_cast(remaining) / static_cast(full); - result = static_cast (percent * 100.0f); - } - return result; -} - -bool CPowerSyscall::PumpPowerEvents(IPowerEventsCallback *callback) -{ - return true; -} diff --git a/xbmc/powermanagement/win10/Win10PowerSyscall.h b/xbmc/powermanagement/win10/Win10PowerSyscall.h deleted file mode 100644 index 289e15b34b..0000000000 --- a/xbmc/powermanagement/win10/Win10PowerSyscall.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -/* - * Copyright (C) 2005-2015 Team Kodi - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Kodi; see the file COPYING. If not, see - * . - * - */ - -#include "powermanagement/IPowerSyscall.h" -#include "powermanagement/PowerManager.h" - -class CPowerSyscall : public CAbstractPowerSyscall -{ -public: - CPowerSyscall(); - ~CPowerSyscall(); - - static IPowerSyscall* CreateInstance(); - static void Register(); - - bool Powerdown() override; - bool Suspend() override; - bool Hibernate() override; - bool Reboot() override; - - bool CanPowerdown() override; - bool CanSuspend() override; - bool CanHibernate() override; - bool CanReboot() override; - int BatteryLevel() override; - - bool PumpPowerEvents(IPowerEventsCallback *callback) override; -}; diff --git a/xbmc/powermanagement/win10/WinIdleTimer.cpp b/xbmc/powermanagement/win10/WinIdleTimer.cpp deleted file mode 100644 index b39441646f..0000000000 --- a/xbmc/powermanagement/win10/WinIdleTimer.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005-2018 Team Kodi - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ -#include "powermanagement/WinIdleTimer.h" -#include "Application.h" - -using namespace Windows::ApplicationModel::Core; -using namespace Windows::Foundation; -using namespace Windows::System::Display; -using namespace Windows::System::Threading; -using namespace Windows::UI::Core; - -void CWinIdleTimer::StartZero() -{ - if (!g_application.IsDPMSActive()) - { - auto workItem = ref new DispatchedHandler([]() - { - try - { - auto displayRequest = ref new DisplayRequest(); - // this couple of calls activate and deactivate a display-required - // request in other words they reset display idle timer - displayRequest->RequestActive(); - displayRequest->RequestRelease(); - } - catch (Platform::Exception^ ex) { } - }); - CoreWindow^ window = CoreApplication::MainView->CoreWindow; - window->Dispatcher->RunAsync(CoreDispatcherPriority::High, workItem); - } - CStopWatch::StartZero(); -} diff --git a/xbmc/windowing/win10/WinSystemWin10.cpp b/xbmc/windowing/win10/WinSystemWin10.cpp index 1b654dd82d..8654570bc6 100644 --- a/xbmc/windowing/win10/WinSystemWin10.cpp +++ b/xbmc/windowing/win10/WinSystemWin10.cpp @@ -27,8 +27,8 @@ #include "messaging/ApplicationMessenger.h" #include "platform/win10/AsyncHelpers.h" #include "platform/win10/input/RemoteControlXbox.h" +#include "platform/win10/powermanagement/Win10PowerSyscall.h" #include "platform/win32/CharsetConverter.h" -#include "powermanagement/win10/Win10PowerSyscall.h" #include "rendering/dx/DirectXHelper.h" #include "rendering/dx/RenderContext.h" #include "ServiceBroker.h" -- cgit v1.2.3