Archived
1
Fork 0

Delete the old Windows and Linux backends, which are now replaced by SDL

This commit is contained in:
redstrate 2021-04-20 10:03:12 -04:00
parent 28dbc34d51
commit 6655dab7a6
7 changed files with 0 additions and 934 deletions

View file

@ -1,25 +0,0 @@
include(../../cmake/AddPlatformExecutable.cmake)
add_platform(
SRC ${CMAKE_CURRENT_SOURCE_DIR}/file.cpp
MAIN_FILE
main.cpp.in
LINK_LIBRARIES
X11
xcb
xcb-randr
Core
GFXVulkan
COMPILE_OPTIONS
-std=c++17
)
function(add_platform_commands target)
if(NOT SKIP_DATA)
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:${target}>/data)
endif()
add_custom_command(TARGET ${target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/shaders)
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/shaders)
endfunction()

View file

@ -1,11 +0,0 @@
#include "file.hpp"
#include "string_utils.hpp"
void file::set_domain_path(const file::Domain domain, const file::Path path) {
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "");
}
file::Path file::get_writeable_directory() {
return "~";
}

View file

@ -1,413 +0,0 @@
#include <@APP_INCLUDE@>
#include <engine.hpp>
#include "gfx_vulkan.hpp"
#include "platform.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <xcb/xcb.h>
#include <xcb/randr.h>
#include <X11/Xutil.h>
@APP_CLASS@* app = nullptr;
GFX* interface = nullptr;
Display *dpy = nullptr;
int mouse_x = -1, mouse_y = -1;
bool mouse_down[2] = {false, false};
int window_width = -1, window_height = -1;
xcb_connection_t* connection = nullptr;
xcb_screen_t* screen = nullptr;
struct WindowConnection {
int identifier = 0;
xcb_connection_t* connection;
xcb_window_t window;
};
std::vector<WindowConnection> window_connections;
xcb_intern_atom_reply_t *atom_wm_delete_window;
static std::map<InputButton, int> inputToKeyCode = { {
{InputButton::A, 38},
{InputButton::W, 25},
{InputButton::S, 39},
{InputButton::D, 40},
{InputButton::Q, 24}
}};
/*
* Platform functions"
*/
const char* platform::get_name() {
return "Linux";
}
bool platform::supports_feature(const PlatformFeature feature) {
if(feature == PlatformFeature::Windowing)
return true;
return false;
}
static inline xcb_intern_atom_reply_t* intern_atom_helper(xcb_connection_t *conn, bool only_if_exists, const char *str)
{
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(conn, only_if_exists, strlen(str), str);
return xcb_intern_atom_reply(conn, cookie, NULL);
}
int platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
auto& win = window_connections.emplace_back();
win.connection = connection;
win.identifier = window_connections.size() - 1;
uint32_t mask;
uint32_t values[32];
xcb_void_cookie_t cookie;
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
values[0] = screen->black_pixel;
values[1] =
XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_KEY_PRESS |
XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_POINTER_MOTION |
XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_BUTTON_RELEASE;
win.window = xcb_generate_id(connection);
cookie = xcb_create_window(win.connection,
XCB_COPY_FROM_PARENT, win.window, screen->root,
rect.offset.x, rect.offset.y, rect.extent.width, rect.extent.height,
0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
screen->root_visual,
mask, values);
/* Magic code that will send notification when window is destroyed */
xcb_intern_atom_reply_t* reply = intern_atom_helper(connection, true, "WM_PROTOCOLS");
atom_wm_delete_window = intern_atom_helper(connection, false, "WM_DELETE_WINDOW");
xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
win.window, (*reply).atom, 4, 32, 1,
&(*atom_wm_delete_window).atom);
xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
win.window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8,
title.size(), title.data());
xcb_map_window(connection, win.window);
xcb_flush(connection);
window_width = rect.extent.width;
window_height = rect.extent.height;
engine->add_window((void*)&win, 0, rect.extent);
app->initialize_render();
return win.identifier;
}
void platform::close_window(const int index) {
}
void platform::force_quit() {
}
float platform::get_window_dpi(const int index) {
return 1.0;
}
float platform::get_monitor_dpi() {
return 1.0;
}
prism::Rectangle platform::get_monitor_resolution() {
// based off of https://stackoverflow.com/a/27141466
xcb_flush(connection);
xcb_randr_get_screen_resources_cookie_t screenResCookie = {};
screenResCookie = xcb_randr_get_screen_resources(connection, screen->root);
xcb_randr_get_screen_resources_reply_t* screenResReply = {};
screenResReply = xcb_randr_get_screen_resources_reply(connection, screenResCookie, 0);
int crtcs_num = xcb_randr_get_screen_resources_crtcs_length(screenResReply);
xcb_randr_crtc_t* firstCRTC = xcb_randr_get_screen_resources_crtcs(screenResReply);
xcb_randr_get_crtc_info_cookie_t* crtcResCookie = new xcb_randr_get_crtc_info_cookie_t[crtcs_num];
for(int i = 0; i < crtcs_num; i++)
crtcResCookie[i] = xcb_randr_get_crtc_info(connection, *(firstCRTC+i), 0);
xcb_randr_get_crtc_info_reply_t** crtcResReply = new xcb_randr_get_crtc_info_reply_t*[crtcs_num];
for(int i = 0; i < crtcs_num; i++)
crtcResReply[i] = xcb_randr_get_crtc_info_reply(connection, crtcResCookie[i], 0);
for(int i = 0; i < crtcs_num; i++) {
// just pick up the first monitor for now
if(crtcResReply[i]) {
prism::Rectangle rect;
rect.extent.width = crtcResReply[i]->width;
rect.extent.height = crtcResReply[i]->height;
return rect;
}
}
return {};
}
prism::Rectangle platform::get_monitor_work_area() {
return platform::get_monitor_resolution();
}
prism::Offset platform::get_window_position(const int index) {
}
prism::Extent platform::get_window_size(const int index) {
return {window_width, window_height};
}
prism::Extent platform::get_window_drawable_size(const int index) {
return {window_width, window_height};
}
bool platform::is_window_focused(const int index) {
}
void platform::set_window_focused(const int index) {
}
void platform::set_window_position(const int index, const prism::Offset offset) {
}
void platform::set_window_size(const int index, const prism::Extent extent) {
}
void platform::set_window_title(const int index, const std::string_view title) {
xcb_change_property(connection, XCB_PROP_MODE_REPLACE,
window_connections[index].window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8,
title.size(), title.data());
}
bool platform::get_key_down(const InputButton key) {
int keycode = inputToKeyCode[key];
char keys[32];
XQueryKeymap(dpy, keys);
return keys[keycode/8]&(0x1<<(keycode%8));
}
int platform::get_keycode(const InputButton key) {
return inputToKeyCode[key];
}
prism::Offset platform::get_cursor_position() {
return {mouse_x, mouse_y};
}
prism::Offset platform::get_screen_cursor_position() {
return {mouse_x, mouse_y};
}
bool platform::get_mouse_button_down(const int button) {
return mouse_down[button];
}
std::tuple<float, float> platform::get_wheel_delta() {
}
std::tuple<float, float> platform::get_right_stick_position() {
}
std::tuple<float, float> platform::get_left_stick_position() {
}
void platform::capture_mouse(const bool capture) {
}
void platform::open_dialog(const bool existing, std::function<void(std::string)> returnFunction, bool openDirectory) {
}
void platform::save_dialog(std::function<void(std::string)> returnFunction) {
}
char* platform::translate_keycode(const unsigned int keycode) {
char* array = new char[2];
XKeyEvent event;
memset(&event, 0, sizeof(event));
event.type = 2;
event.display = dpy;
event.keycode = keycode;
int count = XLookupString(&event, array, 1, nullptr, 0);
array[1] = '\0';
return array;
}
int stdout_copy;
int stderr_copy;
void platform::mute_output() {
stdout_copy = dup(STDOUT_FILENO);
stderr_copy = dup(STDERR_FILENO);
freopen("/dev/null", "a", stdout);
freopen("/dev/null", "a", stderr);
}
void platform::unmute_output() {
dup2(stdout_copy, STDOUT_FILENO);
dup2(stderr_copy, STDERR_FILENO);
close(stdout_copy);
close(stderr_copy);
}
int main(int argc, char* argv[]) {
dpy = XOpenDisplay(nullptr);
const xcb_setup_t *setup;
xcb_screen_iterator_t iter;
int scr;
connection = xcb_connect(NULL, &scr);
setup = xcb_get_setup(connection);
iter = xcb_setup_roots_iterator(setup);
while (scr-- > 0)
xcb_screen_next(&iter);
screen = iter.data;
engine = new prism::Engine(argc, argv);
app = new @APP_CLASS@();
engine->set_app(app);
GFXCreateInfo info = {};
interface = new GFXVulkan();
if(interface->initialize(info)) {
engine->set_gfx(interface);
} else {
return -1;
}
app_main(engine);
while(1) {
xcb_generic_event_t* event = nullptr;
while((event = xcb_poll_for_event (connection))) {
switch(event->response_type & 0x7f) {
case XCB_CLIENT_MESSAGE:
{
if ((*(xcb_client_message_event_t*)event).data.data32[0] ==
(*atom_wm_delete_window).atom) {
engine->quit();
}
}
break;
case XCB_MOTION_NOTIFY:
{
auto ev = (xcb_motion_notify_event_t *)event;
//engine->process_mouse_move(ev->event_x, ev->event_y);
mouse_x = ev->event_x;
mouse_y = ev->event_y;
}
break;
case XCB_BUTTON_PRESS:
{
xcb_button_press_event_t *press = (xcb_button_press_event_t *)event;
int index = 0;
if(press->detail == 3)
index = 1;
//engine->process_mouse(index, press->event_x, press->event_y);
mouse_down[index] = true;
mouse_x = press->event_x;
mouse_y = press->event_y;
}
break;
case XCB_BUTTON_RELEASE:
{
xcb_button_press_event_t *press = (xcb_button_press_event_t *)event;
int index = 0;
if(press->detail == 3)
index = 1;
//engine->process_mouse_released(index);
mouse_down[index] = false;
}
break;
case XCB_CONFIGURE_NOTIFY:
{
const xcb_configure_notify_event_t *cfgEvent = (const xcb_configure_notify_event_t *)event;
int identifier = -1;
for(auto window : window_connections) {
if(window.window == cfgEvent->window)
identifier = window.identifier;
}
window_width = cfgEvent->width;
window_height = cfgEvent->height;
engine->resize(identifier, {cfgEvent->width, cfgEvent->height});
}
break;
case XCB_KEY_PRESS:
{
const xcb_key_release_event_t *keyEvent = (const xcb_key_release_event_t *)event;
//engine->process_key(keyEvent->detail);
}
break;
case XCB_KEY_RELEASE:
{
const xcb_key_release_event_t *keyEvent = (const xcb_key_release_event_t *)event;
//engine->process_key_up(keyEvent->detail);
}
break;
}
free(event);
}
if(engine->is_quitting())
break;
engine->update(1.0 / 60.0);
engine->begin_frame(1.0 / 60.0);
engine->render(0);
engine->end_frame();
}
return 0;
}
PlatformTheme platform::get_theme() {
return PlatformTheme::Light;
}

