Background:
Joystick - Razor Ruiji Master
Visual Studio 2019
Windows Form in C#
I'm trying to figure out how to make a physical joystick button press, press a button on the windows form UI in Visual studio using C#.
Code of Physical joystick:
private void joystickTimer_Tick_1(object sender, EventArgs e)
{
try
{
joystick.UpdateStatus();
joystickButtons = joystick.buttons;
if (joystick.Xaxis == 0)
output.Text+="Left\n";
if (joystick.Xaxis == 65534)
output.Text+="Right\n";
if (joystick.Yaxis == 0)
output.Text+="Up\n";
if (joystick.Yaxis == 65535)
output.Text+="Down\n";
for (int i = 0; i < joystickButtons.Length; i++)
{
if (joystickButtons[0] == true)
output.Text += "Cross\n";
else if(joystickButtons[1] == true)
output.Text += "Circle\n";
else if(joystickButtons[2] == true)
output.Text += "Square\n";
else if (joystickButtons[3] == true)
output.Text += "Triangle\n";
Btn_Emergency_Stop_Click(sender,e);
break;
}
}
catch
{
joystickTimer.Enabled = false;
connectToJoystick(joystick);
}
}
Virtual button to be pressed:
private void Btn_Emergency_Stop_Click(object sender, EventArgs e)
{
}
If there is any information I've missed out in providing please notify me.
What I have tried:
I've tried, using
Btn_Emergency_Stop_Click(null,null);
or
Btn_Emergency_Stop_Click(sender,e);
or
Btn_Emergency_Stop_Click.Click += joystickButtons[3];
Not sure If I'm on the right track any help will be appreciated!
Thank You!