Add keyboard type to Window_OpenKeyboard (not used yet)

This commit is contained in:
UnknownShadow200 2020-10-10 10:37:49 +11:00
parent c508f680a3
commit ecddb28d34
5 changed files with 21 additions and 20 deletions

View File

@ -422,7 +422,7 @@ static void LInput_Select(void* widget, cc_bool wasSelected) {
/* TODO: Only draw outer border */ /* TODO: Only draw outer border */
if (wasSelected) return; if (wasSelected) return;
LWidget_Draw(widget); LWidget_Draw(widget);
Window_OpenKeyboard(); Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
} }
static void LInput_Unselect(void* widget) { static void LInput_Unselect(void* widget) {

View File

@ -944,7 +944,7 @@ static void EditHotkeyScreen_Init(void* screen) {
MenuInputWidget_Create(&s->input, 500, &text, &desc); MenuInputWidget_Create(&s->input, 500, &text, &desc);
Menu_InitBack(&s->cancel, Menu_SwitchHotkeys); Menu_InitBack(&s->cancel, Menu_SwitchHotkeys);
Window_OpenKeyboard(); Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
Window_SetKeyboardText(&text); Window_SetKeyboardText(&text);
} }
@ -1149,7 +1149,7 @@ static void GenLevelScreen_Init(void* screen) {
ButtonWidget_Init(&s->flatgrass, 200, GenLevelScreen_Flatgrass); ButtonWidget_Init(&s->flatgrass, 200, GenLevelScreen_Flatgrass);
ButtonWidget_Init(&s->vanilla, 200, GenLevelScreen_Notchy); ButtonWidget_Init(&s->vanilla, 200, GenLevelScreen_Notchy);
Menu_InitBack(&s->cancel, Menu_SwitchPause); Menu_InitBack(&s->cancel, Menu_SwitchPause);
Window_OpenKeyboard(); Window_OpenKeyboard(KEYBOARD_TYPE_NUMBER);
} }
static const struct ScreenVTABLE GenLevelScreen_VTABLE = { static const struct ScreenVTABLE GenLevelScreen_VTABLE = {
@ -1505,7 +1505,7 @@ static void SaveLevelScreen_Init(void* screen) {
Menu_InitBack(&s->cancel, Menu_SwitchPause); Menu_InitBack(&s->cancel, Menu_SwitchPause);
MenuInputWidget_Create(&s->input, 500, &String_Empty, &desc); MenuInputWidget_Create(&s->input, 500, &String_Empty, &desc);
TextWidget_Init(&s->desc); TextWidget_Init(&s->desc);
Window_OpenKeyboard(); Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
} }
static const struct ScreenVTABLE SaveLevelScreen_VTABLE = { static const struct ScreenVTABLE SaveLevelScreen_VTABLE = {
@ -2252,7 +2252,7 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
s->numWidgets = MENUOPTS_MAX_OPTS + 1 + 3; s->numWidgets = MENUOPTS_MAX_OPTS + 1 + 3;
MenuOptionsScreen_Layout(screen); MenuOptionsScreen_Layout(screen);
MenuOptionsScreen_RedrawInput(s); MenuOptionsScreen_RedrawInput(s);
Window_OpenKeyboard(); Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
Window_SetKeyboardText(&value); Window_SetKeyboardText(&value);
} }

View File

@ -1278,7 +1278,7 @@ void ChatScreen_OpenInput(const String* text) {
s->suppressNextPress = true; s->suppressNextPress = true;
s->grabsInput = true; s->grabsInput = true;
Camera_CheckFocus(); Camera_CheckFocus();
Window_OpenKeyboard(); Window_OpenKeyboard(KEYBOARD_TYPE_TEXT);
Window_SetKeyboardText(text); Window_SetKeyboardText(text);
String_Copy(&s->input.base.text, text); String_Copy(&s->input.base.text, text);

View File

@ -401,7 +401,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
/* TODO: Do we still need to unlock it though? */ /* TODO: Do we still need to unlock it though? */
} }
void Window_OpenKeyboard(void) { SDL_StartTextInput(); } void Window_OpenKeyboard(int type) { SDL_StartTextInput(); }
void Window_SetKeyboardText(const String* text) { } void Window_SetKeyboardText(const String* text) { }
void Window_CloseKeyboard(void) { SDL_StopTextInput(); } void Window_CloseKeyboard(void) { SDL_StopTextInput(); }
@ -934,7 +934,7 @@ static void InitRawMouse(void) {
rawMouseSupported = false; rawMouseSupported = false;
} }
void Window_OpenKeyboard(void) { } void Window_OpenKeyboard(int type) { }
void Window_SetKeyboardText(const String* text) { } void Window_SetKeyboardText(const String* text) { }
void Window_CloseKeyboard(void) { } void Window_CloseKeyboard(void) { }
@ -1818,7 +1818,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
Mem_Free(bmp->scan0); Mem_Free(bmp->scan0);
} }
void Window_OpenKeyboard(void) { } void Window_OpenKeyboard(int type) { }
void Window_SetKeyboardText(const String* text) { } void Window_SetKeyboardText(const String* text) { }
void Window_CloseKeyboard(void) { } void Window_CloseKeyboard(void) { }
@ -2034,7 +2034,7 @@ static void Cursor_DoSetVisible(cc_bool visible) {
} }
} }
void Window_OpenKeyboard(void) { } void Window_OpenKeyboard(int type) { }
void Window_SetKeyboardText(const String* text) { } void Window_SetKeyboardText(const String* text) { }
void Window_CloseKeyboard(void) { } void Window_CloseKeyboard(void) { }
@ -3500,12 +3500,12 @@ EMSCRIPTEN_KEEPALIVE void Window_OnTextChanged(const char* src) {
Event_RaiseString(&InputEvents.TextChanged, &str); Event_RaiseString(&InputEvents.TextChanged, &str);
} }
void Window_OpenKeyboard(void) { void Window_OpenKeyboard(int type) {
if (!Input_TouchMode) return; if (!Input_TouchMode) return;
keyboardOpen = true; keyboardOpen = true;
Platform_LogConst("OPEN SESAME"); Platform_LogConst("OPEN SESAME");
EM_ASM({ EM_ASM_({
var elem = window.cc_inputElem; var elem = window.cc_inputElem;
if (!elem) { if (!elem) {
elem = document.createElement('textarea'); elem = document.createElement('textarea');
@ -3521,7 +3521,7 @@ void Window_OpenKeyboard(void) {
} }
elem.focus(); elem.focus();
elem.click(); elem.click();
}); }, type);
} }
void Window_SetKeyboardText(const String* text) { void Window_SetKeyboardText(const String* text) {
@ -3890,7 +3890,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
Mem_Free(bmp->scan0); Mem_Free(bmp->scan0);
} }
void Window_OpenKeyboard(void) { void Window_OpenKeyboard(int type) {
JNIEnv* env; JNIEnv* env;
JavaGetCurrentEnv(env); JavaGetCurrentEnv(env);
JavaCallVoid(env, "openKeyboard", "()V", NULL); JavaCallVoid(env, "openKeyboard", "()V", NULL);

View File

@ -34,7 +34,8 @@ struct Bitmap;
struct DynamicLibSym; struct DynamicLibSym;
/* The states the window can be in. */ /* The states the window can be in. */
enum WindowState { WINDOW_STATE_NORMAL, WINDOW_STATE_MINIMISED, WINDOW_STATE_FULLSCREEN }; enum WindowState { WINDOW_STATE_NORMAL, WINDOW_STATE_MINIMISED, WINDOW_STATE_FULLSCREEN };
/* Can't name these Window/Display, because it conflicts with X11's Window/Display typedef */ enum KeyboardType { KEYBOARD_TYPE_TEXT, KEYBOARD_TYPE_PASSWORD, KEYBOARD_TYPE_NUMBER };
/* Can't name these structs Window/Display, because it conflicts with X11's Window/Display typedef */
/* Data for the display monitor. */ /* Data for the display monitor. */
CC_VAR extern struct _DisplayData { CC_VAR extern struct _DisplayData {
@ -129,7 +130,7 @@ void Window_FreeFramebuffer(struct Bitmap* bmp);
/* Displays on-screen keyboard for platforms that lack physical keyboard input. */ /* Displays on-screen keyboard for platforms that lack physical keyboard input. */
/* NOTE: On desktop platforms, this won't do anything. */ /* NOTE: On desktop platforms, this won't do anything. */
void Window_OpenKeyboard(void); void Window_OpenKeyboard(int type);
/* Sets the text used for keyboard input. */ /* Sets the text used for keyboard input. */
/* NOTE: This is only used for mobile on-screen keyboard input with the web client, */ /* NOTE: This is only used for mobile on-screen keyboard input with the web client, */
/* because it is backed by a HTML input, rather than true keyboard input events. */ /* because it is backed by a HTML input, rather than true keyboard input events. */