コード例 #1
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = BitConverter.GetBytes(mouse.pTarget.X);
            byte[] bufferY = BitConverter.GetBytes(mouse.pTarget.Y);

            if (Player == 1)
            {
                //Write Axis
                WriteBytes(_P1_X_Address, bufferX);
                WriteBytes(_P1_Y_Address, bufferY);

                //Inputs

                /*if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                 * {
                 *  SendKeyDown(_P1_Trigger_DIK);
                 * }
                 * else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                 * {
                 *  SendKeyUp(_P1_Trigger_DIK);
                 * }
                 * else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                 * {
                 *  if (P1_Next_Dir.Equals("left"))
                 *      SendKeyDown(_P1_Left_DIK);
                 *  else
                 *      SendKeyDown(_P1_Right_DIK);
                 * }
                 * else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                 * {
                 *  if (P1_Next_Dir.Equals("left"))
                 *  {
                 *      SendKeyUp(_P1_Left_DIK);
                 *      P1_Next_Dir = "right";
                 *  }
                 *  else
                 *  {
                 *      SendKeyUp(_P1_Right_DIK);
                 *      P1_Next_Dir = "left";
                 *  }
                 * }
                 * if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                 * {
                 *  SendKeyDown(_P1_Reload_DIK);
                 * }
                 * else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                 * {
                 *  SendKeyUp(_P1_Reload_DIK);
                 * }*/
            }

            /*else if (Player == 2)
             * {
             *  //Write Axis
             *  WriteBytes(_P2_X_Address, bufferX);
             *  WriteBytes(_P2_Y_Address, bufferY);
             *
             *  //Inputs
             *  if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
             *  {
             *      SendKeyDown(_P2_Trigger_DIK);
             *  }
             *  else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
             *  {
             *      SendKeyUp(_P2_Trigger_DIK);
             *  }
             *  else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
             *  {
             *      if (P2_Next_Dir.Equals("left"))
             *          SendKeyDown(_P2_Left_DIK);
             *      else
             *          SendKeyDown(_P2_Right_DIK);
             *  }
             *  else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
             *  {
             *      if (P2_Next_Dir.Equals("left"))
             *      {
             *          SendKeyUp(_P2_Left_DIK);
             *          P2_Next_Dir = "right";
             *      }
             *      else
             *      {
             *          SendKeyUp(_P2_Right_DIK);
             *          P2_Next_Dir = "left";
             *      }
             *  }
             *  if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
             *  {
             *      SendKeyDown(_P2_Reload_DIK);
             *  }
             *  else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
             *  {
             *      SendKeyUp(_P2_Reload_DIK);
             *  }
             * }*/
        }
コード例 #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 + " ]");

                    //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);
        }
