mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 17:17:09 -04:00
3DS/VITA: Fix touching on-screen keyboard button repeatedly typing their button character in
This commit is contained in:
parent
0e1fba3d1e
commit
e2ada4cfe4
@ -325,11 +325,16 @@ struct InputDevice TouchDevice = {
|
||||
*----------------------------------------------------------Mouse----------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
struct Pointer Pointers[INPUT_MAX_POINTERS];
|
||||
struct _PointerHooks PointerHooks;
|
||||
|
||||
void Pointer_SetPressed(int idx, cc_bool pressed) {
|
||||
if (pressed) {
|
||||
if (PointerHooks.DownHook && PointerHooks.DownHook(idx)) return;
|
||||
|
||||
Event_RaiseInt(&PointerEvents.Down, idx);
|
||||
} else {
|
||||
if (PointerHooks.UpHook && PointerHooks.UpHook(idx)) return;
|
||||
|
||||
Event_RaiseInt(&PointerEvents.Up, idx);
|
||||
}
|
||||
}
|
||||
@ -370,7 +375,7 @@ void Pointer_SetPosition(int idx, int x, int y) {
|
||||
/* TODO: reset to -1, -1 when pointer is removed */
|
||||
Pointers[idx].x = x; Pointers[idx].y = y;
|
||||
|
||||
if (Pointers[0].DownHook && Pointers[0].DownHook(idx)) return;
|
||||
if (PointerHooks.MoveHook && PointerHooks.MoveHook(idx)) return;
|
||||
|
||||
#ifdef CC_BUILD_TOUCH
|
||||
if (Input_TouchMode && !(touches[idx].type & TOUCH_TYPE_GUI)) return;
|
||||
|
11
src/Input.h
11
src/Input.h
@ -183,14 +183,17 @@ 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 */
|
||||
struct Pointer {
|
||||
int x, y;
|
||||
struct Pointer { int x, y; };
|
||||
CC_VAR extern struct Pointer Pointers[INPUT_MAX_POINTERS];
|
||||
|
||||
CC_VAR extern struct _PointerHooks {
|
||||
/* Function that overrides all normal pointer input press handling */
|
||||
cc_bool (*DownHook)(int index);
|
||||
/* Function that overrides all normal pointer input release handling */
|
||||
cc_bool (*UpHook) (int index);
|
||||
};
|
||||
CC_VAR extern struct Pointer Pointers[INPUT_MAX_POINTERS];
|
||||
/* Function that overrides all normal pointer input press handling */
|
||||
cc_bool (*MoveHook)(int index);
|
||||
} PointerHooks;
|
||||
|
||||
/* Raises appropriate events for a mouse vertical scroll */
|
||||
void Mouse_ScrollVWheel(float delta);
|
||||
|
@ -821,7 +821,6 @@ static void OnPointerDown(void* obj, int idx) {
|
||||
static void OnPointerUp(void* obj, int idx) {
|
||||
struct Screen* s;
|
||||
int i, x, y;
|
||||
if (Pointers[0].UpHook && Pointers[0].UpHook(idx)) return;
|
||||
|
||||
#ifdef CC_BUILD_TOUCH
|
||||
CheckBlockTap(idx);
|
||||
|
@ -19,6 +19,7 @@ static char kb_buffer[512];
|
||||
static cc_string kb_str = String_FromArray(kb_buffer);
|
||||
static void (*KB_MarkDirty)(void);
|
||||
static int kb_yOffset;
|
||||
static cc_bool kb_clicking;
|
||||
|
||||
#define KB_TILE_SIZE 32
|
||||
static int kb_tileWidth = KB_TILE_SIZE;
|
||||
@ -317,10 +318,13 @@ static cc_bool VirtualKeyboard_GetPointerPosition(int idx, int* kbX, int* kbY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static cc_bool VirtualKeyboard_PointerDown(int idx) {
|
||||
static cc_bool VirtualKeyboard_PointerMove(int idx) {
|
||||
int kbX, kbY;
|
||||
if (!VirtualKeyboard_GetPointerPosition(idx, &kbX, &kbY)) return false;
|
||||
|
||||
if (kb_clicking) return true;
|
||||
kb_clicking = true;
|
||||
|
||||
kb_curX = kbX / kb_tileWidth;
|
||||
kb_curY = kbY / kb_tileHeight;
|
||||
if (kb_curX >= kb->cellsPerRow) kb_curX = kb->cellsPerRow - 1;
|
||||
@ -332,6 +336,8 @@ static cc_bool VirtualKeyboard_PointerDown(int idx) {
|
||||
|
||||
static cc_bool VirtualKeyboard_PointerUp(int idx) {
|
||||
int kbX, kbY;
|
||||
kb_clicking = false;
|
||||
kb_curX = -1;
|
||||
return VirtualKeyboard_GetPointerPosition(idx, &kbX, &kbY);
|
||||
}
|
||||
|
||||
@ -431,8 +437,8 @@ static void VirtualKeyboard_Hook(void) {
|
||||
/* the virtual keyboard in the first place gets mistakenly processed */
|
||||
kb_needsHook = false;
|
||||
Event_Register_(&ControllerEvents.AxisUpdate, NULL, VirtualKeyboard_PadAxis);
|
||||
Pointers[0].DownHook = VirtualKeyboard_PointerDown;
|
||||
Pointers[0].UpHook = VirtualKeyboard_PointerUp;
|
||||
PointerHooks.MoveHook = VirtualKeyboard_PointerMove;
|
||||
PointerHooks.UpHook = VirtualKeyboard_PointerUp;
|
||||
}
|
||||
|
||||
static void VirtualKeyboard_Open(struct OpenKeyboardArgs* args, cc_bool launcher) {
|
||||
@ -480,8 +486,8 @@ static void VirtualKeyboard_Close(void) {
|
||||
VirtualKeyboard_Close3D();
|
||||
|
||||
Event_Unregister_(&ControllerEvents.AxisUpdate, NULL, VirtualKeyboard_PadAxis);
|
||||
Pointers[0].DownHook = NULL;
|
||||
Pointers[0].UpHook = NULL;
|
||||
PointerHooks.MoveHook = NULL;
|
||||
PointerHooks.UpHook = NULL;
|
||||
Window_Main.SoftKeyboardFocus = false;
|
||||
|
||||
KB_MarkDirty = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user