Jump to content

» «

[RELEASE] XInputDotNet

No replies to this topic
  • pedro2555

    Open Sourcer

  • Members
  • Joined: 02 Sep 2012
  • Portugal


Posted 11 March 2013 - 02:28 PM Edited by pedro2555, 12 March 2013 - 12:59 AM.

XInputDotNet - XBox 360 Controller support for .NET Scripthook


Adds support to 360 Controllers using a very well known way to assign actions in Scripthook.
You can subscribe to any Axis change or bind your own methods to button presses on the controller.
For a better gaming experience you can as well send vibration values to both vibration motors independently.

Usage example (C#)

The following script binds a user specified button to simple 'print to screen' method.

First thing, you need to reference XInputDotNet.dll to your project, and make sure SlimDx SDK is installed in your development machine.


using System;
using GTA;
using XInputDotNet;

namespace XInputDotNetSample
   public class XInputDotNetSample : Script
       public XInputDotNetSample()
           // Required to use any function.

           // Binds method Print() to a button press action.
           XboxController.BindButton(XboxController.StringToButton(Settings.GetValueString("Key1", "PAD", "None")), Print);
           // Bind the same action to a keyboard key.
           this.BindKey(Settings.GetValueKey("Key1", "KEYBOARD", System.Windows.Forms.Keys.Z), Print);

           // Reports changes from Axis.
           XboxController.OnRightTriggerAxisChanged += XboxController_OnRightTriggerAxisChanged;

       // capturing axis actions and reading axis value
       void XboxController_OnRightTriggerAxisChanged(object sender, TriggerEventArgs e)
           Game.DisplayText("Axis Changed to " + e.axisValue, 1000);

       // a sample method
       private void Print()
           Game.DisplayText("Button Pressed", 1000);

Client Deployment

For client usage SlimDx.dll (32 or 64 bit depending on client system), must be present in GTA IV root folder (or referenced in 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs').

a folder structure follows :



SlimDx SDK and End User Runtime (Make sure to select .NET 4.0)

XInputDotNet v1.0

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users