コード例 #3
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8) };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8) };

            if (Player == 1)
            {
                //Write Axis
                WriteBytes(_Controls_Base_Address + _P1_X_Offset, bufferX);
                WriteBytes(_Controls_Base_Address + _P1_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte(_Controls_Base_Address + _P1_LBtn_Offset, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte(_Controls_Base_Address + _P1_LBtn_Offset, 0x00);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    if (_RomName.Equals("bel"))
                    {
                        WriteByte(_Controls_Base_Address + _P1_RBtn_Offset, 0x80);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    if (_RomName.Equals("bel"))
                    {
                        WriteByte(_Controls_Base_Address + _P1_RBtn_Offset, 0x00);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    if (!_RomName.Equals("bel"))
                    {
                        WriteByte(_Controls_Base_Address + _P1_RBtn_Offset, 0x80);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    if (!_RomName.Equals("bel"))
                    {
                        WriteByte(_Controls_Base_Address + _P1_RBtn_Offset, 0x00);
                    }
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes(_Controls_Base_Address + _P2_X_Offset, bufferX);
                WriteBytes(_Controls_Base_Address + _P2_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte(_Controls_Base_Address + _P2_LBtn_Offset, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte(_Controls_Base_Address + _P2_LBtn_Offset, 0x00);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    if (_RomName.Equals("bel"))
                    {
                        WriteByte(_Controls_Base_Address + _P2_RBtn_Offset, 0x80);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    if (_RomName.Equals("bel"))
                    {
                        WriteByte(_Controls_Base_Address + _P2_RBtn_Offset, 0x00);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    if (!_RomName.Equals("bel"))
                    {
                        WriteByte(_Controls_Base_Address + _P2_RBtn_Offset, 0x80);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    if (!_RomName.Equals("bel"))
                    {
                        WriteByte(_Controls_Base_Address + _P2_RBtn_Offset, 0x00);
                    }
                }
            }
        }
コード例 #4
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8), 0, 0 };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8), 0, 0 };

            if (Player == 1)
            {
                //Write Axis
                WriteBytes(_P1_X_Address, bufferX);
                WriteBytes(_P1_Y_Address, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte(_P1_Trigger_Address, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte(_P1_Trigger_Address, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    WriteByte(_P1_Change_Address, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    WriteByte(_P1_Change_Address, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    WriteByte(_P1_Action_Address, 0x80);
                    mouse.pTarget.X = 2000;
                    byte[] bufferX_R = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8), 0, 0 };
                    WriteBytes(_P1_X_Address, bufferX_R);
                    System.Threading.Thread.Sleep(20);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteByte(_P1_Action_Address, 0x00);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes(_P2_X_Address, bufferX);
                WriteBytes(_P2_Y_Address, bufferY);

                //P2 uses keyboard so no autoreload when out of screen, so we add:
                if (mouse.pTarget.X <= 1 || mouse.pTarget.X >= 1022 || mouse.pTarget.Y <= 1 || mouse.pTarget.Y >= 596)
                {
                    if (!P2OutOfScreen)
                    {
                        //SendKeyDown(_P2_Reload_DIK);
                        Send_VK_KeyDown(_P2_Reload_VK);
                        P2OutOfScreen = true;
                    }
                }
                else
                {
                    if (P2OutOfScreen)
                    {
                        //SendKeyUp(_P2_Reload_DIK);
                        Send_VK_KeyUp(_P2_Reload_VK);
                        P2OutOfScreen = false;
                    }
                }

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    //SendKeyDown(_P2_Trigger_DIK);
                    Send_VK_KeyDown(_P2_Trigger_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    //SendKeyUp(_P2_Trigger_DIK);
                    Send_VK_KeyUp(_P2_Trigger_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    //SendKeyDown(_P2_Change_DIK);
                    Send_VK_KeyDown(_P2_Change_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    //SendKeyUp(_P2_Change_DIK);
                    Send_VK_KeyUp(_P2_Change_VK);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    //SendKeyDown(_P2_Reload_DIK);
                    //SendKeyDown(_P2_Action_DIK);
                    Send_VK_KeyDown(_P2_Reload_VK);
                    Send_VK_KeyDown(_P2_Action_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    //SendKeyUp(_P2_Reload_DIK);
                    //SendKeyUp(_P2_Action_DIK);
                    Send_VK_KeyUp(_P2_Reload_VK);
                    Send_VK_KeyUp(_P2_Action_VK);
                }
            }
        }
コード例 #5
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8) };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8) };

            if (Player == 1)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    SendKeyDown(_P1_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    SendKeyUp(_P1_Trigger_DIK);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    //Set out of screen Byte
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P1_OUT_Offset, 0x00);
                    //Trigger a shoot to reload !!
                    SendKeyDown(_P1_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    SendKeyUp(_P1_Trigger_DIK);
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P1_OUT_Offset, 0x01);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    SendKeyDown(_P2_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    SendKeyUp(_P2_Trigger_DIK);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    //Set out of screen Byte
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P2_OUT_Offset, 0x00);
                    //Trigger a shoot to reload !!
                    SendKeyDown(_P2_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    SendKeyUp(_P2_Trigger_DIK);
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P2_OUT_Offset, 0x01);
                }
            }
        }
コード例 #6
0
ファイル: Game_Hod2pc.cs プロジェクト: jbryant32/DemulShooter
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = BitConverter.GetBytes((float)(mouse.pTarget.X));
            byte[] bufferY = BitConverter.GetBytes((float)(mouse.pTarget.Y));

            if (Player == 1)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    Send_VK_KeyDown(_P1_Trigger_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    Send_VK_KeyUp(_P1_Trigger_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    Send_VK_KeyDown(_P1_Reload_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    Send_VK_KeyUp(_P1_Reload_VK);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    Send_VK_KeyDown(_P1_Reload_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    Send_VK_KeyUp(_P1_Reload_VK);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    Send_VK_KeyDown(_P2_Trigger_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    Send_VK_KeyUp(_P2_Trigger_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    Send_VK_KeyDown(_P2_Reload_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    Send_VK_KeyUp(_P2_Reload_VK);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    Send_VK_KeyDown(_P2_Reload_VK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    Send_VK_KeyUp(_P2_Reload_VK);
                }
            }
        }
コード例 #7
0
ファイル: Game_BE.cs プロジェクト: jbryant32/DemulShooter
        public override void SendInput(MouseInfo mouse, int Player)
        {
            if (Player == 1)
            {
                //Setting Values in memory for the Codecave to read it
                byte[] buffer = BitConverter.GetBytes(_P1_X_Value);
                WriteBytes(_P1_X_Address, buffer);
                buffer = BitConverter.GetBytes(_P1_Y_Value);
                WriteBytes(_P1_Y_Address, buffer);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    //Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    //Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, 0xFE);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    //Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, 0x02);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    //Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, 0xFD);
                }
            }
            else if (Player == 2)
            {
                //Setting Values in memory for the Codecave to read it
                byte[] buffer = BitConverter.GetBytes(_P2_X_Value);
                WriteBytes(_P2_X_Address, buffer);
                buffer = BitConverter.GetBytes(_P2_Y_Value);
                WriteBytes(_P2_Y_Address, buffer);


                // Player 2 buttons are simulated by x360kb.ini so we just send needed Keyboard strokes
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    SendKeyDown(_P2_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    SendKeyUp(_P2_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    SendKeyDown(_P2_Reload_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    SendKeyUp(_P2_Reload_DIK);
                }
            }
        }
コード例 #8
0
ファイル: Game_Demul.cs プロジェクト: mpalese79/DemulShooter
        /// <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);
        }
コード例 #9
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8) };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8) };

            if (Player == 1)
            {
                //Write Axis
                WriteBytes(_P1_X_Address, bufferX);
                WriteBytes(_P1_Y_Address, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte(_P1_Trigger_Address, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte(_P1_Trigger_Address, 0x00);
                }

                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    if (_AlternativeGameplay)
                    {
                        WriteByte(_P1_Action_Address, 0x00);
                    }
                    else
                    {
                        WriteByte(_P1_Action_Address, 0x80);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    if (_AlternativeGameplay)
                    {
                        WriteByte(_P1_Action_Address, 0x80);
                    }
                    else
                    {
                        WriteByte(_P1_Action_Address, 0x00);
                    }
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes(_P2_X_Address, bufferX);
                WriteBytes(_P2_Y_Address, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte(_P2_Trigger_Address, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte(_P2_Trigger_Address, 0x00);
                }

                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    if (_AlternativeGameplay)
                    {
                        WriteByte(_P2_Action_Address, 0x00);
                    }
                    else
                    {
                        WriteByte(_P2_Action_Address, 0x80);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    if (_AlternativeGameplay)
                    {
                        WriteByte(_P2_Action_Address, 0x80);
                    }
                    else
                    {
                        WriteByte(_P2_Action_Address, 0x00);
                    }
                }
            }
        }
コード例 #10
0
ファイル: Game_BE_OLD.cs プロジェクト: mpalese79/DemulShooter
        public override void SendInput(MouseInfo mouse, int Player)
        {
            if (Player == 1)
            {
                //Setting Values in memory for the Codecave to read it
                byte[] buffer = BitConverter.GetBytes(_P1_X_Value);
                WriteBytes(_P1_X_Address, buffer);
                buffer = BitConverter.GetBytes(_P1_Y_Value);
                WriteBytes(_P1_Y_Address, buffer);
            }
            else if (Player == 2)
            {
                //Setting Values in memory for the Codecave to read it
                byte[] buffer = BitConverter.GetBytes(_P2_X_Value);
                WriteBytes(_P2_X_Address, buffer);
                buffer = BitConverter.GetBytes(_P2_Y_Value);
                WriteBytes(_P2_Y_Address, buffer);

                //changing the Right Axis Gamepad Value so that the game can update positioning
                //If the game does not detect a right axis change, no update is done !!
                _UnusedRightAnalogX = (short)(-_UnusedRightAnalogX);
                _XOutputManager.SetRAxis_X(_Player2_X360_Gamepad_Port, _UnusedRightAnalogX);


                /*
                 * //Value if [-1; 1] float so we convert to [0,32000] int for Xoutput format
                 * WriteLog("Float P2 X -----> " + _P2_X_Value.ToString());
                 * float fx = (_P2_X_Value + 1.0f) * 16000.0f;
                 * float fy = (_P2_Y_Value + 1.0f) * 16000.0f;
                 * WriteLog("           -----> " + fx.ToString());
                 * short ix = (short)fx;
                 * short iy = (short)fy;
                 * WriteLog("           -----> " + ix.ToString());
                 * buffer = BitConverter.GetBytes(ix);
                 * //WriteBytes(_P2_X_Address+0x30, buffer);
                 */
                //_XOutputManager.SetRAxis_X(_Player2_X360_Gamepad_Port,ix);
                //_XOutputManager.SetRAxis_Y(_Player2_X360_Gamepad_Port, iy);

                //Inputs
                //
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    _XOutputManager.SetButton_R2(_Player2_X360_Gamepad_Port, 0xFF);
                    _XOutputManager.SetButton_A(_Player2_X360_Gamepad_Port, true);  //used to validate in menu
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    _XOutputManager.SetButton_R2(_Player2_X360_Gamepad_Port, 0x00);
                    _XOutputManager.SetButton_A(_Player2_X360_Gamepad_Port, false); //used to validate in menu
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    _XOutputManager.SetButton_B(_Player2_X360_Gamepad_Port, true);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    _XOutputManager.SetButton_B(_Player2_X360_Gamepad_Port, false);
                }
            }
        }
コード例 #11
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8) };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8) };

            if (Player == 1)
            {
                //Write Axis
                WriteBytes(_P1_X_Address, bufferX);
                WriteBytes(_P1_Y_Address, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    SendKeyDown(_P1_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    SendKeyUp(_P1_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    if (P1_Next_Dir.Equals("left"))
                    {
                        SendKeyDown(_P1_Left_DIK);
                    }
                    else
                    {
                        SendKeyDown(_P1_Right_DIK);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    if (P1_Next_Dir.Equals("left"))
                    {
                        SendKeyUp(_P1_Left_DIK);
                        P1_Next_Dir = "right";
                    }
                    else
                    {
                        SendKeyUp(_P1_Right_DIK);
                        P1_Next_Dir = "left";
                    }
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    SendKeyDown(_P1_Reload_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    SendKeyUp(_P1_Reload_DIK);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes(_P2_X_Address, bufferX);
                WriteBytes(_P2_Y_Address, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    SendKeyDown(_P2_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    SendKeyUp(_P2_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    if (P2_Next_Dir.Equals("left"))
                    {
                        SendKeyDown(_P2_Left_DIK);
                    }
                    else
                    {
                        SendKeyDown(_P2_Right_DIK);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    if (P2_Next_Dir.Equals("left"))
                    {
                        SendKeyUp(_P2_Left_DIK);
                        P2_Next_Dir = "right";
                    }
                    else
                    {
                        SendKeyUp(_P2_Right_DIK);
                        P2_Next_Dir = "left";
                    }
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    SendKeyDown(_P2_Reload_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    SendKeyUp(_P2_Reload_DIK);
                }
            }
        }
コード例 #12
0
 /// <summary>
 /// Convert screen location of pointer to Client area location
 /// This game does not return a MainWindow Handle
 /// This game does not work in windowed mode
 /// So we keep screen resolution data
 /// </summary>
 public override bool ClientScale(MouseInfo mouse)
 {
     return(true);
 }
コード例 #13
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8) };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8) };

            if (Player == 1)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_BTN_Offset, 0x10);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_BTN_Offset, 0xEF);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_BTN_Offset, 0x20);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_BTN_Offset, 0xDF);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_BTN_Offset, 0x40);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_BTN_Offset, 0xBF);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P2_BTN_Offset, 0x10);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P2_BTN_Offset, 0xEF);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P2_BTN_Offset, 0x20);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P2_BTN_Offset, 0xDF);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P2_BTN_Offset, 0x40);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P2_BTN_Offset, 0xBF);
                }
            }
        }
