Basic idea for Joystick emulation

feature/joystick-binding
Brian Lima 7 years ago
parent 8770f5d958
commit e012a9abd5

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2006
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPHook", "UWPHook\UWPHook.csproj", "{AFE09BCF-28A4-48EE-876B-FEF080D04D5F}"
EndProject
@ -19,4 +19,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {199A9817-2004-4458-B45E-881F742780C3}
EndGlobalSection
EndGlobal

@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UWPHook"
StartupUri="GamesWindow.xaml">
StartupUri="GamesWindow.xaml" Startup="Application_Startup">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

@ -1,4 +1,5 @@
using System.Windows;
using System;
using System.Windows;
namespace UWPHook
{
@ -7,6 +8,17 @@ namespace UWPHook
/// </summary>
public partial class App : Application
{
public static TrayIcon icon;
private void Application_Startup(object sender, StartupEventArgs e)
{
icon = new TrayIcon();
EventsHook eventsHook = new EventsHook();
eventsHook.StartHooking();
}
}
}

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EventHook;
using ScpDriverInterface;
namespace UWPHook
{
class EventsHook
{
private X360Controller controller;
private ScpBus _scpBus;
private byte[] _outputReport = new byte[8];
public void StartHooking()
{
KeyboardWatcher.Start();
MouseWatcher.Start();
MouseWatcher.OnMouseInput += MouseWatcher_OnMouseInput;
KeyboardWatcher.OnKeyInput += KeyboardWatcher_OnKeyInput;
controller = new X360Controller();
_outputReport = new byte[8];
try
{
_scpBus = new ScpBus();
_scpBus.PlugIn((int)1);
}
catch (Exception)
{
throw;
}
}
private void MouseWatcher_OnMouseInput(object sender, MouseEventArgs e)
{
}
private void KeyboardWatcher_OnKeyInput(object sender, KeyInputEventArgs e)
{
switch (e.KeyData.Keyname)
{
case "A":
controller.Buttons ^= X360Buttons.A;
_scpBus.Report((int)1, controller.GetReport(), _outputReport);
break;
default:
break;
}
}
}
}

@ -11,7 +11,7 @@
TextElement.FontSize="14"
FontFamily="Segoe UI Light"
mc:Ignorable="d"
Title="UWPHook" Height="600" Width="800" Icon="/Resources/hook2.ico">
Title="UWPHook" Height="600" Width="800" Icon="/Resources/hook2.ico" Closing="Window_Closing">
<Grid x:Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="28*"/>