View file

@ -1,23 +0,0 @@
include(../../cmake/AddPlatformExecutable.cmake)
add_platform(
MAIN_FILE
main.cpp.in
SRC
${CMAKE_CURRENT_SOURCE_DIR}/file.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows.cpp
EXECUTABLE_PROPERTIES
LINK_LIBRARIES
Core
GFXVulkan
)
add_custom_target(PlatformWindows_IDE SOURCES
main.cpp.in)
function(add_platform_commands target)
set_target_properties(${target} PROPERTIES
LINK_FLAGS /SUBSYSTEM:WINDOWS)
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/shaders)
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:${target}>/data)
endfunction()

View file

@ -1,11 +0,0 @@
#include "file.hpp"
#include "string_utils.hpp"
void file::set_domain_path(const file::Domain domain, const file::Path path) {
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "");
}
file::Path file::get_writeable_directory() {
return "";
}

View file

@ -1,334 +0,0 @@
#ifndef UNICODE
#define UNICODE
#endif
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <windowsx.h>
#undef far
#undef near
#include "platform.hpp"
#include <gfx_vulkan.hpp>
#include <@APP_INCLUDE@>
#include <engine.hpp>
GFX* ginterface = nullptr;
@APP_CLASS@* app = nullptr;
HINSTANCE instance = NULL;
HWND window = NULL;
int cmdShow = 0;
HDC windowDC = NULL;
int defaultWidth, defaultHeight;
bool shouldConfineMouse = false;
const wchar_t CLASS_NAME[] = L"PrismApp";
wchar_t* convertToUnicode(const char* str) {
size_t ret = 0;
mbsrtowcs_s(&ret, NULL, 0, &str, 0, NULL);
wchar_t * buf = new wchar_t[ret + 1]();
mbsrtowcs_s(&ret, buf, ret + 1 , &str, ret + 1, NULL);
return buf;
}
void platform::force_quit() {}
int platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
RECT wr = {rect.offset.x, rect.offset.y, rect.extent.width, rect.extent.height};
AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
defaultWidth = rect.extent.width;
defaultHeight = rect.extent.height;
wchar_t* title_uni = convertToUnicode(title.data());
window = CreateWindowEx(
0,
CLASS_NAME,
title_uni,
flags == WindowFlags::Resizable ? WS_OVERLAPPEDWINDOW : (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX), // Window style
rect.offset.x,
rect.offset.y,
rect.extent.width,
rect.extent.height,
NULL,
NULL,
instance,
NULL
);
delete[] title_uni;
ShowWindow(window, cmdShow);
engine->add_window(window, 0, rect.extent);
app->initialize_render();
return 0;
}
void platform::close_window(const int identifier) {
// does nothing
}
bool showingCursor = true;
void platform::capture_mouse(const bool capture) {
shouldConfineMouse = capture;
// the reason why we do this is because windows expects a ShowCursor(false) to be followed by a ShowCursor(true),
// if you don't do this your cursor pretty much gets sent to bill gate's purgatory and it can never escape
// so this code is to ensure every ShowCursor call gets matched by it's counterpart when you call setCaptureMouse
if(showingCursor && capture) {
ShowCursor(false);
showingCursor = false;
} else if(!showingCursor && !capture) {
ShowCursor(true);
showingCursor = true;
}
}
prism::Offset platform::get_cursor_position() {
POINT p;
GetCursorPos(&p);
ScreenToClient(window, &p);
return {p.x, p.y};
}
prism::Offset platform::get_window_position(const int identifier) {
RECT rect;
GetWindowRect(window, &rect);
return {rect.left, rect.top};
}
prism::Extent platform::get_window_size(const int identifier) {
RECT rect;
GetClientRect(window, &rect);
int width = rect.right - rect.left;
int height = rect.bottom- rect.top;
return {static_cast<uint32_t>(width), static_cast<uint32_t>(height)};
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) {
AllocConsole();
FILE* stream;
freopen_s(&stream, "CONOUT$", "w", stdout);
freopen_s(&stream, "CONOUT$", "w", stderr);
WNDCLASS wc {};
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
instance = hInstance;
cmdShow = nCmdShow;
engine = new prism::Engine(0, nullptr);
ginterface = new GFXVulkan();
if(ginterface->initialize(GFXCreateInfo())) {
engine->set_gfx(ginterface);
} else {
return -1;
}
app = new @APP_CLASS@();
engine->set_app(app);
app_main(engine);
MSG msg = { };
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
delete app;
delete ginterface;
delete engine;
fclose(stream);
return 0;
}
int timeout = 0;
bool mouse_down = false;
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_DESTROY:
{
engine->prepare_quit();
PostQuitMessage(0);
}
return 0;
case WM_PAINT:
{
if(shouldConfineMouse && timeout > 5) {
RECT rect;
GetClientRect(hwnd, &rect);
int width = rect.right - rect.left;
int height = rect.bottom- rect.top;
POINT p;
p.x = width / 2;
p.y = height / 2;
ClientToScreen(window, &p);
SetCursorPos(p.x, p.y);
timeout = 0;
}
timeout++;
HCURSOR arrowCursor = LoadCursor(NULL, IDC_ARROW);
SetCursor(arrowCursor);
engine->update(1.0f / 60.0f);
engine->begin_frame(1.0f / 60.0f);
engine->render(0);
if(engine->is_quitting()) {
engine->prepare_quit();
PostQuitMessage(0);
}
}
return 0;
case WM_LBUTTONDOWN:
{
int xPos = GET_X_LPARAM(lParam);
int yPos = GET_Y_LPARAM(lParam);
engine->process_mouse_down(0, {xPos, yPos});
mouse_down = true;
}
return 0;
case WM_LBUTTONUP:
{
mouse_down = false;
}
return 0;
case WM_KEYDOWN:
{
engine->process_key_down((unsigned int)wParam);
}
return 0;
case WM_KEYUP:
{
engine->process_key_up((unsigned int)wParam);
}
return 0;
case WM_SIZE:
{
RECT rect;
GetClientRect(hwnd, &rect);
int width = rect.right - rect.left;
int height = rect.bottom- rect.top;
if(width == defaultWidth && height == defaultHeight) {
// don't resize when the window was first created!!
} else {
engine->resize(0, {static_cast<uint32_t>(width), static_cast<uint32_t>(height)});
}
}
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
void platform::set_window_title(const int identifier, const std::string_view title) {
SetWindowTextA(window, title.data());
}
std::tuple<float, float> platform::get_right_stick_position() {
return {0.0f, 0.0f};
}
std::tuple<float, float> platform::get_left_stick_position() {
return {0.0f, 0.0f};
}
bool platform::is_window_focused(const int index) {
return false;
}
void platform::set_window_focused(const int index) {
}
prism::Extent platform::get_window_drawable_size(const int identifier) {
RECT rect;
GetClientRect(window, &rect);
int width = rect.right - rect.left;
int height = rect.bottom- rect.top;
return {static_cast<uint32_t>(width), static_cast<uint32_t>(height)};
}
void platform::set_window_size(const int index, const prism::Extent extent) {
}
void platform::set_window_position(const int index, const prism::Offset offset) {
}
prism::Rectangle platform::get_monitor_resolution() {
return prism::Rectangle();
}
prism::Rectangle platform::get_monitor_work_area() {
return prism::Rectangle();
}
prism::Offset platform::get_screen_cursor_position() {
return prism::Offset();
}
float platform::get_window_dpi(const int index) {
return 1.0f;
}
bool platform::get_mouse_button_down(const int index) {
return mouse_down;
}
float platform::get_monitor_dpi() {
return 1.0f;
}
std::tuple<float, float> platform::get_wheel_delta() {
return {0.0f, 0.0f};
}

