Help! Show soft keyboard (imgui)

YbnIU

Platinian
Hey, i used a ImGUI template and everything works like a charm. but wait...
Text Inputs does not show the Keyboard!
which is very annoying.

I Tried Calling InputMethodManager.showSoftInput from Java, and from C++ but failed.

any help would be appreciated <3
 
Solution
auto get_text = (Il2CppString*(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_text(0)"); return get_text(this)->c_str();
you are most likely returning pointer to non existent data, if you construct std::string and return the char* of that string, the string deallocated once it leaves the function, making the returned pointer points to deallocated memory

The solution is to return the std::string instead of char*
If your game is unity, you can try to invoke

TouchScreenKeyboard_InternalConstructorHelper on TouchScreenKeyboard class
i have used that but i have problems with getting the text after the user submits/enters

i use this

C++:
class TouchScreenKeyboard {
public:
    // Static Methods
    static boolean isSupported() {
        auto get_isSupported = (boolean(*)())Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_isSupported(0)");
        return get_isSupported();
    }
    static TouchScreenKeyboard* Open(const char* value, int type, boolean autocorrection, boolean multiline){
        auto open = (TouchScreenKeyboard*(*)(Il2CppString*,int,boolean,boolean))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>Open(4)");
        return open(Il2CppString::Create(value), type, autocorrection, multiline);
    }
    // Other methods
    const char* getText(){
        auto get_text = (Il2CppString*(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_text(0)");
        return get_text(this)->c_str();
    }
    void setText(const char* value){
        auto set_text = (void(*)(void*,Il2CppString*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>set_text(1)");
        set_text(this, Il2CppString::Create(value));
    }
    boolean isActive(){
        auto get_active = (boolean(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_active(0)");
        return get_active(this);
    }
    boolean isDone(){
        auto get_done = (boolean(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_done(0)");
        return get_done(this);
    }
    boolean isCanceled(){
        auto get_wasCanceled = (boolean(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_wasCanceled(0)");
        return get_wasCanceled(this);
    }
};

my input code:

C++:
TouchScreenKeyboard input;
if(ImGui::Button("Click me!")){
   input = TouchScreenKeyboard::Open("", 0, false, true);
}
if (input->IsDone()) {
    ImGui::Text("%s", input->getText());
}

and it shows empty string, even though the length of the string is correct
 
It's seem your code are correct, however you can try to log your
C++:
get_text(this)->c_str();

Is it showing some text or not, this is my code, idk it's good or not, but it's work like a charm

C++:
while (true) {
  bool active = touchScreenKeyboardClass -> Get < UnityResolve::Method > (OBFUSCATE("get_active")) -> Invoke < bool > ();
  if (!active) {
    break; // exit loop
  }
  m_Text = touchScreenKeyboardClass -> Get < UnityResolve::Method > (OBFUSCATE("get_text")) -> Invoke < UnityResolve::UnityType::String * > ();
  usleep(100000); // sleep for 100ms to reduce cpu usage
}
 
It's seem your code are correct, however you can try to log your
C++:
get_text(this)->c_str();

Is it showing some text or not, this is my code, idk it's good or not, but it's work like a charm

C++:
while (true) {
  bool active = touchScreenKeyboardClass -> Get < UnityResolve::Method > (OBFUSCATE("get_active")) -> Invoke < bool > ();
  if (!active) {
    break; // exit loop
  }
  m_Text = touchScreenKeyboardClass -> Get < UnityResolve::Method > (OBFUSCATE("get_text")) -> Invoke < UnityResolve::UnityType::String * > ();
  usleep(100000); // sleep for 100ms to reduce cpu usage
}
1000054288.gif
 
auto get_text = (Il2CppString*(*)(void*))Find("UnityEngine.CoreModule.dll>UnityEngine>TouchScreenKeyboard>get_text(0)"); return get_text(this)->c_str();
you are most likely returning pointer to non existent data, if you construct std::string and return the char* of that string, the string deallocated once it leaves the function, making the returned pointer points to deallocated memory

The solution is to return the std::string instead of char*
 
Solution
Back
Top Bottom