Skip to content

Commit

Permalink
v0.2a
Browse files Browse the repository at this point in the history
-- Added target app to vjoy buttons so focus returns to app when sending buttons as well as keyboard data.
  • Loading branch information
muchimi committed Jul 23, 2022
1 parent 7af0442 commit a2a7144
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 105 deletions.
2 changes: 1 addition & 1 deletion muchimi.vjoy/AddApplication.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion muchimi.vjoy/AddApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using muchimi_vjoy;
using SuchByte.MacroDeck.GUI.CustomControls;

namespace muchimi.vjoy
namespace muchimi_vjoy
{
public partial class AddApplication : DialogForm
{
Expand Down
53 changes: 35 additions & 18 deletions muchimi.vjoy/ConfigData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,25 @@ public bool LoadVjoyConfig(VjoyAction action)
{
return VjoyConfigFromJson(action.Configuration);
}
else
{

// default values
ButtonNumber = 1;
DeviceNumber = 1;
ButtonMode = EButtonMode.pulse;
ButtonPulseInterval = 600;
AxisEnabled = false;
ButtonEnabled = false;
ActionId = Guid.NewGuid().ToString();
TrackState = false;

AxisMode = EAxisMode.absolute;
AxisValue = 0.0; // center
Axis = VJoyAxis.AXIS_X;
AxisHatValue = -1; // center
TargetProcess = Main.Instance.Config.LastApplication;
}

return false;
}
Expand Down Expand Up @@ -680,6 +699,19 @@ public bool VjoyConfigFromJson(string json)
}


var targetProcessText = "";
value = jObject[ConfigData.TARGET_PROCESS];
if (value != null)
{
targetProcessText = value.ToString();
if (string.IsNullOrWhiteSpace(targetProcessText))
{
// default to the focused app entry
targetProcessText = VjoyPluginConfiguration.FOCUSED_APP;
}
}



ButtonNumber = uint.Parse(buttonNumberText);
DeviceNumber = uint.Parse(deviceNumberText);
Expand All @@ -701,25 +733,9 @@ public bool VjoyConfigFromJson(string json)
AxisMode = Enum.TryParse(axisModeText, out EAxisMode axisMode) ? axisMode : EAxisMode.absolute;


TargetProcess = targetProcessText;
}
else
{

// default values
ButtonNumber = 1;
DeviceNumber = 1;
ButtonMode = EButtonMode.pulse;
ButtonPulseInterval = 600;
AxisEnabled = false;
ButtonEnabled = false;
ActionId = Guid.NewGuid().ToString();
TrackState = false;

AxisMode = EAxisMode.absolute;
AxisValue = 0.0; // center
Axis = VJoyAxis.AXIS_X;
AxisHatValue = -1; // center
}

return true;
}
Expand Down Expand Up @@ -959,6 +975,8 @@ public string VJoyConfigToJson()
[ConfigData.AXIS_VALUE] = AxisValue.ToString(),
[ConfigData.AXIS_HATVALUE] = AxisHatValue.ToString(),
[ConfigData.AXIS_PULSE_INTERVAL] = AxisPulseInterval.ToString(),

[ConfigData.TARGET_PROCESS] = TargetProcess,
};
return jObject.ToString();
}
Expand Down Expand Up @@ -1091,7 +1109,6 @@ void Clone(ConfigData source, ref ConfigData dest)
dest.Axis = source.Axis;
dest.AxisValue = source.AxisValue;
dest.AxisHatValue = source.AxisHatValue;

dest.AxisPulseInterval = source.AxisPulseInterval;


Expand Down
2 changes: 1 addition & 1 deletion muchimi.vjoy/InputActionConfigurator.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 18 additions & 21 deletions muchimi.vjoy/InputActionConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,43 +223,40 @@ private void rb_keyup_CheckedChanged(object sender, EventArgs e)



private void cmd_select_application_Click(object sender, EventArgs e)
{
var ofd = new OpenFileDialog();
ofd.Filter = "Applications (*.exe)|*.exe;All Files (*.*)|*.*";
ofd.CheckFileExists = true;
ofd.Multiselect=false;
var result = ofd.ShowDialog();
if (result == DialogResult.OK)
{
var config = Main.Instance.Config;
var name = config.FixedName(Path.GetFileNameWithoutExtension(ofd.FileName));
config.AddApplication(name);
cb_applications.SelectedItem = name;
//private void cmd_select_application_Click(object sender, EventArgs e)
//{
// var ofd = new OpenFileDialog();
// ofd.Filter = "Applications (*.exe)|*.exe;All Files (*.*)|*.*";
// ofd.CheckFileExists = true;
// ofd.Multiselect=false;
// var result = ofd.ShowDialog();
// if (result == DialogResult.OK)
// {
// var config = Main.Instance.Config;
// var name = config.FixedName(Path.GetFileNameWithoutExtension(ofd.FileName));
// config.AddApplication(name);
// cb_applications.SelectedItem = name;


}
// }

}
//}

private void cb_applications_SelectedIndexChanged(object sender, EventArgs e)
{
data.TargetProcess = cb_applications.SelectedItem.ToString();
}


private void cmd_remove_Click(object sender, EventArgs e)
{
var config = Main.Instance.Config;
config.RemoveApplication(cb_applications.SelectedItem.ToString());
}

private void cb_applications_SelectedIndexChanged_1(object sender, EventArgs e)
private void cb_applications_SelectedIndexChanged(object sender, EventArgs e)
{
string name = cb_applications.SelectedItem.ToString();
cmd_remove.Enabled = ! string.IsNullOrEmpty(name);
var config = Main.Instance.Config;
config.LastApplication = name;

data.TargetProcess = name;
}

private void cmd_add_Click(object sender, EventArgs e)
Expand Down
Loading

0 comments on commit a2a7144

Please sign in to comment.