Skip to content

Commit

Permalink
v11.0 update
Browse files Browse the repository at this point in the history
  • Loading branch information
argonlefou committed Jul 2, 2023
1 parent 2b80d8a commit 3dc55b9
Show file tree
Hide file tree
Showing 77 changed files with 1,999 additions and 748 deletions.
1 change: 1 addition & 0 deletions DemulShooter/DemulShooter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<Compile Include="Games\Game_LindberghLgjsp.cs" />
<Compile Include="Games\Game_RtAliensArmageddon.cs" />
<Compile Include="Games\Game_RtTerminatorSalvation.cs" />
<Compile Include="Games\Game_TtxGundam_V2.cs" />
<Compile Include="Games\Game_WndFriction.cs" />
<Compile Include="Games\Game_Model2Vcop.cs" />
<Compile Include="Games\Game_Model2Hotd.cs" />
Expand Down
136 changes: 97 additions & 39 deletions DemulShooter/DemulShooterWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class DemulShooterWindow : ApplicationContext
private bool _HardFfl = false;
private double _ForceScalingX = 1.0;
private bool _NoInput = false;
//private bool _UseSingleMouse = true;
private bool _UseSingleMouse = false;

//InterProcessCommunication (Memory Mapped Files)
private const String DEMULSHOOTER_INPUTS_MMF_NAME = "DemulShooter_MMF_Inputs";
Expand Down Expand Up @@ -168,6 +168,10 @@ public DemulShooterWindow(string[] Args, bool isVerbose)
_DemulVersion = _Target.Substring(5, 3);
}
}
else if (Args[i].ToLower().Equals("-usesinglemouse"))
{
_UseSingleMouse = true;
}
else if (Args[i].ToLower().Equals("-widescreen"))
{
_WidescreenHack = true;
Expand Down Expand Up @@ -565,11 +569,14 @@ public DemulShooterWindow(string[] Args, bool isVerbose)
} break;
case "gsoz":
{
_Game = new Game_TtxGundam(_Rom.ToLower(), _Configurator.Gsoz_Pedal_P1_Enabled, _Configurator.DIK_Gsoz_Pedal_P1, _Configurator.Gsoz_Pedal_P2_Enabled, _Configurator.DIK_Gsoz_Pedal_P2, _NoInput, isVerbose);
_Game = new Game_TtxGundam_V2(_Rom.ToLower(), _Configurator, _NoInput, isVerbose);
} break;
case "gsoz2p":
{
_Game = new Game_TtxGundam(_Rom.ToLower(), _Configurator.Gsoz_Pedal_P1_Enabled, _Configurator.DIK_Gsoz_Pedal_P1, _Configurator.Gsoz_Pedal_P2_Enabled, _Configurator.DIK_Gsoz_Pedal_P2, _NoInput, isVerbose);
//_Game = new Game_TtxGundam(_Rom.ToLower(), _Configurator.Gsoz_Pedal_P1_Enabled, _Configurator.DIK_Gsoz_Pedal_P1, _Configurator.Gsoz_Pedal_P2_Enabled, _Configurator.DIK_Gsoz_Pedal_P2, _NoInput, isVerbose);
_Game = new Game_TtxGundam_V2(_Rom.ToLower(), _Configurator, _NoInput, isVerbose);


} break;
case "hmuseum":
{
Expand Down Expand Up @@ -751,11 +758,13 @@ private IntPtr myWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
case Win32Define.WM_INPUT:
{
ProcessRawInputMessage(lParam);
}break;
}
break;

default:
break;
}

return Win32API.DefWindowProc(hWnd, msg, wParam, lParam);
}

Expand Down Expand Up @@ -783,38 +792,62 @@ private void ProcessRawInputMessage(IntPtr RawInputHandle)

Logger.WriteLog("RawData event for Player #" + Player.ID.ToString() + ":");
Logger.WriteLog("Device rawinput data (Hex) = [ " + Player.RIController.Computed_X.ToString("X8") + ", " + Player.RIController.Computed_Y.ToString("X8") + " ]");

