Coding an Xbox 360 Controller to work with GMOD

Some of you might say this is dumb, I don’t care. Some of you will say something like “Why would you want to use an Xbox controller in GMOD?”, I want to because I can. Some of you will say “Wow gg scrub ur gonna get rekt m8”, I’ll wreck you 1v1 IRL. I want to know if it is possible to use the Xbox controller in gmod with analog sticks walking support, what I mean is if you only push the analog stick only a bit forward, it will move slower, if I push it more, the player will walk faster, is there a way I can do that? Also, I want 2 extra things, is there a way to make it if you go to a usable object, whether it be picking up an object or opening a door, cancel whatever the jump button is (A) and make it do what it would do if I pressed the use key? And last, I know it’s possible to make an image appear on the screen, but can you make it fade in (this is just cosmetic, it doesn’t matter to me if it’s not possible, but it would be nice to have)?

It seems possible on the account of the kinect being in Garry’s Mod.

Here’s a copy of 360controller.cfg from Team Fortress 2

remap it to your liking


joy_name "Xbox360 controller"
joy_advanced 1
joy_advaxisx 3
joy_advaxisy 1
joy_advaxisz 0
joy_advaxisr 2
joy_advaxisu 4
joy_advaxisv 0
joy_forwardsensitivity -1
joy_sidesensitivity 1
joy_pitchsensitivity 1.0
joy_yawsensitivity -1.25
joy_autoaimdampenrange 0.85
joy_autoaimdampen 0.5
joy_lowend 0.65
joy_lowmap 0.15
joy_accelscale 2.0
joy_accelmax 2.0
joy_response_move 0
joy_response_look 1
joyadvancedupdate

joystick 1
hud_fastswitch 2

+jlook

tf_build_menu_controller_mode 1
tf_disguise_menu_controller_mode 1



bind "Z AXIS POS" "+attack2"	// L TRIGGER
bind "Z AXIS NEG" "+attack"		// R TRIGGER

bind "JOY1" "+jump"				// A
bind "JOY2" "+reload"			// B
bind "JOY3" "+context_action"	// X
bind "JOY4" "togglescores"		// Y

bind "JOY5" "invprev"			// L SHOULDER
bind "JOY6" "invnext"			// R SHOULDER

bind "JOY7" "changeclass"		// BACK
bind "JOY8" "pause"			// START

bind "JOY10" "voicemenu 0 0"		// Right Stick Down
bind "JOY9" "+duck"			// Left Stick Down

bind "POV_UP" "slot1"
bind "POV_RIGHT" "slot2"
bind "POV_DOWN" "slot3"
bind "POV_LEFT" "slot4"



Okay, is there an aimassist in gmod that could help me?

lmfao, most you could get is some epic jaymod lue hakes!!!1

Hmm, this is actually an interesting concept. I used an X360 pad a while back and found that it was hard to keep up with a mouse. Maybe I’ll write one, idk.

No aim assist, this is a PC title.

I already have the 360controller.cfg in gmod, but I want to replace it with lua so I can make it more like a Console game, in my first post, I said I wanted to make things fade on the screen, I asked that because I wanted to make the A button jump when I’m not near a door, but when I’m near a door, an image will fade on the screen telling me to press A to open the door, so it would be easier to open doors without having to bind use and jump to the same key, which could cause annoying issues. I also want to make the aim assist so that I’m not necessarily hacking, but just helping me aim a little when I use the Xbox controller, because a controller is not comparable to a keyboard and a mouse in any FPS game, but I want to at least try using something else for a change.

EDIT:Jmod is the dumbest f****** s*** I’ve ever seen, I don’t know why so many f****** people talk about that retarded f****** game.

Is GAC still a thing?

Aim assist isn’t hacking! It’s just helping you aim a little. I know that sounds like hacks, but ho on youtube and search “Aim assist” and ignore anything that says Aim assist is overpowered

also this

You could use the KEY Enums.
pseudocode:
[lua]
local function IsDoor(ent)
if not ent or not ValidEntity(ent) then return false end
local class = ent:GetClass()

    if class == "func_door" or class == "func_door_rotating" or class == "prop_door_rotating" then
            return true
    end
   
    return false

