资源简介
c# DirectX DirectInput 游戏手柄 游戏摇杆 winform程序
项目想要用游戏摇杆控制无人车,用莱仕达的雷霆PRO做实验。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Management;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
namespace RunJoyStickOnLocalMachine
{
public partial class Form1 : Form
{
private Joystick joystick;
private bool[] joystickButtons;
private bool isCalibration = false;
public struct CaliValue
{
public int xMin;
public int xMax;
public int yMin;
public int yMax;
public int xCenter;
public int yCenter;
public int leftThreshold;
public int rightThreshold;
public int upThreshold;
public int downThreshold;
}
CaliValue caliValue;
Point[] ps = new Point[] { new Point(2 0) new Point(2 1) new Point(0 2) new Point(1 2) new Point(3 2) new Point(4 2) new Point(2 3) new Point(2 4) };
//十字大bai小
int sizeP = 1;
//十字的位置
Point pos = new Point(0 0);
private void SetPos(int x int y)
{
pos.X = x - sizeP * 2;
pos.Y = y - sizeP * 2;
}
public Form1()
{
InitializeComponent();
joystick = new Joystick(this.Handle);
connectToJoystick(joystick);
}
private void Form1_Load(object sender EventArgs e)
{
}
//---------------------------------------------------------------------
private void connectToJoystick(Joystick joystick)
{
while (true)
{
string sticks = joystick.FindJoysticks();
if (sticks != null)
{
if (joystick.AcquireJoystick(sticks))
{
enableTimer();
break;
}
}
}
}
private void enableTimer()
{
if (this.InvokeRequired)
{
BeginInvoke(new ThreadStart(delegate()
{
joystickTimer.Enabled = true;
}));
}
else
joystickTimer.Enabled = true;
}
private void joystickTimer_Tick_1(object sender EventArgs e)
{
try
{
Graphics g = pictureBox1.CreateGraphics();
g.Clear(Color.White);
//获取xyz坐标
joystick.UpdateStatus();
joystickButtons = joystick.buttons;
output.Text = “ x: “+ joystick.Xaxis.ToString()+“\n“;
output.Text += “ y: “ + joystick.Yaxis.ToString() + “\n“;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-06-07 15:33 RunJoyStickOnLocalMachine\
目录 0 2020-06-07 15:33 RunJoyStickOnLocalMachine\.vs\
目录 0 2020-06-07 15:33 RunJoyStickOnLocalMachine\.vs\RunJoyStickOnLocalMachine\
目录 0 2020-06-07 15:33 RunJoyStickOnLocalMachine\.vs\RunJoyStickOnLocalMachine\v14\
文件 57856 2020-06-07 17:46 RunJoyStickOnLocalMachine\.vs\RunJoyStickOnLocalMachine\v14\.suo
目录 0 2020-06-07 17:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\
文件 917 2014-11-18 19:23 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine.sln
文件 33280 2014-12-06 03:11 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine.suo
文件 219 2020-06-07 15:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\App.config
目录 0 2014-12-06 03:18 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\
目录 0 2020-06-07 15:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\
文件 159232 2005-03-18 16:23 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\Microsoft.DirectX.DirectInput.dll
文件 345509 2006-03-07 22:46 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\Microsoft.DirectX.DirectInput.xm
文件 223232 2005-03-18 16:23 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\Microsoft.DirectX.dll
文件 265390 2006-03-07 22:46 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\Microsoft.DirectX.xm
文件 15872 2020-06-07 17:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\RunJoyStickOnLocalMachine.exe
文件 219 2020-06-07 15:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\RunJoyStickOnLocalMachine.exe.config
文件 30208 2020-06-07 17:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\RunJoyStickOnLocalMachine.pdb
文件 22696 2020-06-07 17:46 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\RunJoyStickOnLocalMachine.vshost.exe
文件 219 2020-06-07 15:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\RunJoyStickOnLocalMachine.vshost.exe.config
文件 490 2018-02-19 20:12 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\bin\Debug\RunJoyStickOnLocalMachine.vshost.exe.manifest
文件 6542 2020-06-07 17:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\Form1.cs
文件 8258 2020-06-07 17:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\Form1.Designer.cs
文件 6018 2020-06-07 17:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\Form1.resx
文件 4130 2020-06-07 16:53 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\Joystick.cs
目录 0 2020-06-07 15:33 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\obj\
目录 0 2020-06-07 15:33 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\obj\x86\
目录 0 2020-06-07 17:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\obj\x86\Debug\
文件 3442 2020-06-07 15:43 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7360 2020-06-07 17:42 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1577 2020-06-07 17:46 RunJoyStickOnLocalMachine\RunJoyStickOnLocalMachine\obj\x86\Debug\RunJoyStickOnLocalMachine.csproj.FileListAbsolute.txt
............此处省略20个文件信息
- 上一篇:asp.net源码及课程设计报告
- 下一篇:c#实现D8单流向算法
相关资源
- c#实现D8单流向算法
- 基于asp.net c#在线答题页面
- HTTPS证书创建+绑定端口+C#程序监听
- 实现UDP可靠文件传输
- VB.NET C# 截屏小工具
- C# GDI+ Demo.zip
- C#写的控制台NTP服务端以及winform的N
- C# 备份还原sqlserver,SQL server还原,附
- C#的串口助手源码例程
- 立体像对的空间前方交会-点投影系数
- C#交会法测量程序.zip
- 住院收费管理系统,。数据库课程设
- 基于C# Winform完成串口通讯上位机
- 基于C#的点名小软件
- 两个DataGridView通过委托实时传值,安
- 一套类moba的教学视频百度云地址
- C#实现房屋出租管理系统
- C#支持中英文软键盘
- C#工业控制——机械手项目.rar
- 点名神器.zip
- c#操作CAD实时打开关闭
- HTML解析C# 包涵注释,全中文
- C#备忘录+完整源代码
- c#使用sip协议实现呼叫
- C#使用引擎调用MATLAB神经网络工具箱
- 百度云C#开发实战1200例书和光盘
- C# C/S平台软件自动更新程序 SQLServer
- C# socket心跳
- C#最简单最完整的webservice能打log,配
- C# ArcEngine二次开发
评论
共有 条评论