Homebrew RELEASE Simple application using ImGUI (libnx)

mstrVLT

Member
OP
Newcomer
Joined
Nov 8, 2016
Messages
18
Trophies
0
Age
36
XP
286
Country
Russia
A small example for easy development

ImGUI for SDL2
https://github.com/MstrVLT/switch_imgui_sdl2

ImGUI for GLFW (most devs prefer GLFW over SDL2)
https://github.com/MstrVLT/switch_imgui_glfw

Touchscreen is supported
Shared-font + ext example included

ImGui::ShowDemoWindow() function will create a demo window showcasing variety of features and examples.
The code is always available for reference in imgui_demo.cpp

Special thx: Pablo Curiel, Cpasjuste, SciresM, yellows8, fincs and all SwitchBrew members

photo_2020-05-18 14.31.05.jpeg
 
Last edited by mstrVLT,
D

Deleted User

Guest
In your project, you disable next/prev focus keys and unfortunately this is vital to change from window to window using a gamepad. You can look at my repo here https://github.com/notnotme/osp if you want to add mouse emulation using the gamepad (wich is much better than gamepad control in my opinion). The code is in sdl2_impl.cpp.

Good luck
 

mstrVLT

Member
OP
Newcomer
Joined
Nov 8, 2016
Messages
18
Trophies
0
Age
36
XP
286
Country
Russia
...
Good luck

switch_imgui/source/imgui/imgui_impl_sdl.cpp button mapping is wrong for switch i recomend edit it
Code:
MAP_BUTTON(ImGuiNavInput_Cancel, SDL_CONTROLLER_BUTTON_A); // Circle / B
MAP_BUTTON(ImGuiNavInput_Menu, SDL_CONTROLLER_BUTTON_X); // Square / X
MAP_BUTTON(ImGuiNavInput_Input, SDL_CONTROLLER_BUTTON_Y); // Triangle / Y
MAP_BUTTON(ImGuiNavInput_DpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT); // D-Pad Left
MAP_BUTTON(ImGuiNavInput_DpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); // D-Pad Right
MAP_BUTTON(ImGuiNavInput_DpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP); // D-Pad Up
MAP_BUTTON(ImGuiNavInput_DpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN); // D-Pad Down
MAP_BUTTON(ImGuiNavInput_FocusPrev, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB
MAP_BUTTON(ImGuiNavInput_FocusNext, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB
MAP_BUTTON(ImGuiNavInput_TweakSlow, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB
MAP_BUTTON(ImGuiNavInput_TweakFast, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB
MAP_BUTTON(ImGuiNavInput_Activate, SDL_CONTROLLER_BUTTON_B); // Cross / A

Use touch screen for change focus (or hold "Y" and click L trigger)
My touch implementation is bad, but better than nothing
 
Last edited by mstrVLT,

mstrVLT

Member
OP
Newcomer
Joined
Nov 8, 2016
Messages
18
Trophies
0
Age
36
XP
286
Country
Russia
for keyboard input you can use this piece of code but I did not manage to achieve good results)
Code:
            if (io.WantTextInput != prevWantInputText) {
                prevWantInputText = io.WantTextInput;
                if (io.WantTextInput)
                {
                    SwkbdConfig kbd;
                    Result rc;

                    // char input_kbd[255] = input;
 
                    rc = swkbdCreate(&kbd, 0);
                    if (R_SUCCEEDED(rc)) {
                        swkbdConfigMakePresetDefault(&kbd);
                        swkbdConfigSetInitialText(&kbd, input);
                        rc = swkbdShow(&kbd, input, sizeof(input));
                      
                       io.AddInputCharactersUTF8(input);

                        swkbdClose(&kbd);
                    }
                }
            }
 
Last edited by mstrVLT,
  • Like
Reactions: Deleted User
D

Deleted User

Guest
for keyboard input you can use this piece of code but I did not manage to achieve good results)
Code:
            if (io.WantTextInput != prevWantInputText) {
                prevWantInputText = io.WantTextInput;
                if (io.WantTextInput)
                {
                    SwkbdConfig kbd;
                    Result rc;

                    // char input_kbd[255] = input;
 
                    rc = swkbdCreate(&kbd, 0);
                    if (R_SUCCEEDED(rc)) {
                        swkbdConfigMakePresetDefault(&kbd);
                        swkbdConfigSetInitialText(&kbd, input);
                        rc = swkbdShow(&kbd, input, sizeof(input));
                     
                       io.AddInputCharactersUTF8(input);

                        swkbdClose(&kbd);
                    }
                }
            }

Thanks you, if I need keyboard input in one of my apps I'll come back here to use this as a starting point to implement soft keys. I really appreciate.
About the gamepad mapping, I saw it was wrong for switch and edited it too.

My touch implementation is bad, but better than nothing
Mine is not better, act only as simple click, you can't scroll.
 

mstrVLT

Member
OP
Newcomer
Joined
Nov 8, 2016
Messages
18
Trophies
0
Age
36
XP
286
Country
Russia
Add support for nx std + ext font )
 

Attachments

  • 2020052920132600-73613D3DAFC1266C593A5CFF85C3D01D.jpg
    2020052920132600-73613D3DAFC1266C593A5CFF85C3D01D.jpg
    219.8 KB · Views: 779

mstrVLT

Member
OP
Newcomer
Joined
Nov 8, 2016
Messages
18
Trophies
0
Age
36
XP
286
Country
Russia
Last edited by mstrVLT,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Flame @ Flame: Never fight uphill, me boys.