public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    int TotalResX = TotalRes.Right - TotalRes.Left;
                    int TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //Y => [-1 ; 1] float
                    //X => depend on ration Width/Height (ex : [-1.7777; 1.7777] with 1920x1080)

                    float fRatio = (float)TotalResX / (float)TotalResY;
                    _Axis_X_Min = -fRatio;
                    _Axis_X_Max = fRatio;

                    float _Y_Value = (2.0f * Mouse.pTarget.Y / TotalResY) - 1.0f;
                    float _X_Value = (fRatio * 2 * Mouse.pTarget.X / TotalResX) - fRatio;

                    if (_X_Value < _Axis_X_Min)
                    {
                        _X_Value = _Axis_X_Min;
                    }
                    if (_Y_Value < -1.0f)
                    {
                        _Y_Value = -1.0f;
                    }
                    if (_X_Value > _Axis_X_Max)
                    {
                        _X_Value = _Axis_X_Max;
                    }
                    if (_Y_Value > 1.0f)
                    {
                        _Y_Value = 1.0f;
                    }

                    if (Player == 1)
                    {
                        _P1_X_Value = _X_Value;
                        _P1_Y_Value = _Y_Value;
                    }
                    else if (Player == 2)
                    {
                        _P2_X_Value = _X_Value;
                        _P2_Y_Value = _Y_Value;
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //X => [0 -> ClientWidth]
                    //Y => [ClientHeight -> 0]

                    Mouse.pTarget.Y = (int)TotalResY - Mouse.pTarget.Y;

                    if (Mouse.pTarget.X < 0)
                    {
                        Mouse.pTarget.X = 0;
                    }
                    if (Mouse.pTarget.Y < 0)
                    {
                        Mouse.pTarget.Y = 0;
                    }
                    if (Mouse.pTarget.X > (int)TotalResX)
                    {
                        Mouse.pTarget.X = (int)TotalResX;
                    }
                    if (Mouse.pTarget.Y > (int)TotalResY)
                    {
                        Mouse.pTarget.Y = (int)TotalResY;
                    }

                    if (Player == 1)
                    {
                        _P1_X_Value = (float)(Mouse.pTarget.X);
                        _P1_Y_Value = (float)(Mouse.pTarget.Y);
                        _P1_DeltaX  = _P1_X_Value - _P1_LastX;
                        _P1_LastX   = _P1_X_Value;
                    }
                    else if (Player == 2)
                    {
                        _P2_X_Value = (float)(Mouse.pTarget.X);
                        _P2_Y_Value = (float)(Mouse.pTarget.Y);
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        public void GetScreenresolution2()
        {
            IntPtr hDesktop = Win32.GetDesktopWindow();

            Win32.Rect DesktopRect = new Win32.Rect();
            Win32.GetWindowRect(hDesktop, ref DesktopRect);
            _screenWidth  = DesktopRect.Right;
            _screenHeight = DesktopRect.Bottom;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Convert client area pointer location to Game speciffic data for memory injection
        /// </summary>
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Demul Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    int TotalResX = TotalRes.Right - TotalRes.Left;
                    int TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //X => [-1 ; 1] float
                    //Y => [-1 ; 1] float

                    float X_Value = (2.0f * Mouse.pTarget.X / TotalResX) - 1.0f;
                    float Y_Value = 1.0f - (2.0f * Mouse.pTarget.Y / TotalResY);

                    if (X_Value < -1.0f)
                    {
                        X_Value = -1.0f;
                    }
                    if (Y_Value < -1.0f)
                    {
                        Y_Value = -1.0f;
                    }
                    if (X_Value > 1.0f)
                    {
                        X_Value = 1.0f;
                    }
                    if (Y_Value > 1.0f)
                    {
                        Y_Value = 1.0f;
                    }

                    if (Player == 1)
                    {
                        _P1_X_Float = X_Value;
                        _P1_Y_Float = Y_Value;
                    }
                    else if (Player == 2)
                    {
                        _P2_X_Float = X_Value;
                        _P2_Y_Float = Y_Value;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //This engine (common with other TTX shooter) is waiting for X and Y value in range [0 ; WindowSize]
                    //BUT using the raw window size is troublesome when the game is combined with DxWnd as the
                    //resulting real window is not the same size as the game engine parameters (SCREEN_WITH, RENDER_WIDTH, etc...)
                    //That's why we're going to read the memory to find the INI parameter and scale the X,Y values accordingly
                    byte[] bufferX  = ReadBytes((int)_TargetProcess_MemoryBaseAddress + _ScreenWidth_Offset, 4);
                    double GameResX = (double)BitConverter.ToInt32(bufferX, 0);
                    byte[] bufferY  = ReadBytes((int)_TargetProcess_MemoryBaseAddress + _ScreenHeight_Offset, 4);
                    double GameResY = (double)BitConverter.ToInt32(bufferY, 0);

                    WriteLog("Game engine render resolution (Px) = [ " + GameResX + "x" + GameResY + " ]");

                    double RatioX = GameResX / TotalResX;
                    double RatioY = GameResY / TotalResY;

                    Mouse.pTarget.X = Convert.ToInt16(Math.Round(RatioX * Mouse.pTarget.X));
                    Mouse.pTarget.Y = Convert.ToInt16(Math.Round(RatioY * Mouse.pTarget.Y));
                    if (Mouse.pTarget.X < 0)
                    {
                        Mouse.pTarget.X = 0;
                    }
                    if (Mouse.pTarget.Y < 0)
                    {
                        Mouse.pTarget.Y = 0;
                    }
                    if (Mouse.pTarget.X > (int)GameResX)
                    {
                        Mouse.pTarget.X = (int)GameResX;
                    }
                    if (Mouse.pTarget.Y > (int)GameResY)
                    {
                        Mouse.pTarget.Y = (int)GameResY;
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 6
0
        public override void GetScreenResolution()
        {
            WriteLog("using alternative way of Screen size");
            IntPtr hDesktop = Win32.GetDesktopWindow();

            Win32.Rect DesktopRect = new Win32.Rect();
            Win32.GetWindowRect(hDesktop, ref DesktopRect);
            _screenWidth  = DesktopRect.Right;
            _screenHeight = DesktopRect.Bottom;
        }
Exemplo n.º 7
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    Win32.GetWindowRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    WriteLog("Game client window location (Px) = [ " + TotalRes.Left + " ; " + TotalRes.Top + " ]");

                    //X => [-320 ; +320] = 640
                    //Y => [240; -240] = 480
                    double dMaxX = 640.0;
                    double dMaxY = 480.0;

                    Mouse.pTarget.X = Convert.ToInt32(Math.Round(dMaxX * Mouse.pTarget.X / TotalResX) - dMaxX / 2);
                    Mouse.pTarget.Y = Convert.ToInt32((Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY) - dMaxY / 2) * -1);
                    if (Mouse.pTarget.X < -320)
                    {
                        Mouse.pTarget.X = -320;
                    }
                    if (Mouse.pTarget.Y < -240)
                    {
                        Mouse.pTarget.Y = -240;
                    }
                    if (Mouse.pTarget.X > 320)
                    {
                        Mouse.pTarget.X = 320;
                    }
                    if (Mouse.pTarget.Y > 240)
                    {
                        Mouse.pTarget.Y = 240;
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //X => [FED8-0128] = 592
                    //Y => [00D8-FF28] = 432
                    double dMaxX = 592.0;
                    double dMaxY = 432.0;

                    Mouse.pTarget.X = Convert.ToInt16(Math.Round(dMaxX * Mouse.pTarget.X / TotalResX) - dMaxX / 2);
                    Mouse.pTarget.Y = Convert.ToInt16((Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY) - dMaxY / 2) * -1);
                    if (Mouse.pTarget.X < -296)
                    {
                        Mouse.pTarget.X = -296;
                    }
                    if (Mouse.pTarget.Y < -216)
                    {
                        Mouse.pTarget.Y = -216;
                    }
                    if (Mouse.pTarget.X > 296)
                    {
                        Mouse.pTarget.X = 296;
                    }
                    if (Mouse.pTarget.Y > 216)
                    {
                        Mouse.pTarget.Y = 216;
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 9
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //X => [0x0000 ; 0x4000] = 16384
                    //Y => [0x0000 ; 0x4000] = 16384
                    double dMaxX = 16384.0;
                    double dMaxY = 16384.0;

                    Mouse.pTarget.X = Convert.ToInt16(Math.Round(dMaxX * Mouse.pTarget.X / TotalResX));
                    Mouse.pTarget.Y = Convert.ToInt16(Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY));
                    if (Mouse.pTarget.X < 0)
                    {
                        Mouse.pTarget.X = 0;
                    }
                    if (Mouse.pTarget.Y < 0)
                    {
                        Mouse.pTarget.Y = 0;
                    }
                    if (Mouse.pTarget.X > 16384)
                    {
                        Mouse.pTarget.X = 16384;
                    }
                    if (Mouse.pTarget.Y > 16384)
                    {
                        Mouse.pTarget.Y = 16384;
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 10
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //X => [0-FF] = 255
                    //Y => [0-FF] = 255
                    //Axes inversés : 0 = Bas et Droite
                    double dMaxX = 255.0;
                    double dMaxY = 255.0;

                    Mouse.pTarget.X = Convert.ToInt32(dMaxX - Math.Round(dMaxX * Mouse.pTarget.X / TotalResX));
                    Mouse.pTarget.Y = Convert.ToInt32(dMaxY - Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY));
                    if (Mouse.pTarget.X < 0)
                    {
                        Mouse.pTarget.X = 0;
                    }
                    if (Mouse.pTarget.Y < 0)
                    {
                        Mouse.pTarget.Y = 0;
                    }
                    if (Mouse.pTarget.X > (int)dMaxX)
                    {
                        Mouse.pTarget.X = (int)dMaxX;
                    }
                    if (Mouse.pTarget.Y > (int)dMaxY)
                    {
                        Mouse.pTarget.Y = (int)dMaxY;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 11
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    //X => [00-FF] = 255
                    //Y => [00-FF] = 255
                    double dMaxX = 255.0;
                    double dMaxY = 255.0;

                    //Inverted axis : origin in lower-right
                    Mouse.pTarget.X = Convert.ToInt32(dMaxX - Math.Round(dMaxX * Mouse.pTarget.X / TotalResX));
                    Mouse.pTarget.Y = Convert.ToInt32(dMaxY - Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY));
                    if (Mouse.pTarget.X < 0)
                    {
                        Mouse.pTarget.X = 0;
                    }
                    if (Mouse.pTarget.Y < 0)
                    {
                        Mouse.pTarget.Y = 0;
                    }
                    if (Mouse.pTarget.X > (int)dMaxX)
                    {
                        Mouse.pTarget.X = (int)dMaxX;
                    }
                    if (Mouse.pTarget.Y > (int)dMaxY)
                    {
                        Mouse.pTarget.Y = (int)dMaxY;
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 12
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    int TotalResX = TotalRes.Right - TotalRes.Left;
                    int TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //X,Y => [-32768 ; 32767] = 0xFFFF
                    double dMaxX = 65535.0;
                    double dMaxY = 65535.0;

                    Mouse.pTarget.X = Convert.ToInt32(Math.Round(dMaxX * Mouse.pTarget.X / TotalResX) - 32768);
                    Mouse.pTarget.Y = Convert.ToInt32(Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY) - 32768) * -1;
                    if (Mouse.pTarget.X < -32768)
                    {
                        Mouse.pTarget.X = -32768;
                    }
                    if (Mouse.pTarget.Y < -32768)
                    {
                        Mouse.pTarget.Y = -32768;
                    }
                    if (Mouse.pTarget.X > 32767)
                    {
                        Mouse.pTarget.X = 32767;
                    }
                    if (Mouse.pTarget.Y > 32767)
                    {
                        Mouse.pTarget.Y = 32767;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Convert client area pointer location to Game speciffic data for memory injection
        /// </summary>
        public virtual bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);

                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    if (Mouse.pTarget.X < 0)
                    {
                        Mouse.pTarget.X = 0;
                    }
                    if (Mouse.pTarget.Y < 0)
                    {
                        Mouse.pTarget.Y = 0;
                    }
                    if (Mouse.pTarget.X > (int)TotalResX)
                    {
                        Mouse.pTarget.X = (int)TotalResX;
                    }
                    if (Mouse.pTarget.Y > (int)TotalResX)
                    {
                        Mouse.pTarget.Y = (int)TotalResX;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Convert client area pointer location to Game speciffic data for memory injection
        /// </summary>
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Demul Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    /*
                     * //pX and pY in width/heigt % of window
                     * double Xpercent = Mouse.pTarget.X * 100.0 / TotalResX;
                     * double Ypercent = Mouse.pTarget.Y * 100.0 / TotalResY;
                     *
                     * //0% = 0x00 and 100% = 0xFF for padDemul.dll
                     * Mouse.pTarget.X = Convert.ToInt16(Math.Round(Xpercent * 255.0 / 100.0));
                     * Mouse.pTarget.Y = Convert.ToInt16(Math.Round(Ypercent * 255.0 / 100.0));
                     */

                    //Naomi + awave => 0000 - 00FF
                    //JVS => 0000 - 0FFF
                    double dMaxX = 255.0;
                    double dMaxY = 255.0;
                    if (_SystemName.Equals(SYSTEM_NAOMIJVS))
                    {
                        dMaxX = 4095.0;
                        dMaxY = 4095.0;
                    }

                    Mouse.pTarget.X = Convert.ToInt16(Math.Round(dMaxX * Mouse.pTarget.X / TotalResX));
                    Mouse.pTarget.Y = Convert.ToInt16(Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY));
                    if (Mouse.pTarget.X < 0)
                    {
                        Mouse.pTarget.X = 0;
                    }
                    if (Mouse.pTarget.Y < 0)
                    {
                        Mouse.pTarget.Y = 0;
                    }
                    if (Mouse.pTarget.X > (int)dMaxX)
                    {
                        Mouse.pTarget.X = (int)dMaxX;
                    }
                    if (Mouse.pTarget.Y > (int)dMaxY)
                    {
                        Mouse.pTarget.Y = (int)dMaxY;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 15
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //Player 1 and 2 axis limits are different
                    //We can't access the TEST menu so it may be a different calibration for each one so we have to adapt:
                    int    dMinX  = 0;
                    int    dMaxX  = 0;
                    int    dMinY  = 0;
                    int    dMaxY  = 0;
                    double DeltaX = 0.0;
                    double DeltaY = 0.0;


                    if (Player == 1)
                    {
                        //X => [76-215] = 140
                        //Y => [99-202] = 104
                        //Axes inversés : 0 = Bas et Droite
                        dMinX  = _P1_XMin;
                        dMaxX  = _P1_XMax;
                        dMinY  = _P1_YMin;
                        dMaxY  = _P1_YMax;
                        DeltaX = _P1_XMax - _P1_XMin + 1;
                        DeltaY = _P1_YMax - _P1_YMin + 1;
                    }
                    else if (Player == 2)
                    {
                        //X => [55-197] = 143
                        //Y => [96-205] = 110
                        //Axes inversés : 0 = Bas et Droite
                        dMinX  = _P2_XMin;
                        dMaxX  = _P2_XMax;
                        dMinY  = _P2_YMin;
                        dMaxY  = _P2_YMax;
                        DeltaX = _P2_XMax - _P2_XMin + 1;
                        DeltaY = _P2_YMax - _P2_YMin + 1;
                    }

                    Mouse.pTarget.X = Convert.ToInt32(DeltaX - Math.Round(DeltaX * Mouse.pTarget.X / TotalResX)) + dMinX;
                    Mouse.pTarget.Y = Convert.ToInt32(DeltaY - Math.Round(DeltaY * Mouse.pTarget.Y / TotalResY)) + dMinY;
                    if (Mouse.pTarget.X < dMinX)
                    {
                        Mouse.pTarget.X = dMinX;
                    }
                    if (Mouse.pTarget.Y < dMinY)
                    {
                        Mouse.pTarget.Y = dMinY;
                    }
                    if (Mouse.pTarget.X > dMaxX)
                    {
                        Mouse.pTarget.X = dMaxX;
                    }
                    if (Mouse.pTarget.Y > dMaxY)
                    {
                        Mouse.pTarget.Y = dMaxY;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Convert client area pointer location to Game speciffic data for memory injection
        /// For These 2 games, there are no calibration available so we face a ratio issue problem
        /// Exemple : 16/9 monitor + 4/3 option in demul in fullscreen : aim is not good because of black borders
        ///
        /// To fix it, we try to read the setting (4/3, 16/9 or stretch) and resolution in demul's memory (in gpuDX11.dll)
        /// this way, we can do some math to know the exact position
        /// </summary>
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                //if no gpudx11.dll used or not found, default behavior with black border issue
                if (_GpuModuleBaseAddress == IntPtr.Zero)
                {
                    try
                    {
                        //Demul Window size
                        Win32.Rect TotalRes = new Win32.Rect();
                        Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                        double TotalResX = TotalRes.Right - TotalRes.Left;
                        double TotalResY = TotalRes.Bottom - TotalRes.Top;

                        WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                        double dMaxX = 640;
                        double dMaxY = 480;

                        Mouse.pTarget.X = Convert.ToInt16(Math.Round(dMaxX * Mouse.pTarget.X / TotalResX));
                        Mouse.pTarget.Y = Convert.ToInt16(Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY));

                        if (Mouse.pTarget.X < 0)
                        {
                            Mouse.pTarget.X = 0;
                        }
                        if (Mouse.pTarget.Y < 0)
                        {
                            Mouse.pTarget.Y = 0;
                        }
                        if (Mouse.pTarget.X > (int)dMaxX)
                        {
                            Mouse.pTarget.X = (int)dMaxX;
                        }
                        if (Mouse.pTarget.Y > (int)dMaxY)
                        {
                            Mouse.pTarget.Y = (int)dMaxY;
                        }
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                    }
                }
                else
                {
                    try
                    {
                        //Display option in demul menu : 0=Stretch / 1=4:3 / 2 = 16:9
                        byte DisplayType = ReadByte((int)_GpuModuleBaseAddress + _GpuDisplayType_Offset);;
                        WriteLog("Demul display type is : " + DisplayType.ToString());

                        //Demul Window size
                        Win32.Rect TotalRes = new Win32.Rect();
                        Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                        double TotalResX = TotalRes.Right - TotalRes.Left;
                        double TotalResY = TotalRes.Bottom - TotalRes.Top;

                        WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");


                        //If stretch the whole window is used so, no change
                        //If 4:3 we keep correct Y but have to change X because of black borders
                        if (DisplayType == 1)
                        {
                            double RealX = TotalResY * 4.0 / 3.0;
                            WriteLog("Game real resolution (Px) = [ " + RealX.ToString() + "x" + TotalResY.ToString() + " ]");
                            Mouse.pTarget.X -= ((int)TotalResX - (int)RealX) / 2;
                            TotalResX        = RealX;
                        }
                        //If 6:9 we keep the correct X but we have to change Y because of black borders
                        if (DisplayType == 2)
                        {
                            double RealY = TotalResX * 9.0 / 16.0;
                            WriteLog("Game real resolution (Px) = [ " + TotalResX.ToString() + "x" + RealY.ToString() + " ]");
                            Mouse.pTarget.Y -= ((int)TotalResY - (int)RealY) / 2;
                            TotalResY        = RealY;
                        }

                        double dMaxX = 640;
                        double dMaxY = 480;

                        Mouse.pTarget.X = Convert.ToInt16(Math.Round(dMaxX * Mouse.pTarget.X / TotalResX));
                        Mouse.pTarget.Y = Convert.ToInt16(Math.Round(dMaxY * Mouse.pTarget.Y / TotalResY));

                        if (Mouse.pTarget.X < 0)
                        {
                            Mouse.pTarget.X = 0;
                        }
                        if (Mouse.pTarget.Y < 0)
                        {
                            Mouse.pTarget.Y = 0;
                        }
                        if (Mouse.pTarget.X > (int)dMaxX)
                        {
                            Mouse.pTarget.X = (int)dMaxX;
                        }
                        if (Mouse.pTarget.Y > (int)dMaxY)
                        {
                            Mouse.pTarget.Y = (int)dMaxY;
                        }
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                    }
                }
            }
            return(false);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Convert client area pointer location to Game speciffic data for memory injection
        /// </summary>
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Model2 Window size
                    //Usually we get ClientRect but for model2 there's a bug and we need to get windowsrect
                    Win32.Rect TotalRes = new Win32.Rect();
                    //Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    Win32.GetWindowRect(_TargetProcess.MainWindowHandle, ref TotalRes);

                    //WriteLog("Client rect == " + TotalRes.Left.ToString() + ";" + TotalRes.Right.ToString() + ";" + TotalRes.Top.ToString() + ";" + TotalRes.Bottom.ToString());

                    double GameResX  = 0.0;
                    double GameResY  = 0.0;
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;
                    WriteLog("Model2 window resolution = " + TotalResX.ToString() + "x" + TotalResY.ToString());

                    //Just like some TTX games, Model2 is waiting for data according to it's resolution
                    // (i.e there are no fixed boundaries for X and Y axis values)
                    //But when used with DxWnd with a different window resolution than the actual D3D resolution, this will
                    //block cursors in a limited part of the game
                    //That's why we're going to read the memory to find real X and Y rendering values and scale data accordingly
                    if (TotalResX != 0 && TotalResY != 0)
                    {
                        byte[] buffer          = ReadBytes((int)_TargetProcess_MemoryBaseAddress + 0x009CEC00, 4);
                        int    _RealResAddress = BitConverter.ToInt32(buffer, 0);
                        WriteLog("Model2 real resolution address = 0x" + _RealResAddress.ToString("X8"));
                        byte[] bufferX = ReadBytes(_RealResAddress + 0x00002D8C, 4);
                        GameResX = (double)BitConverter.ToInt32(bufferX, 0);
                        byte[] bufferY = ReadBytes(_RealResAddress + 0x00002D90, 4);
                        GameResY = (double)BitConverter.ToInt32(bufferY, 0);
                        WriteLog("Model2 render resolution = " + GameResX.ToString() + "x" + GameResY.ToString());

                        if (GameResX != 0 && GameResY != 0)
                        {
                            double RatioX = GameResX / TotalResX;
                            double RatioY = GameResY / TotalResY;

                            Mouse.pTarget.X = Convert.ToInt16(Math.Round(RatioX * Mouse.pTarget.X));
                            Mouse.pTarget.Y = Convert.ToInt16(Math.Round(RatioY * Mouse.pTarget.Y));
                        }
                        //Game rendering resolution autodetection failure ?
                        else
                        {
                            WriteLog("Automatic resolution detection failed, using old game scaling method");
                            GameResX = TotalResX;
                            GameResY = TotalResY;
                        }
                    }
                    // Some user have issue with the emulator and it's window size
                    // In that case, reverting back to OLD method
                    else
                    {
                        WriteLog("Model2 main window size is null, using old game scaling method");
                        GameResX = TotalResX;
                        GameResY = TotalResY;
                    }

                    if (Mouse.pTarget.X < 0)
                    {
                        Mouse.pTarget.X = 0;
                    }
                    if (Mouse.pTarget.Y < 0)
                    {
                        Mouse.pTarget.Y = 0;
                    }
                    if (Mouse.pTarget.X > (int)GameResX)
                    {
                        Mouse.pTarget.X = (int)GameResX;
                    }
                    if (Mouse.pTarget.Y > (int)GameResY)
                    {
                        Mouse.pTarget.Y = (int)GameResY;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 18
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    //Window size
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    double TotalResX = TotalRes.Right - TotalRes.Left;
                    double TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //Direct input mouse : double from -1 to +1
                    if (Player == 1)
                    {
                        //Convert client coordonnate to [-1, 1-] coordonates
                        double dX = Mouse.pTarget.X / TotalResX * 2.0 - 1.0;
                        double dY = Mouse.pTarget.Y / TotalResY * 2.0 - 1.0;
                        if (dX < -1)
                        {
                            dX = -1;
                        }
                        else if (dX > 1)
                        {
                            dX = 1;
                        }
                        if (dY < -1)
                        {
                            dY = -1;
                        }
                        else if (dY > 1)
                        {
                            dY = 1;
                        }

                        Mouse.pTarget.X = (int)(dX * 1000);
                        Mouse.pTarget.Y = (int)(dY * 1000);
                    }
                    //Dinput ATRAK :
                    //min = FFFFFF80 max 0000080 , change from FFFFFF to 000000 at zero
                    //min = top left
                    else if (Player == 2)
                    {
                        double dMax = 254.0;

                        if (Mouse.pTarget.X < 0)
                        {
                            Mouse.pTarget.X = 0xFF80;
                        }
                        else if (Mouse.pTarget.X > (int)TotalResX)
                        {
                            Mouse.pTarget.X = 0x0080;
                        }
                        else
                        {
                            Mouse.pTarget.X = Convert.ToInt32(Math.Round(dMax * Mouse.pTarget.X / TotalResX) - 0x7F);
                        }

                        if (Mouse.pTarget.Y < 0)
                        {
                            Mouse.pTarget.Y = 0xFF80;
                        }
                        else if (Mouse.pTarget.Y > (int)TotalResY)
                        {
                            Mouse.pTarget.Y = 0x0080;
                        }
                        else
                        {
                            Mouse.pTarget.Y = Convert.ToInt32(Math.Round(dMax * Mouse.pTarget.Y / TotalResY) - 0x7F);
                        }
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }
Exemplo n.º 19
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    Win32.Rect TotalRes = new Win32.Rect();
                    Win32.GetClientRect(_TargetProcess.MainWindowHandle, ref TotalRes);
                    int TotalResX = TotalRes.Right - TotalRes.Left;
                    int TotalResY = TotalRes.Bottom - TotalRes.Top;

                    WriteLog("Game client window resolution (Px) = [ " + TotalResX + "x" + TotalResY + " ]");

                    //During Menus :
                    //Y => [0; RezY] en float
                    //X => [0; RezX] en float

                    _P1_X_Menu_Value = (float)Mouse.pTarget.X;
                    _P1_Y_Menu_Value = (float)Mouse.pTarget.Y;

                    if (_P1_X_Menu_Value < 0.0f)
                    {
                        _P1_X_Menu_Value = 0.0f;
                    }
                    if (_P1_Y_Menu_Value < 0.0f)
                    {
                        _P1_Y_Menu_Value = 0.0f;
                    }
                    if (_P1_X_Menu_Value > (float)TotalResX)
                    {
                        _P1_X_Menu_Value = (float)TotalResX;
                    }
                    if (_P1_Y_Menu_Value > (float)TotalResY)
                    {
                        _P1_Y_Menu_Value = (float)TotalResY;
                    }

                    //In Game, Shoot :
                    //Y => [-1;1] en float
                    //X => [-1;1] en float
                    _P1_X_Shoot_Value = (2.0f * Mouse.pTarget.X / TotalResX) - 1.0f;
                    _P1_Y_Shoot_Value = (2.0f * Mouse.pTarget.Y / TotalResY) - 1.0f;

                    if (_P1_X_Shoot_Value < -1.0f)
                    {
                        _P1_X_Shoot_Value = -1.0f;
                    }
                    if (_P1_Y_Shoot_Value < -1.0f)
                    {
                        _P1_Y_Shoot_Value = -1.0f;
                    }
                    if (_P1_X_Shoot_Value > 1.0f)
                    {
                        _P1_X_Shoot_Value = 1.0f;
                    }
                    if (_P1_Y_Shoot_Value > 1.0f)
                    {
                        _P1_Y_Shoot_Value = 1.0f;
                    }

                    //In Game, Crosshair :
                    //Y => [-0.5;0.5] en float
                    //X => [-0.5;0.5] en float
                    _P1_Crosshair_X_Value = _P1_X_Shoot_Value / 2.0f;
                    _P1_Crosshair_Y_Value = _P1_Y_Shoot_Value / 2.0f;

                    return(true);
                }
                catch (Exception ex)
                {
                    WriteLog("Error scaling mouse coordonates to GameFormat : " + ex.Message.ToString());
                }
            }
            return(false);
        }