Added coord labels to Controller Readings display

This commit is contained in:
Travis Nickles 2020-03-25 09:10:55 -05:00
parent 107ac3bfa7
commit 3fbe37c4ea
4 changed files with 170 additions and 57 deletions

View File

@ -9,7 +9,7 @@
lex:ResxLocalizationProvider.DefaultDictionary="Strings"
xmlns:local="clr-namespace:DS4WinWPF.DS4Forms"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="430">
d:DesignHeight="450" d:DesignWidth="460">
<DockPanel LastChildFill="False">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<Label x:Name="inputContNum" Content="#" FontWeight="Bold"/>
@ -22,7 +22,7 @@
</Label.Foreground>
</Label>
</StackPanel>
<Grid DockPanel.Dock="Top" Width="430" Margin="0,8,0,0">
<Grid DockPanel.Dock="Top" Width="450" Margin="0,8,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
@ -42,6 +42,26 @@
<Rectangle x:Name="lsValRec" Width="6" Height="6" Canvas.Left="62" Canvas.Top="62" Fill="Black">
</Rectangle>
</Canvas>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal">
<Label Content="LX (I): " />
<Label x:Name="lxInValLb" Content="" Width="30" Padding="2,5" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="LX (O): " />
<Label x:Name="lxOutValLb" Content="" Width="30" Padding="2,5" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal">
<Label Content="LY (I): "/>
<Label x:Name="lyInValLb" Content="" Width="30" Padding="2,5" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="LY (O): " />
<Label x:Name="lyOutValLb" Content="" Width="30" />
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="1">
<Label Content="{lex:Loc RightStick}" HorizontalAlignment="Center" Padding="0"/>
@ -58,6 +78,26 @@
<Rectangle x:Name="rsValRec" Width="6" Height="6" Canvas.Left="62" Canvas.Top="62" Fill="Black">
</Rectangle>
</Canvas>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Label Content="RX (I): "/>
<Label x:Name="rxInValLb" Content="" Width="30" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="RX (O): "/>
<Label x:Name="rxOutValLb" Content="" Width="30" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Label Content="RY (I): "/>
<Label x:Name="ryInValLb" Content="" Width="30" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="RY (O): "/>
<Label x:Name="ryOutValLb" Content="" Width="30" />
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="2">
<TextBlock Text="SixAxis: X Axis is flipped so it is easier to read" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center"/>
@ -73,6 +113,26 @@
<Rectangle x:Name="sixAxisValRec" Width="6" Height="6" Canvas.Left="62" Canvas.Top="62" Fill="Black">
</Rectangle>
</Canvas>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Label Content="X (I): "/>
<Label x:Name="sixAxisXInValLb" Content="" Width="40" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="X (O): "/>
<Label x:Name="sixAxisXOutValLb" Content="" Width="40" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Label Content="Z (I): "/>
<Label x:Name="sixAxisZInValLb" Content="" Width="40" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Z (O): "/>
<Label x:Name="sixAxisZOutValLb" Content="" Width="40" />
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
<Grid DockPanel.Dock="Top" Margin="8,40,8,8">
@ -80,32 +140,58 @@
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1.75*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Height="100" Grid.Column="0" RenderTransformOrigin="0,0" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal" Margin="0,0,20,0">
<Label x:Name="l2ValLb" Content="L2" Height="16" VerticalAlignment="Top" HorizontalAlignment="Left" RenderTransformOrigin="0.5,1" Padding="0" Margin="0,0,4,0" >
<Label.RenderTransform>
<TransformGroup>
<TranslateTransform x:Name="l2ValLbTrans" Y="77" />
</TransformGroup>
</Label.RenderTransform>
<Label.Foreground>
<SolidColorBrush x:Name="l2ValLbBrush" Color="Black" />
</Label.Foreground>
</Label>
<Slider x:Name="l2Slider" Orientation="Vertical" Minimum="0" Maximum="255" Value="0" Height="80" Focusable="False" />
<StackPanel Orientation="Horizontal" MinHeight="100" Grid.Column="0" RenderTransformOrigin="0,0" HorizontalAlignment="Center">
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,20,0">
<Label x:Name="l2ValLb" Content="L2" Height="16" VerticalAlignment="Top" HorizontalAlignment="Left" RenderTransformOrigin="0.5,1" Padding="0" Margin="0,0,4,0" >
<Label.RenderTransform>
<TransformGroup>
<TranslateTransform x:Name="l2ValLbTrans" Y="66" />
</TransformGroup>
</Label.RenderTransform>
<Label.Foreground>
<SolidColorBrush x:Name="l2ValLbBrush" Color="Black" />
</Label.Foreground>
</Label>
<Slider x:Name="l2Slider" Orientation="Vertical" Minimum="0" Maximum="255" Value="0" Height="80" Focusable="False" />
</StackPanel>
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="I: " Width="30" />
<Label x:Name="l2InValLb" Content="" Width="30" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="O: " Width="30" />
<Label x:Name="l2OutValLb" Content="" Width="30" />
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Slider x:Name="r2Slider" Orientation="Vertical" Minimum="0" Maximum="255" Value="0" Height="80" Focusable="False" />
<Label x:Name="r2ValLb" Content="R2" Height="16" VerticalAlignment="Top" HorizontalAlignment="Left" RenderTransformOrigin="0.5,1" Padding="0" Margin="0,0,4,0" >
<Label.RenderTransform>
<TransformGroup>
<TranslateTransform x:Name="r2ValLbTrans" Y="77"/>
</TransformGroup>
</Label.RenderTransform>
<Label.Foreground>
<SolidColorBrush x:Name="r2ValLbBrush" Color="Black" />
</Label.Foreground>
</Label>
<StackPanel>
<StackPanel Orientation="Horizontal">
<Slider x:Name="r2Slider" Orientation="Vertical" Minimum="0" Maximum="255" Value="0" Height="80" Focusable="False" />
<Label x:Name="r2ValLb" Content="R2" Height="16" VerticalAlignment="Top" HorizontalAlignment="Left" RenderTransformOrigin="0.5,1" Padding="0" Margin="0,0,4,0" >
<Label.RenderTransform>
<TransformGroup>
<TranslateTransform x:Name="r2ValLbTrans" Y="66"/>
</TransformGroup>
</Label.RenderTransform>
<Label.Foreground>
<SolidColorBrush x:Name="r2ValLbBrush" Color="Black" />
</Label.Foreground>
</Label>
</StackPanel>
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="I: " Width="30" />
<Label x:Name="r2InValLb" Content="" Width="30" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="O: " Width="30" />
<Label x:Name="r2OutValLb" Content="" Width="30" />
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
<Border BorderBrush="Black" Grid.Column="1" BorderThickness="1">

