4 个解决方案
#1
如果是3
说明1和2是一起按的
说明1和2是一起按的
#2
然后你需要死循环不停的去读取按键操作
如果按下了,就执行你预设的方法呗
如果不是跟游戏里手柄使用方式一样,按住就一直执行某个方法,而是第一次按下的时候执行,继续按不执行
那么你需要每个按键再加变量判断它变没变
如果按下了,就执行你预设的方法呗
如果不是跟游戏里手柄使用方式一样,按住就一直执行某个方法,而是第一次按下的时候执行,继续按不执行
那么你需要每个按键再加变量判断它变没变
#3
难道你不装驱动的吗?
不同的手柄有不同的工作方式:有的模拟键盘、有的模拟鼠标、有的有专门的接口。
我还是那句话:找供应商要程序调用例子。
不同的手柄有不同的工作方式:有的模拟键盘、有的模拟鼠标、有的有专门的接口。
我还是那句话:找供应商要程序调用例子。
#4
Public Class MainForm
Dim Joy As New joystick.Gamehandle
Dim Joy_Name As String
Dim Lx, Ly, Rx, Ry, DirectionAngle, ButtonBack, ButtonStart, ButtonX, ButtonY, ButtonA, ButtonB, ButtonLb, ButtonLT, ButtonRb, ButtonRt, ButtonLz, ButtonRz As Integer
Delegate Sub Read_Joy(ByRef Lx As Integer, ByRef Ly As Integer, ByRef Rx As Integer, ByRef Ry As Integer, ByRef DirectionAngle As Integer, ByRef ButtonBack As Integer, ByRef ButtonStart As Integer, ByRef ButtonX As Integer, ByRef ButtonY As Integer, ByRef ButtonA As Integer, ByRef ButtonB As Integer, ByRef ButtonLb As Integer, ByRef ButtonLt As Integer, ByRef ButtonRb As Integer, ByRef ButtonRt As Integer, ByRef ButtonLz As Integer, ByRef ButtonRz As Integer)
Dim Run_boolean As Boolean
Sub Read_Joy_Sub(ByRef Lx As Integer, ByRef Ly As Integer, ByRef Rx As Integer, ByRef Ry As Integer, ByRef DirectionAngle As Integer, ByRef ButtonBack As Integer, ByRef ButtonStart As Integer, ByRef ButtonX As Integer, ByRef ButtonY As Integer, ByRef ButtonA As Integer, ByRef ButtonB As Integer, ByRef ButtonLb As Integer, ByRef ButtonLt As Integer, ByRef ButtonRb As Integer, ByRef ButtonRt As Integer, ByRef ButtonLz As Integer, ByRef ButtonRz As Integer)
TextBox3.Text = Lx
TextBox4.Text = Ly
TextBox5.Text = Rx
TextBox6.Text = Ry
TextBox7.Text = DirectionAngle
TextBox8.Text = ButtonBack
TextBox9.Text = ButtonStart
TextBox10.Text = ButtonX
TextBox11.Text = ButtonY
TextBox12.Text = ButtonA
TextBox13.Text = ButtonB
TextBox14.Text = ButtonLb
TextBox15.Text = ButtonLt
TextBox16.Text = ButtonRb
TextBox17.Text = ButtonRt
TextBox18.Text = ButtonLz
TextBox19.Text = ButtonRz
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = Run_boolean
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Joy.InitGamehandle(Joy_Name) = True Then
Me.Text = Joy_Name
Else
MessageBox.Show("没有找到游戏手柄")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If BackgroundWorker1.IsBusy = False Then
Run_boolean = True
BackgroundWorker1.RunWorkerAsync()
End If
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
While Run_boolean = True
If Joy.GetGameButtonStatus(Lx, Ly, Rx, Ry, DirectionAngle, ButtonBack, ButtonStart, ButtonX, ButtonY, ButtonA, ButtonB, ButtonLb, ButtonLT, ButtonRb, ButtonRt, ButtonLz, ButtonRz) = True Then
Invoke(New Read_Joy(AddressOf Read_Joy_Sub), Lx, Ly, Rx, Ry, DirectionAngle, ButtonBack, ButtonStart, ButtonX, ButtonY, ButtonA, ButtonB, ButtonLb, ButtonLT, ButtonRb, ButtonRt, ButtonLz, ButtonRz)
End If
End While
Application.Exit()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Run_boolean = False
End Sub
End Class
#1
如果是3
说明1和2是一起按的
说明1和2是一起按的
#2
然后你需要死循环不停的去读取按键操作
如果按下了,就执行你预设的方法呗
如果不是跟游戏里手柄使用方式一样,按住就一直执行某个方法,而是第一次按下的时候执行,继续按不执行
那么你需要每个按键再加变量判断它变没变
如果按下了,就执行你预设的方法呗
如果不是跟游戏里手柄使用方式一样,按住就一直执行某个方法,而是第一次按下的时候执行,继续按不执行
那么你需要每个按键再加变量判断它变没变
#3
难道你不装驱动的吗?
不同的手柄有不同的工作方式:有的模拟键盘、有的模拟鼠标、有的有专门的接口。
我还是那句话:找供应商要程序调用例子。
不同的手柄有不同的工作方式:有的模拟键盘、有的模拟鼠标、有的有专门的接口。
我还是那句话:找供应商要程序调用例子。
#4
Public Class MainForm
Dim Joy As New joystick.Gamehandle
Dim Joy_Name As String
Dim Lx, Ly, Rx, Ry, DirectionAngle, ButtonBack, ButtonStart, ButtonX, ButtonY, ButtonA, ButtonB, ButtonLb, ButtonLT, ButtonRb, ButtonRt, ButtonLz, ButtonRz As Integer
Delegate Sub Read_Joy(ByRef Lx As Integer, ByRef Ly As Integer, ByRef Rx As Integer, ByRef Ry As Integer, ByRef DirectionAngle As Integer, ByRef ButtonBack As Integer, ByRef ButtonStart As Integer, ByRef ButtonX As Integer, ByRef ButtonY As Integer, ByRef ButtonA As Integer, ByRef ButtonB As Integer, ByRef ButtonLb As Integer, ByRef ButtonLt As Integer, ByRef ButtonRb As Integer, ByRef ButtonRt As Integer, ByRef ButtonLz As Integer, ByRef ButtonRz As Integer)
Dim Run_boolean As Boolean
Sub Read_Joy_Sub(ByRef Lx As Integer, ByRef Ly As Integer, ByRef Rx As Integer, ByRef Ry As Integer, ByRef DirectionAngle As Integer, ByRef ButtonBack As Integer, ByRef ButtonStart As Integer, ByRef ButtonX As Integer, ByRef ButtonY As Integer, ByRef ButtonA As Integer, ByRef ButtonB As Integer, ByRef ButtonLb As Integer, ByRef ButtonLt As Integer, ByRef ButtonRb As Integer, ByRef ButtonRt As Integer, ByRef ButtonLz As Integer, ByRef ButtonRz As Integer)
TextBox3.Text = Lx
TextBox4.Text = Ly
TextBox5.Text = Rx
TextBox6.Text = Ry
TextBox7.Text = DirectionAngle
TextBox8.Text = ButtonBack
TextBox9.Text = ButtonStart
TextBox10.Text = ButtonX
TextBox11.Text = ButtonY
TextBox12.Text = ButtonA
TextBox13.Text = ButtonB
TextBox14.Text = ButtonLb
TextBox15.Text = ButtonLt
TextBox16.Text = ButtonRb
TextBox17.Text = ButtonRt
TextBox18.Text = ButtonLz
TextBox19.Text = ButtonRz
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = Run_boolean
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Joy.InitGamehandle(Joy_Name) = True Then
Me.Text = Joy_Name
Else
MessageBox.Show("没有找到游戏手柄")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If BackgroundWorker1.IsBusy = False Then
Run_boolean = True
BackgroundWorker1.RunWorkerAsync()
End If
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
While Run_boolean = True
If Joy.GetGameButtonStatus(Lx, Ly, Rx, Ry, DirectionAngle, ButtonBack, ButtonStart, ButtonX, ButtonY, ButtonA, ButtonB, ButtonLb, ButtonLT, ButtonRb, ButtonRt, ButtonLz, ButtonRz) = True Then
Invoke(New Read_Joy(AddressOf Read_Joy_Sub), Lx, Ly, Rx, Ry, DirectionAngle, ButtonBack, ButtonStart, ButtonX, ButtonY, ButtonA, ButtonB, ButtonLb, ButtonLT, ButtonRb, ButtonRt, ButtonLz, ButtonRz)
End If
End While
Application.Exit()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Run_boolean = False
End Sub
End Class