资源简介
前些日子做开发的时候用到游戏手柄,这两天整理了一下。这个代码是用C#编写的,希望对大家有所帮助。编译环境是VS2010。手柄的接口类型是DirectInput形式的,通过使用系统底层API函数来获取手柄状态。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace JoyKeys.DirectInputJoy
{
public class API
{
#region 消息定义
public const int MM_JOY1MOVE = 0x3A0;
public const int MM_JOY2MOVE = 0x3A1;
public const int MM_JOY1BUTTONDOWN = 0x3B5;
public const int MM_JOY2BUTTONDOWN = 0x3B6;
public const int MM_JOY1BUTTONUP = 0x3B7;
public const int MM_JOY2BUTTONUP = 0x3B8;
#endregion
#region 按钮定义
public const int JOY_BUTTON1 = 0x0001;
public const int JOY_BUTTON2 = 0x0002;
public const int JOY_BUTTON3 = 0x0004;
public const int JOY_BUTTON4 = 0x0008;
public const int JOY_BUTTON5 = 0x0010;
public const int JOY_BUTTON6 = 0x0020;
public const int JOY_BUTTON7 = 0x0040;
public const int JOY_BUTTON8 = 0x0080;
public const int JOY_BUTTON9 = 0x0100;
public const int JOY_BUTTON10 = 0x0200;
public const int JOY_BUTTON11 = 0x0400;
public const int JOY_BUTTON12 = 0x0800;
//Button up/down
public const int JOY_BUTTON1CHG = 0x0100;
public const int JOY_BUTTON2CHG = 0x0200;
public const int JOY_BUTTON3CHG = 0x0400;
public const int JOY_BUTTON4CHG = 0x0800;
#endregion
#region 手柄Id定义
///
/// 主游戏手柄Id
///
public const int JOYSTICKID1 = 0;
///
/// 副游戏手柄Id
///
public const int JOYSTICKID2 = 1;
#endregion
#region 错误号定义
///
/// 没有错误
///
public const int JOYERR_NOERROR = 0;
///
/// 参数错误
///
public const int JOYERR_PARMS = 165;
///
/// 无法正常工作
///
public const int JOYERR_NOCANDO = 166;
///
/// 操纵杆未连接
///
public const int JOYERR_UNPLUGGED = 167;
#endregion
///
/// 游戏手柄的参数信息JoystickEventArgs
///
[StructLayout(LayoutKind.Sequential)]
public struct JOYCAPS
{
public ushort wMid;
public ushort wPid;
[MarshalAs(UnmanagedType.ByValTStr SizeConst = 32)]
public string szPname;
public int wXmin;
public int wXmax;
public int wYmin;
public int wYmax;
public int wZmin;
public int wZmax;
public int wNumButtons;
public int wPeriodMin;
public int wPeriodMax;
public int wRmin;
public int wRmax;
public int wUmin;
public int wUmax;
public int wVmin;
public int wVmax;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 16896 2014-08-27 08:30 Jokstick\JoyKeys\bin\Debug\JoyKeys.dll
文件 62976 2014-08-27 08:30 Jokstick\JoyKeys\bin\Debug\JoyKeys.pdb
文件 6391 2014-08-22 13:52 Jokstick\JoyKeys\DirectInputJoy\API.cs
文件 8884 2014-08-22 13:50 Jokstick\JoyKeys\DirectInputJoy\JoystickAPI.cs
文件 1972 2014-05-12 10:07 Jokstick\JoyKeys\DirectInputJoy\JoystickEventArgs.cs
文件 12387 2014-08-22 13:51 Jokstick\JoyKeys\DirectInputJoy\Joystick_P.cs
文件 11758 2014-08-22 13:54 Jokstick\JoyKeys\DirectInputJoy\Joystick_V.cs
文件 2657 2014-08-27 08:30 Jokstick\JoyKeys\JoyKeys.csproj
文件 5906 2014-08-27 08:30 Jokstick\JoyKeys\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 2993 2014-08-27 08:30 Jokstick\JoyKeys\obj\Debug\JoyKeys.csproj.FileListAbsolute.txt
文件 16896 2014-08-27 08:30 Jokstick\JoyKeys\obj\Debug\JoyKeys.dll
文件 62976 2014-08-27 08:30 Jokstick\JoyKeys\obj\Debug\JoyKeys.pdb
文件 1346 2014-02-20 15:57 Jokstick\JoyKeys\Properties\AssemblyInfo.cs
文件 2658 2014-08-27 08:29 Jokstick\JoyKeys.sln
..A..H. 489984 2014-08-27 08:31 Jokstick\JoyKeys.suo
文件 16896 2014-08-27 08:30 Jokstick\JoyKeysTest\bin\Debug\JoyKeys.dll
文件 62976 2014-08-27 08:30 Jokstick\JoyKeysTest\bin\Debug\JoyKeys.pdb
文件 14336 2014-08-27 08:30 Jokstick\JoyKeysTest\bin\Debug\JoyKeysTest.exe
文件 34304 2014-08-27 08:30 Jokstick\JoyKeysTest\bin\Debug\JoyKeysTest.pdb
文件 11600 2014-08-27 08:31 Jokstick\JoyKeysTest\bin\Debug\JoyKeysTest.vshost.exe
文件 490 2012-06-02 22:34 Jokstick\JoyKeysTest\bin\Debug\JoyKeysTest.vshost.exe.manifest
文件 6964 2014-08-22 16:49 Jokstick\JoyKeysTest\FormTest.cs
文件 12364 2014-08-22 16:49 Jokstick\JoyKeysTest\FormTest.Designer.cs
文件 6014 2014-08-22 16:48 Jokstick\JoyKeysTest\FormTest.resx
文件 3905 2014-08-22 16:49 Jokstick\JoyKeysTest\JoyKeysTest.csproj
文件 2867 2014-08-22 13:46 Jokstick\JoyKeysTest\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6391 2014-08-27 08:30 Jokstick\JoyKeysTest\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1801 2014-08-27 08:31 Jokstick\JoyKeysTest\obj\x86\Debug\JoyKeysTest.csproj.FileListAbsolute.txt
文件 1036 2014-08-27 08:30 Jokstick\JoyKeysTest\obj\x86\Debug\JoyKeysTest.csproj.GenerateResource.Cache
文件 15095 2014-08-27 08:30 Jokstick\JoyKeysTest\obj\x86\Debug\JoyKeysTest.csprojResolveAssemblyReference.cache
............此处省略31个文件信息
相关资源
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
评论
共有 条评论