@ -36,7 +36,7 @@ namespace UWPHook
}
}
private void Launcher()
public void Launcher()
{
//So, for some reason, Steam is now stopping in-home streaming if the launched app is minimized, so not hiding UWPHook's window is doing the trick for now
if (Properties.Settings.Default.StreamMode)
@ -90,9 +90,11 @@ namespace UWPHook
//The user has probably finished using the app, so let's close UWPHook to keep the experience clean
this.Close();
App.icon.Close();
}
}
private void ExportButton_Click(object sender, RoutedEventArgs e)
{
bwrSave = new BackgroundWorker();
@ -273,6 +275,11 @@ namespace UWPHook
return (appEntry.Aumid.ToLower().Contains(textBox.Text.ToLower()));
}
private void Window_Closing(object sender, CancelEventArgs e)
{
App.icon.Close();
}
private void HelpButton_Click(object sender, RoutedEventArgs e)
{
SettingsWindow window = new SettingsWindow();

Binary file not shown.

Binary file not shown.

@ -41,19 +41,22 @@
<ToggleButton x:Name="language_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="4,56,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" />
<Label ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="label1" Content="Set system language when launching an app*" Margin="5,48,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.ColumnSpan="2"/>
<ComboBox ToolTip="Some apps use the system language to choose what language to display, this setting will store your current language, change it so you can play in another language and then revert your system back to your default display language." x:Name="cultures_comboBox" Margin="0,48,10,0" VerticalAlignment="Top" Height="31" Grid.Column="3" HorizontalAlignment="Right" Width="93"/>
<Button x:Name="save_button" Content="Save" HorizontalAlignment="Right" Margin="0,42,10,0" VerticalAlignment="Top" Width="93" Click="saveButton_Click" Grid.Column="3" Grid.Row="2"/>
<Button x:Name="save_button" Content="Save" HorizontalAlignment="Right" Margin="0,151,10,0" VerticalAlignment="Top" Width="93" Click="saveButton_Click" Grid.Column="3" Grid.Row="2"/>
<Label x:Name="label3" Content="Check if the launched app is running every" Margin="5,0,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"/>
<ComboBox x:Name="seconds_comboBox" Margin="0,10,10,0" VerticalAlignment="Top" Height="31" Grid.Column="3" HorizontalAlignment="Right" Width="93" Grid.Row="1"/>
<Button x:Name="update_button" Click="update_button_Click" Content="Check for updates" Grid.Column="1" Margin="0,0,5,10" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="162"/>
<Button x:Name="help_button" Click="help_button_Click" Content="Get help at our Reddit" Grid.Column="2" Margin="8,0,0,10" Grid.Row="2" VerticalAlignment="Bottom" Grid.ColumnSpan="2" HorizontalAlignment="Left" Width="163"/>
<ToggleButton x:Name="streaming_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="0,17,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" Grid.Row="2" />
<Label ToolTip="This fixes Steam in-home Streaming, set this in the host computer." x:Name="label1_Copy" Content="Enable streaming mode" Margin="5,10,0,0" VerticalAlignment="Top" Height="29" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2"/>
<ToggleButton x:Name="hook_toggle" Style="{StaticResource MaterialDesignSwitchToggleButton}" VerticalAlignment="Top" Margin="0,44,0,0" ToolTip="MaterialDesignSwitchToggleButton" IsChecked="False" Height="18" HorizontalAlignment="Left" Width="46" Grid.Row="2" />
<Label ToolTip="This uses a system hook to query for mouse and keyboard inputs used to emulate a controller for streaming mode." x:Name="label1_Copy1" Content="Enable system hooks" Margin="5,38,0,0" VerticalAlignment="Top" Height="30" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2"/>
<Button x:Name="setup_button" Content="Setup Emulated Joystick" HorizontalAlignment="Right" Margin="0,23,10,0" VerticalAlignment="Top" Width="217" Click="saveButton_Click" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2"/>
</Grid>
<Grid Margin="10,10,10,0" Grid.Column="1" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="63*"/>
<ColumnDefinition Width="164*"/>
<ColumnDefinition Width="59*"/>
<ColumnDefinition Width="62*"/>
<ColumnDefinition Width="Auto" MinWidth="163"/>
<ColumnDefinition Width="61*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="278*"/>
@ -90,7 +93,7 @@
<materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" VerticalAlignment="Top" Height="27" Grid.ColumnSpan="3">
<Label Content="About" HorizontalAlignment="Left" Margin="-10,-15,0,-17" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="14" Height="32" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone>
<Image x:Name="image2" Height="150" VerticalAlignment="Top" Source="Resources/briano.png" Stretch="UniformToFill" Margin="8,32,0,0" HorizontalAlignment="Left" Width="150" Grid.Column="1"/>
<Image x:Name="image2" Height="150" VerticalAlignment="Top" Source="Resources/briano.png" Stretch="UniformToFill" Margin="5,32,0,0" HorizontalAlignment="Left" Width="150" Grid.Column="1"/>
<TextBlock TextWrapping="WrapWithOverflow" x:Name="textBlock_Copy" VerticalAlignment="Top" Height="59" Text="This project uses the MaterialDesignXAMLToolkit. Special thanks to /r/Forza and /r/Steam communities at Reddit." TextAlignment="Justify" Grid.Row="3" Grid.ColumnSpan="3" Margin="0,44,0,0" Grid.RowSpan="2"/>
</Grid>
</Grid>

@ -0,0 +1,13 @@
<Window x:Class="UWPHook.TrayIcon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:UWPHook"
mc:Ignorable="d"
Title="TrayIcon" Height="300" Width="300">
<Grid>
<tb:TaskbarIcon ToolTipText="UWPHook" x:Name="icon" TrayMouseDoubleClick="icon_TrayMouseDoubleClick" IconSource="Resources/hook2.ico"/>
</Grid>
</Window>

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace UWPHook
{
/// <summary>
/// Interaction logic for TrayIcon.xaml
/// </summary>
public partial class TrayIcon : Window
{
public TrayIcon()
{
InitializeComponent();
}
private void icon_TrayMouseDoubleClick(object sender, RoutedEventArgs e)
{
}
}
}

@ -56,13 +56,31 @@
<StartupObject>UWPHook.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="EventHook, Version=1.4.39.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EventHook.1.4.39\lib\net45\EventHook.dll</HintPath>
</Reference>
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
</Reference>
<Reference Include="MaterialDesignColors, Version=1.1.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaterialDesignThemes.Wpf, Version=2.1.0.657, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignThemes.2.1.0.657\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
<Private>True</Private>
<Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Concurrent, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Concurrent.dll</HintPath>
</Reference>
<Reference Include="Nito.AsyncEx.Enlightenment, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Enlightenment.dll</HintPath>
</Reference>
<Reference Include="ScpDriverInterface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\ScpDriverInterface.dll</HintPath>
</Reference>
<Reference Include="SharpSteam">
<HintPath>..\..\SharpSteam\SharpSteam\bin\Release\SharpSteam.dll</HintPath>
@ -100,11 +118,15 @@
<Compile Include="GamesWindow.xaml.cs">
<DependentUpon>GamesWindow.xaml</DependentUpon>
</Compile>
<Compile Include="EventsHook.cs" />
<Compile Include="ScriptManager.cs" />
<Compile Include="Settings.cs" />
<Compile Include="SettingsWindow.xaml.cs">
<DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="TrayIcon.xaml.cs">
<DependentUpon>TrayIcon.xaml</DependentUpon>
</Compile>
<Page Include="GamesWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -118,6 +140,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TrayIcon.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@ -184,6 +210,11 @@
<ItemGroup>
<Resource Include="Resources\hook2.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="References\ScpDriverInterface.dll" />
<Content Include="References\SharpSteam.dll" />
<Content Include="References\VDFParser.dll" />
</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.

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EventHook" version="1.4.39" targetFramework="net461" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net461" />
<package id="MaterialDesignColors" version="1.1.3" targetFramework="net461" />
<package id="MaterialDesignThemes" version="2.1.0.657" targetFramework="net461" />
<package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net461" />
<package id="Nito.AsyncEx" version="3.0.1" targetFramework="net461" />
<package id="System.Management.Automation" version="6.1.7601.17515" targetFramework="net461" />
</packages>
Loading…
Cancel
Save