コード例 #14
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] buffer = { (byte)(mouse.pTarget.X >> 8), (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.Y >> 8), (byte)(mouse.pTarget.Y & 0xFF) };
            if (Player == 1)
            {
                //Write Axis
                WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_X_Offset, buffer);
                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P1_Fire_Button_Offset, 0xFB);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P1_Fire_Button_Offset, 0xFF);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    /* For Sprtshot, we force offscreen shoot for reload */
                    if (_RomName.Equals("sprtshot"))
                    {
                        buffer[0] = (byte)(0);
                        buffer[1] = (byte)(0);
                        buffer[2] = (byte)(0);
                        buffer[3] = (byte)(0);
                        WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_X_Offset, buffer);
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P1_Fire_Button_Offset, 0xFB);
                        System.Threading.Thread.Sleep(50);
                    }
                    else
                    {
                        //Read Value and set Bit 2 to 0
                        byte val = ReadByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P1_Start_Button_Offset);
                        val = (byte)(val & 0xFB);
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P1_Start_Button_Offset, val);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    if (_RomName.Equals("sprtshot"))
                    {
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P1_Fire_Button_Offset, 0xFF);
                    }
                    else
                    {
                        //Read Value and set Bit 2 to 1
                        byte val = ReadByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P1_Start_Button_Offset);
                        val = (byte)(val | 0x04);
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P1_Start_Button_Offset, val);
                    }
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_X_Offset, buffer);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P2_Fire_Button_Offset, 0xFB);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P2_Fire_Button_Offset, 0xFF);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    /* For Sprtshot, we force offscreen shoot for reload */
                    if (_RomName.Equals("sprtshot"))
                    {
                        buffer[0] = (byte)(0);
                        buffer[1] = (byte)(0);
                        buffer[2] = (byte)(0);
                        buffer[3] = (byte)(0);
                        WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_X_Offset, buffer);
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P2_Fire_Button_Offset, 0xFB);
                        System.Threading.Thread.Sleep(50);
                    }
                    else
                    {
                        //Read Value and set Bit 2 to 0
                        byte val = ReadByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P2_Start_Button_Offset);
                        val = (byte)(val & 0xFB);
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P2_Start_Button_Offset, val);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    if (_RomName.Equals("sprtshot"))
                    {
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P2_Fire_Button_Offset, 0xFF);
                    }
                    else
                    {
                        //Read Value and set Bit 2 to 1
                        byte val = ReadByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P2_Start_Button_Offset);
                        val = (byte)(val | 0x04);
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_Aw_P2_Start_Button_Offset, val);
                    }
                }
            }
        }
