This commit is contained in:
twinaphex 2020-08-18 15:48:13 +02:00
parent 79db13d5e7
commit ed52146f8c

View File

@ -51,9 +51,9 @@ using namespace Windows::Foundation::Collections;
using namespace Windows::Graphics::Display;
using namespace Windows::Devices::Enumeration;
char uwp_dir_install[PATH_MAX_LENGTH];
char uwp_dir_data[PATH_MAX_LENGTH];
char uwp_device_family[128];
char uwp_dir_install[PATH_MAX_LENGTH] = { 0 };
char uwp_dir_data[PATH_MAX_LENGTH] = { 0 };
char uwp_device_family[128] = { 0 };
char win32_cpu_model_name[128] = { 0 };
// Some keys are unavailable in the VirtualKey enum (wtf) but the old-style constants work
@ -172,32 +172,35 @@ const struct rarch_key_map rarch_key_map_uwp[] = {
};
#define MAX_TOUCH 16
struct input_pointer {
struct input_pointer
{
int id;
short x;
short y;
short full_x;
short full_y;
bool isInContact;
short x, y;
short full_x, full_y;
};
struct uwp_input_state_t {
struct uwp_input_state_t
{
struct input_pointer touch[MAX_TOUCH]; /* int alignment */
unsigned touch_count;
short mouse_screen_x;
short mouse_screen_y;
short mouse_rel_x;
short mouse_rel_y;
short mouse_wheel_left;
short mouse_wheel_up;
bool mouse_left;
bool mouse_right;
bool mouse_middle;
bool mouse_button4;
bool mouse_button5;
short mouse_wheel_left;
short mouse_wheel_up;
unsigned touch_count;
struct input_pointer touch[MAX_TOUCH];
};
struct uwp_input_state_t uwp_current_input, uwp_next_input;
// Taken from DirectX UWP samples - on Xbox, everything is scaled 200% so getting the DPI calculation correct is crucial
static inline float ConvertDipsToPixels(float dips, float dpi)
{
@ -210,11 +213,13 @@ static inline float ConvertDipsToPixels(float dips, float dpi)
int main(Platform::Array<Platform::String^>^)
{
Platform::String^ install_dir = Windows::ApplicationModel::Package::Current->InstalledLocation->Path + L"\\";
wcstombs(uwp_dir_install, install_dir->Data(), PATH_MAX_LENGTH);
wcstombs(uwp_dir_install, install_dir->Data(), sizeof(upw_dir_install));
Platform::String^ data_dir = Windows::Storage::ApplicationData::Current->LocalFolder->Path + L"\\";
wcstombs(uwp_dir_data, data_dir->Data(), PATH_MAX_LENGTH);
wcstombs(uwp_dir_data, data_dir->Data(), sizeof(uwp_dir_data));
wcstombs(uwp_device_family, AnalyticsInfo::VersionInfo->DeviceFamily->Data(), 128);
wcstombs(uwp_device_family,
AnalyticsInfo::VersionInfo->DeviceFamily->Data(),
sizeof(uwp_device_family));
RARCH_LOG("Data dir: %ls\n", data_dir->Data());
RARCH_LOG("Install dir: %ls\n", install_dir->Data());
@ -787,7 +792,7 @@ extern "C" {
char lang_bcp[16] = { 0 };
char lang_iso[16] = { 0 };
wcstombs(lang_bcp, lang->Data(), 16);
wcstombs(lang_bcp, lang->Data(), sizeof(lang_bcp));
/* Trying to convert BCP 47 language codes to ISO 639 ones */
split = string_split(lang_bcp, "-");
@ -843,7 +848,7 @@ extern "C" {
if (!cpu_name)
return "Unknown";
wcstombs(win32_cpu_model_name, cpu_name->Data(), 128);
wcstombs(win32_cpu_model_name, cpu_name->Data(), sizeof(win32_cpu_model_name));
return win32_cpu_model_name;
}
}