It is currently October 3rd, 2024, 11:58 pm

New Plugin: XInput

Share and get help with Plugins and Addons
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

New Plugin: XInput

Post by dgrace »

In my continuing series of "plugins that are almost totally useless but look kinda cool"...

This plugin monitors the status of an XInput controller. If you're working in, say, Unreal Editor 4 and want to see the raw values of your connected controller, this plugin is for you. ;) If I'm really motivated/bored I might do a DirectInput one.

The example skin is pretty crappy art-wise, but the code works. Enjoy!

dave
You do not have the required permissions to view the files attached to this post.
User avatar
VasTex
Posts: 407
Joined: September 20th, 2012, 3:17 pm
Location: USA - Montana

Re: New Plugin: XInput

Post by VasTex »

I've been out of the loop for a while now, but this was interesting enough to bring me back in for a bit.

Anyway, I played around with it a bit and it works really well. No lag or heavy CPU usage that I can see which is always a plus. I did decide to rework it for myself and add a bit of an interface to keep track of things a bit easier and figured I'd share what I whipped up.

A few issues (with my coding, not the plugin) are that I need to rework the IfConditions for the Joystick directions as it seems to hang a bit in places with a jerking motion here and there, add some styles and generally just clean it up, but it's here if anyone wants to play with it.

I've also added a gif below so you can see exactly what it is and download it as well.
Xinput Interface Demo.gif
Xinput Interface_1.0.0.rmskin
You do not have the required permissions to view the files attached to this post.
01010100 01100101 01100011 01101000 01101110 01101111 01101100 01101111 01100111 01101001
01100011 01100001 01101100 00100000 01000010 01100001 01100100 01100001 01110011 01110011
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: New Plugin: XInput

Post by dgrace »

Sweet! That's exactly the kind of art I was too lazy to do. ;) Nice one!

Oh I forgot to put in my original skin - there's a channel called "Connected" to report if the controller is plugged in, but I didn't test it. So the full list of options:

Device (optional, default 0):
  • integer, 0-3
Channel (required): one of:
  • JoyL_X
    JoyL_Y
    JoyR_X
    JoyR_Y
    Dpad_U
    Dpad_D
    Dpad_L
    Dpad_R
    Face_U
    Face_D
    Face_L
    Face_R
    LTrig1
    RTrig1
    LTrig2
    RTrig2
    JoyL_Click
    JoyR_Click
    Start
    Back
    Connected
dave

p.s. looking forward to seeing desktop Space Invaders in Lua. ;)
User avatar
VasTex
Posts: 407
Joined: September 20th, 2012, 3:17 pm
Location: USA - Montana

Re: New Plugin: XInput

Post by VasTex »

As far as I can tell all of the channels work properly. The connected status in my skin is represented by the center guide button turning green and going grey when unplugged. The gif I made starts out unplugged and grey.

As for the device (0-3) option I'm not sure what that is. Could you elaborate a bit more on that?
01010100 01100101 01100011 01101000 01101110 01101111 01101100 01101111 01100111 01101001
01100011 01100001 01101100 00100000 01000010 01100001 01100100 01100001 01110011 01110011
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: New Plugin: XInput

Post by dgrace »

Apparently you can connect up to 4 controllers (though I only have 1). The Device # lets you address the other 3, if you have them.

I couild probably whip up a DirectInput version pretty quick if anyone was interested, or just kick the code up to github I guess. The only question is whether DirectInput allows shared access to the same ID. (e.g. I wouldn't want to disconnect the controller from your game so that I could show the values in Rainmeter) The XInput API is really simple and doesn't seem to mind getting queries from multiple apps at the same time.

dave
User avatar
VasTex
Posts: 407
Joined: September 20th, 2012, 3:17 pm
Location: USA - Montana

Re: New Plugin: XInput

Post by VasTex »

Ah that makes sense.

I'm sure I have a spare controller lying around, but I'm not sure if it's wired or not and I don't have a wireless adapter. If I get a chance though I'll play around with the device list. I'd also be interested in seeing what the differences would be between this and the DirectInput version, but I suppose that that's up to you.
01010100 01100101 01100011 01101000 01101110 01101111 01101100 01101111 01100111 01101001
01100011 01100001 01101100 00100000 01000010 01100001 01100100 01100001 01110011 01110011
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: New Plugin: XInput

Post by dgrace »

I made a nice clean skin, but I had to modify the Rainmeter code to support ATan2 in the math expression parser, so it won't work on anyone else's build until that change gets pulled into the main branch. I'll upload it once that change goes live.

dave
You do not have the required permissions to view the files attached to this post.
User avatar
VasTex
Posts: 407
Joined: September 20th, 2012, 3:17 pm
Location: USA - Montana

Re: New Plugin: XInput

Post by VasTex »

Very nice,

I had tried to create a skin almost identical to that following the graphical version I made, but couldn't properly translate the magnitude on the axis of the joysticks to create the direction of the line within the circle.

Perhaps I'm just slow, but I also found the aTan function less than helpful on this.

Looks nice though!
01010100 01100101 01100011 01101000 01101110 01101111 01101100 01101111 01100111 01101001
01100011 01100001 01101100 00100000 01000010 01100001 01100100 01100001 01110011 01110011
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: New Plugin: XInput

Post by dgrace »

Nope, atan is almost useless. You want atan2, but for some reason it wasn't included in Rainmeter's math functions until I added it over the weekend. Just need to poke one of the other guys who makes builds to pull the change in. ;)

dave
User avatar
jsmorley
Developer
Posts: 22802
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Plugin: XInput

Post by jsmorley »

dgrace wrote:Nope, atan is almost useless. You want atan2, but for some reason it wasn't included in Rainmeter's math functions until I added it over the weekend. Just need to poke one of the other guys who makes builds to pull the change in. ;)

dave
Consider us poked. Should be in the next beta.