コード例 #15
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8) };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8) };

            if (Player == 1)
            {
                //Write Axis
                WriteByte((int)_TargetProcess_MemoryBaseAddress + _P1_X_Offset, bufferX[0]);
                WriteByte((int)_TargetProcess_MemoryBaseAddress + _P1_Y_Offset, bufferY[0]);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask(_P1_CustomButtons_Address, 0x02);
                    System.Threading.Thread.Sleep(20);
                    Apply_AND_ByteMask(_P1_CustomButtons_Address, 0xFD);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    Apply_AND_ByteMask(_P1_CustomButtons_Address, 0xFD);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess.MainModule.BaseAddress + _P1_Buttons_Offset, 0x02);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess.MainModule.BaseAddress + _P1_Buttons_Offset, 0xFD);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask(_P1_CustomButtons_Address, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    Apply_AND_ByteMask(_P1_CustomButtons_Address, 0xFE);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteByte((int)_TargetProcess_MemoryBaseAddress + _P2_X_Offset, (byte)(mouse.pTarget.X & 0xFF));
                WriteByte((int)_TargetProcess_MemoryBaseAddress + _P2_Y_Offset, (byte)(mouse.pTarget.Y & 0xFF));

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask(_P2_CustomButtons_Address, 0x02);
                    System.Threading.Thread.Sleep(20);
                    Apply_AND_ByteMask(_P2_CustomButtons_Address, 0xFD);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    Apply_AND_ByteMask(_P2_CustomButtons_Address, 0xFD);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess.MainModule.BaseAddress + _P2_Buttons_Offset, 0x02);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess.MainModule.BaseAddress + _P2_Buttons_Offset, 0xFD);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask(_P2_CustomButtons_Address, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    Apply_AND_ByteMask(_P2_CustomButtons_Address, 0xFE);
                }
            }
        }
コード例 #16
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);
        }
コード例 #17
0
ファイル: Game_Reload.cs プロジェクト: mpalese79/DemulShooter
        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);
        }
