Repository: godotengine/godot
File: platform/uwp/os_uwp.cpp (C++)

Code before:
String OS_UWP::get_environment(const String &p_var) const {
	return "";
};

bool OS_UWP::set_environment(const String &p_var, const String &p_value) const {
	return false;
}

String OS_UWP::get_stdin_string() {
	return String();
}

void OS_UWP::move_window_to_foreground() {
}

Error OS_UWP::shell_open(String p_uri) {
	return FAILED;
}

String OS_UWP::get_locale() const {
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // this should work on phone 8.1, but it doesn't
	return "en";
#else
	Platform::String ^ language = Windows::Globalization::Language::CurrentInputMethodLanguageTag;
	return String(language->Data()).replace("-", "_");
#endif
}

void OS_UWP::release_rendering_thread() {
	gl_context->release_current();
}

void OS_UWP::make_rendering_thread() {
	gl_context->make_current();
}

void OS_UWP::swap_buffers() {
	gl_context->swap_buffers();
}

bool OS_UWP::has_touchscreen_ui_hint() const {
	TouchCapabilities ^ tc = ref new TouchCapabilities();
	return tc->TouchPresent != 0 || UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch;
}

bool OS_UWP::has_virtual_keyboard() const {
	return UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Touch;
}

void OS_UWP::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
	InputPane ^ pane = InputPane::GetForCurrentView();

Review comment (bug):
```suggestion
	// Get the hardware token and read it into an array of bytes.
	HardwareToken ^ token = HardwareIdentification::GetPackageSpecificToken(nullptr);
	IBuffer hwId = token->Id;
	DataReader ^ dr = DataReader::FromBuffer(hwId);
	uint8_t *data = new uint8_t[hwId->Length];
	dr->ReadBytes(Platform::ArrayReference<uint8_t>(data, hwId->Length));

	// Convert the byte array to hexadecimal.
	String id;
	char hexStr[3] = "00";

	for (int i = 0; i < hwId->Length; i++) {
		// Convert next byte to hexadecimal.
		sprintf(hexStr, "%x", (int)data[i]);

		if (data[i] < 16) {
			hexStr[1] = hexStr[0];
			hexStr[0] = '0';
		}

		// Add the next 2 hexits to the ID string.
		id += hexStr;
	}

	// Free the temporary data array and return the device ID.
	delete[] data;
	return id;
```

We don't use `auto`, and want the types to be explicit to code reviewers. I had to look up the MSDN documentation to know what type this is.

Also style fixes to the comments.

Code after:
	HardwareToken ^ token = HardwareIdentification::GetPackageSpecificToken(nullptr);
	IBuffer hwId = token->Id;
	DataReader ^ dr = DataReader::FromBuffer(hwId);
	uint8_t *data = new uint8_t[hwId->Length];
	dr->ReadBytes(Platform::ArrayReference<uint8_t>(data, hwId->Length));

	// Convert the byte array to hexadecimal.
	String id;
	char hexStr[3] = "00";

	for (int i = 0; i < hwId->Length; i++) {
		// Convert next byte to hexadecimal.
		sprintf(hexStr, "%x", (int)data[i]);

		if (data[i] < 16) {
			hexStr[1] = hexStr[0];
			hexStr[0] = '0';
		}

		// Add the next 2 hexits to the ID string.
		id += hexStr;
	}

	// Free the temporary data array and return the device ID.
	delete[] data;
	return id;
}

bool OS_UWP::has_environment(const String &p_var) const {
	return false;
};

String OS_UWP::get_environment(const String &p_var) const {
	return "";
};

bool OS_UWP::set_environment(const String &p_var, const String &p_value) const {
	return false;
}

String OS_UWP::get_stdin_string() {
	return String();
}

void OS_UWP::move_window_to_foreground() {
}

Error OS_UWP::shell_open(String p_uri) {
	return FAILED;
}