mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Consoles: Don't auto show virtual keyboard when an input field is selected, only show it after A/Start is pressed
This commit is contained in:
parent
73ea4968bc
commit
c0a6811d56
@ -579,10 +579,27 @@ static cc_uint64 caretStart;
|
||||
static Rect2D caretRect, lastCaretRect;
|
||||
#define Rect2D_Equals(a, b) a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height
|
||||
|
||||
static void LInput_OpenKeyboard(struct LInput* w) {
|
||||
struct OpenKeyboardArgs args;
|
||||
|
||||
if (w->kbShowing) return;
|
||||
w->kbShowing = true;
|
||||
OpenKeyboardArgs_Init(&args, &w->text, w->inputType);
|
||||
OnscreenKeyboard_Open(&args);
|
||||
}
|
||||
|
||||
static void LInput_OnClick(void* widget) {
|
||||
struct LInput* w = (struct LInput*)widget;
|
||||
LInput_OpenKeyboard(w);
|
||||
}
|
||||
|
||||
void LBackend_InputInit(struct LInput* w, int width) {
|
||||
w->width = Display_ScaleX(width);
|
||||
w->height = Display_ScaleY(LINPUT_HEIGHT);
|
||||
w->minWidth = w->width;
|
||||
|
||||
if (Window_Main.SoftKeyboard)
|
||||
w->OnClick = LInput_OnClick;
|
||||
|
||||
/* Text may end up being wider than minimum width */
|
||||
if (w->text.length) LBackend_InputUpdate(w);
|
||||
@ -681,20 +698,20 @@ void LBackend_InputTick(struct LInput* w) {
|
||||
}
|
||||
|
||||
void LBackend_InputSelect(struct LInput* w, int idx, cc_bool wasSelected) {
|
||||
struct OpenKeyboardArgs args;
|
||||
caretStart = Stopwatch_Measure();
|
||||
w->caretShow = true;
|
||||
w->kbShowing = false;
|
||||
LInput_MoveCaretToCursor(w, idx);
|
||||
LBackend_MarkDirty(w);
|
||||
|
||||
if (wasSelected) return;
|
||||
OpenKeyboardArgs_Init(&args, &w->text, w->inputType);
|
||||
OnscreenKeyboard_Open(&args);
|
||||
|
||||
if (Window_Main.SoftKeyboard && Input_TouchMode)
|
||||
LInput_OpenKeyboard(w);
|
||||
}
|
||||
|
||||
void LBackend_InputUnselect(struct LInput* w) {
|
||||
caretStart = 0;
|
||||
w->caretShow = false;
|
||||
w->kbShowing = false;
|
||||
LBackend_MarkDirty(w);
|
||||
OnscreenKeyboard_Close();
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ struct LInput {
|
||||
cc_uint8 inputType;
|
||||
/* Whether caret is currently visible */
|
||||
cc_bool caretShow;
|
||||
cc_bool kbShowing;
|
||||
/* Filter applied to text received from the clipboard. Can be NULL. */
|
||||
void (*ClipboardFilter)(cc_string* str);
|
||||
/* Callback invoked when the text is changed. Can be NULL. */
|
||||
|
@ -176,34 +176,32 @@ void Matrix_LookRot(struct Matrix* result, Vec3 pos, Vec2 rot) {
|
||||
Matrix_Mul(result, &trans, result);
|
||||
}
|
||||
|
||||
/* TODO: Move to matrix instance instead */
|
||||
static float
|
||||
frustum00, frustum01, frustum02, frustum03,
|
||||
frustum10, frustum11, frustum12, frustum13,
|
||||
frustum20, frustum21, frustum22, frustum23,
|
||||
frustum30, frustum31, frustum32, frustum33,
|
||||
frustum40, frustum41, frustum42, frustum43;
|
||||
|
||||
static void FrustumCulling_Normalise(float* plane0, float* plane1, float* plane2, float* plane3) {
|
||||
float val1 = *plane0, val2 = *plane1, val3 = *plane2;
|
||||
struct Plane { float a, b, c, d; };
|
||||
static struct Plane frustumR, frustumL, frustumB, frustumT, frustumF;
|
||||
|
||||
static void FrustumCulling_Normalise(struct Plane* plane) {
|
||||
float val1 = plane->a, val2 = plane->b, val3 = plane->c;
|
||||
float t = Math_SqrtF(val1 * val1 + val2 * val2 + val3 * val3);
|
||||
*plane0 /= t; *plane1 /= t; *plane2 /= t; *plane3 /= t;
|
||||
plane->a /= t; plane->b /= t; plane->c /= t; plane->d /= t;
|
||||
}
|
||||
|
||||
cc_bool FrustumCulling_SphereInFrustum(float x, float y, float z, float radius) {
|
||||
float d = frustum00 * x + frustum01 * y + frustum02 * z + frustum03;
|
||||
float d;
|
||||
|
||||
d = frustumR.a * x + frustumR.b * y + frustumR.c * z + frustumR.d;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum10 * x + frustum11 * y + frustum12 * z + frustum13;
|
||||
d = frustumL.a * x + frustumL.b * y + frustumL.c * z + frustumL.d;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum20 * x + frustum21 * y + frustum22 * z + frustum23;
|
||||
d = frustumB.a * x + frustumB.b * y + frustumB.c * z + frustumB.d;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum30 * x + frustum31 * y + frustum32 * z + frustum33;
|
||||
d = frustumT.a * x + frustumT.b * y + frustumT.c * z + frustumT.d;
|
||||
if (d <= -radius) return false;
|
||||
|
||||
d = frustum40 * x + frustum41 * y + frustum42 * z + frustum43;
|
||||
d = frustumF.a * x + frustumF.b * y + frustumF.c * z + frustumF.d;
|
||||
if (d <= -radius) return false;
|
||||
/* Don't test NEAR plane, it's pointless */
|
||||
return true;
|
||||
@ -214,47 +212,47 @@ void FrustumCulling_CalcFrustumEquations(struct Matrix* projection, struct Matri
|
||||
Matrix_Mul(&clip, modelView, projection);
|
||||
|
||||
/* Extract the RIGHT plane */
|
||||
frustum00 = clip.row1.w - clip.row1.x;
|
||||
frustum01 = clip.row2.w - clip.row2.x;
|
||||
frustum02 = clip.row3.w - clip.row3.x;
|
||||
frustum03 = clip.row4.w - clip.row4.x;
|
||||
FrustumCulling_Normalise(&frustum00, &frustum01, &frustum02, &frustum03);
|
||||
frustumR.a = clip.row1.w - clip.row1.x;
|
||||
frustumR.b = clip.row2.w - clip.row2.x;
|
||||
frustumR.c = clip.row3.w - clip.row3.x;
|
||||
frustumR.d = clip.row4.w - clip.row4.x;
|
||||
FrustumCulling_Normalise(&frustumR);
|
||||
|
||||
/* Extract the LEFT plane */
|
||||
frustum10 = clip.row1.w + clip.row1.x;
|
||||
frustum11 = clip.row2.w + clip.row2.x;
|
||||
frustum12 = clip.row3.w + clip.row3.x;
|
||||
frustum13 = clip.row4.w + clip.row4.x;
|
||||
FrustumCulling_Normalise(&frustum10, &frustum11, &frustum12, &frustum13);
|
||||
frustumL.a = clip.row1.w + clip.row1.x;
|
||||
frustumL.b = clip.row2.w + clip.row2.x;
|
||||
frustumL.c = clip.row3.w + clip.row3.x;
|
||||
frustumL.d = clip.row4.w + clip.row4.x;
|
||||
FrustumCulling_Normalise(&frustumL);
|
||||
|
||||
/* Extract the BOTTOM plane */
|
||||
frustum20 = clip.row1.w + clip.row1.y;
|
||||
frustum21 = clip.row2.w + clip.row2.y;
|
||||
frustum22 = clip.row3.w + clip.row3.y;
|
||||
frustum23 = clip.row4.w + clip.row4.y;
|
||||
FrustumCulling_Normalise(&frustum20, &frustum21, &frustum22, &frustum23);
|
||||
frustumB.a = clip.row1.w + clip.row1.y;
|
||||
frustumB.b = clip.row2.w + clip.row2.y;
|
||||
frustumB.c = clip.row3.w + clip.row3.y;
|
||||
frustumB.d = clip.row4.w + clip.row4.y;
|
||||
FrustumCulling_Normalise(&frustumB);
|
||||
|
||||
/* Extract the TOP plane */
|
||||
frustum30 = clip.row1.w - clip.row1.y;
|
||||
frustum31 = clip.row2.w - clip.row2.y;
|
||||
frustum32 = clip.row3.w - clip.row3.y;
|
||||
frustum33 = clip.row4.w - clip.row4.y;
|
||||
FrustumCulling_Normalise(&frustum30, &frustum31, &frustum32, &frustum33);
|
||||
frustumT.a = clip.row1.w - clip.row1.y;
|
||||
frustumT.b = clip.row2.w - clip.row2.y;
|
||||
frustumT.c = clip.row3.w - clip.row3.y;
|
||||
frustumT.d = clip.row4.w - clip.row4.y;
|
||||
FrustumCulling_Normalise(&frustumT);
|
||||
|
||||
/* Extract the FAR plane (Different for each graphics backend) */
|
||||
#if (CC_GFX_BACKEND == CC_GFX_BACKEND_D3D9) || (CC_GFX_BACKEND == CC_GFX_BACKEND_D3D11)
|
||||
/* OpenGL and Direct3D require slightly different behaviour for NEAR clipping planes */
|
||||
/* https://www.gamedevs.org/uploads/fast-extraction-viewing-frustum-planes-from-world-view-projection-matrix.pdf */
|
||||
/* (and because reverse Z is used, 'NEAR' plane is actually the 'FAR' clipping plane) */
|
||||
frustum40 = clip.row1.z;
|
||||
frustum41 = clip.row2.z;
|
||||
frustum42 = clip.row3.z;
|
||||
frustum43 = clip.row4.z;
|
||||
frustumF.a = clip.row1.z;
|
||||
frustumF.b = clip.row2.z;
|
||||
frustumF.c = clip.row3.z;
|
||||
frustumF.d = clip.row4.z;
|
||||
#else
|
||||
frustum40 = clip.row1.w - clip.row1.z;
|
||||
frustum41 = clip.row2.w - clip.row2.z;
|
||||
frustum42 = clip.row3.w - clip.row3.z;
|
||||
frustum43 = clip.row4.w - clip.row4.z;
|
||||
frustumF.a = clip.row1.w - clip.row1.z;
|
||||
frustumF.b = clip.row2.w - clip.row2.z;
|
||||
frustumF.c = clip.row3.w - clip.row3.z;
|
||||
frustumF.d = clip.row4.w - clip.row4.z;
|
||||
#endif
|
||||
FrustumCulling_Normalise(&frustum40, &frustum41, &frustum42, &frustum43);
|
||||
FrustumCulling_Normalise(&frustumF);
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ void Window_Init(void) {
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
DisplayInfo.ContentOffsetY = 10;
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_VIRTUAL;
|
||||
|
||||
#if defined HW_RVL
|
||||
WPAD_Init();
|
||||
|
@ -55,6 +55,7 @@ void Window_Init(void) {
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
DisplayInfo.ContentOffsetY = 10;
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_VIRTUAL;
|
||||
|
||||
padInit(0);
|
||||
padPortOpen(0, 0, padBuf0);
|
||||
@ -80,7 +81,7 @@ static void ResetGfxState(void) {
|
||||
fb_colors[0].height = DisplayInfo.Height;
|
||||
fb_colors[0].mask = 0;
|
||||
fb_colors[0].psm = GS_PSM_32;
|
||||
fb_colors[0].address = graph_vram_allocate(fb_colors[0].width, fb_colors[0].height, fb_colors[1].psm, GRAPH_ALIGN_PAGE);
|
||||
fb_colors[0].address = graph_vram_allocate(fb_colors[0].width, fb_colors[0].height, fb_colors[0].psm, GRAPH_ALIGN_PAGE);
|
||||
|
||||
fb_colors[1].width = DisplayInfo.Width;
|
||||
fb_colors[1].height = DisplayInfo.Height;
|
||||
|
@ -63,6 +63,7 @@ void Window_Init(void) {
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 20;
|
||||
DisplayInfo.ContentOffsetY = 20;
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_VIRTUAL;
|
||||
|
||||
ioPadInit(MAX_PORT_NUM);
|
||||
ioKbInit(MAX_KB_PORT_NUM);
|
||||
|
@ -42,6 +42,7 @@ void Window_Init(void) {
|
||||
Window_Main.Exists = true;
|
||||
Window_Main.UIScaleX = DEFAULT_UI_SCALE_X;
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_VIRTUAL;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
sceDisplaySetMode(0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
|
@ -81,6 +81,7 @@ void Window_Init(void) {
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
DisplayInfo.ContentOffsetX = 10;
|
||||
DisplayInfo.ContentOffsetY = 10;
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_VIRTUAL;
|
||||
|
||||
#ifndef CC_BUILD_CXBX
|
||||
usbh_core_init();
|
||||
|
@ -42,6 +42,7 @@ void Window_Init(void) {
|
||||
Window_Main.UIScaleY = DEFAULT_UI_SCALE_Y;
|
||||
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
Window_Main.SoftKeyboard = SOFT_KEYBOARD_VIRTUAL;
|
||||
|
||||
usb_init();
|
||||
usb_do_poll();
|
||||
|
@ -46,7 +46,7 @@
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/* ClassiCube patch - don't export FreeType symbols to avoid conflicting with system */
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__GNUC__) && !defined(_WIN32)
|
||||
#define FT_EXPORT( x ) __attribute__((visibility("hidden"))) extern x
|
||||
#define FT_BASE( x ) __attribute__((visibility("hidden"))) extern x
|
||||
#elif defined(__cplusplus)
|
||||
|
Loading…
x
Reference in New Issue
Block a user