コード例 #18
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = BitConverter.GetBytes(mouse.pTarget.X);
            byte[] bufferY = BitConverter.GetBytes(mouse.pTarget.Y);

            if (Player == 1)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    byte b = ReadByte((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset);
                    b |= 0x01;
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, b);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    byte b = ReadByte((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset);
                    b &= 0xFE;
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, b);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    byte b = ReadByte((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset);
                    b |= 0x02;
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, b);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    byte b = ReadByte((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset);
                    b &= 0xFD;
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, b);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    byte b = ReadByte((int)_TargetProcess_MemoryBaseAddress + _P2_Buttons_Offset);
                    b |= 0x01;
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P2_Buttons_Offset, b);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    byte b = ReadByte((int)_TargetProcess_MemoryBaseAddress + _P2_Buttons_Offset);
                    b &= 0xFE;
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P2_Buttons_Offset, b);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    byte b = ReadByte((int)_TargetProcess_MemoryBaseAddress + _P2_Buttons_Offset);
                    b |= 0x02;
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P2_Buttons_Offset, b);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    byte b = ReadByte((int)_TargetProcess_MemoryBaseAddress + _P2_Buttons_Offset);
                    b &= 0xFD;
                    WriteByte((int)_TargetProcess_MemoryBaseAddress + _P2_Buttons_Offset, b);
                }
            }
        }
コード例 #19
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            if (Player == 1)
            {
                WriteByte(_Base_Player_Data_Address + P1_X_OFFSET, (byte)mouse.pTarget.X);
                WriteByte(_Base_Player_Data_Address + P1_Y_OFFSET, (byte)mouse.pTarget.Y);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte(_Base_Player_Data_Address + P1_TRIGGER_OFFSET, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte(_Base_Player_Data_Address + P1_TRIGGER_OFFSET, 0x00);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    WriteByte(_Base_Player_Data_Address + P1_WPNBTN_OFFSET, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    WriteByte(_Base_Player_Data_Address + P1_WPNBTN_OFFSET, 0x00);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    WriteByte(_Base_Player_Data_Address + P1_RELOAD_OFFSET, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteByte(_Base_Player_Data_Address + P1_RELOAD_OFFSET, 0x00);
                }
            }
            else if (Player == 2)
            {
                WriteByte(_Base_Player_Data_Address + P2_X_OFFSET, (byte)mouse.pTarget.X);
                WriteByte(_Base_Player_Data_Address + P2_Y_OFFSET, (byte)mouse.pTarget.Y);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte(_Base_Player_Data_Address + P2_TRIGGER_OFFSET, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte(_Base_Player_Data_Address + P2_TRIGGER_OFFSET, 0x00);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    WriteByte(_Base_Player_Data_Address + P2_WPNBTN_OFFSET, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    WriteByte(_Base_Player_Data_Address + P2_WPNBTN_OFFSET, 0x00);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    WriteByte(_Base_Player_Data_Address + P2_RELOAD_OFFSET, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteByte(_Base_Player_Data_Address + P2_RELOAD_OFFSET, 0x00);
                }
            }
        }
コード例 #20
0
        public override bool GameScale(MouseInfo Mouse, int Player)
        {
            if (_ProcessHandle != IntPtr.Zero)
            {
                try
                {
                    double dMaxX = 1280.0;
                    double dMaxY = 480.0;

                    if (_RomName.Equals("gsoz2p"))
                    {
                        //Side by Side dual screen, each one 640x480 max coordonates
                        //So total X is 1280
                        Mouse.pTarget.X = Convert.ToInt16(Math.Round(dMaxX * Mouse.pTarget.X / _screenWidth));

                        //For Y we need to change reference from Screen[X, Y] to real Game [X, Y] with black border;
                        double Ratio = _screenWidth / dMaxX;
                        WriteLog("Ratio = " + Ratio.ToString());
                        double GameHeight = Ratio * dMaxY;
                        WriteLog("Real game height (px) = " + GameHeight);
                        double Border = (_screenHeight - GameHeight) / 2.0;
                        WriteLog("Black boder top and bottom (px) = " + Border.ToString());
                        double y       = Mouse.pTarget.Y - Border;
                        double percent = y * 100.0 / GameHeight;
                        Mouse.pTarget.Y = (int)(percent * dMaxY / 100.0);

                        //Player One will have X value cut-off to [0-639] next
                        //For player 2 we first shift value to the left
                        if (Player == 2)
                        {
                            Mouse.pTarget.X -= 640;
                        }
                    }
                    else if (_RomName.Equals("gsoz"))
                    {
                        //Single screen, each one 640x480 max coordonates
                        //So total Y is 480
                        Mouse.pTarget.Y = Convert.ToInt16(Math.Round(dMaxY * Mouse.pTarget.Y / _screenHeight));

                        //For X we need to change reference from Screen[X, Y] to real Game [X, Y] with black border
                        dMaxX = 640.0;

                        double Ratio = _screenHeight / dMaxY;
                        WriteLog("Ratio = " + Ratio.ToString());
                        double GameWidth = Ratio * dMaxX;
                        WriteLog("Real game width (px) = " + GameWidth);
                        double Border = (_screenWidth - GameWidth) / 2.0;
                        WriteLog("Black boder left and right (px) = " + Border.ToString());
                        double x       = Mouse.pTarget.X - Border;
                        double percent = x * 100.0 / GameWidth;
                        Mouse.pTarget.X = (int)(percent * dMaxX / 100.0);
                    }

                    if (Mouse.pTarget.X < 1)
                    {
                        Mouse.pTarget.X = 1;
                    }
                    if (Mouse.pTarget.X > 639)
                    {
                        Mouse.pTarget.X = 639;
                    }
                    if (Mouse.pTarget.Y < 1)
                    {
                        Mouse.pTarget.Y = 1;
                    }
                    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);
        }
コード例 #21
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] buffer = { (byte)(mouse.pTarget.X >> 8), (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.Y >> 8), (byte)(mouse.pTarget.Y & 0xFF) };
            if (Player == 1)
            {
                //Write Axis
                WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_X_Offset, buffer);
                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x02);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset + 2, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset + 2, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x00);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_X_Offset, buffer);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x02);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset + 2, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset + 2, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x00);
                }
            }
        }
