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: 780

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
  • Psionic Roshambo @ Psionic Roshambo:
    Also a food allergy study would be a good idea
  • K3Nv2 @ K3Nv2:
    Turns out you can't sprinkle methamphetamine on McDonald's French fries
    +1
  • ZeroT21 @ ZeroT21:
    they wouldn't be called french fries at that point
    +1
  • ZeroT21 @ ZeroT21:
    Probably just meth fries
    +1
  • K3Nv2 @ K3Nv2:
    White fries hold up
    +1
  • The Real Jdbye @ The Real Jdbye:
    @K3Nv2 sure you can
  • BakerMan @ BakerMan:
    why tf do people hate android users? is it the video quality? just because "AnDrOiD = pOoR" bc they don't cost an arm and a leg like iphones do?
    +1
  • BakerMan @ BakerMan:
    i won't be turned off by an iphone, but don't pick on me for having an android, that's just how this shit should work
  • ZeroT21 @ ZeroT21:
    Should say more what these kind of android users say bout nokia 3310 users
  • BigOnYa @ BigOnYa:
    I've owned both iPhone and Androids over the years. Both are just as good, other than Apples higher price. I'm currently on Android, Samsung S21 I think, and very happy with it.
  • K3Nv2 @ K3Nv2:
    Got my 60 minute steps in whew
    +2
  • BigOnYa @ BigOnYa:
    I get mine in everyday, going back n forth to the fridge for a beer.
    +1
  • K3Nv2 @ K3Nv2:
    6,000 steps in so far legs almost broke getting off
    +1
  • K3Nv2 @ K3Nv2:
    Your mind gets in a werid pattern of just finishing then when you're done you're like I need a soda
  • BigOnYa @ BigOnYa:
    You get a "walkers" high?
  • K3Nv2 @ K3Nv2:
    Not really I just use to love building up a sweat
  • BigOnYa @ BigOnYa:
    Funny, that's what uremum always says
  • K3Nv2 @ K3Nv2:
    Yeah and people that take viagra think they have a big dick
    +1
  • K3Nv2 @ K3Nv2:
    You cant fix one insult edit for another edit you pog
  • BigOnYa @ BigOnYa:
    Nuh I'm on my tablet n it always auto corrects me
  • K3Nv2 @ K3Nv2:
    Heorin and uremum do have close quarters
  • Sonic Angel Knight @ Sonic Angel Knight:
    BIG CHICKEN :P
    K3Nv2 @ K3Nv2: https://youtu.be/q855tNpvDoQ?si=Tl57KMjiVjyBherB