Skip to content

Commit

Permalink
fix floating textbox and xinput entries in configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
I5UCC committed Mar 6, 2024
1 parent 22c5228 commit 3327eec
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>

<CheckBox Grid.Column="0" IsChecked="{Binding IsSelected}" Content="{Binding DisplayString}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked"/>
<CheckBox Grid.Column="1" IsChecked="{Binding Unsigned}" Content="Unsigned" ToolTip="{Binding Text}" Visibility="{Binding Unsigned_Visibility}" Margin="-13, 0, 0, 0" Checked="CheckBox_Checked_Unsigned" Unchecked="CheckBox_Checked_Unsigned"/>
<TextBox Width="100" Grid.Column="1" PreviewTextInput="TextBox_PreviewTextInput" TextChanged="TextBox_TextChanged" ToolTip="{Binding Text}" Text="{Binding Floating}" Margin="70, 0, 0, 0" IsEnabled="{Binding isEnabled}"/>
<ComboBox Grid.Column="2" Margin="20, 0, 0, 0" SelectedIndex="{Binding AlwaysSend}" ToolTip="{Binding Text}" SelectionChanged="ComboBox_SelectionChanged" Width="120">
<ComboBoxItem>Send On Change</ComboBoxItem>
<ComboBoxItem>Send On Positive</ComboBoxItem>
<ComboBoxItem>Always Send</ComboBoxItem>
</ComboBox>
<CheckBox Grid.Column="1" IsChecked="{Binding Unsigned}" Content="Unsigned" ToolTip="{Binding Text}" Visibility="{Binding Unsigned_Visibility}" Margin="-13, 0, 0, 0" Checked="CheckBox_Checked_Unsigned" Unchecked="CheckBox_Checked_Unsigned"/>

</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ private void CheckBox_Checked_Unsigned(object sender, RoutedEventArgs e)
}
}
}
foreach (Action a in config.xinput_actions)
{
if (a.type == "vector2")
{
JArray tmp = ((JArray)a.osc_parameter);
JArray tmp2 = ((JArray)a.unsigned);

for (int i = 0; i < tmp.Count; i++)
{
if (tmp[i].ToString() == name)
{
tmp2[i] = check;
a.unsigned = tmp2;
return;
}
}
}
}

}

Expand Down Expand Up @@ -194,7 +212,33 @@ private void CheckBox_Checked(object sender, RoutedEventArgs e)
}
}
}

foreach (Action a in config.xinput_actions)
{
if (a.type != "vector2")
{
if (a.osc_parameter.ToString() == name)
{
a.enabled = check;
return;
}
}
else
{
JArray tmp = ((JArray)a.osc_parameter);
JArray tmp2 = ((JArray)a.enabled);

for (int i = 0; i < tmp.Count; i++)
{
if (tmp[i].ToString() == name)
{
tmp2[i] = check;
a.enabled = tmp2;
return;
}
}
}
}

}

private void TextChanged(object sender, TextChangedEventArgs e)
Expand Down Expand Up @@ -370,6 +414,20 @@ private void Mode_Click(object sender, RoutedEventArgs e)
a.always = value;
}
}
foreach (Action a in config.xinput_actions)
{
if (a.type == "vector2")
{
if (((JArray)a.enabled).Count > 2)
a.always = new JArray(new int[3] { value, value, value });
else
a.always = new JArray(new int[2] { value, value });
}
else
{
a.always = value;
}
}
Startup = false;
Lbx_Params.Items.Refresh();
}
Expand Down Expand Up @@ -414,6 +472,38 @@ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
}

}
for (int i = 0; i < config.xinput_actions.Count; i++)
{
Action a = config.xinput_actions[i];
if (a.osc_parameter is string)
{
if (a.osc_parameter.ToString() == ((TextBox)sender).ToolTip.ToString())
{
a.floating = float.Parse(text.Replace(".", ","));
return;
}
}
else
{
string[] temp = ((JArray)a.osc_parameter).ToObject<string[]>();
float[] floats = null;

if (a.floating is Single[])
floats = (Single[])a.floating;
else
floats = ((JArray)a.floating).ToObject<float[]>();

for (int j = 0; j < temp.Length; j++)
{
if (temp[j].ToString() == ((TextBox)sender).ToolTip.ToString())
{
floats[j] = float.Parse(text.Replace(".", ","));
config.xinput_actions[i].floating = floats;
}
}
}

}
}

private void TextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
Expand Down Expand Up @@ -477,6 +567,33 @@ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs
}
}
}

foreach (Action a in config.xinput_actions)
{
if (a.type != "vector2")
{
if (a.osc_parameter.ToString() == name)
{
a.always = value;
return;
}
}
else
{
JArray tmp = ((JArray)a.osc_parameter);
JArray tmp2 = ((JArray)a.always);

for (int i = 0; i < tmp.Count; i++)
{
if (tmp[i].ToString() == name)
{
tmp2[i] = value;
a.always = tmp2;
return;
}
}
}
}
}

private void Untick_SteamVR_Parameters(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 3327eec

Please sign in to comment.