end // ripped from wire door controller
if input.WasKeyPressed() == KEY_XBUTTON_A then
local trace = LocalPlayer():GetEyeTrace()
local ent = trace.Entity
if IsValid(ent) and (IsDoor(ent)) and (trace.HitPos:Distance(LocalPlayer():GetShootPos()) < 100) then
RunConsoleCommand("+use")
else
RunConsoleCommand("+jump")
end
end
[/lua]

Joy to key would only be good with buttons, if you want to make analog sticks work how they would in a n Xbox game, than Joytokey is useless, also, I prefer Xpadder, it costs money, but things that cost money are usually better anyway

You can actually do that with j2k now (based on how far you move the stick, it’ll change what buttons are pressed, just like xpadder)

I’m more thinking of j2k being used in collaberation with sources natural support of controllers (Aka, move and look with sticks, and use 2 modes with j2k, Combat, and Build mode)

Y button could toggle between toolgun, phys, and grav. Of course this can be done with clever .cfg files but its easier with j2k or XPadder

You could be freaky and set the Run Speed with the help of the JOYSTICK enum

Okay, but doesn’t just running the console command +jump make the player keep jumping? Wouldn’t I have to add that code again to run -jump, because when I run +attack1 in the console, the player doesn’t stop shooting.

cslua

That’s why i wrote PSEUDO Code. I’m just giving you some basic ideas. none of my code works because im too lazy to write proper code.
[lua]local function IsDoor(ent)
if not ent or not ValidEntity(ent) then return false end
local class = ent:GetClass()

    if class == "func_door" or class == "func_door_rotating" or class == "prop_door_rotating" then
            return true
    end
   
    return false

end // ripped from wire door controller
if input.WasKeyPressed() == KEY_XBUTTON_A then
local trace = LocalPlayer():GetEyeTrace()
local ent = trace.Entity
if IsValid(ent) and (IsDoor(ent)) and (trace.HitPos:Distance(LocalPlayer():GetShootPos()) < 100) then
RunConsoleCommand("+use")
timer.Simple(0.2, function() RunConsoleCommand("-use") end)
else
RunConsoleCommand("+jump")
timer.Simple(0.2, function() RunConsoleCommand("-jump") end)
end
end[/lua]

tbh you’re going to NEED aim assist if you have a controller, because even then you won’t be as accurate as you would with a mouse

of course, a controller for building would probably be a LOT more relaxing

[editline]12th February 2015[/editline]

that plus controller has the benefit of using DPad for contraptions

enter your contraption and control it with the dpad, or change mode and control it that way

I’m probably going to leave the moving to the 360controller.cfg, I’m just going to code something for the door overriding the jump key and some images to appear on screen when I have to press a button that Isn’t so easy to remember.

[editline]13th February 2015[/editline]

I’ll test it on a local TTT server and I’ll get a friend to join somehow, happy?

[editline]13th February 2015[/editline]

So, how would I make an Aim assist system? After watching some videos, I thought that what I would do is make something like this:

Aim assist would be activated by pressing a button(LB or LT(and disable scope, but then I would have ot set something up in the lua to disable it when I’m in a sniper)), because I don’t want it to be toggle-able, when the button is held, it will not show any noticeable actions if there are any players nearby, when I go over a player’s body part with the crosshair and they are alive, it will keep move the crosshair slowly to follow where they go, so I’ll still have to move the joystick, but it will help me aim a little bit better and get me closer to players thinking I’m using a mouse.

The problems I’m having with this idea is this: How would I make it so the things switches body parts to aim at really quick without to much lag, I’m thinking of a setting a variable, and then putting some code to aim at the body part, how much lag do you think that would cause with all the variables being changed

Also, I want to set something else up, when I’m sniping someone, I want it to use entirely different code, what I want to do is make something where I can click RB on my target, and it would highlight their player unless their dead or behind a wall, I’m setting those because I want to use these on TTT, so if someone is disguised, it won’t show their name, but I know that I’m shooting the right target, if their in a crowd. I want to know how to put an overlay over a player’s body.

And if people answer these questions, can you give me any useful links I might need?