Character inputs and filesystem stuff

This commit is contained in:
Reece Mackie 2020-04-30 14:55:19 +01:00
parent c083aed903
commit 3767a324a7
4 changed files with 25 additions and 4 deletions

View File

@ -79,6 +79,7 @@ void App::SetWindow(Windows::UI::Core::CoreWindow^ window)
// Hook keyboard events. // Hook keyboard events.
window->KeyDown += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyDown); window->KeyDown += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyDown);
window->KeyUp += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyUp); window->KeyUp += ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &App::OnKeyUp);
window->CharacterReceived += ref new Windows::Foundation::TypedEventHandler<Windows::UI::Core::CoreWindow^, Windows::UI::Core::CharacterReceivedEventArgs^>(this, &raylibUWP::App::OnCharacterReceived);
// The CoreWindow has been created, we can pass this to raylib for EGL context creation when it's time // The CoreWindow has been created, we can pass this to raylib for EGL context creation when it's time
UWPSetCoreWindowPtr((void*)window); UWPSetCoreWindowPtr((void*)window);
@ -448,6 +449,11 @@ void App::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyE
args->Handled = true; args->Handled = true;
} }
void App::OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args)
{
UWPKeyCharEvent(args->KeyCode);
}
// AppSource implementation // AppSource implementation
Windows::ApplicationModel::Core::IFrameworkView ^AppSource::CreateView() Windows::ApplicationModel::Core::IFrameworkView ^AppSource::CreateView()
{ {

View File

@ -39,6 +39,7 @@ namespace raylibUWP
void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); 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 OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
void OnKeyUp(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 ref class AppSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource

View File

@ -2233,6 +2233,10 @@ void SaveStorageValue(unsigned int position, int value)
strcpy(path, CORE.Android.internalDataPath); strcpy(path, CORE.Android.internalDataPath);
strcat(path, "/"); strcat(path, "/");
strcat(path, STORAGE_DATA_FILE); strcat(path, STORAGE_DATA_FILE);
#elif defined(PLATFORM_UWP)
strcpy(path, CORE.UWP.internalDataPath);
strcat(path, "/");
strcat(path, STORAGE_DATA_FILE);
#else #else
strcpy(path, STORAGE_DATA_FILE); strcpy(path, STORAGE_DATA_FILE);
#endif #endif
@ -2306,6 +2310,10 @@ int LoadStorageValue(unsigned int position)
strcpy(path, CORE.Android.internalDataPath); strcpy(path, CORE.Android.internalDataPath);
strcat(path, "/"); strcat(path, "/");
strcat(path, STORAGE_DATA_FILE); strcat(path, STORAGE_DATA_FILE);
#elif defined(PLATFORM_UWP)
strcpy(path, CORE.UWP.internalDataPath);
strcat(path, "/");
strcat(path, STORAGE_DATA_FILE);
#else #else
strcpy(path, STORAGE_DATA_FILE); strcpy(path, STORAGE_DATA_FILE);
#endif #endif
@ -5371,14 +5379,16 @@ void UWPKeyDownEvent(int key, bool down, bool controlKey)
{ {
CORE.Input.Keyboard.currentKeyState[key] = down; CORE.Input.Keyboard.currentKeyState[key] = down;
} }
}
// TODO: void UWPKeyCharEvent(int key)
/*if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_CHARS_QUEUE) {
if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_CHARS_QUEUE)
{ {
// Add character to the queue // Add character to the queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key; CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key;
CORE.Input.Keyboard.keyPressedQueueCount++; CORE.Input.Keyboard.keyPressedQueueCount++;
}*/ }
} }
void UWPMouseButtonEvent(int button, bool down) void UWPMouseButtonEvent(int button, bool down)

View File

@ -36,6 +36,7 @@ extern "C" {
// Determine if UWP functions are set and ready for raylib's use. // Determine if UWP functions are set and ready for raylib's use.
bool UWPIsConfigured(); bool UWPIsConfigured();
// Call this to set the UWP data path you wish for saving and loading.
void UWPSetDataPath(const char* path); void UWPSetDataPath(const char* path);
// Function for getting program time. // Function for getting program time.
@ -75,6 +76,9 @@ void UWPSetMouseSetPosFunc(UWPMouseSetPosFunc func);
// Call this when a Key is pressed or released. // Call this when a Key is pressed or released.
void UWPKeyDownEvent(int key, bool down, bool controlKey); 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 // Call when a mouse button state changes
void UWPMouseButtonEvent(int button, bool down); void UWPMouseButtonEvent(int button, bool down);