Expose more functionality for plugins

This commit is contained in:
UnknownShadow200 2024-07-31 20:11:51 +10:00
parent f09b8d9375
commit eb0f36ce58
5 changed files with 19 additions and 7 deletions

View File

@ -182,7 +182,15 @@ extern struct TouchPointer touches[INPUT_MAX_POINTERS];
#define TOUCH_TYPE_ALL (TOUCH_TYPE_GUI | TOUCH_TYPE_CAMERA | TOUCH_TYPE_BLOCKS)
/* Data for mouse and touch */
extern struct Pointer { int x, y; } Pointers[INPUT_MAX_POINTERS];
struct Pointer {
int x, y;
/* Function that overrides all normal pointer input press handling */
void (*DownHook)(int index);
/* Function that overrides all normal pointer input release handling */
void (*UpHook) (int index);
};
CC_VAR extern struct Pointer Pointers[INPUT_MAX_POINTERS];
/* Raises appropriate events for a mouse vertical scroll */
void Mouse_ScrollVWheel(float delta);
/* Raises appropriate events for a mouse horizontal scroll */

View File

@ -784,6 +784,8 @@ cc_bool KeyBind_IsPressed(InputBind binding) { return Bind_IsTriggered[binding];
static void OnPointerDown(void* obj, int idx) {
struct Screen* s;
int i, x, y, mask;
if (Pointers[idx].DownHook) { Pointers[idx].DownHook(idx); return; }
/* Always set last click time, otherwise quickly tapping */
/* sometimes triggers a 'delete' in InputHandler_Tick, */
/* and then another 'delete' in CheckBlockTap. */
@ -820,6 +822,8 @@ static void OnPointerDown(void* obj, int idx) {
static void OnPointerUp(void* obj, int idx) {
struct Screen* s;
int i, x, y;
if (Pointers[idx].UpHook) { Pointers[idx].UpHook(idx); return; }
#ifdef CC_BUILD_TOUCH
CheckBlockTap(idx);
if (Input_TouchMode && !(touches[idx].type & TOUCH_TYPE_GUI)) return;

View File

@ -638,7 +638,7 @@ void String_AppendUtf8(cc_string* value, const void* data, int numBytes) {
}
}
void String_DecodeCP1252(cc_string* value, const void* data, int numBytes) {
void String_AppendCP1252(cc_string* value, const void* data, int numBytes) {
const cc_uint8* chars = (const cc_uint8*)data;
int i; char c;

View File

@ -201,16 +201,16 @@ int Convert_CP437ToUtf8(char c, cc_uint8* data);
/* Attempts to append all characters from UTF16 encoded data to the given string. */
/* Characters not in code page 437 are omitted. */
void String_AppendUtf16(cc_string* str, const void* data, int numBytes);
CC_API void String_AppendUtf16(cc_string* str, const void* data, int numBytes);
/* Attempts to append all characters from UTF8 encoded data to the given string. */
/* Characters not in code page 437 are omitted. */
void String_AppendUtf8(cc_string* str, const void* data, int numBytes);
CC_API void String_AppendUtf8(cc_string* str, const void* data, int numBytes);
/* Attempts to append all characters from CP-1252 encoded data to the given string. */
/* Characters not in code page 437 are omitted. */
void String_DecodeCP1252(cc_string* str, const void* data, int numBytes);
CC_API void String_AppendCP1252(cc_string* str, const void* data, int numBytes);
/* Encodes a string in UTF8 format, also null terminating the string. */
/* Returns the number of bytes written, excluding trailing NULL terminator. */
int String_EncodeUtf8(void* data, const cc_string* src);
CC_API int String_EncodeUtf8(void* data, const cc_string* src);
/* Attempts to convert the given string into an unsigned 8 bit integer. */
CC_API cc_bool Convert_ParseUInt8(const cc_string* str, cc_uint8* value);

View File

@ -458,7 +458,7 @@ void Clipboard_GetText(cc_string* value) {
if (unicode) {
String_AppendUtf16(value, src, size - 2);
} else {
String_DecodeCP1252(value, src, size - 1);
String_AppendCP1252(value, src, size - 1);
}
GlobalUnlock(hGlobal);