Skip to content

Commit ede5108

Browse files
committed
[app-main] Improved vkb visible handling
1 parent 272d720 commit ede5108

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

applications/main/modules/module.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -398,52 +398,48 @@ void MainApp_Init(App_t *app) {
398398
static void Slide_EventHandler(void *ds_event, void *param, int action) {
399399

400400
SDL_Event *event = (SDL_Event *) param;
401-
402-
if (GetModuleByName("vkb")) {
403-
uintptr_t vkb = GET_EXPORT_ADDR("VirtKeyboardIsVisible");
404-
if (((int (*)(void))vkb)()) {
405-
return;
406-
}
407-
}
408401

409402
switch(event->type) {
410-
403+
411404
case SDL_JOYBUTTONDOWN:
412405
switch(event->jbutton.button) {
413406
case SDL_DC_L:
407+
if (IsVirtKeyboardVisible()) {
408+
break;
409+
}
414410
MainApp_SlideLeft(NULL);
415411
break;
416412

417413
case SDL_DC_R:
414+
if (IsVirtKeyboardVisible()) {
415+
break;
416+
}
418417
MainApp_SlideRight(NULL);
419418
break;
420-
419+
421420
default:
422421
break;
423422
}
424423
break;
425-
424+
426425
case SDL_KEYDOWN:
427-
switch (event->key.keysym.sym)
428-
{
426+
switch (event->key.keysym.sym) {
429427
case SDLK_COMMA:
430428
MainApp_SlideLeft(NULL);
431429
break;
432-
430+
433431
case SDLK_PERIOD:
434432
MainApp_SlideRight(NULL);
435433
break;
436-
434+
437435
default:
438436
break;
439437
}
440-
441438
break;
442-
439+
443440
default:
444441
break;
445442
}
446-
447443
}
448444

449445
void MainApp_Shutdown(App_t *app) {

include/gui.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* \file gui.h
33
* \brief DreamShell GUI
4-
* \date 2006-2023
4+
* \date 2006-2025
55
* \author SWAT www.dc-swat.ru
66
*/
77

@@ -12,9 +12,9 @@
1212
#include "video.h"
1313
#include "list.h"
1414
#include "events.h"
15+
#include "module.h"
1516
#include "SDL/SDL_gui.h"
1617

17-
1818
/* Virtual keyboard from vkb module */
1919
int VirtKeyboardInit();
2020
void VirtKeyboardShutdown();
@@ -24,6 +24,15 @@ void VirtKeyboardShow();
2424
void VirtKeyboardHide();
2525
void VirtKeyboardToggle();
2626

27+
static inline int IsVirtKeyboardVisible() {
28+
if (GetModuleByName("vkb")) {
29+
uintptr_t vkb = GET_EXPORT_ADDR("VirtKeyboardIsVisible");
30+
if (vkb) {
31+
return ((int (*)(void))vkb)();
32+
}
33+
}
34+
return 0;
35+
}
2736

2837
/* Main GUI */
2938
int InitGUI();
@@ -35,7 +44,6 @@ void GUI_Enable();
3544
int GUI_Object2Trash(GUI_Object *object);
3645
void GUI_ClearTrash();
3746

38-
3947
/* GUI utils */
4048
Uint32 colorHexToRGB(char *color, SDL_Color *clr);
4149
SDL_Color Uint32ToColor(Uint32 c);

0 commit comments

Comments
 (0)