User Tag List

Results 1 to 5 of 5

Thread: Making the jump into gamepad support - question after watching VACCINE video

  1. #1
    Clicker Fusion 2.5 Developer

    Join Date
    Apr 2014
    Location
    Snohomish, WA
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making the jump into gamepad support - question after watching VACCINE video

    Hi all

    On my current project, I've blazed a new trail for myself and am including support for remapping keys on the keyboard in-game, as well as gamepad support. I've been messing around with and testing Joystick 2, seems like that's what everyone uses. It feels very similar to the Keyboard Object, in that you test if a keypress is happening and that keypress matches the ID that's stored in order to determine if that key is supposed to do something.

    Today, CT tweeted a video for VACCINE, which was pretty cool to see how weird the data is that comes out of the controllers, and what it does to simplify it. However I think for my purposes, the gameplay is fairly simple and I'm not sure I really need a robust system like that. Basically, I'm planning to setup the gamepad code to be just like the keyboard code:

    Repeat while LeftKey is pressed ("LeftKey" being the name of a global value that stores the key value set on an in-game options screen)
    - Do stuff

    Likewise, I'll have globals set to the button values, and check if those are pressed. What I'm curious about is, will this work universally as long as the player has set their controller on the option screen? The game is a retro platformer: left/right, jump, shoot, use jetpack. I don't think I will need anything complicated to make this work. As long as they set their preferred buttons and those values are stored, it should work? The only thing I can maybe see there being issues with after watching the video is the sticks or analog triggers, which I'll have to figure out on their own.

    I have tested a couple random gamepads, including an N64 controller with USB adapter, and my tests all seem to work fine. Just curious if I'm oversimplifying and setting myself up for failure.

    Thanks
    Chris

  2. #2
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,275
    Mentioned
    90 Post(s)
    Tagged
    0 Thread(s)
    If you want something as simple as Repeat while LeftKey is pressed for gamepads, then Joystick 2 object on its own (ie. without VACCiNE) probably won't give it to you. However, VACCiNE has almost 1000 events, so I can definitely understand the reluctance to shoehorn it into your project for what seems like fairly simple functionality.

    I think you can use Joystick 2 on its own successfully, without "setting yourself up for failure". Just be prepared that it'll get a bit messier than your keyboard controls. I don't have a N64 controller, so I don't know how that will work, but this is roughly what it would look like for an xbox gamepad (which, since it's the defacto standard PC gamepad, you'd probably want to support if you're serious about letting others play your game using a gamepad):

    For dpad, it'd be similar to keyboard:
    if POVdegrees( "Joystick 2 object", LastActiveJoystick( "Joystick 2 object" ) ) = 270
    -then move left


    For left-stick, you'd probably ignore the 360 data and stick with 8-direction controls, which would look like:
    if joydir( "Joystick 2 object", LastActiveJoystick( "Joystick 2 object" ) ) = 4
    -then move left


    However, you'll likely find that allowing only western movement of the stick (=4) will feel restrictive....you may also want to include northwestern (=3) and southwestern movement (=5), so you could simply do
    if joydir( "Joystick 2 object", LastActiveJoystick( "Joystick 2 object" ) ) > 2
    if joydir( "Joystick 2 object", LastActiveJoystick( "Joystick 2 object" ) ) < 6
    -then move left


    For right movement, it's a little fiddlier, because east is 0 and northeast is 1, but southeast is 7, so you'd need to do something like:
    if joydir( "Joystick 2 object", LastActiveJoystick( "Joystick 2 object" ) ) > -1
    if joydir( "Joystick 2 object", LastActiveJoystick( "Joystick 2 object" ) ) <2
    OR
    if joydir( "Joystick 2 object", LastActiveJoystick( "Joystick 2 object" ) ) = 7
    -then move right


    If you wanted to allow the right joystick, then that's different again, because 360degree and 8-directional movements aren't supplied at all by Joystick 2, there's no single value you can look out for, but a big continuum called RawXrotation that goes from 0-32766 for left and 32767-65535 for right...however, those have absolutely no deadzone, so you'd need to choose one yourself - perhaps 0-15000 for left and 50535-65535 for right. So for left, you'd have something like:
    if xRotation( "Joystick 2 object", LastActiveJoystick( "Joystick 2 object" ) ) < 32767
    -then move left



    So, as you can see, to move left in Joystick 2 is not exactly the cleanest thing in the world, and certainly not as simple as with keyboard, or VACCiNE:
    if movementLeft("VACinput") = 1
    -then move left

    (which takes care of keyboard, dpad, and leftStick all at once, on xbox and PS4 gamepads.....though not N64)

    But VACCiNE also comes with a bunch of crap that you probably don't need. And while the Joystick 2 code above isn't ultra lean, it's hardly diabolical. It's certainly doable. It won't hurt to try doing it using just Joystick 2. You can always switch to VACCiNE down the track if you want. Especially since it sounds like you won't be hardcoding all of your input but will be storing the input data in a global variable. If you switched to VACCiNE one day, it could potentially be almost painless, for example with the following line seamlessly letting VACCiNE work with your existing code:
    Always
    set LeftKey to movementLeft("VACinput")

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Apr 2014
    Location
    Snohomish, WA
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dammit, I typed up this whole long response, and it somehow didn't get posted. ugh. Basically, what I said was first and foremost, thank you for this in depth response: you hit the nail on the head. I'm extremely hesitant to incorporate a huge amount of someone else's code that I'm not familiar with into my engine that I (stupidly) built without gamepad support in mind. So now I'm adding it after the fact and I think adding external code could cause Fusion to misbehave. I'm out of town right now, but as soon as I'm back I'm going to jump into VACCiNE and see how it's structured and how I could potentially incorporate it into my own game. Much appreciated that you took the time to respond and answer my question - very cool of you to do so!

    Thanks
    Chris

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,275
    Mentioned
    90 Post(s)
    Tagged
    0 Thread(s)
    I made VACCiNE as user-friendly as possible. Ideally, you should be able to happily ignore 99% of the code. Having said that, I usually hate wading through other people's code. No matter how well organised it is, it always takes me ages to get my head around it, and makes my brain hurt (in fact, I've just been doing that with some code I wrote myself 3 years ago, and that was hard enough!). So I definitely understand your reservation about diving into VACCiNE!

  5. #5
    Clicker Fusion 2.5 Developer

    Join Date
    Apr 2014
    Location
    Snohomish, WA
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Haha, I hear you. Only in the past year or so have I started naming alterable/global values, grouped objects into folders, that kind of a thing...I have so many old projects I've been looking through that are so disorganized, it freaking kills me

Similar Threads

  1. VACCiNE - a universal gamepad and debugger engine
    By Volnaiskra in forum Fusion 2.5
    Replies: 67
    Last Post: 27th October 2018, 12:07 PM
  2. Highscores that have gamepad support
    By rosse119 in forum Fusion 2.5
    Replies: 2
    Last Post: 27th May 2016, 10:10 AM
  3. Not sure what to do with the gamepad support.
    By J3sseM in forum Fusion 2.5
    Replies: 13
    Last Post: 13th May 2016, 03:00 AM
  4. Replies: 3
    Last Post: 28th September 2015, 10:45 AM
  5. iOS 7 Gamepad support
    By Koji_Kabuto in forum iOS Export Module Version 2.0
    Replies: 14
    Last Post: 20th November 2013, 12:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •