Project

ffi-xinput

0.0
No commit activity in last 3 years
No release in over 3 years
An FFI wrapper for the XInput controller library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.9.25
 Project Readme

ffi-xinput

ffi-xinput is an FFI wrapper that can be used to interface with the XInput controller library for Windows. It can read the state of any controller hooked up to a system that supports XInput, or activate it's rumble feature.

Installation

gem install ffi-xinput

Usage

Enable XInput support in your project:

require "ffi-xinput"

Create a new XInput controller instance:

xinput = XInput.new(controller_id) #id can be 0-3

Check if a controller is connected:

xinput.connected?
XInput.connected?(controller_id)

Get the state of a controller (returns a hash containing the state of all controller buttons/axis):

xinput.state
XInput.state(controller_id)

Set the vibration level for the left/right motor:

xinput.vibrate(left_motor, right_motor) #values can range from 0.0 to 1.0
XInput.vibrate(controller_id, left_motor, right_motor)

License

This library is licensed under the MIT license.