More work towards joystick binding

feature/joystick-binding
Brian Lima 7 years ago
parent e6183e29f7
commit 9bc8a42d5a

@ -49,10 +49,12 @@ namespace UWPHook
private void KeyboardWatcher_OnKeyInput(object sender, KeyInputEventArgs e) private void KeyboardWatcher_OnKeyInput(object sender, KeyInputEventArgs e)
{ {
KeyToXboxButton button = (KeyToXboxButton)keyboardToController.ListButtons.Select(x => x.Key == e.KeyData.Keyname); KeyToXboxButton button = keyboardToController.ListButtons.FirstOrDefault(x => x.Key == e.KeyData.Keyname);
if (button != null) //We do have a bind for this key
controller.Buttons ^= button.x360Buttons; {
_scpBus.Report((int)1, controller.GetReport(), _outputReport); controller.Buttons ^= button.x360Buttons;
_scpBus.Report((int)1, controller.GetReport(), _outputReport);
}
} }
internal void StopHooking() internal void StopHooking()

@ -35,11 +35,12 @@
<Grid Margin="10" Grid.Row="1"> <Grid Margin="10" Grid.Row="1">
<DataGrid x:Name="listGames" Margin="0,25,0,0" CanUserSortColumns="True" CanUserAddRows="False" <DataGrid x:Name="listGames" Margin="0,25,0,0" CanUserSortColumns="True" CanUserAddRows="False"
materialDesign:DataGridAssist.CellPadding="4 2 2 2" materialDesign:DataGridAssist.ColumnHeaderPadding="4 2 2 2"/> materialDesign:DataGridAssist.CellPadding="4 2 2 2" materialDesign:DataGridAssist.ColumnHeaderPadding="4 2 2 2"/>
<Label x:Name="label" Content="Press 'Load installed apps' to get a list of installed apps on your system." HorizontalAlignment="Left" Margin="0,-10,0,0" VerticalAlignment="Top"/> <Label x:Name="labelStatus" Content="Press 'Load installed apps' to get a list of installed apps on your system." HorizontalAlignment="Left" Margin="0,-10,0,0" VerticalAlignment="Top"/>
</Grid> </Grid>
<Button Content="Export selected apps to Steam" Click="ExportButton_Click" HorizontalAlignment="Right" Margin="0,0,10,10" Grid.Row="2" VerticalAlignment="Bottom" Width="227"/> <Button Content="Export selected apps to Steam" Click="ExportButton_Click" HorizontalAlignment="Right" Margin="0,0,10,10" Grid.Row="2" VerticalAlignment="Bottom" Width="227"/>
<ProgressBar Visibility="Collapsed" x:Name="progressBar" Margin="10,215,10,174" Grid.Row="1" IsIndeterminate="True" /> <ProgressBar Visibility="Collapsed" x:Name="progressBar" Margin="10,215,10,174" Grid.Row="1" IsIndeterminate="True" />
<Label Content="Filter AUMIDS:" HorizontalAlignment="Left" Margin="5,16,0,0" Grid.Row="2" VerticalAlignment="Top"/> <Label Content="Filter AUMIDS:" HorizontalAlignment="Left" Margin="5,16,0,0" Grid.Row="2" VerticalAlignment="Top"/>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="25" Margin="104,17,0,0" Grid.Row="2" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="217" TextChanged="textBox_TextChanged"/> <TextBox x:Name="textBox" HorizontalAlignment="Left" Height="25" Margin="104,17,0,0" Grid.Row="2" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="217" TextChanged="textBox_TextChanged"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="410,17,0,0" Grid.Row="2" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
</Grid> </Grid>
</Window> </Window>

