【问题标题】:C# DirectX input problemC# DirectX 输入问题
【发布时间】:2011-07-06 20:58:11
【问题描述】:

所以我有一个简单的应用程序,只有几行:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX.DirectInput;

namespace asdasd
{
    public partial class Form1 : Form
    {
        public Device joystick;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (
                DeviceInstance di in
                Manager.GetDevices(
                    DeviceClass.GameControl,
                    EnumDevicesFlags.AttachedOnly))
            {
                joystick = new Device(di.InstanceGuid);
                break;
            }

            if (joystick == null)
            {
                throw new Exception("No joystick found.");
            }
        }
    }
}

我尝试在我的计算机上获取活动操纵杆,但出现错误:

我安装了 Microsoft.DirectX.DirectInput 程序集,并安装了 directX SDK 2010。

谁能告诉我问题出在哪里?

【问题讨论】:

    标签: c# input directx device


    【解决方案1】:

    尝试将其添加到配置文件中:

    http://devonenote.com/2010/08/mixed-mode-assembly-error-after-upgrading-to-dotnet-4-0/

    (如果配置已经存在,只需将它们合并) 而且,也许这不是正确的地方,但看看 XNA... 事情通常会容易得多。

    我无法在此处直接粘贴 XML,它不显示。

    【讨论】:

      【解决方案2】:

      DirectX 程序集是针对 .NET v1.1 构建的,Microsoft 在 .NET v2.0 发布之前就停止积极开发它们。

      它们不能用于 .NET v1.1 以外的项目。 XNA 是管理对 Direct X 功能的访问的“有福”的前进道路。我不知道它的全部功能,但SlimDX 似乎为 C# 提供了比 XNA 更直接的 X 感觉 API,虽然我没有使用它,但我听说过很多。

      不过,您可能会在 gamedev.stackexchange.com 上找到更好的选择升级路径的答案。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-30
        相关资源
        最近更新 更多