View File

@ -108,8 +108,9 @@ namespace DS4WinWPF.DS4Forms
private LatencyWarnMode warnMode;
private LatencyWarnMode prevWarnMode;
private const int canvasWidth = 130;
private const int canvasMidpoint = canvasWidth / 2;
private const int CANVAS_WIDTH = 130;
private const int CANVAS_MIDPOINT = CANVAS_WIDTH / 2;
private const double TRIG_LB_TRANSFORM_OFFSETY = 66.0;
public ControllerReadingsControl()
{
@ -133,26 +134,26 @@ namespace DS4WinWPF.DS4Forms
private void ChangeSixAxisDeadControls(object sender, EventArgs e)
{
sixAxisDeadEllipse.Width = sixAxisXDead * canvasWidth;
sixAxisDeadEllipse.Height = sixAxisZDead * canvasWidth;
Canvas.SetLeft(sixAxisDeadEllipse, canvasMidpoint - (sixAxisXDead * canvasWidth / 2.0));
Canvas.SetTop(sixAxisDeadEllipse, canvasMidpoint - (sixAxisZDead * canvasWidth / 2.0));
sixAxisDeadEllipse.Width = sixAxisXDead * CANVAS_WIDTH;
sixAxisDeadEllipse.Height = sixAxisZDead * CANVAS_WIDTH;
Canvas.SetLeft(sixAxisDeadEllipse, CANVAS_MIDPOINT - (sixAxisXDead * CANVAS_WIDTH / 2.0));
Canvas.SetTop(sixAxisDeadEllipse, CANVAS_MIDPOINT - (sixAxisZDead * CANVAS_WIDTH / 2.0));
}
private void ChangeRsDeadControls(object sender, EventArgs e)
{
rsDeadEllipse.Width = rsDead * canvasWidth;
rsDeadEllipse.Height = rsDead * canvasWidth;
Canvas.SetLeft(rsDeadEllipse, canvasMidpoint - (rsDead * canvasWidth / 2.0));
Canvas.SetTop(rsDeadEllipse, canvasMidpoint - (rsDead * canvasWidth / 2.0));
rsDeadEllipse.Width = rsDead * CANVAS_WIDTH;
rsDeadEllipse.Height = rsDead * CANVAS_WIDTH;
Canvas.SetLeft(rsDeadEllipse, CANVAS_MIDPOINT - (rsDead * CANVAS_WIDTH / 2.0));
Canvas.SetTop(rsDeadEllipse, CANVAS_MIDPOINT - (rsDead * CANVAS_WIDTH / 2.0));
}
private void ChangeLsDeadControls(object sender, EventArgs e)
{
lsDeadEllipse.Width = lsDead * canvasWidth;
lsDeadEllipse.Height = lsDead * canvasWidth;
Canvas.SetLeft(lsDeadEllipse, canvasMidpoint - (lsDead * canvasWidth / 2.0));
Canvas.SetTop(lsDeadEllipse, canvasMidpoint - (lsDead * canvasWidth / 2.0));
lsDeadEllipse.Width = lsDead * CANVAS_WIDTH;
lsDeadEllipse.Height = lsDead * CANVAS_WIDTH;
Canvas.SetLeft(lsDeadEllipse, CANVAS_MIDPOINT - (lsDead * CANVAS_WIDTH / 2.0));
Canvas.SetTop(lsDeadEllipse, CANVAS_MIDPOINT - (lsDead * CANVAS_WIDTH / 2.0));
}
public void UseDevice(int index)
@ -197,31 +198,31 @@ namespace DS4WinWPF.DS4Forms
int x = baseState.LX;
int y = baseState.LY;
Canvas.SetLeft(lsValRec, x / 255.0 * canvasWidth - 3);
Canvas.SetTop(lsValRec, y / 255.0 * canvasWidth - 3);
Canvas.SetLeft(lsValRec, x / 255.0 * CANVAS_WIDTH - 3);
Canvas.SetTop(lsValRec, y / 255.0 * CANVAS_WIDTH - 3);
//bool mappedLS = interState.LX != x || interState.LY != y;
//if (mappedLS)
//{
Canvas.SetLeft(lsMapValRec, interState.LX / 255.0 * canvasWidth - 3);
Canvas.SetTop(lsMapValRec, interState.LY / 255.0 * canvasWidth - 3);
Canvas.SetLeft(lsMapValRec, interState.LX / 255.0 * CANVAS_WIDTH - 3);
Canvas.SetTop(lsMapValRec, interState.LY / 255.0 * CANVAS_WIDTH - 3);
//}
x = baseState.RX;
y = baseState.RY;
Canvas.SetLeft(rsValRec, x / 255.0 * canvasWidth - 3);
Canvas.SetTop(rsValRec, y / 255.0 * canvasWidth - 3);
Canvas.SetLeft(rsMapValRec, interState.RX / 255.0 * canvasWidth - 3);
Canvas.SetTop(rsMapValRec, interState.RY / 255.0 * canvasWidth - 3);
Canvas.SetLeft(rsValRec, x / 255.0 * CANVAS_WIDTH - 3);
Canvas.SetTop(rsValRec, y / 255.0 * CANVAS_WIDTH - 3);
Canvas.SetLeft(rsMapValRec, interState.RX / 255.0 * CANVAS_WIDTH - 3);
Canvas.SetTop(rsMapValRec, interState.RY / 255.0 * CANVAS_WIDTH - 3);
x = exposeState.getAccelX() + 127;
y = exposeState.getAccelZ() + 127;
Canvas.SetLeft(sixAxisValRec, x / 255.0 * canvasWidth - 3);
Canvas.SetTop(sixAxisValRec, y / 255.0 * canvasWidth - 3);
Canvas.SetLeft(sixAxisMapValRec, Math.Min(Math.Max(interState.Motion.outputAccelX + 127.0, 0), 255.0) / 255.0 * canvasWidth - 3);
Canvas.SetTop(sixAxisMapValRec, Math.Min(Math.Max(interState.Motion.outputAccelZ + 127.0, 0), 255.0) / 255.0 * canvasWidth - 3);
Canvas.SetLeft(sixAxisValRec, x / 255.0 * CANVAS_WIDTH - 3);
Canvas.SetTop(sixAxisValRec, y / 255.0 * CANVAS_WIDTH - 3);
Canvas.SetLeft(sixAxisMapValRec, Math.Min(Math.Max(interState.Motion.outputAccelX + 127.0, 0), 255.0) / 255.0 * CANVAS_WIDTH - 3);
Canvas.SetTop(sixAxisMapValRec, Math.Min(Math.Max(interState.Motion.outputAccelZ + 127.0, 0), 255.0) / 255.0 * CANVAS_WIDTH - 3);
l2Slider.Value = baseState.L2;
l2ValLbTrans.Y = Math.Min(interState.L2, Math.Max(0, 255)) / 255.0 * -70.0 + 77.0;
l2ValLbTrans.Y = Math.Min(interState.L2, Math.Max(0, 255)) / 255.0 * -70.0 + TRIG_LB_TRANSFORM_OFFSETY;
if (interState.L2 >= 255)
{
l2ValLbBrush.Color = Colors.Green;
@ -236,7 +237,7 @@ namespace DS4WinWPF.DS4Forms
}
r2Slider.Value = baseState.R2;
r2ValLbTrans.Y = Math.Min(interState.R2, Math.Max(0, 255)) / 255.0 * -70.0 + 77.0;
r2ValLbTrans.Y = Math.Min(interState.R2, Math.Max(0, 255)) / 255.0 * -70.0 + TRIG_LB_TRANSFORM_OFFSETY;
if (interState.R2 >= 255)
{
r2ValLbBrush.Color = Colors.Green;
@ -283,6 +284,8 @@ namespace DS4WinWPF.DS4Forms
}
prevWarnMode = warnMode;
UpdateCoordLabels(baseState, interState, exposeState);
ds.ReadWaitEv.Set();
});
}
@ -292,5 +295,29 @@ namespace DS4WinWPF.DS4Forms
readingTimer.Start();
}
}
private void UpdateCoordLabels(DS4State inState, DS4State mapState,
DS4StateExposed exposeState)
{
lxInValLb.Content = inState.LX;
lxOutValLb.Content = mapState.LX;
lyInValLb.Content = inState.LY;
lyOutValLb.Content = mapState.LY;
rxInValLb.Content = inState.RX;
rxOutValLb.Content = mapState.RX;
ryInValLb.Content = inState.RY;
ryOutValLb.Content = mapState.RY;
sixAxisXInValLb.Content = exposeState.AccelX;
sixAxisXOutValLb.Content = mapState.Motion.outputAccelX;
sixAxisZInValLb.Content = exposeState.AccelZ;
sixAxisZOutValLb.Content = mapState.Motion.outputAccelZ;
l2InValLb.Content = inState.L2;
l2OutValLb.Content = mapState.L2;
r2InValLb.Content = inState.R2;
r2OutValLb.Content = mapState.R2;
}
}
}

View File

@ -25,7 +25,7 @@
</Button>
</StackPanel>
<TabControl x:Name="sidebarTabControl" Width="440" DockPanel.Dock="Left" SelectionChanged="SidebarTabControl_SelectionChanged">
<TabControl x:Name="sidebarTabControl" Width="460" DockPanel.Dock="Left" SelectionChanged="SidebarTabControl_SelectionChanged">
<TabItem Header="Controls">
<DockPanel Width="440" LastChildFill="False">
<DockPanel.Background>

View File

@ -11,6 +11,6 @@
* ~~Look into logging exceptions thrown in background threads~~
* ~~Add mutex for controller input reader thread (better control
Controller Readings display)~~
* Add numeric data to Controller Readings tab
* ~~Add numeric data to Controller Readings tab~~
* ~~Look into making input delay display as a double. Check app performannce~~