Skip to content

Commit

Permalink
- FocusFakerEnabler: commited but it's really just a failed experimen…
Browse files Browse the repository at this point in the history
…t (didn't quite understand at the time what global hooks were)

- Borderlands.js: Doesn't need to hide the taskbar anymore, now works perfectly with gamepads (keyboard is still a hell that I can't fix, as the mouse ends up controlling both windows).
- GameControl.cs: Updated to hold a IGameInfo also, so we can use the same control on the GameList form.
- GameList.cs: A form that shows all the possible games that NucleusCoop can handle
- MainForm.cs: Removed expanding (now its always expanded, much like Steam).  Added functionality to choose exactly what game you want to be interpreted by the application, instead of just enabling by the name of the executable.
- GenericContext/GenericGameInfo: Added options for enabling windowproc hooking
- GenericGameHandler: Added support for wndproc hooking (writes an INI that's read by my custom x360ce dll).
- User32Interop: Added methods for bringing window to foreground/making it active
- LogManager: Made it thread safe
- GameManager: Added support for adding games by IGameInfo, and not executable name.
- PlayerCountControl.cs: Fixed scaling of the control.
- UserInputControl: Added a reference to the UserGameInfo
- xinput: Remade x360ce dlls: cloned their most recent version, and modified to be able to also hook to game's WndProcs so we can intercept anything we don't want to be handled by the game (like the game knowing it's going to the background). This makes Borderlands think it should always accept input (which is still bad, because the mouse controls all windows, but at least the gamepads work 11/10).
- XLogParser: Parser application for the log files generated by the custom xinput files (so I can read all the events received by the WndProc in the application, and make sure everything is handled accordingly).
- Added x360ce submodule
- Updated readme
  • Loading branch information
distrohelena committed Oct 11, 2016
1 parent 766e089 commit a677299
Show file tree
Hide file tree
Showing 45 changed files with 1,313 additions and 250 deletions.
6 changes: 3 additions & 3 deletions Master/FocusFaker/FocusFaker.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -23,13 +23,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
106 changes: 7 additions & 99 deletions Master/FocusFaker/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ BOOL APIENTRY DllMain(HMODULE hModule,
LPVOID lpReserved
)
{
g_hinstDLL = hModule;

switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
g_hinstDLL = hModule;
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
Expand Down Expand Up @@ -43,120 +43,28 @@ BOOL APIENTRY DllMain(HMODULE hModule,
HHOOK g_hhkCallWndProcRet = NULL;
#pragma data_seg() /* end the shared data segment and default back to normal behavior */

std::vector<HWND> windows;

// get top level windows
struct EnumWindowsCallbackArgs
{
EnumWindowsCallbackArgs(DWORD p) : pid(p) { }
const DWORD pid;
std::vector<HWND> handles;
};
static BOOL CALLBACK EnumWindowsCallback(HWND hnd, LPARAM lParam)
{
EnumWindowsCallbackArgs *args = (EnumWindowsCallbackArgs *)lParam;

DWORD windowPID;
(void)::GetWindowThreadProcessId(hnd, &windowPID);
if (windowPID == args->pid)
{
args->handles.push_back(hnd);
}

return TRUE;
}
std::vector<HWND> getToplevelWindows()
{
EnumWindowsCallbackArgs args(::GetCurrentProcessId());
if (::EnumWindows(&EnumWindowsCallback, (LPARAM)&args) == FALSE)
{
// XXX Log error here
return std::vector<HWND>();
}
return args.handles;
}

LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == 9)
{
return 1;
}
else if (nCode == 5)
if (nCode == 0x7 || nCode == 0x8)
{
// 5 => Focus got here
HWND toBe = (HWND)wParam;
LPCBTACTIVATESTRUCT data = (LPCBTACTIVATESTRUCT)wParam;
//return NULL;
if (windows.empty())
{
windows = getToplevelWindows();
}
for (int i = 0; i < windows.size(); i++)
{
HWND win = windows[i];
if (toBe == win)
{
return 0;
}
}
/*HWND toBe = (HWND)wParam;*/
return 1;
}
return 0;

/* If nCode is greater than or equal to HC_ACTION,
* we should process the message. */
//if (nCode >= HC_ACTION)
//{
// /* Retrieve a pointer to the structure that contains details about
// * the message, and see if it is one that we want to handle. */
// const LPCWPSTRUCT lpcwprs = (LPCWPSTRUCT)lParam;

// switch (lpcwprs->message)
// {
// /* ...SNIP: process the messages we're interested in ... */
// case WM_KILLFOCUS:
// return 1;
// break;
// case WM_SETFOCUS:
// return 1;
// break;
// default:
// return CallNextHookEx(g_hhkCallWndProcRet, nCode, wParam, lParam);
// break;
// }
//}

/* At this point, we are either not processing the message
* (because nCode is less than HC_ACTION),
* or we've already finished processing it.
* Either way, pass the message on. */
}



extern "C" __declspec(dllexport) BOOL __stdcall InstallHook(DWORD threadId)
extern "C" __declspec(dllexport) BOOL __stdcall InstallHook(void)
{
/* Try to install the WH_CALLWNDPROCRET hook,
* if it is not already installed. */
if (!g_hhkCallWndProcRet)
{
MessageBox(NULL,
(LPCWSTR)L"Initialized",
(LPCWSTR)L"Account Details",
MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2
);
g_hhkCallWndProcRet = SetWindowsHookEx(WH_CBT,
CallWndProc,
g_hinstDLL,
threadId);
//g_hhkCallWndProcRet = SetWindowsHookEx(WH_CBT, CallWndProc, g_hinstDLL, threadId);
g_hhkCallWndProcRet = SetWindowsHookEx(WH_CALLWNDPROC, CallWndProc, g_hinstDLL, 0);
if (!g_hhkCallWndProcRet)
{
/* ...SNIP: handle failure condition ... */
return FALSE;
}
}

return TRUE;
}

Expand Down
6 changes: 6 additions & 0 deletions Master/FocusFakerEnabler/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
66 changes: 66 additions & 0 deletions Master/FocusFakerEnabler/FocusFakerEnabler.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{089DABA1-F168-4502-981B-3160E85240BE}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FocusFakerEnabler</RootNamespace>
<AssemblyName>FocusFakerEnabler</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="..\Debug\FocusFaker.dll">
<Link>FocusFaker.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
45 changes: 45 additions & 0 deletions Master/FocusFakerEnabler/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace FocusFakerEnabler
{
class Program
{
[DllImport("FocusFaker.dll", EntryPoint = "_InstallHook@0")]
public static extern bool InstallHook();

[DllImport("FocusFaker.dll", EntryPoint = "_RemoveHook@0")]
public static extern bool RemoveHook();

static void Main(string[] args)
{
bool installed = InstallHook();

if (installed)
{
Console.WriteLine("Global hook installed");
}
else
{
Console.WriteLine("Global hook not installed");
}

Console.ReadLine();

installed = RemoveHook();
if (installed)
{
Console.WriteLine("Global hook removed");
}
else
{
Console.WriteLine("Global hook not removed");
}
Console.ReadLine();
}
}
}
36 changes: 36 additions & 0 deletions Master/FocusFakerEnabler/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("FocusFakerEnabler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FocusFakerEnabler")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("089daba1-f168-4502-981b-3160e85240be")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
8 changes: 2 additions & 6 deletions Master/Games/Nucleus.Coop.Games.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="TheHooker.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TheHooker.dll" />
<None Include="GamesKey.snk" />
<None Include="Resident Evil 5\resources\Splitscreen Mod PC RE5.zip" />
<None Include="Resident Evil 5\resources\Splitscreen Mod PC RE5\re5ssmod\splitscreen.cfg" />
Expand Down Expand Up @@ -172,9 +170,7 @@
<None Include="Resources\v2\xinput3.dll" />
<None Include="Resources\v2\xinput4.dll" />
<Content Include="tested.txt" />
<None Include="TheHooker.lib">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TheHooker.lib" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="GamesResources.resx">
Expand Down
5 changes: 4 additions & 1 deletion Master/Games/games/Borderlands.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ Game.NeedsSteamEmulation = true;
Game.LauncherTitle = "splashscreen";
Game.SaveType = Nucleus.SaveType.INI;
Game.SupportsPositioning = true;
Game.HideTaskbar = true;
Game.HideTaskbar = false;
Game.CustomXinput = true;
Game.StartArguments = "-windowed -NoLauncher -nostartupmovies";
Game.HookNeeded = true;
Game.HookWindows = 7;
Game.HookGameWindow = 1;

Game.Play = function () {
Context.ModifySave = [
Expand Down
Binary file modified Master/NucleusCoop.VC.db
Binary file not shown.
Loading

0 comments on commit a677299

Please sign in to comment.