コード例 #22
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8) };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8) };

            if (Player == 1)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Trigger_Offset, new byte[] { 0x01, 0x01, 0x00 });
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Trigger_Offset, new byte[] { 0x00, 0x00, 0x01 });
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_WeaponChange_Offset, new byte[] { 0x01, 0x01, 0x00 });
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_WeaponChange_Offset, new byte[] { 0x00, 0x00, 0x01 });
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    //With "Pedal mode", enable right-click to shoot only when hiding
                    if (_Pedal1_Enable != 0)
                    {
                        if (!_isPedal1_Pushed)
                        {
                            WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Trigger_Offset, new byte[] { 0x01, 0x01, 0x00 });
                        }
                    }
                    else
                    {
                        WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Trigger_Offset, new byte[] { 0x01, 0x01, 0x00 });
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P1_Trigger_Offset, new byte[] { 0x00, 0x00, 0x01 });
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_X_Offset, bufferX);
                WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Trigger_Offset, new byte[] { 0x01, 0x01, 0x00 });
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Trigger_Offset, new byte[] { 0x00, 0x00, 0x01 });
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_WeaponChange_Offset, new byte[] { 0x01, 0x01, 0x00 });
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_WeaponChange_Offset, new byte[] { 0x00, 0x00, 0x01 });
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    //With "Pedal mode", enable right-click to shoot only when hiding
                    if (_Pedal2_Enable != 0)
                    {
                        if (!_isPedal2_Pushed)
                        {
                            WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Trigger_Offset, new byte[] { 0x01, 0x01, 0x00 });
                        }
                    }
                    else
                    {
                        WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Trigger_Offset, new byte[] { 0x01, 0x01, 0x00 });
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteBytes((int)_TargetProcess_MemoryBaseAddress + _P2_Trigger_Offset, new byte[] { 0x00, 0x00, 0x01 });
                }
            }
        }
