sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    SP3 feature: Joystick and Keyboard.

    Scheduled Pinned Locked Moved SketchyPhysics
    15 Posts 6 Posters 4.3k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      CPhillips
      last edited by CPhillips

      SP2 supported up to 2 joypad axis from a Ps2 style controller by setting the values in a joints controller field to "joyLX", "joyLY", etc. That was all and no buttons were supported.

      For SP3 the originial "joyLX" values will work as before but there is now support for buttons and even an expanded controller. Currently it is configured to take input from an wired XBOX 360 controller plugged into the USB port. It has to be a wired one because DirectX doesn't recognize the wireless ones (unfortunately)

      The new controll values are:
      leftx= left joystick in the horizontal direction
      lefty= left joystick in the vertical direction
      rightx= Right joystick horiz
      righty= Vertical

      And for buttons:
      a
      b
      x
      y
      lb
      rb
      start
      back

      Triggers are partially supported via "lt" and "rt"

      When you run the simulation you can use the WASD and UP/DOWN/LEFT/RIGHT keys to emulate a 360 (and joyLX,joyLY) controller. The buttons are not currently emulated but will be soon.

      Issues:
      -This feature isnt fully finished yet. Buttons are not mapped to keyboard and some joy axis don't work. Also missing is a config util.
      -Make sure the "Control Panel" window has focus when you try to use the keyboard. Otherwise you will probably hit one of SU's hot keys and abort the sim.
      -Keyboard UP/DOWN are reversed when emulating joystick. Will be fixed in next release.

      No video for this one.


      NewJoystick2.skp

      1 Reply Last reply Reply Quote 0
      • P Offline
        Platypus5
        last edited by

        I am having a hard time getting it to work. Can you show me exactly what I should put if I want a motor to be controllable by the keyboard?

        1 Reply Last reply Reply Quote 0
        • P Offline
          Platypus5
          last edited by

          Also, would it be possible to assign your own keys to the controllers?for example, have "space" trigger the piston behind a piston-gun?

          1 Reply Last reply Reply Quote 0
          • C Offline
            CPhillips
            last edited by

            @platypus5 said:

            Also, would it be possible to assign your own keys to the controllers?for example, have "space" trigger the piston behind a piston-gun?

            The motorboat example uses keyboard for servo and magnet control.

            I decided not to support arbitrary keyboard access because there would be all kinds of configuration problems with non-english keyboards. But I will map the spacebar to one of the buttons.

            1 Reply Last reply Reply Quote 0
            • P Offline
              Platypus5
              last edited by

              @cphillips said:

              @platypus5 said:

              Also, would it be possible to assign your own keys to the controllers?for example, have "space" trigger the piston behind a piston-gun?

              The motorboat example uses keyboard for servo and magnet control.

              I decided not to support arbitrary keyboard access because there would be all kinds of configuration problems with non-english keyboards. But I will map the spacebar to one of the buttons.

              true....oh well. it would make tank style steering much easier.

              1 Reply Last reply Reply Quote 0
              • C Offline
                CPhillips
                last edited by

                Updated first post with new sample. Also I found a bug where keyboard emulation of the right y axis (UP/DOWN) seems to be backwards. Fixed in next release.

                1 Reply Last reply Reply Quote 0
                • W Offline
                  Wacov
                  last edited by

                  I'm using a 360 style wired joypad. This is what my controls do:

                  A=B
                  X=A
                  Y=Y
                  B=X

                  Analog triggers= joyRY
                  Triggers=Triggers
                  Left stick=joyLX,joyLY,leftx,lefty
                  Right stick=rightx,righty
                  Other=joyRX doesn't work

                  Will I be able to fix this with the config utility? Does anyone else have a similar problem?

                  http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    CPhillips
                    last edited by

                    @wacov said:

                    I'm using a 360 style wired joypad. This is what my controls do:

                    A=B
                    X=A
                    Y=Y
                    B=X

                    Analog triggers= joyRY
                    Triggers=Triggers
                    Left stick=joyLX,joyLY,leftx,lefty
                    Right stick=rightx,righty
                    Other=joyRX doesn't work

                    Will I be able to fix this with the config utility? Does anyone else have a similar problem?

                    Except the buttons (ABXY) that looks about right. Your specific controller must map those buttons differently. And yes the config should fix this problem.

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      Sgt.A.Johnson
                      last edited by

                      Is there any support for the individual triggers on an xbox controller. IM trying to make a car using them for accelerator and brake but i dont want to use joyRY for various reasons.

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        CPhillips
                        last edited by

                        Are you talking about the two analog triggers on top of the controller? If so that is "lt" and "rt". BUT. They dont quite behave as you'd expect. If you hold the left one down you will get a value of -1 and if you hold the right one down you will get a 1 if you hold both down you get a value of 0.

                        1 Reply Last reply Reply Quote 0
                        • W Offline
                          Wacov
                          last edited by

                          @sgt.a.johnson said:

                          Is there any support for the individual triggers on an xbox controller. IM trying to make a car using them for accelerator and brake but i dont want to use joyRY for various reasons.

                          I think I see what you want to do... you only want the input from one trigger or the other, not both? If you stil want it to be analog, try:

                          if joyRY>0.5
                          joyRY
                          else
                          0.5
                          end
                          

                          (Reverse to < for the other trigger)

                          Or, if you just want it to act as on/off:

                          if joyRY>0.5
                          1
                          end
                          

                          Overall, pretty simple stuff. It can be further shortened with:

                          joyRY>0.5? joyRY;0.5
                          

                          or:

                          joyRY>0.5? 1;0
                          

                          Hope this helps!

                          I suppose something of note is my trigger input seems to be reversed... my left trigger gives a positive value, and vise versa.

                          http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

                          1 Reply Last reply Reply Quote 0
                          • S Offline
                            Sgt.A.Johnson
                            last edited by

                            @cphillips said:

                            Are you talking about the two analog triggers on top of the controller? If so that is "lt" and "rt". BUT. They dont quite behave as you'd expect. If you hold the left one down you will get a value of -1 and if you hold the right one down you will get a 1 if you hold both down you get a value of 0.

                            Thats what happens when i use joyRY but i want to be able to use both triggers at the same time but for 2 different things. best example i can think of is halo using duel wield to have a gun in either hand

                            1 Reply Last reply Reply Quote 0
                            • C Offline
                              CPhillips
                              last edited by

                              I understand. But it will have to wait for a future version. Microsoft has two different controller api's. One for pc style joystics and one for 360 style. I used the common one because thats what most folks have. I will add the 360 style as soon as I can.

                              1 Reply Last reply Reply Quote 0
                              • L Offline
                                latur maku
                                last edited by

                                how to use this code? is this ruby?

                                @unknownuser said:

                                if joyRY>0.5
                                > joyRY
                                > else
                                > 0.5
                                > end
                                

                                (Reverse to < for the other trigger)

                                1 Reply Last reply Reply Quote 0
                                • M Offline
                                  Matt Falacinski
                                  last edited by

                                  edit

                                  1 Reply Last reply Reply Quote 0
                                  • 1 / 1
                                  • First post
                                    Last post
                                  Buy SketchPlus
                                  Buy SUbD
                                  Buy WrapR
                                  Buy eBook
                                  Buy Modelur
                                  Buy Vertex Tools
                                  Buy SketchCuisine
                                  Buy FormFonts

                                  Advertisement