//Overrriding RAWINPUT data (relative movement) for single mouse by a call to GetCursorPos WIN32 API
//That way we can get mouse position as if it's Absolute position
if (_UseSingleMouse)
{
Logger.WriteLog("Switching to Single Mouse procedure :");
POINT p = new POINT();
if (Win32API.GetCursorPos(out p))
{
Logger.WriteLog("WM_MOUSEMOVE Cursor position = [ " + p.X + "," + p.Y + " ]");
Player.RIController.Computed_X = p.X;
Player.RIController.Computed_Y = p.Y;
Logger.WriteLog("OnScreen Cursor Position (Px) = [ " + Player.RIController.Computed_X + ", " + Player.RIController.Computed_Y + " ]");
}
else
{
Logger.WriteLog("WM_MOUSEMOVE : GetCursorPos() returned error");
return;
}
}

if (_EnableInputsIpc)
_MMF_Inputs.UpdateRawPlayerData(Player.ID, (UInt32)Player.RIController.Computed_X, (UInt32)Player.RIController.Computed_Y);

_Game.GetScreenResolution();
Logger.WriteLog("PrimaryScreen Size (Px) = [ " + _Game.ScreenWidth + "x" + _Game.ScreenHeight + " ]");

//If manual calibration override for analog guns
if (Player.RIController.DeviceType == RawInputDeviceType.RIM_TYPEHID && Player.AnalogAxisRangeOverride)
{
Logger.WriteLog("Overriding player axis range values : X => [ " + Player.AnalogManual_Xmin.ToString() + ", " + Player.AnalogManual_Xmax.ToString() + " ], Y => [ " + Player.AnalogManual_Ymin.ToString() + ", " + Player.AnalogManual_Ymax.ToString() + " ]");
Player.RIController.Computed_X = _Game.ScreenScale(Player.RIController.Computed_X, Player.AnalogManual_Xmin, Player.AnalogManual_Xmax, 0, _Game.ScreenWidth);
Player.RIController.Computed_Y = _Game.ScreenScale(Player.RIController.Computed_Y, Player.AnalogManual_Ymin, Player.AnalogManual_Ymax, 0, _Game.ScreenHeight);
}
else
{
Player.RIController.Computed_X = _Game.ScreenScale(Player.RIController.Computed_X, Player.RIController.Axis_X_Min, Player.RIController.Axis_X_Max, 0, _Game.ScreenWidth);
Player.RIController.Computed_Y = _Game.ScreenScale(Player.RIController.Computed_Y, Player.RIController.Axis_Y_Min, Player.RIController.Axis_Y_Max, 0, _Game.ScreenHeight);
}

//Optionnal invert axis
if (Player.InvertAxis_X)
Player.RIController.Computed_X = _Game.ScreenWidth - Player.RIController.Computed_X;
if (Player.InvertAxis_Y)
Player.RIController.Computed_Y = _Game.ScreenHeight - Player.RIController.Computed_Y;

Logger.WriteLog("OnScreen Cursor Position (Px) = [ " + Player.RIController.Computed_X + ", " + Player.RIController.Computed_Y + " ]");

if (_Configurator.Act_Labs_Offset_Enable)
if (!_UseSingleMouse)
{
Player.RIController.Computed_X += Player.Act_Labs_Offset_X;
Player.RIController.Computed_Y += Player.Act_Labs_Offset_Y;
Logger.WriteLog("ActLabs adaptated OnScreen Cursor Position (Px) = [ " + Player.RIController.Computed_X + ", " + Player.RIController.Computed_Y + " ]");
//If manual calibration override for analog guns
if (Player.RIController.DeviceType == RawInputDeviceType.RIM_TYPEHID && Player.AnalogAxisRangeOverride)
{
Logger.WriteLog("Overriding player axis range values : X => [ " + Player.AnalogManual_Xmin.ToString() + ", " + Player.AnalogManual_Xmax.ToString() + " ], Y => [ " + Player.AnalogManual_Ymin.ToString() + ", " + Player.AnalogManual_Ymax.ToString() + " ]");
Player.RIController.Computed_X = _Game.ScreenScale(Player.RIController.Computed_X, Player.AnalogManual_Xmin, Player.AnalogManual_Xmax, 0, _Game.ScreenWidth);
Player.RIController.Computed_Y = _Game.ScreenScale(Player.RIController.Computed_Y, Player.AnalogManual_Ymin, Player.AnalogManual_Ymax, 0, _Game.ScreenHeight);
}
else
{
Player.RIController.Computed_X = _Game.ScreenScale(Player.RIController.Computed_X, Player.RIController.Axis_X_Min, Player.RIController.Axis_X_Max, 0, _Game.ScreenWidth);
Player.RIController.Computed_Y = _Game.ScreenScale(Player.RIController.Computed_Y, Player.RIController.Axis_Y_Min, Player.RIController.Axis_Y_Max, 0, _Game.ScreenHeight);
}

//Optionnal invert axis
if (Player.InvertAxis_X)
Player.RIController.Computed_X = _Game.ScreenWidth - Player.RIController.Computed_X;
if (Player.InvertAxis_Y)
Player.RIController.Computed_Y = _Game.ScreenHeight - Player.RIController.Computed_Y;

Logger.WriteLog("OnScreen Cursor Position (Px) = [ " + Player.RIController.Computed_X + ", " + Player.RIController.Computed_Y + " ]");

if (_Configurator.Act_Labs_Offset_Enable)
{
Player.RIController.Computed_X += Player.Act_Labs_Offset_X;
Player.RIController.Computed_Y += Player.Act_Labs_Offset_Y;
Logger.WriteLog("ActLabs adaptated OnScreen Cursor Position (Px) = [ " + Player.RIController.Computed_X + ", " + Player.RIController.Computed_Y + " ]");
}
}

