diff --git a/projects/VS2017.UWP/raylib.App.UWP/App.cpp b/projects/VS2017.UWP/raylib.App.UWP/App.cpp index 10a2f94d1..517672d3c 100644 --- a/projects/VS2017.UWP/raylib.App.UWP/App.cpp +++ b/projects/VS2017.UWP/raylib.App.UWP/App.cpp @@ -79,6 +79,7 @@ void App::SetWindow(Windows::UI::Core::CoreWindow^ window) // Hook keyboard events. window->KeyDown += ref new TypedEventHandler(this, &App::OnKeyDown); window->KeyUp += ref new TypedEventHandler(this, &App::OnKeyUp); + window->CharacterReceived += ref new Windows::Foundation::TypedEventHandler(this, &raylibUWP::App::OnCharacterReceived); // The CoreWindow has been created, we can pass this to raylib for EGL context creation when it's time UWPSetCoreWindowPtr((void*)window); @@ -448,8 +449,13 @@ void App::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyE args->Handled = true; } +void App::OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args) +{ + UWPKeyCharEvent(args->KeyCode); +} + // AppSource implementation Windows::ApplicationModel::Core::IFrameworkView ^AppSource::CreateView() { return ref new App(); -} \ No newline at end of file +} diff --git a/projects/VS2017.UWP/raylib.App.UWP/App.h b/projects/VS2017.UWP/raylib.App.UWP/App.h index b0d800025..892d85922 100644 --- a/projects/VS2017.UWP/raylib.App.UWP/App.h +++ b/projects/VS2017.UWP/raylib.App.UWP/App.h @@ -39,6 +39,7 @@ namespace raylibUWP void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); + void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args); }; ref class AppSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource diff --git a/src/core.c b/src/core.c index 8379087af..e83065d31 100644 --- a/src/core.c +++ b/src/core.c @@ -2233,6 +2233,10 @@ void SaveStorageValue(unsigned int position, int value) strcpy(path, CORE.Android.internalDataPath); strcat(path, "/"); strcat(path, STORAGE_DATA_FILE); +#elif defined(PLATFORM_UWP) + strcpy(path, CORE.UWP.internalDataPath); + strcat(path, "/"); + strcat(path, STORAGE_DATA_FILE); #else strcpy(path, STORAGE_DATA_FILE); #endif @@ -2306,6 +2310,10 @@ int LoadStorageValue(unsigned int position) strcpy(path, CORE.Android.internalDataPath); strcat(path, "/"); strcat(path, STORAGE_DATA_FILE); +#elif defined(PLATFORM_UWP) + strcpy(path, CORE.UWP.internalDataPath); + strcat(path, "/"); + strcat(path, STORAGE_DATA_FILE); #else strcpy(path, STORAGE_DATA_FILE); #endif @@ -5371,14 +5379,16 @@ void UWPKeyDownEvent(int key, bool down, bool controlKey) { CORE.Input.Keyboard.currentKeyState[key] = down; } +} - // TODO: - /*if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_CHARS_QUEUE) +void UWPKeyCharEvent(int key) +{ + if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_CHARS_QUEUE) { // Add character to the queue CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key; CORE.Input.Keyboard.keyPressedQueueCount++; - }*/ + } } void UWPMouseButtonEvent(int button, bool down) diff --git a/src/uwp_events.h b/src/uwp_events.h index 0165cc3e9..84d18986d 100644 --- a/src/uwp_events.h +++ b/src/uwp_events.h @@ -36,6 +36,7 @@ extern "C" { // Determine if UWP functions are set and ready for raylib's use. bool UWPIsConfigured(); +// Call this to set the UWP data path you wish for saving and loading. void UWPSetDataPath(const char* path); // Function for getting program time. @@ -75,6 +76,9 @@ void UWPSetMouseSetPosFunc(UWPMouseSetPosFunc func); // Call this when a Key is pressed or released. void UWPKeyDownEvent(int key, bool down, bool controlKey); +// Call this on the CoreWindow::CharacterRecieved event +void UWPKeyCharEvent(int key); + // Call when a mouse button state changes void UWPMouseButtonEvent(int button, bool down);