summaryrefslogtreecommitdiff
path: root/libs/raylib/src/uwp_events.h
blob: 2c403fd3676b65694f30775654a536035ea6af4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**********************************************************************************************
*
*   raylib.uwp_events - Functions for bootstrapping UWP functionality within raylib's core.
*
*
*   LICENSE: zlib/libpng
*
*   Copyright (c) 2020-2020 Reece Mackie (@Rover656)
*
*   This software is provided "as-is", without any express or implied warranty. In no event
*   will the authors be held liable for any damages arising from the use of this software.
*
*   Permission is granted to anyone to use this software for any purpose, including commercial
*   applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
*     1. The origin of this software must not be misrepresented; you must not claim that you
*     wrote the original software. If you use this software in a product, an acknowledgment
*     in the product documentation would be appreciated but is not required.
*
*     2. Altered source versions must be plainly marked as such, and must not be misrepresented
*     as being the original software.
*
*     3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/

#ifndef UWP_EVENTS_H
#define UWP_EVENTS_H

#if defined(__cplusplus)
extern "C" {
#endif

#if defined(PLATFORM_UWP)

// 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.
typedef double(*UWPQueryTimeFunc)();
UWPQueryTimeFunc UWPGetQueryTimeFunc(void);
void UWPSetQueryTimeFunc(UWPQueryTimeFunc func);

// Function for sleeping the current thread
typedef void (*UWPSleepFunc)(double sleepUntil);
UWPSleepFunc UWPGetSleepFunc(void);
void UWPSetSleepFunc(UWPSleepFunc func);

// Function for querying the display size
typedef void(*UWPDisplaySizeFunc)(int* width, int* height);
UWPDisplaySizeFunc UWPGetDisplaySizeFunc(void);
void UWPSetDisplaySizeFunc(UWPDisplaySizeFunc func);

// Functions for mouse cursor control
typedef void(*UWPMouseFunc)(void);
UWPMouseFunc UWPGetMouseLockFunc();
void UWPSetMouseLockFunc(UWPMouseFunc func);
UWPMouseFunc UWPGetMouseUnlockFunc();
void UWPSetMouseUnlockFunc(UWPMouseFunc func);
UWPMouseFunc UWPGetMouseShowFunc();
void UWPSetMouseShowFunc(UWPMouseFunc func);
UWPMouseFunc UWPGetMouseHideFunc();
void UWPSetMouseHideFunc(UWPMouseFunc func);

// Function for setting mouse cursor position.
typedef void (*UWPMouseSetPosFunc)(int x, int y);
UWPMouseSetPosFunc UWPGetMouseSetPosFunc();
void UWPSetMouseSetPosFunc(UWPMouseSetPosFunc func);

// The below functions are implemented in core.c but are placed here so they can be called by user code.
// This choice is made as platform-specific code is preferred to be kept away from raylib.h

// 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);

// Call when the mouse cursor moves
void UWPMousePosEvent(double x, double y);

// Call when the mouse wheel moves
void UWPMouseWheelEvent(int deltaY);

// Call when the window resizes
void UWPResizeEvent(int width, int height);

// Call when a gamepad is made active
void UWPActivateGamepadEvent(int gamepad, bool active);

// Call when a gamepad button state changes
void UWPRegisterGamepadButton(int gamepad, int button, bool down);

// Call when a gamepad axis state changes
void UWPRegisterGamepadAxis(int gamepad, int axis, float value);

// Call when the touch point moves
void UWPGestureMove(int pointer, float x, float y);

// Call when there is a touch down or up
void UWPGestureTouch(int pointer, float x, float y, bool touch);

// Set the core window pointer so that we can pass it to EGL.
void* UWPGetCoreWindowPtr();
void UWPSetCoreWindowPtr(void* ptr);

#if defined(__cplusplus)
}
#endif

#endif // PLATFORM_UWP

#endif // UWP_EVENTS_H