//Change X asxis scaling based on user requirements
Expand All @@ -827,24 +860,49 @@ private void ProcessRawInputMessage(IntPtr RawInputHandle)
Logger.WriteLog("Forced scaled OnScreen Cursor Position (Px) = [ " + Player.RIController.Computed_X + ", " + Player.RIController.Computed_Y + " ]");
}

if (!_Game.ClientScale(Player))
_Game.IsFullscreen = _Game.GetFullscreenStatus();
if (!_Game.IsFullscreen)
{
Logger.WriteLog("Error converting screen location to client location");
return;
Logger.WriteLog("ClientWindow Style = Windowed");

//Retrieve info for debug/replay purpose
_Game.GetClientwindowInfo();

if (!_Game.ClientScale(Player))
{
Logger.WriteLog("Error converting screen location to client location");
return;
}
Logger.WriteLog("ClientWindow Location (px) = [ " + _Game.clientWindowLocation.X.ToString() + ", " + _Game.clientWindowLocation.Y.ToString() + " ]");
Logger.WriteLog("ClientWindow Size (px) = [ " + (_Game.WindowRect.Right - _Game.WindowRect.Left).ToString() + "x" + (_Game.WindowRect.Bottom - _Game.WindowRect.Top).ToString() + " ]");
Logger.WriteLog("OnClient Cursor Position (Px) = [ " + Player.RIController.Computed_X + ", " + Player.RIController.Computed_Y + " ]");

if (!_Game.GetClientRect())
{
Logger.WriteLog("Error getting client Rect");
return;
}
}
if (_Game.IsWindowFullScreen)
Logger.WriteLog("ClientWindow Style = Fullscreen");
else
Logger.WriteLog("ClientWindow Style = Windowed");
Logger.WriteLog("ClientWindow Location (px) = [ " + _Game.clientWindowLocation.X.ToString() + ", " + _Game.clientWindowLocation.Y.ToString() + " ]");
Logger.WriteLog("ClientWindow Size (px) = [ " + (_Game.clientWindowRect.Right - _Game.clientWindowRect.Left).ToString() + "x" + (_Game.clientWindowRect.Bottom - _Game.clientWindowRect.Top).ToString() + " ]");
Logger.WriteLog("OnClient Cursor Position (Px) = [ " + Player.RIController.Computed_X + ", " + Player.RIController.Computed_Y + " ]");
{
Logger.WriteLog("ClientWindow Style = FullScreen");

//No need to translate coordinates from screen -> client and risk error.
//As fuulscreen, we will consider window size = screen size

Rect r = new Rect();
r.Top = 0;
r.Left = 0;
r.Bottom = _Game.ScreenHeight;
r.Right = _Game.ScreenWidth;
_Game.ClientRect = r;
}

if (!_Game.GameScale(Player))
{
Logger.WriteLog("Error converting client location to game location");
return;
}
}

Logger.WriteLog("Game Position (Hex) = [ " + Player.RIController.Computed_X.ToString("X4") + ", " + Player.RIController.Computed_Y.ToString("X4") + " ]");
Logger.WriteLog("Game Position (Dec) = [ " + Player.RIController.Computed_X.ToString() + ", " + Player.RIController.Computed_Y.ToString() + " ]");
Expand Down
Loading

0 comments on commit 3dc55b9

Please sign in to comment.