A DLL saved my life

Well, not really. But I found this Windows Input Simulator pretty useful in a somewhat annoying situation. While working with a custom controller, I found that input wasn’t being rendered the way I expected. I was using Unity, and the controller only provides a boolean based on if the button is being pressed.* Usually Unity makes life easier giving you the following function to reference whatever key or button you may have set up in your input settings:

  • Input.GetButtonDown(“Fire”)
  • Input.GetButtonUp(“Fire”)
  • Input.GetButton(“Fire”)

What I ended up doing is mapping keys to my actions in the input settings, and adding InputSimulation() to my Update(), manually mapping my controller to the keys referenced in input settings:

public void InputSimulation()
{

if(myControllerButton)

{

InputSimulator.SimulateKeyPress(VirtualKeyCode.VK_H);

}

}

It works for our use, and I’m glad somebody made this DLL so I could rig my project up. You can download the DLL here.

 

*Typically this controller is used with a specific piece of hardware, but we needed to use it on a PC in this case.

 

Leave a Reply

Your email address will not be published. Required fields are marked *