mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
3DS: Use virtual keyboard built-in to ClassiCube instead of trying to use 3DS's keyboard
This commit is contained in:
parent
1b85f54dbf
commit
9016c3aaff
4 changed files with 43 additions and 50 deletions
|
@ -498,6 +498,7 @@ cc_bool Gfx_WarnIfNecessary(void) {
|
|||
if (String_ContainsConst(&renderer, "llvmpipe")) {
|
||||
Chat_AddRaw("&cSoftware rendering is being used, performance will greatly suffer.");
|
||||
Chat_AddRaw("&cVSync may not work, and you may see disappearing clouds and map edges.");
|
||||
Chat_AddRaw("&cYou may need to install video card drivers.");
|
||||
return true;
|
||||
}
|
||||
if (String_ContainsConst(&renderer, "Intel")) {
|
||||
|
|
|
@ -599,7 +599,16 @@ static void Gfx_RestoreState(void) {
|
|||
Bitmap_Init(bmp, 1, 1, pixels);
|
||||
Gfx_RecreateTexture(&white_square, &bmp, 0, false);
|
||||
}
|
||||
cc_bool Gfx_WarnIfNecessary(void) { return false; }
|
||||
|
||||
cc_bool Gfx_WarnIfNecessary(void) {
|
||||
if (String_ContainsConst(&renderer, "llvmpipe")) {
|
||||
Chat_AddRaw("&cSoftware rendering is being used, performance will greatly suffer.");
|
||||
Chat_AddRaw("&cVSync may also not work.");
|
||||
Chat_AddRaw("&cYou may need to install video card drivers.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int GetPostProcess(void) { return postProcess; }
|
||||
static void SetPostProcess(int v) {
|
||||
|
|
|
@ -181,6 +181,22 @@ static void VirtualKeyboard_CalcPosition(int* x, int* y, int width, int height)
|
|||
if (*x < 0) *x = 0;
|
||||
}
|
||||
|
||||
static int VirtualKeyboard_WindowWidth(void) {
|
||||
#ifdef CC_BUILD_DUALSCREEN
|
||||
return launcherMode ? Window_Main.Width : Window_Alt.Width;
|
||||
#else
|
||||
return Window_Main.Width;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int VirtualKeyboard_WindowHeight(void) {
|
||||
#ifdef CC_BUILD_DUALSCREEN
|
||||
return launcherMode ? Window_Main.Height : Window_Alt.Height;
|
||||
#else
|
||||
return Window_Main.Height;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Input handling------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
|
@ -290,7 +306,7 @@ static void VirtualKeyboard_PointerDown(void* obj, int idx) {
|
|||
int width = VirtualKeyboard_Width();
|
||||
int height = VirtualKeyboard_Height();
|
||||
int kbX, kbY;
|
||||
VirtualKeyboard_CalcPosition(&kbX, &kbY, Window_Main.Width, Window_Main.Height);
|
||||
VirtualKeyboard_CalcPosition(&kbX, &kbY, VirtualKeyboard_WindowWidth(), VirtualKeyboard_WindowHeight());
|
||||
|
||||
int x = Pointers[idx].x, y = Pointers[idx].y;
|
||||
if (x < kbX || y < kbY || x >= kbX + width || y >= kbY + height) return;
|
||||
|
@ -361,7 +377,7 @@ static void VirtualKeyboard_MakeTexture(void) {
|
|||
Context2D_Free(&ctx);
|
||||
|
||||
int x, y;
|
||||
VirtualKeyboard_CalcPosition(&x, &y, Window_Main.Width, Window_Main.Height);
|
||||
VirtualKeyboard_CalcPosition(&x, &y, VirtualKeyboard_WindowWidth(), VirtualKeyboard_WindowHeight());
|
||||
kb_texture.x = x; kb_texture.y = y;
|
||||
}
|
||||
|
||||
|
@ -379,6 +395,7 @@ static void VirtualKeyboard_Display3D(float delta) {
|
|||
if (!kb_texture.ID) return;
|
||||
}
|
||||
|
||||
Gfx_3DS_SetRenderScreen(BOTTOM_SCREEN);
|
||||
Gfx_SetVertexFormat(VERTEX_FORMAT_TEXTURED);
|
||||
Gfx_BindTexture(kb_texture.ID);
|
||||
|
||||
|
@ -387,6 +404,7 @@ static void VirtualKeyboard_Display3D(float delta) {
|
|||
Gfx_Make2DQuad(&kb_texture, PACKEDCOL_WHITE, ptr);
|
||||
Gfx_UnlockDynamicVb(kb_vb);
|
||||
Gfx_DrawVb_IndexedTris(4);
|
||||
Gfx_3DS_SetRenderScreen(TOP_SCREEN);
|
||||
}
|
||||
|
||||
/*########################################################################################################################*
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
static cc_bool launcherMode;
|
||||
static u16 top_width, top_height;
|
||||
static u16 btm_width, btm_height;
|
||||
#include "VirtualKeyboard.h"
|
||||
|
||||
struct _DisplayData DisplayInfo;
|
||||
struct cc_window WindowInfo;
|
||||
|
@ -235,55 +236,19 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
|
|||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Soft keyboard------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static void OnscreenTextChanged(const char* text) {
|
||||
char tmpBuffer[NATIVE_STR_LEN];
|
||||
cc_string tmp = String_FromArray(tmpBuffer);
|
||||
String_AppendUtf8(&tmp, text, String_Length(text));
|
||||
|
||||
Event_RaiseString(&InputEvents.TextChanged, &tmp);
|
||||
Input_SetPressed(CCKEY_ENTER);
|
||||
Input_SetReleased(CCKEY_ENTER);
|
||||
}
|
||||
|
||||
void OnscreenKeyboard_Open(struct OpenKeyboardArgs* args) {
|
||||
const char* btnText = args->type & KEYBOARD_FLAG_SEND ? "Send" : "Enter";
|
||||
char input[NATIVE_STR_LEN] = { 0 };
|
||||
char output[NATIVE_STR_LEN] = { 0 };
|
||||
SwkbdState swkbd;
|
||||
String_EncodeUtf8(input, args->text);
|
||||
|
||||
int mode = args->type & 0xFF;
|
||||
int type = (mode == KEYBOARD_TYPE_INTEGER || mode == KEYBOARD_TYPE_NUMBER) ? SWKBD_TYPE_NUMPAD : SWKBD_TYPE_WESTERN;
|
||||
|
||||
swkbdInit(&swkbd, type, 3, -1);
|
||||
swkbdSetInitialText(&swkbd, input);
|
||||
swkbdSetHintText(&swkbd, args->placeholder);
|
||||
//swkbdSetButton(&swkbd, SWKBD_BUTTON_LEFT, "Cancel", false);
|
||||
//swkbdSetButton(&swkbd, SWKBD_BUTTON_RIGHT, btnText, true);
|
||||
swkbdSetButton(&swkbd, SWKBD_BUTTON_CONFIRM, btnText, true);
|
||||
|
||||
if (mode == KEYBOARD_TYPE_INTEGER) {
|
||||
swkbdSetNumpadKeys(&swkbd, '-', 0);
|
||||
} else if (mode == KEYBOARD_TYPE_NUMBER) {
|
||||
swkbdSetNumpadKeys(&swkbd, '-', '.');
|
||||
}
|
||||
DisplayInfo.ShowingSoftKeyboard = true;
|
||||
|
||||
if (mode == KEYBOARD_TYPE_PASSWORD)
|
||||
swkbdSetPasswordMode(&swkbd, SWKBD_PASSWORD_HIDE_DELAY);
|
||||
if (args->multiline)
|
||||
swkbdSetFeatures(&swkbd, SWKBD_MULTILINE);
|
||||
|
||||
// TODO filter callbacks and OnscreenKeyboard_SetText ??
|
||||
int btn = swkbdInputText(&swkbd, output, sizeof(output));
|
||||
if (btn != SWKBD_BUTTON_CONFIRM) return;
|
||||
OnscreenTextChanged(output);
|
||||
}
|
||||
void OnscreenKeyboard_SetText(const cc_string* text) { }
|
||||
kb_tileWidth = 20;
|
||||
kb_tileHeight = 20;
|
||||
|
||||
void OnscreenKeyboard_Close(void) {
|
||||
DisplayInfo.ShowingSoftKeyboard = false;
|
||||
/* TODO implement */
|
||||
VirtualKeyboard_Open(args, launcherMode);
|
||||
}
|
||||
|
||||
void OnscreenKeyboard_SetText(const cc_string* text) {
|
||||
VirtualKeyboard_SetText(text);
|
||||
}
|
||||
|
||||
void OnscreenKeyboard_Close(void) {
|
||||
VirtualKeyboard_Close();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue