Paso 4: Un código VB sencillo
Public Class GamepadLauncher
Privada Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja Button1.Click
Si SerialPort1.IsOpen = False Then
Si <> de TextBox1.Text "" y TextBox2.Text <> "" entonces
SerialPort1.PortName = TextBox1.Text
SerialPort1.BaudRate = TextBox2.Text
Si SerialPort1.IsOpen = False Then
SerialPort1.Open()
MsgBox ("serie abierta")
Timer1.Enabled = True
End If
Otra cosa
MsgBox ("Puerto entrar COM y baudios)
End If
End If
End Sub
Privada Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja MyBase.Load
SerialPort1.Close()
End Sub
Privada Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja Button2.Click
Si SerialPort1.IsOpen = True Then
SerialPort1.Close()
Timer1.Enabled = False
End If
End Sub
Privada Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja Timer1.Tick
Dim como cadena = ""
un = SerialPort1.ReadExisting
TextBox3.Text = TextBox3.Text + a
If a = "1" entonces
SendKeys.Send("{up}")
ElseIf a = "2" y luego SendKeys.Send("{down}")
ElseIf a = "3" entonces SendKeys.Send("{left}")
ElseIf a = "4" y SendKeys.Send("{right}")
End If
End Sub
Clase final