@ -49,9 +49,12 @@ namespace UWPHook
this.WindowStyle = WindowStyle.None; this.WindowStyle = WindowStyle.None;
this.WindowState = WindowState.Maximized; this.WindowState = WindowState.Maximized;
this.Title = "UWPHook: Streaming a game"; this.Title = "UWPHook: Streaming a game";
this.label.Content = "UWPHook is streaming your game, fasten your seatbelts."; this.labelStatus.Content = "UWPHook is streaming your game, fasten your seatbelts.";
//The user is trying to Stream his game probably, so let's start to emulate his controller //The user is trying to Stream his game probably, so let's start to emulate his controller
//Steam's in-home streaming treats UWPHook with it's "Desktop mode" config, causing all types of
//Weird conflicts, every time a button on the remote computer's controller is pressed, the client
//Receives a keyboard button instead. This should be a good approach
KeyboardToController Joystick = null; KeyboardToController Joystick = null;
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/Joysticks.json")) if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/Joysticks.json"))
@ -64,15 +67,7 @@ namespace UWPHook
{ {
this.listJoystick = JsonConvert.DeserializeObject<List<KeyboardToController>>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/Joysticks.json")); this.listJoystick = JsonConvert.DeserializeObject<List<KeyboardToController>>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/Joysticks.json"));
//Try to load the config for this game //Try to load the config for this game
foreach (var item in listJoystick) Joystick = listJoystick.FirstOrDefault(x => x.Game == "X"/*Environment.GetCommandLineArgs()[1]*/);
{
if (item.Game == Environment.GetCommandLineArgs()[1])
{
Joystick = item;
break;
}
}
//Joystick = (KeyboardToController)(listJoystick.q(x => x.Game == "X"/*Environment.GetCommandLineArgs()[1]*/)[0]);
} }
var json = JsonConvert.SerializeObject(listJoystick); var json = JsonConvert.SerializeObject(listJoystick);
@ -254,7 +249,7 @@ namespace UWPHook
grid.IsEnabled = true; grid.IsEnabled = true;
progressBar.Visibility = Visibility.Collapsed; progressBar.Visibility = Visibility.Collapsed;
label.Content = "Installed Apps"; labelStatus.Content = Apps.Entries.Count + " Installed Apps";
} }
private void Bwr_DoWork(object sender, DoWorkEventArgs e) private void Bwr_DoWork(object sender, DoWorkEventArgs e)
@ -325,6 +320,12 @@ namespace UWPHook
App.icon.Close(); App.icon.Close();
} }
private void Button_Click(object sender, RoutedEventArgs e)
{
JoystickSetup setup = new JoystickSetup();
setup.Show();
}
private void HelpButton_Click(object sender, RoutedEventArgs e) private void HelpButton_Click(object sender, RoutedEventArgs e)
{ {
SettingsWindow window = new SettingsWindow(); SettingsWindow window = new SettingsWindow();

@ -17,32 +17,27 @@
<RowDefinition Height="83*"/> <RowDefinition Height="83*"/>
<RowDefinition Height="486*"/> <RowDefinition Height="486*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" Height="80"> <materialDesign:ColorZone Padding="16" materialDesign:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" Height="80"/>
<Label x:Name="label1" Content="Welcome to UWPHook, the easier way to add UWP games and apps to Steam!" HorizontalAlignment="Left" Margin="172,-14,0,0" VerticalAlignment="Top" Foreground="#DDFFFFFF"/>
</materialDesign:ColorZone>
<Grid HorizontalAlignment="Left" Height="466" Margin="10,10,0,0" Grid.Row="1" VerticalAlignment="Top" Width="572"> <Grid HorizontalAlignment="Left" Height="466" Margin="10,10,0,0" Grid.Row="1" VerticalAlignment="Top" Width="572">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="572"/> <ColumnDefinition Width="572"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Margin="10,10,0,0" Content="Button A" VerticalAlignment="Top" Height="28" HorizontalAlignment="Left" Width="111"/> <TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="It seems that you don't have a emulated joystick for streamming this game!" VerticalAlignment="Top"/>
<Button Margin="126,10,0,0" VerticalAlignment="Top" Height="28" Content="Button B" HorizontalAlignment="Left" Width="105"/> <TextBlock HorizontalAlignment="Left" Margin="10,34,0,0" TextWrapping="Wrap" Text="Please, center ALL your axys and follow the instructions bellow to setup for first use" VerticalAlignment="Top"/>
<Button Margin="236,10,0,0" VerticalAlignment="Top" Height="28" Content="Button X" HorizontalAlignment="Left" Width="105"/>
<Button Margin="346,10,0,0" VerticalAlignment="Top" Height="28" Content="Button Y" HorizontalAlignment="Left" Width="105"/> <Grid Margin="0,58,0,0" >
<Button Margin="456,10,10,0" VerticalAlignment="Top" Height="28" Content="Start"/> <materialDesign:DialogHost BorderBrush="AliceBlue" BorderThickness="20">
<Button Margin="456,43,10,0" VerticalAlignment="Top" Height="28" Content="Select"/> <Border BorderThickness="2" BorderBrush="{DynamicResource PrimaryHueMidBrush}"
<Button Margin="10,43,451,0" VerticalAlignment="Top" Height="28" Content="Up Arrow"/> MinWidth="256" MinHeight="256" ClipToBounds="True">
<Button Margin="345,43,121,0" VerticalAlignment="Top" Height="28" Content="Down Arrow"/> <Button HorizontalAlignment="Right" VerticalAlignment="Center"
<Button Margin="126,43,341,0" VerticalAlignment="Top" Height="28" Content="Left Arrow"/> Command="{Binding OpenSample4DialogCommand}" Margin="0,186,232,186"
<Button Margin="236,43,231,0" VerticalAlignment="Top" Height="28" Content="Right Arrow"/> >Bind Joystick</Button>
<Button Margin="236,76,231,0" VerticalAlignment="Top" Height="28" Content="Left Trigger"/> </Border>
<Button Margin="346,76,121,0" VerticalAlignment="Top" Height="28" Content="Left Bumper"/> </materialDesign:DialogHost>
<Button Margin="126,76,341,0" VerticalAlignment="Top" Content="Right Trigger" Height="28"/> <!-- Executes a command on DialogsViewModel.cs, which will launch the dialog from code -->
<Button Margin="10,76,451,0" VerticalAlignment="Top" Content="Right Bumper" Height="28"/> <!--<Button Width="128" Command="{Binding RunDialogCommand}" Content="Bind Joystick" Margin="212,0"/>-->
<Button Margin="10,109,451,0" VerticalAlignment="Top" Height="28" Content="LS X Axys"/> <!-- Executes a command on DialogsViewModel.cs, which will launch the dialog from code -->
<Button Margin="126,109,341,0" VerticalAlignment="Top" Height="28" Content="LS Y Axys"/> </Grid>
<Button Margin="236,109,231,0" VerticalAlignment="Top" Height="28" Content="RS X Axys"/>
<Button Margin="346,109,121,0" VerticalAlignment="Top" Height="28" Content="RS Y Axys"/>
<Button Margin="456,76,11,0" VerticalAlignment="Top" Height="28" Content="Xbox Button"/>
</Grid> </Grid>
</Grid> </Grid>

Loading…
Cancel
Save