View file

@ -1,117 +0,0 @@
#include "platform.hpp"
#include <tchar.h>
#include <windows.h>
#include <winuser.h>
#include <thread>
#include <map>
#include <winrt/Windows.UI.ViewManagement.h>
#pragma comment(lib, "windowsapp")
std::map<InputButton, int> inputToKeyCode = { {
{InputButton::C, 67},
{InputButton::V, 86},
{InputButton::X, 58},
{InputButton::Y, 59},
{InputButton::Z, 60},
{InputButton::Backspace, 8},
{InputButton::Enter, 4},
{InputButton::Space, 20},
{InputButton::Ctrl, 17},
{InputButton::Shift, 10},
{InputButton::A, 65},
{InputButton::W, 87},
{InputButton::S, 83},
{InputButton::D, 68},
{InputButton::Escape, 27},
{InputButton::Tab, 9}
}};
const char* platform::get_name() {
return "Windows";
}
bool platform::supports_feature(const PlatformFeature feature) {
return false;
}
std::vector<const char*> platform::get_native_surface_extension() {
return {"VK_KHR_surface", "VK_KHR_win32_surface"};
}
bool platform::get_key_down(const InputButton key) {
if (inputToKeyCode.count(key)) {
return (GetKeyState(inputToKeyCode[key]) & 0x8000) != 0;
}
}
int platform::get_keycode(const InputButton key) {
return inputToKeyCode[key];
}
void platform::open_dialog(const bool existing, const std::function<void(std::string)> returnFunction, const bool openDirectory) {
const auto openDialog = [returnFunction] {
const int BUFSIZE = 1024;
char buffer[BUFSIZE] = { 0 };
OPENFILENAME ofns = { 0 };
ofns.lStructSize = sizeof(ofns);
ofns.lpstrFile = buffer;
ofns.nMaxFile = BUFSIZE;
ofns.lpstrTitle = "Open File";
if (GetOpenFileName(&ofns))
returnFunction(buffer);
};
std::thread* ot = new std::thread(openDialog);
}
void platform::save_dialog(const std::function<void(std::string)> returnFunction) {
const auto saveDialog = [returnFunction] {
const int BUFSIZE = 1024;
char buffer[BUFSIZE] = { 0 };
OPENFILENAME ofns = { 0 };
ofns.lStructSize = sizeof(ofns);
ofns.lpstrFile = buffer;
ofns.nMaxFile = BUFSIZE;
ofns.lpstrTitle = "Save File";
if (GetSaveFileName(&ofns))
returnFunction(buffer);
};
std::thread* ot = new std::thread(saveDialog);
}
char* platform::translate_keycode(const unsigned int keycode) {
char* uc = new char[5];
BYTE kb[256];
GetKeyboardState(kb);
ToUnicode(keycode, 0, kb, (LPWSTR)uc, 4, 0);
return uc;
}
void platform::mute_output() {
}
void platform::unmute_output() {
}
PlatformTheme platform::get_theme() {
using namespace winrt::Windows::UI::ViewManagement;
// TODO: figure out if this works pre-anniversary update/other windows other than 10
UISettings settings;
auto background = settings.GetColorValue(UIColorType::Background);
auto foreground = settings.GetColorValue(UIColorType::Foreground);
if (background == winrt::Windows::UI::Colors::White())
return PlatformTheme::Light;
else
return PlatformTheme::Dark;
}