Jitnaught Posted February 27, 2016 Share Posted February 27, 2016 Is there a way to disable the controller but not the keyboard, programmatically? Disabling the device itself or unplugging it will not do. Link to comment Share on other sites More sharing options...
jedijosh920 Posted February 27, 2016 Share Posted February 27, 2016 (edited) Why? You really can't restrain yourself from using your controller instead of the keyboard/mouse? Edited February 27, 2016 by jedijosh920 Link to comment Share on other sites More sharing options...
Jitnaught Posted February 27, 2016 Author Share Posted February 27, 2016 Why? You really can't restrain yourself from using your controller instead of the keyboard/mouse? For a mod. Link to comment Share on other sites More sharing options...
ikt Posted February 27, 2016 Share Posted February 27, 2016 Do you want to accept none at all? You can disable controls and you can detect if the last input was either a controller or kb+m, or do you need to use both at once? Link to comment Share on other sites More sharing options...
Jitnaught Posted February 27, 2016 Author Share Posted February 27, 2016 Do you want to accept none at all? You can disable controls and you can detect if the last input was either a controller or kb+m, or do you need to use both at once? I would need to use both at the same time. Link to comment Share on other sites More sharing options...
stillhere Posted February 28, 2016 Share Posted February 28, 2016 (edited) Do you want to accept none at all? You can disable controls and you can detect if the last input was either a controller or kb+m, or do you need to use both at once? I would need to use both at the same time. You can use _GET_LAST_INPUT_METHOD For example, look at the script for Superman's LaserEye Heatvision 1.1 I changed "UsingGamepad" to "UsingKeyboard" so it makes more sense. bool UsingKeyboard = Function.Call<bool>(Hash._GET_LAST_INPUT_METHOD);if (UsingKeyboard == false) { if (Game.IsControlPressed(2, GTA.Control.ScriptPadLeft) && Game.IsControlPressed(2, GTA.Control.FrontendAccept)) { if (toggle) { toggle = false; UI.ShowSubtitle("HeatVision OFF"); Wait(200); } else if (!toggle) { toggle = true; UI.ShowSubtitle("HeatVision ON"); Wait(200); } } if (Game.IsControlPressed(2, GTA.Control.ScriptLT) && toggle) { LaserEyeOn = true; } else { LaserEyeOn = false; } } Those statements will only work if the last input came from a controller. TL;DR you can put the parts of your script that you want to run when only using a keyboard or gamepad under the if UsingKeyboard == true or false condition: bool UsingKeyboard = Function.Call<bool>(Hash._GET_LAST_INPUT_METHOD);if (UsingKeyboard == true) // if using a keyboard{}if (UsingKeyboard == false) //if using a Gamepad/Controller{} Edited February 28, 2016 by stillhere Link to comment Share on other sites More sharing options...
Jitnaught Posted February 28, 2016 Author Share Posted February 28, 2016 (edited) Thank you, but I don't think that will work either, sorry. Edited February 28, 2016 by LetsPlayOrDy Link to comment Share on other sites More sharing options...
ikt Posted February 28, 2016 Share Posted February 28, 2016 Do you want to get something where you can control the player with the keyboard while all controller input is ignored, if they both are simultaneously touched? Link to comment Share on other sites More sharing options...
Jitnaught Posted February 28, 2016 Author Share Posted February 28, 2016 Do you want to get something where you can control the player with the keyboard while all controller input is ignored, if they both are simultaneously touched? Exactly. Link to comment Share on other sites More sharing options...
alex8b Posted March 1, 2016 Share Posted March 1, 2016 You can hook XInput and filter controller input the way you want (even inject stuff): https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/HidEmulation/ControllerEmulation.cs Link to comment Share on other sites More sharing options...
Jitnaught Posted March 1, 2016 Author Share Posted March 1, 2016 You can hook XInput and filter controller input the way you want (even inject stuff): https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/HidEmulation/ControllerEmulation.cs I've never done any hooking before, so I just messed with the code a bit to see if I could get it the way I wanted, but couldn't. Could you possibly give me an example of how I could hook XInput and get it to ignore the gamepad? Thanks! Link to comment Share on other sites More sharing options...
alex8b Posted March 2, 2016 Share Posted March 2, 2016 I've never done any hooking before, so I just messed with the code a bit to see if I could get it the way I wanted, but couldn't. Could you possibly give me an example of how I could hook XInput and get it to ignore the gamepad? Thanks! https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/HidEmulation/ControllerEmulation.cs You will need EasyHook library: https://github.com/EasyHook/EasyHook A class that will set up XInputGetState hook https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/HidEmulation/ControllerEmulation.cs Here's a usage example (input injection and blocking) https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/ControlsProcessor.cs Link to comment Share on other sites More sharing options...
Jitnaught Posted March 2, 2016 Author Share Posted March 2, 2016 You will need EasyHook library: https://github.com/EasyHook/EasyHook A class that will set up XInputGetState hook https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/HidEmulation/ControllerEmulation.cs Here's a usage example (input injection and blocking) https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/ControlsProcessor.cs I looked through ControlsProcessor, and (I think) I see where you inject input, but I don't see where you block it (I don't know what it looks like or how you do it). Again, I'm completely new to this. I'll understand if you don't want to waste your time with me. Link to comment Share on other sites More sharing options...
ikt Posted March 2, 2016 Share Posted March 2, 2016 You will need EasyHook library: https://github.com/EasyHook/EasyHook A class that will set up XInputGetState hook https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/HidEmulation/ControllerEmulation.cs Here's a usage example (input injection and blocking) https://github.com/alex8b/gta5eyetracking/blob/master/Gta5EyeTracking/ControlsProcessor.cs I looked through ControlsProcessor, and (I think) I see where you inject input, but I don't see where you block it (I don't know what it looks like or how you do it). Again, I'm completely new to this. I'll understand if you don't want to waste your time with me. With XInput you can read the state of the controller. These things are the thumb sticks, the triggers and all buttons. The thumb sticks and triggers are read as four properties and the buttons are read as a 16-bit unsigned number. I don't know how SharpDX.XInput works, but for me XInput has all properties as read-only, though the class ControllerEmulation seems to work around that? It seems to be a slightly different implementation that gives the (XInput???) EventArgs a setter. Link to comment Share on other sites More sharing options...
alex8b Posted March 3, 2016 Share Posted March 3, 2016 Check XInputGetState_Hooked(int dwUserIndex, out State state), ProcessState and OnModifyControllerState You receive entire controller state (original) that you can read from SharpDX.XInput as you normally do. But the game receives only whatever you set as out state in XInputGetState_Hooked which calls ProcessState and OnModifyControllerState to modify it. OnModifyControllerState has some code to disable and inject buttons (conditionally) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now