This is the AMP version of this page.
If you want to load the real page instead, click this text.

Discussion Touches registering to game

MinimalXenon

Platinian
C++:
HOOKAF(void, Input, void *thiz, void *ex_ab, void *ex_ac)
{
    origInput(thiz, ex_ab, ex_ac);
    ImGui_ImplAndroid_HandleInputEvent((AInputEvent *)thiz);
    return;
}

Has anyone figured out a way to fix the issue where when using the imgui the touches also register to the background (the game)?
 
Solution
In the meantime, I have found a temporary solution to the problem.
It should be easier to implement to any projects that experiences this annoying behavior.



(Only for Unity Games)

The solution requires one to hook into Input.GetTouch of UnityEngine.
Code:
public static Touch GetTouch(int index) { }

1. Find the "Touch" struct of the game in the dump and define it in your project.
C++:
struct Touch {
    int m_FingerId;
    Vector2 m_Position;
    Vector2 m_RawPosition;
    Vector2 m_PositionDelta;
    float m_TimeDelta;
    int m_TapCount;
    int m_Phase; // Enum TouchPhase
    int m_Type;  // Enum TouchType
    float m_Pressure;
    float m_MaximumPossiblePressure;
    float m_Radius...
return the value of "Began", in other words, return zero.
This is my setup


Code:
Touch (*o_GetTouch)(int index);
Touch n_GetTouch(int index) {
Touch _touch = o_GetTouch(index);
    if (index == 0) {
        ImGuiIO &io = ImGui::GetIO(ctx);
        if (io.WantCaptureMouse) {
            _touch.m_Phase = 0; // << IMGUI can't Touch Only Game Receive Touch
        }
    }
return o_GetTouch(index);
}