资源简介
用C#写的游戏手柄的访问程序,并封装成windows 消息,访问非常方便。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace JoyKeys
{
public partial class Form1 : Form
{
private Core.Joystick joystick;
public Form1()
{
InitializeComponent();
}
protected override void onload(EventArgs e)
{
base.onload(e);
joystick = new JoyKeys.Core.Joystick();
joystick.Click += new EventHandler(joystick_Click);
joystick.Register(base.Handle Core.API.JOYSTICKID1);
joystick.Register(base.Handle Core.API.JOYSTICKID2);
}
protected override void OnClosing(CancelEventArgs e)
{
joystick.UnRegister(Core.API.JOYSTICKID1);
joystick.UnRegister(Core.API.JOYSTICKID2);
base.OnClosing(e);
}
void joystick_Click(object sender JoyKeys.Core.JoystickEventArgs e)
{
// Core.API.JOYINFO joy2 = new JoyKeys.Core.API.JOYINFO();
if (e.JoystickId == Core.API.JOYSTICKID1)
{
this.Text = “1号手柄“;
}
else if (e.JoystickId == Core.API.JOYSTICKID2)
{
this.Text = “2号手柄“;
}
int x = 1;
int y = 1;
string str = ““;
this.Text = ““ + e.Move.X + “ “ + e.Move.Y;
if ((e.Buttons & JoyKeys.Core.JoystickButtons.UP) == JoyKeys.Core.JoystickButtons.UP) y--;
if ((e.Buttons & JoyKeys.Core.JoystickButtons.Down) == JoyKeys.Core.JoystickButtons.Down) y++;
if ((e.Buttons & JoyKeys.Core.JoystickButtons.Left) == JoyKeys.Core.JoystickButtons.Left) x--;
if ((e.Buttons & JoyKeys.Core.JoystickButtons.Right) == JoyKeys.Core.JoystickButtons.Right) x++;
if (x == 0 && y == 0) this.label1.TextAlign = ContentAlignment.TopLeft;
if (x == 1 && y == 0) this.label1.TextAlign = ContentAlignment.TopCenter;
if (x == 2 && y == 0) this.label1.TextAlign = ContentAlignment.TopRight;
if (x == 0 && y == 1) this.label1.TextAlign = ContentAlignment.MiddleLeft;
if (x == 1 && y == 1) this.label1.TextAlign = ContentAlignment.MiddleCenter;
if (x == 2 && y == 1) this.label1.TextAlign = ContentAlignment.MiddleRight;
if (x == 0 && y == 2) this.label1.TextAlign = ContentAlignment.BottomLeft;
if (x == 1 && y == 2) this.label1.TextAlign = ContentAlignment.BottomCenter;
if (x == 2 && y == 2) this.label1.TextAlign = ContentAlignment.BottomRight;
this.label1.Text = “+“;
this.label2.BackColor = ((e.Buttons & JoyKeys.Core.JoystickButtons.B1) == JoyKeys.Core.JoystickButtons.B1) ? Color.Red : SystemColors.Control;
相关资源
- FTP上传、、创建目录、重命名、删除
- c# 调用百度地图API
- C#软件注册和注册机的实现源码
- c# 图片编辑方法集合
- c#五子棋游戏源代码200445
- c# 加密和解密相关代码
- C#编写txt小说阅读器()
- C#实现简洁的绘图界面
- C#实现的读取CAD表格文字
- C#高质量仿腾讯截图程序(改)
- 员工管理信息系统C#源代码
- c#连接sqlite简单
- WPF制作的取色器ColorPicker
- C#登录页面
- 11 如何在工具栏添加下拉菜单.rar
- C#把文件拖动到窗口上面 Q698507 问题的
- halcon联合C#车牌识别
- 员工信息管理系统C#源码
- C# UDPSocket异步传输文件
- C#提取二进制STL文件并生成TXT文件
- c#实现哈夫曼编码的压缩
- C#编程修复Access数据库
- STK与C#联合编程
- C#文件加密解密完整项目
- C# datagridview 与数据源绑定后对数据的
- c#Form窗体增删改操作
- c#红绿灯程序源代码
- ASP.NET/C# +SQL小区收费系统
- VS2010下 C#最小二乘法图形界面及源代
- C#将tif影像转成jpg方法显示保持颜色不
评论
共有 条评论