Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewired - Advanced Input for Unity

Discussion in 'Assets and Asset Store' started by guavaman, Sep 25, 2014.

  1. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    One physical difference on Vita compared to a normal gamepad is that it only has one pair of shoulder buttons. So it's possible that you'd have to deal with that. Like if you wanted what's normally controlled by triggers to be the Vita's shoulder buttons, it'd just a matter of creating a map for how you want the Vita to map to your actions. But even if you needed to do that (which is easy), you don't have to touch any of your code, since you access controls by action name.

    I have an old Saitek X45. It isn't supported natively in Rewired (yet), so I had to create my own profile for it. It took a fair amount of work (so... many... buttons...); the author walked me through the specifics. Creating an entirely new joystick profile isn't the focus of Rewired, since guavaman prefers you use the built-in profiles, but it's certainly possible and that stuff all has in-editor UI's even. Rewired does come with some CH profiles though.
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I hadn't thought of that, but now that you mention it, it may be better if I change it so the L/R buttons are derived from the Shoulder 2 on the Dual Analog Gamepad Template so it will correspond to what's normally a trigger. I'll think about this.

    I just recorded a tutorial video on the process and will be uploading it to YouTube to hopefully make the process a little more clear. But yes, I prefer to map the devices myself so they're supported on all platforms instead of just one. Regardless, if you make a controller definition, please do share it with me so I can include it in Rewired for everyone else. Edit: Here's the tutorial video.
     
    Last edited: Dec 4, 2014
  3. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    That would probably make sense, since the triggers on a gamepad would commonly be used for "primary" game actions like weapon firing and gas/brake. Still, most games beyond very basic action games would probably use the gamepad shoulder buttons for stuff too, so you'd still have to deal with how you're going to handle that on the Vita, which means you'd likely want to set up a map for it anyway. So it's probably not that significant either way.
     
  4. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Just a quick point that it seems to be in the wrong Asset store section. Not in 'scripting/input-output'
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Actually it's not. It doesn't belong under scripting as it's a number of DLLs and editor tools. And the scripting section does not have the 1 license per seat requirement like Editor Extensions does (this is automatic based on how you categorize it in the store). There are no suitable categories under Editor Extensions for it, so I had to place it in the root category.
     
  6. HKSpadez

    HKSpadez

    Joined:
    Apr 24, 2013
    Posts:
    87
    hey there. im liking it so far but i have a question.

    is there an easy way to tell which controller is "active?"

    cause say i have a 2 player game. and it just says "press start"

    and i want the first 2 controllers which press start to be the ones in play.

    is there a way i can grab the "playerid" from the next "start" input? so that i can set my playerId for
    player = ReInput.players.GetPlayer(playerId);
     
  7. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Thanks for sharing about the Vita.

    Saitek X45 with all of those buttons. :) I can only imagine just looking at the CH profiles (FighterStick / Eclipse Yoke and Pro Pedals) included in Rewired



    Rewired_CH_FighterStick.JPG

    Rewired_CH_EclipseYoke.JPG

    Rewired_CH_Pro_pedals.JPG
     
    guavaman likes this.
  8. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    34 buttons and 6 axes. Just trying to figure out what to call some of them was a challenge, since many of them aren't labeled. I mean, what do you call a 4-way switch that doesn't look like a hat switch?

    One cool thing that guavaman showed me was a way to remap axis values. Like, in my game, a gamepad thumbstick controls forward and reverse throttle. The X45 throttle goes from -1 to 1, but there's no easy physical way to move to the zero (enter) position. It doesn't spring back like a thumbstick and there's no center detent. But in the "hardware joystick map" in Rewired has a way to map the -1 to 1 values to instead be 0 to 1. Which in my case was perfect.
     
    guavaman likes this.
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Active, yes. A specific Action or controller element when no controllers have been assigned to Players, not directly, no.

    Rewired is designed to auto-assign controllers on start to the various players or you can assign them yourself if you disable this feature. Because controller maps loaded by the Player and not the Controller, there is no "Start" input generated unless you assign that controller to a Player first.

    ---------------

    Method 4: [Edit: Added this new method which is better than the below methods]

    This involves basically using a variable Rewired.Player as an input source for your own Player object.

    1. Make your Players (let's say Player 0 – 3) in the editor.
    2. Assign them all joystick maps for the controllers you want to support.
    3. Create a “Start” action and be sure it is assigned in the controller maps you assigned to the Players on some button -- preferably, multiple buttons just to be sure in case a particular controller has no Start button (or “Center 2” as defined in the Dual Analog Gamepad Template.) A safe bet would be to put it on “Center 2” and “Action Bottom Row 1” for the Dual Analog Gamepad Template, and Button 0 on Unknown Controller (if you're defining an Unknown Controller map).
    4. Leave controller auto assignment enabled. Rewired will give each Rewired.Player a controller if available.
    5. Loop through all Rewired.Players and check for player.GetButtonDown(“Start”).
    6. Now in your game code, simply assign whichever Rewired.Player returned TRUE to your game-side player object. Your game-side player object may be Player[0], but the Rewired.Player doesn’t have to be. The user could press a button on the controller assigned to Rewired.Player[3], but you can still then use Rewired.Player[3] as the input source for your game-side Player[0].

    It’s a whole lot less work than trying to loop through maps and such and you get all the benefits of working with named Actions for detecting “Start”. However, if you also support Keyboard and Mouse, at that point you might want to go ahead and load the appropriate keyboard map layouts for your Player[0] into Rewired.Player[3]. This works best if keyboard layouts for the various in-game players will be fixed. IE: Player 1 always uses the WASD set, Player 2 always uses JIKM, etc. (There are ways to make this assignment dynamic too but that's not covered here.)

    ------------------

    In order to do what you're trying to do you're going to have to write your own assignment system.

    Method 1: Easy but does not detect "Start", only any button press:

    1) Disable controller auto assignment in the Rewired Editor.
    2) In your script, iterate over all joysticks and check for any button press. (or use the polling methods in the ControllerWithAxes class )
    3) Assign that joystick to the first player.

    You will not be able to detect for the "Start" as a button because Controllers do not load the controller maps -- Player does. So by bypassing the Player system, you do not have access to any of the mapping information. The best you can do is detect for any button press.

    Method 2: Detect "Start" button press:

    1) Assign all controllers to the System Player on start so we can detect the result of Actions.
    2) Check for the value of the "Start" Action you've created and assigned to the Start button in the gamepad maps.
    3) Loop through the controller maps in the System Player for each joystick, loop through each button map looking for the actionId of your "Start" action. (Or use the ControllerMap.GetButtonMapsWithAction method instead.)
    4) Then use the elementIndex in the button map to find which button index corresponds to the "Start" action in that controller.
    5) In each controller, then check the value of the button at that index to see if that was the controller that was activated.
    6) If it was, assign that controller to Player 1 and deassign it from System.

    What you're essentially doing here is working backwards from the result of the Action trying to find what controller element(s) contributed to this final combined value. It goes against the source controller-agnostic nature of Rewired's player-centric system, but it is possible to do.

    A quicker but less accurate method would be to do step 1 and 2 above then:

    3) Loop through each controller in the System Player and find out which controller was the last to have any button pressed and assign that controller to the Player.

    This isn't perfect since any button could have been pressed on any controller besides the ones assigned to the "Start" action, but in most cases it would probably work fine.

    There are also other functions to get the last active controller, but they won't help you here because you're only concerned with the "Start" button press and not axes, etc.

    Method 3: This method only works if you know your users are going to only be using one specific controller type (such as an Xbox controller on an Xbox system).

    1) Use ReInput.controllers.polling.PollAllControllersForAllButtons to poll for button presses.
    2) Check the returned ControllerPollingInfo.elementIdentifierId or ControllerPollingInfo.elementIdentifierName to determine which button was pressed.
     
    Last edited: Feb 5, 2015
    andreiagmu likes this.
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
  11. HKSpadez

    HKSpadez

    Joined:
    Apr 24, 2013
    Posts:
    87
    In the example you set Action Row 1 as fire. On my xbox controller that was A. how do you know what each of these "action row" buttons do. or action top row. etc.

    is there a picture I can reference to figure out which of these refer to which button?
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I tried to be as descriptive as possible with the names so as to not require a pictorial guide.

    Imagine a 6 button gamepad:

    O O O = Action Top Row
    O O O = Action Bottom Row

    1, 2, 3 from Left to Right

    Xbox 360 pad:
    A = Action Bottom Row 1
    B = Action Bottom Row 2
    X = Action Top Row 1
    Y = Action Top Row 2

    Xbox only has 4 buttons so the last two buttons are not usable.

    Everything else is self-explanatory except maybe center:

    Center 1 = Select
    Center 2 = Start
    Center 3 = Optional 3rd center button

    Shoulder/Triggers:

    Left Shoulder 1 = Left Shoulder Button 1
    Left Shoulder 2 = Left Trigger / Left Shoulder Button 2
    Same for right side
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.15 is ready for download for registered users. If you purchased Rewired and would like to get access to all the latest downloads immediately, please contact me here with your email address and I'll send you a download link.

    The update will be available through the Asset Store within 7-14 days usually.

     
  14. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    One thing that helped me visualize that naming was to grab a gamepad controller and rotate it 45 degrees clockwise. Then the top row/bottom row naming makes sense.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    True. Back in the days, the SNES gamepad had coloring to highlight the rows. And 6 button controllers can't be laid out at 45 degrees so they naturally form bottom and top rows. Most gamepads label these buttons sequentially by row as well. Either A, B and X, Y, or 1, 2 and 3, 4.
     
  16. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I've got a question on how to determine which on-screen glyphs (icons) to display. I've noticed that a lot of PC games will automatically switch their on-screen prompts based on the last input device used.

    With GetLastActiveController, I can look at the controller "type" to determine if the last input was keyboard or joystick, so that's helpful to know if the player is currently using a keyboard. If they start using a joystick, I'd like to be able to display prompts specific to the gamepad (triangle for PS3 gamepad versus Y for Xbox, etc).

    Is there a way to do that?
     
  17. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    With my old Logitech gamepad, the "bottom row" is 2 and 3 and the "top row" is 1 and 4. That's a pretty bizarre case of course. :)
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You would have to check the controller(s) the player is using to identify it and match it up to a set of icons. Use these to identify it:
    Controller.hardwareIdentifier
    Controller.hardwareName
    Controller.name
    Controller.type
    Joystick.hardwareTypeGuid

    The best one would be Joystick.hardwareTypeGuid which would work for any recognized controller. You can get the GUID from the Hardware Joystick Map file.

    To find the ActionElementMap for a specific Action so you can display "Press X to Jump", etc., loop over the joystick maps in player for the joystick you're interested in:
    player.controllers.maps.GetMaps
    JoystickMap.ContainsAction
    JoystickMap.ElementMapsWithAction
    JoystickMap.ButtonMapsWithAction
    JoystickMap.AxisMapsWithAction

    Or use:
    player.controllers.maps.GetFirstElementMapWithAction
    player.controllers.maps.GetFirstButtonMapWithAction
    player.controllers.maps.GetFirstAxisMapWithAction

    Then:
    ActionElementMap.elementIdentifierName

    Now you'll have to match that with an icon of your choice.
     
    Last edited: Dec 6, 2014
    IvayloDev likes this.
  19. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Ah, perfect. I was able to get a quick test to work using the second method, specifically GetFirstElementMapWithAction. I may end up wanting to try the looping through everything method when I implement the icons for real.

    For my game, I may be able to get away with not checking the Joystick.hardwareTypeGuid. I'll likely have generic icons for A, B, X, Y, Triangle, Square, Cross, Circle, "Button 1", etc. If I get those values, that's enough information I think, given that I know whether the last controller was a keyboard or joystick. I'm not going to worry about Y buttons styled differently on different gamepads or whatever. And stuff like "Left Trigger" I can have generic icons for. It's nice to know that I can get more specific if I need to though.

    Thanks for the answer!!!
     
    guavaman likes this.
  20. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That definitely is a challenge.

    That is great being able to use 0 to 1 instead -1 to 1.
     
  21. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Seems like counter clockwise numbering rather than row based. :)

    How many different controllers are you working with?
     
  22. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Rewired certainly has the best variety of game controllers (Light guns, Flight simulation controllers and now the G27 Racing wheel) supported out of the box.

    Having separate raw input and direct Input in this update will be very useful.

    If you look in the UnityFS (flight simulation) thread someone was wishing that they had this option in Unity.

    "... After some digging I see that the problem is in relation to whether your joystick/hotas is sending it output as either DirectInput or RawInput.

    Until Unity allow us to configure as one or the other, ..."

    http://forum.unity3d.com/threads/unityfs-flight-simulation-toolkit.171604/page-6 (msg #288).

    Looks like this Rewired update will certainly solve that problem.
     
    Last edited: Dec 7, 2014
    guavaman likes this.
  23. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    As a European gamer, the SNES gamepad had different colours for each button. So for me it was more like a duplicate D-Pad. Especially after playing Super Smash TV ;)

    Thank you for making Rewired, it was very easy to implement and packed with features. Looking forward to more updates!
     
  24. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I'd like to support as many controllers as possible, with an emphasis on gamepad-style controllers. It's a nice bonus to be able to support HOTAS devices too, since it's a space sim game, but gamepads actually work better for my particular game. A decent number of people use the X52 Pro with Elite: Dangerous though, so they are out there. I have a fairly decent mouse/keyboard control scheme, but that's definitely not the intended experience.

    Personally, I have the Logitech Rumblepad 2, DualShock3 (PS3), DualShock4 (PS4), Xbox 360, Xbox One, and OUYA gamepads. I also have a truly weird one that came with an Android TV dev kit. The only HOTAS one I have is the old X45. Probably want to add X52 and X52 Pro support in my game, since those are more common, but I don't have either of those. Maybe when I get further along I can justify picking one or both of those up. I haven't played flight stick style games since the 90's, but it does seem that with the space game resurgence they're coming back at least a bit.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks! I'm glad everyone I've heard from so far has been very pleased!

    Now that you mention it, I think the mutli-colored buttons were also used in the Japanese Super Famicom. Most controllers since have followed suit -- old/current Gravis gamepads, Xbox 1/2/3, all the current Logitechs...

    If anyone has a better suggestion on the naming of those Dual Analog Gamepad template elements, let me know. Changing their names won't affect anything since they're never accessed from code. (When the template is loaded for a controller, it maps it to a controller map for that specific device and the real element names show up to the user, not the Template element names. The template element names are only used in the editor.) This template needs to support up to a 6-button layout though just in case.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I have a developer friend who lives nearby with an X52. I gave him a copy of Rewired to see if it solved the very common X52 input lag problem in Unity and he said it did and it works perfectly. I intend to borrow it and map it for inclusion in Rewired, but that will have to wait until January.
     
  27. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Any indication on how common the Saitek X-55 is? What about other HOTAS brands like Thrustmaster? I only hear about CH and Saitek most of the time.
     
  28. yung

    yung

    Joined:
    Nov 22, 2010
    Posts:
    274
    Bought this during the sales, definitely interested in the UFPS integration!
     
  29. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Hi, I'll add to the expression of interest for Playmaker and UFPS support, and also UnityFS if possible- there's a rundown of the input system here. I imagine it wouldn't be too hard to set up UnityFS through reflection with an appropriate component driven by Rewired?

    I considered purchasing Rewired during the recent sale, as I've just implemented controller support and feel it's not terribly flexible using the Unity input system. Not a coder, so ultimately decided I should hedge my bets with Unity 5 input. Playmaker, UnityFS and UFPS support in Rewired would make purchase a pretty clear choice in my case. I'll probably pick it up soon anyway, as I can usually work out how to tweak scripts. Just wanted to second the earlier feature request!

    Cheers

    Edit: Just bought Rewired, it looks fantastic- should definitely be able to make headway on my own. I'm working on a flightsim so it's fairly paramount that I can accommodate a multitude of peripherals.
     
    Last edited: Dec 9, 2014
  30. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That sounds like a good set of integrations to be done to me.

    Rewired works great too. I am Interested in hearing what controllers you are planning on supporting.
     
  31. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Agreed. UFPS integration would be great.
     
  32. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    I've been developing with an Xbox 360 controller, so the inputs I've been using don't exceed available axis' or buttons on that. Frankly, I'll probably just set up for the included controllers applicable to me and then add custom layouts if requested after release. There aren't toooo many to do. Was also planning on keeping controls remappable as simmers (myself included) tend to be quite particular about that.
     
    Last edited: Dec 9, 2014
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    It's not very scientific, but I tend to look at number of reviews on Amazon:

    X52 = 360 reviews
    Thrustmaster HOTAS Warthog = 120 reviews

    I'll definitely be looking into PM and UFPS support in January after finishing framerate independent input.
     
    Karearea and OnePxl like this.
  34. AdamGoodrich

    AdamGoodrich

    Joined:
    Feb 12, 2013
    Posts:
    3,780
    Hi,

    Bit tired so haven't read all the forum to answer this myself, but read a heap and it didn't jump put. From what I understand this is a system that standardises inputs from a whole range in input controllers.

    That sounds awesome - writing your game to handle events that you have defined - and having the various input controllers map to them! Sweet!

    So - is it possible to map touch inputs to events as well ? Swipe left / right, touch, pinch zoom etc. I have prototyped something that handles mouse, controller, touch and keyboard, but its not robust, and certainly doesn't handle the range of devices here.

    Thanks,
    Adam.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Hi,

    Rewired doesn't handle swiping, pinch zooming, and other gestures directly at present. It would be conceivable to use a CustomController in that situation to bridge the gap and associate gestures or any other kind of float or boolean data to Rewired Actions.

    The documentation on this topic:
    Custom Controllers
    How To's - Creating On-Screen Touch Controllers

    Rewired handles on-screen touch controls through the CustomController class which lets you feed any arbitrary float or Boolean value into the system and handle it as an axis/button value for an Action. There aren't any included touch controllers that detect swipes, drags, pinch zooms, etc. at this point. Instead, you can make your own or use existing controls on the asset store and then feed the Rewired CustomController elements the data so you can associate them to Actions.

    I may be adding actual drop-in touch controls in the future, but there are a number of other items on the radar which will be addressed first. Thanks!
     
  36. AdamGoodrich

    AdamGoodrich

    Joined:
    Feb 12, 2013
    Posts:
    3,780
    Thanks for your response :)
     
  37. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    You do that on Amazon also. Do you read all of the amazon reviews too? :) The reviews have some very interesting case studies.

    I see Rewired 1.0.0.15 is available now so we have both raw input and Direct input as separate now. Yea!
     
    Last edited: Dec 11, 2014
  38. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I am interested in what your results will be for supporting all of those controllers. I have been reading some of your comments in the UnityFS thread too. For flight simulation we usually have the hardest game controllers to handle for mapping (due to the large number of buttons and axis) to the appropriate control surfaces.
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    :) Not really unless I'm going to buy one for fun or mapping.

    Yes, it is! 1.0.0.15 is available for download on the Unity Asset Store now.

    1.0.0.17 is available for registered users to download now through the website. Changes in this version:

     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Wow, the Asset Store released 1.0.0.18 immediately. Awesome! It's available for download now.

    In addition to the .16 and .17 changes above, .18 includes:
     
  41. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That is very interesting. I thought the mapping would be the same as Windows store apps already?
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    It's not. Windows App Store uses XInput whereas Xbox One uses Unity's input manager. The mappings are identical to the Windows Fallback platform, except the controller name is different. Still, it needs its own mappings for that platform to be detected and used.
     
  43. Shiratori

    Shiratori

    Joined:
    Aug 27, 2014
    Posts:
    21
    Hey there! First of I wanted to thank you for the great effort you put into this plugin! It's really awesome, and I couldn't recommend it more!

    I have a small question however:

    When I started using the plugin I couldn't get any mouse input to work at all. I troubleshot for a while and was about to contact you regarding what I was doing wrong since no one else had mentioned that as a problem. However I found out what the problem was. I had missed the small toggle in the player settings in the Rewired editor: "Assign Mouse on Start". Felt sort of stupid for missing it at first :p. Maybe it was just me, but maybe it should be mentioned in the documentation for people like me that missed it by mistake :p.

    Is there a reason for it not being enabled for the first player by default? And another question: I probably missed it at fist because of the "Start Enabled" toggle when you assign the mouse map to the player. What is the difference between those two toggles? wouldn't the second be enough?

    You probably have a good reason for that, but just asking :).

    Thanks again for a great plugin!
     
  44. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    Hey, I picked this up a couple weeks ago thinking I would need it eventually. I have cInput, but this appears more robust and focused on multiplayer and multi platform - which is great because my dream scenario is getting this game on PC/Mac but also Xbone, PS4, WiiU and Vita :)

    Currently just prototyping on PC, but trying to test out how the gameplay feels on an Xbox 360 (wired) controller - and have a specific question:

    I have a game where I move the cursor around within the screen bounds to select things. This works fine with the mouse, but I'm trying to get support for the Right Stick of the 360 controller to move a cursor around as well. This would be similar to how it's done in the Telltale games.

    Eventually I want to have the game support local MP (couchplay) so I'd need 4 of these cursors being moved around the screen bounds (camera stays fixed or on a fixed rail movement). This leads me to think that I should be using a software/virtual cursor instead of the hardware one that I'm using (by default), and somehow match the software/virtual cursor to the mouse's or gamepad's movements.

    I see a few ways to do this online, but since I'll probably be adopting your system, I'm just curious what course of action you'd recommend in conjunction with Rewired ... or if infact Rewired has an easy way to implement this itself?


    Oh - also, I'd prefer to use uGUI to create/track the virtual cursors so they could be easily animated... I'm taking a look into how to do this now, but if you have any tips greatly appreciated :)

    Cheers,
    Jesse
     
    Last edited: Dec 12, 2014
  45. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I had the exact same experience. If it makes you feel any better, I didn't figure it out myself and ended up bugging guavaman. :)
     
    guavaman and Shiratori like this.
  46. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I converted my current game from cInput to Rewired a few weeks ago and I can say that's a massive understatement. :)
     
    guavaman likes this.
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks! I'm really glad you like it!

    On the Quick Start:
    http://guavaman.com/projects/rewired/docs/QuickStart.html
    So you missed it in the documentation as well. :)

    It's also implied in the Players page where it mentions that Players must have controllers assigned to them in order to function. The checkbox itself and a description of its purpose is shown in Rewired Editor - Players.

    There really are a ton of things one could miss. I've had a lot of people suggest adding things to or emphasizing various things in the docs because they missed something, but in reality isn't isn't very practical unless I were to add it to a "Why isn't X working?" to the Troubleshooting page for every one of these cases. It's already in the Quick Start tutorial which is presented as one of the first things to read in the docs.

    I've added several entries to the Troubleshooting page, but I've found most people miss that page anyway and end up sending a support question for the issues posted there. Unfortunately there is no way possible to document everything that one might possibly miss in a way that would be impossible for them to also miss in the docs when they have a problem.

    Yes, the reason is not all games will necessarily want a mouse assigned to Player 0 and may just use the System player for mouse controls for menus and such since that's active regardless of which Players are playing. The mouse is always assigned to the System player on start. Additionally, because you can change and reorder players however you like, what was once the first player in your list could easily become Player 6 after you move them around.

    StartEnabled in maps only applies to the maps themselves. You could load 15 maps into your mouse or joystick and enable/disable them on start and then change that setting through code during runtime. See Controller Maps to understand their uses.

    Assign Mouse on Start is completely different. It simply assigns the mouse to the Player just like a joystick has to be assigned to a Player to work. The only difference is you probably left "Assign Joysticks To Players Automatically" checked and never realized this assignment had to be done with joysticks as well because it was done automatically for you.

    These are all just issues of a player-based system. Most game developers are used to simply accessing controls with joystick id's and such, but a player-based system changes all that and requires a number of extra steps to get input going.
     
    Last edited: Dec 12, 2014
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks! Support for console controllers is coming slowly as I work with users who want support for them. I just added Xbox One controller mappings for the Xbox One platform in the latest release. I've had others interested in WiiU, so hopefully that will be coming sometime soon.

    This is kind of outside of the scope of Rewired. Rewired can provide you the input data for the 4 controllers easily, but what you do with that data is game implementation and up to you.

    In terms of Rewired usage, you would just:
    1) Set up 4 players
    2) Create actions for moving your cursor vertically and horizontally
    3) Create joystick maps for all the controllers/templates you want to support
    4) Assign those actions to elements in your map(s). (Left Stick X = MoveHorizontal, LeftStickY = MoveVertical for example)
    5) Assign those joystick maps to the Players
    6) In your game, use player.GetAxis to get the axis from these actions to drive your cursor position. Rewired will return a -1 to 1 value for each which you can use to move your cursor a certain distance per frame.
    7) If needed, you can use Map Categories to create separate maps for the mouse movement and other aspects of your game assuming there are some parts of your game where you don't want mouse movement, in which case you can enable/disable the maps as needed.

    In terms of actual implementation of your pointers, simple Sprites and some raycasting to detect objects to click on would probably work just fine.
     
    Last edited: Dec 12, 2014
  49. Shiratori

    Shiratori

    Joined:
    Aug 27, 2014
    Posts:
    21
    Haha, I thought I read through the manual at least three times, but still missed it :p.

    Thanks for the reply and the explanation anyway!
     
    guavaman likes this.
  50. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    121
    Just integrated Rewired with UFPS and acParkour, and almost everything is working (they're epic with a gamepad).

    The only thing that seems to not be working in the Sky City demo at the moment is Zoom and Fire. I press Zoom (with GetButton()) and it Zooms, and then I press Fire and it stops Zooming and goes into a rest state, where it's also not firing.

    My guess is this might be UFPS and not Rewired at all, but since I'm overloading the UFPS code I'll ask here first instead of there.

    Zoom code:

    // zoom / ADS
    // if (vp_Input.GetButton("Zoom"))
    if (rewiredPlayer.GetButton("Zoom"))
    FPPlayer.Zoom.TryStart();
    else
    FPPlayer.Zoom.TryStop();


    Fire code:

    // if (vp_Input.GetButton("Attack"))
    if (rewiredPlayer.GetButton("Fire"))
    FPPlayer.Attack.TryStart();
    else
    FPPlayer.Attack.TryStop();


    It's pretty basic, and they work individually, just not together.

    I tested it the other way, it is works similarly. I can hold down Fire, and it shoots full auto (M4), and then when I press Zoom it stops work. If I release Zoom it starts firing again. It appears the Left Bumper Bottom and Right Bumper Bottom may be interfering with each other. Im still assuming this is a UFPS integration issue, rather than Rewired not being able to take both button presses at once.

    Anyone have any ideas on this?
     
    Last edited: Dec 14, 2014