making HUD analog joystick that lines up with gamepad

0 favourites
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hi there,

    I'm doing something that uses the analog joysticks for the Ouya at first.

    I'm trying to show the joystick moving on the screen.

    my main focus is on figuring out how to properly capture / quantize the input for both joysticks on the X and Y..

    there is the compare axis, which offers some comparison, but it does't seem to really allow realtime comparison of ranges of value.. since we don't just want simple on / off in this case

    there don't seem to be any actions for "every tick" directly tied to the gamepad... now if i go to "compare to values" from the system i can see a few things as seen in this screenshot

    I just am not used to working with this kind of data.. I was able to capture -1 and +1 data but it seems to only offer X data.. i couldn't figure out how to get the Y data.. and then how to indicate if the data is from the Left or Right analog stick

    I attached the file too

    Thanks!

    Caleb

  • http://part12studios.com/temp/ControllerTest2/ this is a better version but ultimately I can only get this to work if the analog joysticks are simply "on" or "off".

    I can see that I can compare any value coming from the joystick, but it seems like it would be terribly tedious to create a bunch of degrees of "between this and that value" incrementally.

    just seems like a fluid system could be created, but I can't figure out how I can capture the true X and Y data from each analog joystick to make use of that data.

    Attached an updated capx..

  • Ok so I've had some success with the analog joystick stuff, but I'm reaching my edge of understanding what is going on with the gamepad.. but I think we're close to having this pegged.

    here is a video of the joystick in motion:

    https://dl.dropboxusercontent.com/u/699 ... ue%201.mov

    here is a working (kinda) project:

    http://part12studios.com/temp/ControllerTest3/

    here is where I believe the trouble is at:

    so in this picture you will see I'm using this basic formula.. both for X and Y..

    Left_Analog_Y_Pos+((Gamepad.Axis(0,0))/2)

    and

    Left_Analog_X_Pos+((Gamepad.Axis(0,0))/2)

    so I'm listening to this gamepad.axis value but it has two values.. 0,0 which I assume is for X,Y

    the issue I'm having is I don't know how I would tell Construct to listen to the second value and ignore the first one.. the diagonal motion is basically because when I move either direction I'm adding the same X value to both X and Y which causes the diagonal motion.. if I could listen to that second 0 for the Y events, then everything should be pretty darn peachy.

    Thanks!

    Caleb

  • As far as I can understand it should work like this:

    Create a 200 by 200 round sprite (the Base) and a small sprite (the stick)

    every tick set the small sprites position : X = base.x+Gamepad.axis(0,0) Y= base.Y+Gamepad.Axis(0,1)

  • LittleStain yes that worked! I've never used set position before.. i always did set x and set y (which of course I can now see isn't the best way to do it

    So there is only one other question I need to figure out as part of this.. this seems to be a non specific axis input.. but Construct 2 supports left and right joysticks.. so I have to figure out how to capture the raw data from both the Left and Right joystick..

  • So this is a little further along. I've mapped out more buttons and the analog (Left and Right) are linked up

    http://part12studios.com/temp/ControllerTest4/

    because as far as I can tell there is no way to define the Gamepad.axis as left or right analog.

    this also raises the question of accessing the analog left and right triggers..

    seems there are effectively four unique analog inputs coming from a standard xbox controller so its critical to know how to track these values independently and from the options listed, I don't get a sense of how that would work.

  • have you tried gamepad.axis(0,2) and (0,3)?

  • I had tried (1,1) and (1,2) but hadn't tried that and yes your suggestion worked! Thanks again!

    I didn't know what those values represented.. I thought maybe it was some kind of on / off thing or something.

    So any suggestions on how to get the analog value from the left and right triggers? I've done some testing (0,5) ,etc and that didn't seem to work.. I can get them to react ive they are called on, but not sure how to reach the analog value.

    Thanks!

    Caleb

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So also here is the project attached in it's current state.. i've switched over to doing a configuration for an xbox controller since that's the official controller.. although i believe this is a madcatz from the original xbox, but seems to have all the same buttons.

    I'm also attaching the capx this time.. this is totally setup as it should be except for the analog left and right triggers (up top)

    you'll see a blue and green box up top.. these are meant to be the analog triggers.. i figure they could either just move up and down or perhaps grow/shrink with the increasing and decreasing of value.. full height when the player is not pulling on it..

    http://part12studios.com/temp/ControllerTest5/

    What will be nice is this can act as a template for future folks who might want to do something with a gamepad and be sure its working.

    Thanks!

    Caleb

  • Have you tried gamepad.button(0,0) , (0,1) etcetera?

  • LittleStain hadn't because buttons are binary events, but certainly worth a try so I did it and yea it doesn't seem to offer any analog value.. just on/off output.

    Taking that logic I also tried Rawaxis which seemed to produce the same 4 values that the normal Axis offers.

    it seems like there must be a hidden other two analag values somewhere.. I know that the keypress action offers "trigger left" and "trigger right" so I can get that much data from the controller, but if they really do support "xbox360 input" then this data must be in there somewhere to access because it's a standard control input.

    http://part12studios.com/temp/ControllerTest6/

    this is an updated version.. it has been updated to reflect a true xbox360 controller.. although my goal is the Ouya, I'd rather work with what Scirra officially supports so this joystick is an xbox controller. getting the ouya's differences (and there definitely are some) can be sorted out later.

  • One of those button indexnumbers should give analog input between 0 and 100..

    If there is an analog button that is..

    From the manual:

    Button(Gamepad, Index)

    Retrieve the current button press value of a button on a specific gamepad. Index specifies the zero-based index of a button from the dropdown list in the Is button down condition (e.g. 0 returns the value for the A button). The returned value depends on the features of the button: if the button is pressure sensitive, it can return any value from 0 to 100 depending on the pressure; otherwise it returns 0 for not pressed and 100 for pressed. Buttons which are not pressure sensitive are easier to detect using the Is button down condition.

  • Should be gamepad.button(0,10) and (0,11) if I understand correctly..

  • aah ok I wasn't sure i followed the talk of index stuff and why it matter..

    turns out its actually 6 and 7, but yes I was able to capture the analog input of the controller this way! man talk about some cat and mousing, heh. I'll be sure to come up with some illustration for the tutorial to set the record straight.

    Thanks LittleStain for your help has been amazing as always!

    http://part12studios.com/temp/ControllerTest7/

    this effectively maps the entire xbox360 controller. Making it for the Ouya is just a matter of figuring out what buttons are different.

  • Superb work - been following this thread with great interest.

    Are you sharing the .capx for your fantastic efforts? Certainly would help any dev's on here that will be targeting OUYA releases.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)