コード例 #23
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            if (Player == 1)
            {
                //Setting Values in memory for the Codecave to read it
                byte[] buffer = BitConverter.GetBytes(_P1_X_Value);
                WriteBytes(_P1_X_Address, buffer);
                buffer = BitConverter.GetBytes(_P1_Y_Value);
                WriteBytes(_P1_Y_Address, buffer);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, 0x01);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, 0xFE);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    //If the player is aiming on the left side of the screen before pressing the button
                    //=> Cover Left
                    if (_P1_X_Value < _Axis_X_Min + _CoverDelta)
                    {
                        Send_VK_KeyDown(_P1_CoverLeft_VK);
                        _CoverLeftEnabled = true;
                    }
                    //If the player is aiming on the bottom side of the screen before pressing the button
                    //=> Cover Down
                    else if (_P1_Y_Value > (1.0f - _CoverDelta))
                    {
                        Send_VK_KeyDown(_P1_CoverBottom_VK);
                        _CoverBottomEnabled = true;
                    }
                    //If the player is aiming on the right side of the screen before pressing the button
                    //=> Cover Right
                    else if (_P1_X_Value > _Axis_X_Max - _CoverDelta)
                    {
                        Send_VK_KeyDown(_P1_CoverRight_VK);
                        _CoverRightEnabled = true;
                    }
                    //If the player is aiming on the top side of the screen before pressing the button
                    //=> W [QTE]
                    else if (_P1_Y_Value < (-1.0f + _CoverDelta))
                    {
                        Send_VK_KeyDown(_P1_QTE_W_VK);
                        _QTE_W_Enabled = true;
                    }
                    //If nothing above
                    //=> Spacebar [QTE]
                    else
                    {
                        Send_VK_KeyDown(_P1_QTE_Space_VK);
                        _QTE_Spacebar_Enabled = true;
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    if (_CoverLeftEnabled)
                    {
                        Send_VK_KeyUp(_P1_CoverLeft_VK);
                        _CoverLeftEnabled = false;
                    }
                    if (_CoverBottomEnabled)
                    {
                        Send_VK_KeyUp(_P1_CoverBottom_VK);
                        _CoverBottomEnabled = false;
                    }
                    if (_CoverRightEnabled)
                    {
                        Send_VK_KeyUp(_P1_CoverRight_VK);
                        _CoverRightEnabled = false;
                    }
                    if (_QTE_W_Enabled)
                    {
                        Send_VK_KeyUp(_P1_QTE_W_VK);
                        _QTE_W_Enabled = false;
                    }
                    if (_QTE_Spacebar_Enabled)
                    {
                        Send_VK_KeyUp(_P1_QTE_Space_VK);
                        _QTE_Spacebar_Enabled = false;
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    Apply_OR_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, 0x02);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    Apply_AND_ByteMask((int)_TargetProcess_MemoryBaseAddress + _P1_Buttons_Offset, 0xFD);
                }
            }
            else if (Player == 2)
            {
                //Setting Values in memory for the Codecave to read it
                byte[] buffer = BitConverter.GetBytes(_P2_X_Value);
                WriteBytes(_P2_X_Address, buffer);
                buffer = BitConverter.GetBytes(_P2_Y_Value);
                WriteBytes(_P2_Y_Address, buffer);


                // Player 2 buttons are simulated by x360kb.ini so we just send needed Keyboard strokes
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    SendKeyDown(_P2_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    SendKeyUp(_P2_Trigger_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    if (_P2_X_Value < _Axis_X_Min + _CoverDelta)
                    {
                        SendKeyDown(_P2_CoverLeft_DIK);
                    }
                    else if (_P2_Y_Value > (1.0f - _CoverDelta))
                    {
                        SendKeyDown(_P2_CoverDown_DIK);
                    }
                    else if (_P2_X_Value > _Axis_X_Max - _CoverDelta)
                    {
                        SendKeyDown(_P2_CoverRight_DIK);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    SendKeyUp(_P2_CoverLeft_DIK);
                    SendKeyUp(_P2_CoverDown_DIK);
                    SendKeyUp(_P2_CoverRight_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    SendKeyDown(_P2_Reload_DIK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    SendKeyUp(_P2_Reload_DIK);
                }
            }
        }
コード例 #24
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);
        }
コード例 #25
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            if (Player == 1 && _KeybMouse_BaseAddress != 0)
            {
                double fX      = (double)mouse.pTarget.X / (double)1000;
                double fY      = (double)mouse.pTarget.Y / (double)1000;
                byte[] bufferX = BitConverter.GetBytes(fX);
                byte[] bufferY = BitConverter.GetBytes(fY);

                //Write Axis
                WriteBytes(_KeybMouse_BaseAddress + _KeybMouse_X_Offset, bufferX);
                WriteBytes(_KeybMouse_BaseAddress + _KeybMouse_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte(_KeybMouse_BaseAddress + _KeybMouse_LBTN_Offset, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte(_KeybMouse_BaseAddress + _KeybMouse_LBTN_Offset, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    WriteByte(_KeybMouse_BaseAddress + _KeybMouse_MBTN_Offset, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    WriteByte(_KeybMouse_BaseAddress + _KeybMouse_MBTN_Offset, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    WriteByte(_KeybMouse_BaseAddress + _KeybMouse_RBTN_Offset, 0x80);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteByte(_KeybMouse_BaseAddress + _KeybMouse_RBTN_Offset, 0x00);
                }
            }
            else if (Player == 2 && _ATRAK_BaseAddress != 00)
            {
                //Converting 0xFF80 to 0xFFFFFF80 and so on...
                byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8), (byte)(mouse.pTarget.X >> 8), (byte)(mouse.pTarget.X >> 8) };
                byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8), (byte)(mouse.pTarget.Y >> 8), (byte)(mouse.pTarget.Y >> 8) };

                //Write Axis
                WriteBytes(_ATRAK_BaseAddress + _ATRAK_X_Offset, bufferX);
                WriteBytes(_ATRAK_BaseAddress + _ATRAK_Y_Offset, bufferY);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    SendKeyDown(DIK_KEY_LCLICK);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    SendKeyUp(DIK_KEY_LCLICK);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
                {
                    SendKeyDown(DIK_KEY_MCLICK);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
                {
                    SendKeyUp(DIK_KEY_MCLICK);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    SendKeyDown(DIK_KEY_RCLICK);
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    SendKeyUp(DIK_KEY_RCLICK);
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// For this one, P2 is totally disabled in Demul emulation
        /// Coordinates by player are 2x2bytes, encoded on 3 bytes. So we have to recreate the encoding to inject it on the IO board emulation
        /// The total output is : 6 bytes containing Buttons+X+Y for each players
        /// </summary>
        public override void SendInput(MouseInfo mouse, int Player)
        {
            int Data = 0;
            int CurrentBtnStatus;

            if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
            {
                _Btn_Status[Player - 1] |= 1;
            }
            else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
            {
                _Btn_Status[Player - 1]   &= 0xE;
                _TriggerPushed[Player - 1] = 0;
                _TimerHoldTrigger[Player - 1].Stop();
            }
            else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN)
            {
                _Btn_Status[Player - 1] |= 2;
            }
            else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP)
            {
                _Btn_Status[Player - 1] &= 0xD;
            }

            Data  = _Btn_Status[Player - 1];
            Data &= 0x01;
            Data  = ~Data + 1;
            Data &= 0x00000C00;

            CurrentBtnStatus = _Btn_Status[Player - 1];
            if ((CurrentBtnStatus & 0x01) != 0)
            {
                if (_TriggerPushed[Player - 1] == 0)
                {
                    _TimerHoldTrigger[Player - 1].Start();
                }
                else
                {
                    CurrentBtnStatus &= 0xFE;
                }
            }

            CurrentBtnStatus = CurrentBtnStatus << 0x0C;
            Data            |= CurrentBtnStatus;
            Data            |= mouse.pTarget.Y;
            Data             = Data << 0xA;
            Data            |= mouse.pTarget.X;

            byte[] buffer = BitConverter.GetBytes(Data);

            if (Player == 1)
            {
                WriteByte(_P1_Data, buffer[0]);
                WriteByte(_P1_Data + 1, buffer[1]);
                WriteByte(_P1_Data + 2, buffer[2]);
            }
            else if (Player == 2)
            {
                WriteByte(_P2_Data, buffer[0]);
                WriteByte(_P2_Data + 1, buffer[1]);
                WriteByte(_P2_Data + 2, buffer[2]);
            }
        }
コード例 #27
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);
        }
コード例 #28
0
ファイル: Game.cs プロジェクト: MrLightgun/DemulShooter
 public virtual void SendInput(MouseInfo mouse, int Player)
 {
 }
コード例 #29
0
        public override void  SendInput(MouseInfo mouse, int Player)
        {
            //creating X-Y Hex value buffer to write memory
            byte[] buffer = { (byte)(mouse.pTarget.X >> 8), (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.Y >> 8), (byte)(mouse.pTarget.Y & 0xFF) };

            if (Player == 1)
            {
                //Write Axis
                WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_X_Offset, buffer);
                //Inputs
                //pokasuka is special, needs other values
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x02);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    //lupinsho reloads only when cursor get to max value ( = out of window) so we force it for Gun who don't update in realtime
                    if (_RomName.Equals("lupinsho"))
                    {
                        buffer[0] = (byte)(0);
                        buffer[1] = (byte)(0xFF);
                        buffer[2] = (byte)(0);
                        buffer[3] = (byte)(0xFF);
                        WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_X_Offset, buffer);
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x01);
                        System.Threading.Thread.Sleep(50);
                    }
                    else
                    {
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x01);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P1_Buttons_Offset, 0x00);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_X_Offset, buffer);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x02);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x00);
                }
                if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    //lupinsho reloads only when cursor get to max value ( = out of window) so we force it for Gun who don't update in realtime
                    if (_RomName.Equals("lupinsho"))
                    {
                        buffer[0] = (byte)(0);
                        buffer[1] = (byte)(0xFF);
                        buffer[2] = (byte)(0);
                        buffer[3] = (byte)(0xFF);
                        WriteBytes((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_X_Offset, buffer);
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x01);
                    }
                    else
                    {
                        WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x01);
                    }
                }
                else if (mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    WriteByte((int)_PadDemul_ModuleBaseAddress + _Paddemul_P2_Buttons_Offset, 0x00);
                }
            }
        }
コード例 #30
0
        public override void SendInput(MouseInfo mouse, int Player)
        {
            byte[] bufferX = { (byte)(mouse.pTarget.X & 0xFF), (byte)(mouse.pTarget.X >> 8) };
            byte[] bufferY = { (byte)(mouse.pTarget.Y & 0xFF), (byte)(mouse.pTarget.Y >> 8) };

            if (Player == 1)
            {
                //Write Axis
                WriteByte(_Data_Base_Address + _P1_X_Offset, bufferX[0]);
                WriteByte(_Data_Base_Address + _P1_Y_Offset, bufferY[0]);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    byte b = ReadByte(_Data_Base_Address + _P1_Buttons_Offset);
                    b |= 0x02;
                    WriteByte(_Data_Base_Address + _P1_Buttons_Offset, b);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    byte b = ReadByte(_Data_Base_Address + _P1_Buttons_Offset);
                    b &= 0xFD;
                    WriteByte(_Data_Base_Address + _P1_Buttons_Offset, b);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN || mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    byte b = ReadByte(_Data_Base_Address + _P1_Buttons_Offset);
                    b |= 0x01;
                    WriteByte(_Data_Base_Address + _P1_Buttons_Offset, b);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP || mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    byte b = ReadByte(_Data_Base_Address + _P1_Buttons_Offset);
                    b &= 0xFE;
                    WriteByte(_Data_Base_Address + _P1_Buttons_Offset, b);
                }
            }
            else if (Player == 2)
            {
                //Write Axis
                WriteByte(_Data_Base_Address + _P2_X_Offset, bufferX[0]);
                WriteByte(_Data_Base_Address + _P2_Y_Offset, bufferY[0]);

                //Inputs
                if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_DOWN)
                {
                    byte b = ReadByte(_Data_Base_Address + _P2_Buttons_Offset);
                    b |= 0x02;
                    WriteByte(_Data_Base_Address + _P2_Buttons_Offset, b);
                }
                else if (mouse.button == Win32.RI_MOUSE_LEFT_BUTTON_UP)
                {
                    byte b = ReadByte(_Data_Base_Address + _P2_Buttons_Offset);
                    b &= 0xFD;
                    WriteByte(_Data_Base_Address + _P2_Buttons_Offset, b);
                }
                if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_DOWN || mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_DOWN)
                {
                    byte b = ReadByte(_Data_Base_Address + _P2_Buttons_Offset);
                    b |= 0x01;
                    WriteByte(_Data_Base_Address + _P2_Buttons_Offset, b);
                }
                else if (mouse.button == Win32.RI_MOUSE_MIDDLE_BUTTON_UP || mouse.button == Win32.RI_MOUSE_RIGHT_BUTTON_UP)
                {
                    byte b = ReadByte(_Data_Base_Address + _P2_Buttons_Offset);
                    b &= 0xFE;
                    WriteByte(_Data_Base_Address + _P2_Buttons_Offset, b);
                }
            }
        }