Search Unity

Rewired - Advanced Input for Unity

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

  1. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    I would also like to know this before the sale is up... thanks!
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I assume you are the person who just posted the review with the same question. (Not an appropriate place for questions.)

    This is what I'm working on:
    http://forum.unity3d.com/threads/50...d-input-for-unity.270693/page-14#post-2081967

    The new uGUI remapping system I'm creating is not just an example, it's a full-blown usable UI system with tons of options. It takes a lot of time to develop something like that in the midst of other large improvements coming in the next release. (Full Xbox One support for one.)

    If what you're looking for is an example of how to interact with the API to do the remapping, saving/loading, polling, etc., whether it's onGUI or uGUI should be irrelevant. You can learn everything you need from either. The legacy GUI example shows from A-Z how to do everything with regards to control mapping. Now if you're looking for a system you can just drop in and use, which is an entirely different story, it's coming.

    Some other very (very) popular input systems don't even give you an example remapping system of any kind and don't do a quarter of what Rewired does.
     
    Last edited: Jul 2, 2015
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired 1.0.0.57 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address. The update will be live on the asset store in 5-10 days.

    1.0.0.57:

    Changes:
    - Improved Xbox One platform support -- includes vibration.
    - Added Xbox One platform.
    - Moved OuyaInputSource.cs into the project. Installation step is no longer required.
    - Microsoft Xbox One gamepad controller definition now uses individual trigger axes on Xbox One fallback platform.
    - Added Amazon Fire TV as a separate platform due to mapping differences vs Android.
    - Added the following controller definitions for Amazon Fire TV platform:
    - Amazon Fire Game Controller
    - Google Nexus Player Gamepad
    - Microsoft XBox 360 Controller (wired)
    - Microsoft XBox 360 Controller (wireless)
    - Sony DualShock 4
    - Mad Catz C.T.R.L.R
    - Mad Catz C.T.R.L.R Micro
    - Red Samurai Gamepad (G mode)
    - SteelSeries FREE
    - 8Bitdo NES30 (Bluetooth, Mode 1)
    - 8Bitdo NES30 (Bluetooth, Joy Mode)
    - Ouya Gamepad
    - GameStick Controller
    - Added default Placeholder path in Windows App Store DLL for Unity 5+.

    API Changes:
    - Added Controller.Extension class
    - Added Controller.extension property
    - Added Controller.GetExtension<T>() method
    - Added Joystick.systemId property
    - Added Joystick.unityId property
    - Added Joystick.SetVibration(int motorIndex, float motorLevel) method
    - Added Joystick.SetVibration(int motorIndex, float motorLevel, bool stopOtherMotors) method
    - Added ReInput.TimeHelper class
    - Added ReInput.time property
    - Added Interfaces.IControllerVibrator interface
    - Added Platforms.XboxOne.XboxOneGamepadExtension class
    - Added Platforms.XboxOne.XboxOneGamepadMotorType enum
    - Added Platforms.XboxOne.XboxOneGamepadVibration struct

    Bug Fixes:
    - Removed all Dictionary usage due to memory allocation bug in iOS Dictionary handling. Now allocates no memory on normal updates in iOS.
    - Fixed rare joystick matching issue on Unity fallback platforms and Custom platforms.
    - Fixed rare crash in Windows 64-bit builds and 64-bit editor.
    - Fixed Windows input sources failing to initialize on certain systems in the Unity editor.
    - Fixed product name on Google Nexus Player remote controller definition.
    - Fixed Game Controller Back and Menu button assignments on Android platform.
     
    Last edited: Jul 2, 2015
    Crazydadz likes this.
  4. davebutlerenator2

    davebutlerenator2

    Joined:
    Nov 8, 2014
    Posts:
    26
    Is there a means of receiving input through Rewired while the game is running in the background (i.e. another application is in the foreground?). I'm looking to run two builds simultaneously and handle mouse/keyboard input in one and gamepad input in the other.

    Thanks!
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Currently the behavior in Windows is a bit inconsistent now that I just tested it.

    Rewired should not respond to input when the window is not focused, however it currently does respond to input from XInput controllers (if XInput is enabled) and controllers if using Direct Input, but not from Raw Input. Mouse input is never active when the window is not focused. I may be changing this in a future release to filter out XInput and Direct Input values if not focused.
     
    HelenL likes this.
  6. davebutlerenator2

    davebutlerenator2

    Joined:
    Nov 8, 2014
    Posts:
    26
    Wow that's amazing. Any chance it could be left in as an option in the Rewired Editor Settings? It's great for testing multiplayer games.

    Great product btw.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I'll look into it when I get to fixing this. The same would probably be desirable for OSX. First comes the remapping system and then PlayMaker actions at least since those have been pushed back too much already.

    Thanks! :)
     
  8. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    Can't wait to use it. Please post when you add Xbox One support (plus UFPS). I bought it, and will play around with it soon.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I just did that yesterday. It's already out for registered users to get on my site. Submitted it to the UAS today, but that usually takes a while.
     
    99thmonkey likes this.
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired 1.0.0.58 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address. The update will be live on the asset store in 5-10 days.

    1.0.0.58:

    Changes:
    - Removed null product name on Sony DualShock 3 on Android platform due to possible matching conflicts.
    - Android, Amazon Fire TV, and PS4 platforms now ignore joysticks with null names to account for Unity's changed handling of removed joysticks on these platforms.
    - Android and Amazon Fire TV platforms now ignore joysticks with "keyboard" in the name to filter out keyboards.

    Bug Fixes:
    - Separated Amazon Fire TV Remote controller definition for Android and Amazon Fire TV platforms and fixed buttons assignments.
    - Amazon Fire TV Stick platform now correctly detected.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Discovered a new bug in Unity 5.02+ that renders remotes (Nexus Player, Amazon Fire TV) undetectable. (5.0 works fine.)

    Unity introduced a new bug in this version that makes the remote appear with a NULL name in the Input.GetJoystickNames array. There is no way to identify these remotes because of this. The bug exists as of 5.1.1f1. It will be reported.
     
  12. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    767
    Hi Guavaman,

    I'm having a special user case and was wondering of this is even possible with Rewire. In our game we have an actionbar with 8 slots, each slot has its button assigned (like 1..8 for the keyboard). We however allow support for a gamepad (or other joystick for that matter) and assigned A,B,X,Y to the first four actions and the same buttons but with the left trigger pressed for the remaining four actions.
    I noticed you can add modifier to keyboard buttons (like alt, ctrl, shift, etc) but I'm looking for modifiers on gamepads/joystick like R-Trigger, L-Trigger in combination with a button. Is this possible?
     
  13. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Hi. ControlRemapping1 demo is too complicated to understand in short time.
    Isn't there any simpler demo of joystick remapping ?
    I just want to know how to use "ReplaceElementMap" with my button input.
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired gives you access to so much through the API, there aren't a lot of things NOT possible with Rewired. But not everything is going to be automatic.

    No. You have to implement it yourself in your own code. Rewired doesn't handle this for you. If you think this through you'll understand why.

    There are pretty much infinite combinations of how a system like this could possibly work depending on your use case. You have so many possible variables such as timings, whether buttons have to be pressed simultaneously or in sequence, what order they have to be pressed in, if the "combo button" is invalidated when one of the individual buttons is released only to be allowed again after all individuals are released, whether these buttons should still return values for Actions mapped to the individual buttons in the combo or silence the values if multiple buttons start to be pressed that are part of a combo, the timings for all of that, how this meshes with axis movements and axes treated like buttons, plus far, far more possibilities for all kinds of use cases. It's much simpler for the developer to implement the system they want for their specific needs. Keep in mind, there's no reason you can't name your Actions more like buttons and use them as such for cases like this. As in Street Fighter 2, Jab + Strong + Fierce = Spin Punch.

    You can use the time properties in Player in combination with GetButton to help with time issues since using GetButtonDown will not work well for this case as nobody will be able to hit multiple buttons EXACTLY at the same time (same frame).

    http://guavaman.com/projects/rewire...rload_Rewired_Player_GetButtonTimePressed.htm
    http://guavaman.com/projects/rewire...oad_Rewired_Player_GetButtonTimeUnpressed.htm

    Apart from all that, as mentioned above, user control remapping with button combos treated as a single Action could be a really big problem. You'd have users remapping the individual underlying buttons to different Actions but the combo Action's buttons would remain unchanged causing all kinds of possible side effects.
     
    Last edited: Jul 3, 2015
    andreiagmu likes this.
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Sorry. I spent a great deal of time writing that code to give you a complete example. You want something super simple, but that doesn't exist when you think through what's going on here. You have to handle a ton of situations including assignment conflicts, mapping axes to buttons and buttons to axes (or preventing that), multiple players, and a lot more. If you can't take the time to read the example, wait for the new uGUI drop-in remapping screen I'm working on right now.
     
    Last edited: Jul 3, 2015
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    In case I wasn't clear enough, you can combine Actions in your code as if they're buttons.

    Code (csharp):
    1. if((player.GetButton("MyAction1") && player.GetButton("MyAction2")) {
    2.     // Do something
    3. }
    This solves all the issues such as user remapping that you would run into with button combos above.
     
    andreiagmu likes this.
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    See ControlRemappingDemo1.cs line 2095 for the usage of ReplaceOrCreateElementMap:
    Code (csharp):
    1. public void ReplaceOrCreateActionElementMap() {
    2.   controllerMap.ReplaceOrCreateElementMap(this.ToElementAssignment()); // create new element map or replace existing
    3. }
    4.  
    5. public ElementAssignment ToElementAssignment() {
    6.   // Create an ElementAssignment struct for use in assignment
    7.   return new ElementAssignment(
    8.   controllerType, pollingInfo.elementType, pollingInfo.elementIdentifierId, AssignedAxisRange, pollingInfo.keyboardKey,
    9.   modifierKeyFlags, actionId, actionAxisContribution, invert, actionElementMapId
    10.   );
    11. }
    12.  

    Polling to get the button press (Line 931):

    Code (csharp):
    1. private void PollJoystickForAssignment(ElementAssignmentChange entry) {
    2.   // Poll the controller via the owning player
    3.   Player player = ReInput.players.GetPlayer(entry.playerId);
    4.   if(player == null) {
    5.   dialog.Cancel();
    6.   return;
    7.   }
    8.  
    9.   // Just poll the controller for the first axis or button press
    10.   entry.pollingInfo = player.controllers.polling.PollControllerForFirstElementDown(entry.controllerType, entry.controllerId);
    11.   if(entry.pollingInfo.success) { // polling returned a result
    12.   dialog.Confirm(); // finish
    13.   }
    14. }
     
  18. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    767
    This is how it is actually implemented now but maybe there was a special treatment possible with rewired (like let the user deside which modifier they wanted for the remaining 4 buttons). Asking doesn't cost anything right? I'll stick to the current implementation logic (as you mentioned also) and make sure the user is aware of the constraint within the mapping UI. Thanks for the feedback.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    You could also designate a separate Action for your "ChangePanelMode" modifier and assign that to a button/key even if that button/key is assigned to something else already. So if you don't want the "ChangePanelMode" function hard bound to whatever the current "Fire" (or whatever) Action is bound to, just use the separate "ChangePanelMode" Action. That way the user can decide what they want their "ChangePanelMode" button to be separately from their "Fire" button, or they can make them share the same button if they choose.

    Code (csharp):
    1. // Both "ChangePanelMode" and "Fire" could be bound to the same button/key or not depending
    2.  
    3. bool isModifierHeld = player.GetButton("ChangePanelMode");
    4.  
    5. if(player.GetButtonDown("PanelAction1")) {
    6.     if(isModifierHeld) // Do secondary action
    7.     else // Do primary action
    8. }
    9.  
    10. if((player.GetButtonDown("Fire")) {
    11.     // Fire
    12. }
    13.  
    14. // User can remap "ChangePanelMode" to a different button without it having to always be bound to "Fire".
    15.  
     
    Last edited: Jul 3, 2015
    andreiagmu and cygnusprojects like this.
  20. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Thanks for reply, that's your "philosophy" and what I need is more than simple. I don't care about assignment conflicts, mapping axis to buttons, and my game doesn't even use multi-players, and so on. You'd better to consider about minimum-use of your asset.

    Your documentation doesn't explain Non of these parameters. what's elementMapId? what's actionId? How do I know an ID of my "circle button" and put it on which parameter of them?
     
    Last edited: Jul 4, 2015
  21. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    I got it this time, since i saw this PM actions. I'll be using it in my next game.
    Thanks for the great work.
     
    guavaman likes this.
  22. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Hi Guavaman,

    Having some weird error showing up occasionnally, seems like an incompatiblity between native rewired and steamworks code. Not sure how to go from there, any idea ?.

    NullReferenceException: Object reference not set to an instance of an object
    (wrapper unknown) Steamworks.LobbyInvite_t:ptrToStructure (intptr,object)
    Steamworks.Callback`1[Steamworks.LobbyInvite_t].OnRunCallResult (IntPtr thisptr, IntPtr pvParam, Boolean bFailed, UInt64 hSteamAPICall) (at Assets/Plugins/Steamworks.NET/CallbackDispatcher.cs:160)
    UnityEngine.Debug:LogException(Exception)
    Steamworks.CallbackDispatcher:ExceptionHandler(Exception) (at Assets/Plugins/Steamworks.NET/CallbackDispatcher.cs:68)
    Steamworks.Callback`1:OnRunCallResult(IntPtr, IntPtr, Boolean, UInt64) (at Assets/Plugins/Steamworks.NET/CallbackDispatcher.cs:163)
    SUWyUYUnRGQtDDFInHfnhLGiJbND:HLzYEnOdHfMEHSQUgSkuIOTNetBK(UInt32, String, String, UInt32, Int32, Int32, Int32, Int32, IntPtr, IntPtr, IntPtr, IntPtr)
    SUWyUYUnRGQtDDFInHfnhLGiJbND:BQbNitSzSnTvYKbSxcPQOYFHpap(String)
    SUWyUYUnRGQtDDFInHfnhLGiJbND:.ctor(String, Boolean, uacFgWzZAJzhcbMAjaNHnsIkMBb)
    IuGQRULxLgYkcsFGtYWoAOTZEKy:loIVlJwwyyqNomSIaYmFYYzgtEH()
    IuGQRULxLgYkcsFGtYWoAOTZEKy:hSvGWRWVZBGfKJchPfqHgfTtYGTC()
    IuGQRULxLgYkcsFGtYWoAOTZEKy:mqQfZfVbvDHHfaoortkAotpdABi()
    IuGQRULxLgYkcsFGtYWoAOTZEKy:.ctor()
    XugvwESTMUrGPKaeCOEWcBOYHTog:.ctor(ConfigVars, Func`2, Func`1)
    Rewired.InputManagers.Initializer:Initialize(ConfigVars)
    System.Type:InvokeMember(String, BindingFlags, Binder, Object, Object[])
    GpximtcEHvzUmOYrMDNkghccxiJ:psSdEzCGOxqONbADZvdJinnGAFym(String, List`1, ConfigVars)
    Rewired.InputManager_Base:InitializePlatform(ConfigVars)
    Rewired.ReInput:QomdyCAwRipXKpdUTCfXhwvaybsS(Func`2)
    Rewired.ReInput:psSdEzCGOxqONbADZvdJinnGAFym(InputManager_Base, Func`2, ConfigVars, ControllerDataFiles, UserData)
    Rewired.InputManager_Base:Initialize()
    Rewired.InputManager_Base:Awake()
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    This is no "philosophy", they are real issues. What are you going to do when your user tries to assign the key "A" to several different actions? Or left trigger to both Brake and Reverse? Just allow them to cross their assignments? Or when they want to map their gamepad's D-Pad (buttons) to your Movement actions (axes)? Or when they want to assign an Xbox trigger (axis) to a Fire action (button)? What if they want Accelerate (axis) to be on "A" (button) instead? What if someone needs to invert an axis because a joystick manufacturer chose to invert it in the hardware? Assigning keyboard keys (W, S) to only half an axis-type action (walk up, down), one being positive and the other being negative? These issues come up in nearly every single game that exists.

    I created an example that shows everything you could possibly want to do. This covers minimum and maximum use of my asset. I'm sorry you won't spend the time to understand it, but I simply can't tailor my asset to every single person's individual use case.

    I am already addressing the "minimum use" scenario, which is far better served by providing a ready-to-use remapping screen and PlayMaker actions than providing basic minimalistic example code that doesn't even cover the necessary things for proper input customization. The "minimum" use case is people who don't even want to see a line of code, and that's exactly what I'm working on right now.

    Control remapping is an advanced topic and I state so in my documentation. The absolute minimum use of my asset is to not even have user control customization. If your users use any of the huge list of recognized controllers that I've mapped, they don't need customization at all.

    Those parameters are named in such way as to be understood by the name:

    actionId = The Id of the Action you're assigning. You can see the Action Id in the Rewired Editor.
    elementMapId = The unique id of the ActionElementMap you're trying to replace. It's optional and only used if you're replacing an existing ActionElementMap.

    If you looked at the code I posted, you would see how to get the id of "Circle Button" using polling. The user presses a button while you're polling, it gives you a ControllerPollingInfo struct. This struct contains a ton of information about what they just pressed including the elementIdentifierId and elementIndex, which is what points to the "circle button" in question.

    The attached example shows the most simplified version possible of remapping a keyboard key.
     

    Attached Files:

    Last edited: Jul 4, 2015
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    More information required:
    What Steamworks plugin are you using? What version?
    What Unity version?
    What OS?
    What Rewired version?
    XInput, Raw Input, Direct Input? (Windows)
    Native Mouse Handling?
    Is this in the Unity editor or a build?

    I can't understand why would Steamworks ever be called during Rewired's initialization phase, because that's clearly what's happening based on the stack trace. Nothing Rewired is doing could possibly do this. The only way I could see this happening is if Steamworks is intercepting all external calls and passing it through their code somehow.

    There have been many games Released on Steam using Rewired, BTW.
     
    Last edited: Jul 5, 2015
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    @okumasama

    The attached project is about as simple as it will ever get. It doesn't do anything but allow you to map axes and buttons to a few actions in the first joystick assigned to the first player. The code is very small and doesn't show much of anything but polling and creating ActionElementMaps.

    The interaction with the UI is extremely basic and NOT meant to be a good example of usage. Nothing is dynamically generated here.
     

    Attached Files:

  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Question: Did you change the script execution order of Rewired from the default -32000 that it starts with? Based on the stack trace, it appears to me that Steamworks is initializing before Rewired is. That would be the only way it could possibly be setting up an event before Rewired initializes. Either that or it's doing something in a native plugin to set up that event.

    Or, if you are instantiating the Rewired input manager after you initialize Steamworks, this would be possible too. Try changing that order so Rewired inits first always.
     
    Last edited: Jul 5, 2015
  27. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    ha yeah rewired is spawned after steamworks, i'll try a work arround this and let you know if we get that error again, thanks for the help !
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I am unable to reproduce any problem in Unity 5.1.1f1 w/ SteamWorks 6.0.0 in the editor on Windows with Raw Input and XInput enabled even when repeatedly initializing SteamWorks before Rewired. I need more information about your setup if I am to be of any help. Please answer the questions I asked in the message above and give me any other information you can about your setup and what you're calling before Rewired inits.
     
  29. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    OK, that's your "philosophy", because supporting those things (like user mistaken) is just one selective way of developer policy. These issues MAY come up, or often not. If there's only one key to play a game? If they not configure "Action-Key" map but "Key-Action" map and allows conflict (life smash-bros)?

    No. Maximum doesn't always cover minimum, especially tutorial, help or something you teach to other ( So commercial middle ware products often contains both simple and advanced sample. ) If your sample code is good for "separativity", so I read simple functions that I just needed. But it doesn't: you mixed up all optional functions in the code. It's hard to read in 10-30 minutes that I can spend to use ready-made asset other than write configurable Input Manager code by myself.

    There's no Saturn pad which often used by fighting game player.

    And I appreciate you finally give simple code to me. Its not the simplest yet, but easier to read than asset contained sample.
    I'll try with this and will write own tutorial for other developers suffering from Unity built-in Input.
    Thanks.
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Like I said, I could not possibly design a system/example custom-tailored to your specific fringe use case like a one-button game. How can I predict what you exactly want to do with it? But you could easily implement a one-button game with my system because it tries to cover a very broad field of use cases.

    This is your "philosophy," not mine. I designed a system that handle almost anything. If I gave you more than you need, it's up to you to ignore / exclude the features you don't need. That's my "philosophy" -- give the developer as many options and features as I can to cover as many use cases as I possibly can. For your specific basic needs, you need to put some work in to make it like you want it. I can't do all the work for you.

    Which happen to be written by large teams of people who are actually making money off the software they sell. I do all this myself with no profit whatsoever and spend a tremendous amount of time adding features and supporting customers.

    There is also a finite amount of time I can put into each area of the software. I prioritize bug fixes, so when they come up, I stop what I'm working on to fix them. At launch (just over 9 months ago) I provided a complete working remapping example which works and shows every possible remapping feature. Since that time, many many other issues had to be address and other features added before I could get back to the remapping system.I am presently working on the customizable drop-in uGUI remapping system (which should be ready in a few days).

    Like I say in my docs, a remapping system is an advanced topic and provided an example for those advanced enough to use it to learn. I did not have the time to write a basic newbie's step-by-step tutorial to making a remapping system. In a perfect world with infinite time, I would be able to cover everything. There were more important matters that needed to be addressed. Take a look at the change logs over the last 9 months -- 59 releases. That's an average of 6.55 releases a month -- more than 1.5 per week.

    The code is well organized with regions by topic.

    Minimum isn't meant to and cannot possibly cover every use case. It covers the vast majority. And you can always create a controller definition for that Saturn pad yourself because I designed the system to allow that. Give the customer the maximum, never the minimum.

    183 lines of code including dealing with the UI? Sounds like you're looking for a single line of code solution. Good luck to you then.
     
    Last edited: Jul 5, 2015
    Silly_Rollo, NinjaISV and BTStone like this.
  31. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Hey, I don't have a time to hear your long excuses. Stay simple, as I want this asset with. I don't matter if you're busy or has no money, but I just suggested you about simplification.
    That's exactly I wanted to say. You can't predict what your users want, so you can prepare them maximized functional code, but can't enforce it to several users who doesn't need it ( as you said at first, "You HAVE TO handle a ton of situations including assignment conflicts" ). So I described you comment as "philosophy".

    OK, I'll stop complaining about other incoherence because actually you did great work on this and give me simple code sample deliberately. (Last time I couldn't notice RewiredSimpleJoystickRemapping.zip, and this is exactly what I need. I said "not yet simple" to Keyboard sample one.) Thanks.
     
    Last edited: Jul 5, 2015
  32. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    You know you can't stay "simple" if you're going to cover the vast majority of use-cases. Rewired is absolutely fine as it is. If you're searching for a One-Single-Line-Of-Code-Solution this asset is not for you. It's stated on the website and at this topic:
    • Rewired is not for those who want to make games with zero coding knowledge. Coding is required.
     
    ZJP, Karearea, NinjaISV and 1 other person like this.
  33. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    @okumasama
    Rewired is very easy to use and modify. I've customized Gauvaman's "maximum" re-mapping screen to suit my own needs, and I found it quite simple to do. If you're having a hard time with Rewired, perhaps you may wan't to just stay with Unity's native input system. (Like it states in many places, Rewired is not simple. It takes programming knowledge and skill to use.)

    And thanks again for all the help/support with Rewired, Gauvaman, we really appreciate it.
     
    guavaman likes this.
  34. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Hi, so here goes your answers:

    Steamworks.net ? 6.0.0
    What Unity version? 5.1.1p2
    What OS? windows 8.1
    What Rewired version? 1.0.0.56.U5 (according to your 'about' popup)
    XInput, Raw Input, Direct Input
    Native Mouse Handling? Yes
    Is this in the Unity editor or a build? Recently saw it in editor but i believe it happened in build in the past as well


    Important to note, it's not an error that happens all the time and I have yet to find repro steps. It happened several times to me so I was kind of hoping it would be a known issue to be honest.

    I'll setup starting steamworks after rewired and watch out for the error.
     
  35. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    @okumasama it takes some time to get into the remapping script but once your grasp it and narrow down what you need it has everything. If one thing is missing in Rewired its some comments in the API doc but nethertheless its an awsome piece of software, its easy to tell the tremendous amount of work that has been put into it...
     
    Last edited: Jul 6, 2015
    guavaman and NinjaISV like this.
  36. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Nothing to say you three who cannot even understand the difference of "difficult" and "complicated" or "easy" and "simple". Bye.
     
    Last edited: Jul 6, 2015
  37. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    767
    Hi Guavaman,

    I'm having a great time with Rewire, it works intuative once you've taken the time to grasp the concept of player centered input. However while getting the in- and outs I noticed some errors in the documentation: within the Receiving joystick connect and disconnect events on this page http://guavaman.com/projects/rewired/docs/HowTos.html#get-input all the events have the following code:
    Code (CSharp):
    1. args.name + " Id = " + args.controllerId + " Type = " + controllerType
    however that doesn't compile it's better to use
    Code (CSharp):
    1. args.name + " Id = " + args.controllerId + " Type = " + args.controllerType
    Just some friendly advice ;)
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Oops, you're right. Fixed! Thanks!
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Okay, thanks for the info. I think the fact you're using DirectInput instead of Raw and X is very important. DirectInput works very differently from Raw and automatically handles its own system for receiving the controller messages. I'll see if I can test some with that.

    One thing that would probably help though would be to know what Steam API calls you're making before you were spawning Rewired. I noticed looking through the source code that the CallbackDispatcher, which is what is ultimately throwing the exception, was never called or setup that I can tell by just initializing Steam. So some other calls you're making are setting the CallbackDispatcher system in motion, but I don't know what.
     
    Last edited: Jul 6, 2015
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Rewired 1.0.0.58 is now live on the Unity Asset Store!

    1.0.0.58:
    Changes:
    - Removed null product name on Sony DualShock 3 on Android platform due to possible matching conflicts.
    - Android, Amazon Fire TV, and PS4 platforms now ignore joysticks with null names to account for Unity's changed handling of removed joysticks on these platforms.
    - Android and Amazon Fire TV platforms now ignore joysticks with "keyboard" in the name to filter out keyboards.

    Bug Fixes:
    - Separated Amazon Fire TV Remote controller definition for Android and Amazon Fire TV platforms and fixed buttons assignments.
    - Amazon Fire TV Stick platform now correctly detected.

    1.0.0.57:

    Changes:
    - Improved Xbox One platform support -- includes vibration.
    - Added Xbox One platform.
    - Moved OuyaInputSource.cs into the project. Installation step is no longer required.
    - Microsoft Xbox One gamepad controller definition now uses individual trigger axes on Xbox One fallback platform.
    - Added Amazon Fire TV as a separate platform due to mapping differences vs Android.
    - Added the following controller definitions for Amazon Fire TV platform:
    - Amazon Fire Game Controller
    - Google Nexus Player Gamepad
    - Microsoft XBox 360 Controller (wired)
    - Microsoft XBox 360 Controller (wireless)
    - Sony DualShock 4
    - Mad Catz C.T.R.L.R
    - Mad Catz C.T.R.L.R Micro
    - Red Samurai Gamepad (G mode)
    - SteelSeries FREE
    - 8Bitdo NES30 (Bluetooth, Mode 1)
    - 8Bitdo NES30 (Bluetooth, Joy Mode)
    - Ouya Gamepad
    - GameStick Controller
    - Added default Placeholder path in Windows App Store DLL for Unity 5+.

    API Changes:
    - Added Controller.Extension class
    - Added Controller.extension property
    - Added Controller.GetExtension<T>() method
    - Added Joystick.systemId property
    - Added Joystick.unityId property
    - Added Joystick.SetVibration(int motorIndex, float motorLevel) method
    - Added Joystick.SetVibration(int motorIndex, float motorLevel, bool stopOtherMotors) method
    - Added ReInput.TimeHelper class
    - Added ReInput.time property
    - Added Interfaces.IControllerVibrator interface
    - Added Platforms.XboxOne.XboxOneGamepadExtension class
    - Added Platforms.XboxOne.XboxOneGamepadMotorType enum
    - Added Platforms.XboxOne.XboxOneGamepadVibration struct

    Bug Fixes:
    - Removed all Dictionary usage due to memory allocation bug in iOS Dictionary handling. Now allocates no memory on normal updates in iOS.
    - Fixed rare joystick matching issue on Unity fallback platforms and Custom platforms.
    - Fixed rare crash in Windows 64-bit builds and 64-bit editor.
    - Fixed Windows input sources failing to initialize on certain systems in the Unity editor.
    - Fixed product name on Google Nexus Player remote controller definition.
    - Fixed Game Controller Back and Menu button assignments on Android platform.
     
    NinjaISV likes this.
  41. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Nice update! I really like the new
    Code (CSharp):
    1. Joystick.SetVibration(int motorIndex, float motorLevel);
    method.
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Thanks! Yes, I'm trying to gear up toward supporting more controller and platform-specific functionality (like Xbox One) rather than only that which can be abstracted. Until now, vibration was Windows XInput, Xbox 360 gamepad only (left/right motor). To support more devices with different schemes, I created that method where you could access the motor by index, and I've added the Controller.Extension class which can be used to access device-specific features such as the Xbox One gamepad (on Xbox One platform) and have access to its unique functionality such as trigger motors easier. This is also how I plan to implement extended PS4 gamepad support because it has a touch pad, gyro, lights, and its own motor layout. It might even make supporting some of the more complicated WiiU devices a possibility in the future.
     
    Last edited: Jul 6, 2015
    _met44 likes this.
  43. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    LOL !!!
     
  44. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Sounds awesome.
    Also, one quick question. Even though I'm almost %100 sure Rewired doesn't have a pre-setup function that looks like:
    Code (CSharp):
    1. SetButtonDown("button1");
    (Send the input into the system as if the player had pressed it on his/her device.) I was wondering if there is something already like this. I realize I could do this fairly easily myself, but I was just curious if it came pre-setup with Rewired.
    Thanks!
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    No, it doesn't. All device input is determined by the input library(ies) currently in use. Not all work equally. Some send messages, some have to be polled. Interfering with those that send messages by substituting your own values would cause some pretty weird problems, so I intentionally left out the ability to set or even clear device input.

    Input values at the Player/Action level, being a combination of all (enabled) mapped source inputs, would be able to handle it, but there's no direct "SetButton" method. (Actually, if this existed, you would only be able to SetRawAxis, not Button or ButtonDown, because the "Button" state is determined by the axis value compared to the threshold in the InputBehavior and the "Down" state is determined by the current and the previous frame's axis value in the current input update loop.)

    You could force your own values into the Controller's axes and buttons using reflection, but that would be messy and slow. The only "approved" way to inject your own input values into the Player is through a CustomController.
     
  46. NinjaISV

    NinjaISV

    Joined:
    Dec 29, 2014
    Posts:
    124
    Alright, thank you for the informative reply. I've already worked through this using a different approach, and from the sounds of it, it wouldn't have been a great idea anyway.
     
  47. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    Finally, I have fully integrated Rewired into my project, but now I'm not able to build a running Windows 8.1 Universal WSA version. I'm building to a new blank Visual Studio project (building on top of my old project doesn't seem to work, since it does not compile at all).

    My first problem was that Rewired.ReInput.players would always return null. I have added a Rewired.ReInput.isReady to catch the nullpointer exception. However, Rewired.ReInput.isReady always returns false...

    I have tried to use Window->Rewired->Setup->Install Platform Support->Windows App Store, but it didn't help.

    Any ideas what I could be doing wrong?

    [EDIT 1]:
    found this Rewired related error in the log:
    Code (CSharp):
    1. Exception: Exception of type 'System.OutOfMemoryException' was thrown.
    2. Type: System.OutOfMemoryException
    3. Module: WinRTBridge
    4. InnerException: <No Data>
    5. AdditionalInfo:<No Data>
    6.    at WinRTBridge.SerializationWeaverReader.ReadString()
    7.  
    8.    at Rewired.Data.Player_Editor.Unity_Deserialize()
    9.  
    10.    at Rewired.Data.UserData.Unity_Deserialize()
    11.  
    12.    at Rewired.InputManager.Unity_Deserialize()
    13.  
    14.    at UnityEngine.IUnitySerializable.$Invoke0(Int64 instance, Int64* args)
    15.  
    16.    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    17. (Filename:  Line: 88)
    18.  
    19. OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
    20.    at WinRTBridge.SerializationWeaverReader.ReadString()
    21.  
    22.    at Rewired.Data.Player_Editor.Unity_Deserialize()
    23.  
    24.    at Rewired.Data.UserData.Unity_Deserialize()
    25.  
    26.    at Rewired.InputManager.Unity_Deserialize()
    27.  
    28.    at UnityEngine.IUnitySerializable.$Invoke0(Int64 instance, Int64* args)
    29.  
    30.    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    31. (Filename: TODO Line: 0)
    32.  
    33. A script behaviour has a different serialization layout when loading. (Read 180 bytes but expected 11236 bytes)
    34. Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
    35. (Filename:  Line: 1170)
    36.  
    37. Error! DataFiles is missing or corrupt! Make sure you have the DataFiles file linked in the inspector.
    38. (Filename: C:/buildslave/unity/build/artifacts/MetroSupportGenerated/UnityEngineDebug.cpp Line: 55)
    Any ideas?

    [EDIT 2]:
    I'm on Unity 4.6.1 and Rewired 1.0.0.55.U4 (also tested with Unity 4.6.4)

    [EDIT 3]:
    Hours later... found this bug report here:
    http://issuetracker.unity3d.com/iss...s-with-system-dot-argumentoutofrangeexception
    If this is the problem, then I'm unable to use Rewired for WSA...
     
    Last edited: Jul 8, 2015
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Get 1.0.0.58 from the Unity Asset Store. There are no issues with this release. Tested in 4.3.0 and 4.6.6. Please always use the latest version when submitting bug reports.
     
    Last edited: Jul 8, 2015
    FreebordMAD likes this.
  49. FreebordMAD

    FreebordMAD

    Joined:
    Mar 15, 2013
    Posts:
    633
    I have updated to 1.0.0.58 and indeed the error has disappeared and Rewired.ReInput.players doesn't return null any more. However, it still does not work. This time I have imported the 1.0.0.58 and built the ControlRemapping1 example. While everything works fine in the editor, the build simply does not recognize my joystick. There is no Joystick button in the demo and ReInput.controllers.Joysticks is always empty. Later today I will get hands on some Xbox controllers and try with them... Any ideas why it works in the editor and doesn't in the build?

    [EDIT:] it indeed seems to work with Xbox 360 controllers. Still, it is strange that my techsolo TG-20 controller is not working in the build, but works in the editor...
     
    Last edited: Jul 9, 2015
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Windows App Store builds only support XInput. No other controllers are functional in WSA builds. This is expected and documented behavior. (See the supported controller list, Windows Store column.) The editor is not running under WSA, it's running under Windows and doesn't have the same limitations. Just as if you were to be testing a PS4 build in your Windows editor, it wouldn't be running on a PS4, therefore it wouldn't be using the PS4 input libraries.

    With Windows 8.1, Microsoft released a new API that allows for the support of non-XInput HID devices. Prior to 8.1, this wasn't even possible. Unity's 5.0 release touted support for these devices, but my testing showed that it has never worked. No devices are ever detected. Rewired doesn't implement Unity input in WSA, but rather implements XInput. I have not written my own native library to support non-XInput devices in WSA and Unity's implementation does not work, therefore, the only devices supported in WSA are XInput devices.
     
    FreebordMAD likes this.