Search Unity

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Not with Rewired, sorry.
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Thanks!

    How To's: Modifying InputBehaviors during Runtime

    Code (csharp):
    1. InputBehavior behavior = ReInput.mapping.GetInputBehavior(playerId, "ActionName");
    You want to find out how long the button was held after it's been released? You'd have to store the values because you're interested in evaluating the previous state after the fact. GetButtonTimePressed and GetButtonTimeUnpressed will tell you what you need to know, but for the current state, not the previous state. But you could also do this by checking the current value of GetButtonTimePressed watching for a time threshold you've set, then once it meets that threshold, flag that it's been met, then on the release, run your code. (Default state = None. When true, change state = Tap. When held for >= 0.2s, change state = Held. When !true, execute action, clear state to None.)

    You're not going to be able to do this kind of manual evaluation without tracking some variable in your script outside of Rewired as there is no history of pressed/unpressed times nor an event queue to analyze. In essence, this is a gesture detection of sorts, which always requires a history.
     
    Last edited: Jan 26, 2016
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Several things might be happening here. One that I get very often in support emails, almost always misinterpreted as XInput problems is this, from the docs:

    A user will be making a 1-player game, have 2 joysticks plugged into the computer, but only allow assigning 1 joystick per player. They pick up one controller expecting that to control their player, but Rewired has assigned the other controller to the Player and left the one they expect to use unassigned. Rarely, they may have software installed on the system that creates a software HID device, which Rewired sees and assigns, but the user doesn't know exists. (Certain remote access software does this.) Check how many joysticks Rewired sees by checking ReInput.controllers.joystickCount and enumerate them with ReInput.controllers.Joysticks.

    I would suggest the next time it happens, to check in your Windows Control Panel gamepad section and see if the joystick is appearing and if the joystick responds to axis movement and button presses. There is no reason at all Rewired should not be able to see the joystick or use it if it's appearing to XInput as XInput is extremely simple. There's really no way to mess up with XInput. Either XInput reports the device is there and returning values or it doesn't. If XInput is detecting the controller, Rewired will see it and use it. If not, then there's a system problem here.

    FYI, I'm also using Windows 10 and I've never seen this issue.
     
    Last edited: Jan 26, 2016
  4. EskemaGames

    EskemaGames

    Joined:
    Jun 23, 2010
    Posts:
    319
    Fear not, this is not a rewired issue (never said it was), it's a windows bug by whatever reason, software installed, some driver doing we don't know what, etc, etc.

    It's not that I have 2 controllers or anything like that, like I said simply windows doesn't recognise the controller afer plugged in, so obviously rewired will not do any miracle if the OS cannot detect the controller :)
     
  5. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I'm switching controller map layouts at runtime, but I would like to retrieve the names of the layouts I have set up in the rewired input manager. the name property however is empty, as the documentation says, is unused. Is there any other way to retrieve the controller map name at runtime?
     
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Controller maps do not store a name. You can get/load the controller map by Category and Layout. If you want the name of the Layout or Category, use the methods is the Mapping Helper class to get the Layout and check its name.

    http://guavaman.com/projects/rewired/docs/HowTos.html#important-classes
    http://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ReInput_MappingHelper.htm

    ReInput.mapping.GetLayout, etc. All methods for dealing with data stored in the Rewired Input Manager are in this class.
     
    Xarbrough likes this.
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    I know, I understood that it wasn't a Rewired issue. However I'm trying to understand what could cause it. As I said, I'm using Windows 10 and I've never seen a situation where XInput just fails. I haven't seen this on Windows Vista, 7, or 8 either.
     
    Last edited: Jan 27, 2016
  8. EskemaGames

    EskemaGames

    Joined:
    Jun 23, 2010
    Posts:
    319
    Hard to tell what could be, could be any other app causing any weird behaviour with the usb port when you plug the controller, maybe windows cannot load the xbox one driver for the controller "on time", could be unity blocking the detection (less likely but considering the amount of bugs that unity has....).
    Sadly it happened me twice in 4 months, but well it's easy to fix, just the classic rebooting windows operation....
     
    guavaman likes this.
  9. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Do you have any other usb hardware (e.g. game controllers [flight controllers], midi controllers, JTAG for flash downloading on embedded devices) attached to your system? For example some usb devices have software that filters all usb commands that come through the system and then just handle only their usb specific commands. Some flight controllers (e.g. Saitek flight controller software (not the drivers) but software to handle special features of the device). Some of the older usb Midi controller software has done this also.

    Are you using a usb 2.0 or usb 3.0 port when this happens? Are you using a usb port directly on your computer or usb hub?
     
  10. garrido86

    garrido86

    Joined:
    Dec 17, 2013
    Posts:
    233
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Hi, thanks for that, but I've already made one (and for the FC30 Pro) which will be included in the next Rewired release. It covers all compatible platforms that Rewired supports. When you upgrade, I suggest you delete your definition to avoid a clash.
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Ahh, I see. If it's that rare, there's really no way to track it down. Thanks for all the explanation! Glad everything's up and running again.
     
  13. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    any suggestions for possible things i've missed for having touch work on iOS and Android?

    the custom touch control works with mouse input in the editor
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Please explain. Touch for what? I can only assume you mean Unity UI.
     
  15. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    sorry, on screen touch buttons and touch joystick
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Have you followed the documentation on setting up Custom Controllers?

    http://guavaman.com/projects/rewired/docs/CustomControllers.html

    There is also a basic example included that shows the concepts:
    http://guavaman.com/projects/rewired/docs/Examples.html#custom-controllers-touch

    I can't tell you what you've missed in the process as I haven't seen any of your implementation.

    Setting up a touchscreen joystick control:
    1. Get a touchscreen joystick control component that will output two float values or a Vector2. (Make one or download one.)
    2. Create a Custom Controller in the Rewired Input Manager with two axes.
    3. Assign that Custom Controller to a Player.
    4. Create some Actions and a Custom Controller map and assigning the Actions to the axes in the Custom Controller map.
    5. Assign that Custom Controller map to your Player.
    6. Create a script that will gather the data from the touch joystick and send it into the axes in the Custom Controller. The example shows you how to get and interact with a Custom Controller via scripting.

    Do the same thing for each button.
     
    Last edited: Jan 31, 2016
  17. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    Thank you for the information,

    the touch controls are setup and work with mouse input

    found my mistake
    Code (CSharp):
    1. if(onMouseDown)
    2. // set presses
    to
    Code (CSharp):
    1. if(!allowMouseControl || (allowMouseControl && onMouseDown))
    2. // set presses
    but whats the best way to handle the multiple presses for each touch,
    with mouse i just set presses only with onMouseDown as seen above
     
  18. MuffinArray

    MuffinArray

    Joined:
    Jan 30, 2016
    Posts:
    6
    I am making a custom theme for Control Mapper. In the theme settings there are some options I don't see, I was wondering if you will implement these or if I can change things directly in your Control Mapper scripts.

    What I'd like to do is: Make the entire Control Mapper windows centered, move the buttons at the top to below the key binding panel, move the "Done" "Remove Defaults" buttons below the keybinding panel and change "Done" text to back, rearrange the order of the Action names (move vertical / horizontal axis to bottom), change the text of the word "Action", change Font sizes and bold the Title text / keybind grid text / button text.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    I'm not sure I understand what you're asking. You want to filter out press and hold and make it only respond to touches when it is newly pressed like GetButtonDown works with a real joystick button? You'll need to record the finger id and position and determine if the finger has ever left the button before allowing a touch again.

    These are matters of programming a touch button/joystick, not inputting the control data into Rewired. Implementation of a touch button/joystick is a big topic and it can be done in dozens of different ways. You can also buy or download one on the asset store and integrate it with Rewired through the Custom Controller.
     
  20. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    Thank you for the advice :)
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Fonts and the Action title can all be changed using the options provided. See Language for changing the titles: http://guavaman.com/projects/rewired/docs/ControlMapper.html

    Font sizes and bolding are not part of the theming system. They will have to be changed on the Text components in the scene and/or on the prefabs. You can also change the prefabs in the Prefabs/Parts folder, but be aware changes to these will be reverted when you update Rewired. To avoid that, copy them, then assign them to your Control Mapper to be used under the last option: Advanced Settings -> Prefabs.

    As for rearranging the window elements, sorry, that's not possible without modifying the objects and sometimes scripts themselves. Creating a responsive layout that handles different aspect ratios in Unity UI was an extremely difficult task. It's generally not a simple matter of moving things around as sometimes things will break, but you can try. The prefab hierarchy can be cloned into a new prefab and you can change whatever you want.

    Certain settings can be changed on the prefabs like the Canvas object or other objects in the hierarchy, for example, to center or resize the UI.

    The Action list can be drawn from categories or you can customize each Action to show individually. If you want to reorder them, just reorder them in the Rewired Input Manager or choose the individual Actions to be shown in the options.

    As for moving vertical / horizontal to the bottom, they are already below the full axis binding. Do you mean separate them entirely from the full axis binding? This won't be possible without changing the scripts.

    I advise against that. There would be no way to get to those buttons with joystick control if the keybinding panel has to scroll without scrolling all the way through the bindings each time.
     
    Last edited: Jan 31, 2016
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    One thing I neglected to mention is that even if you set the Custom Controller button state to TRUE every single frame (just holding it), querying player.GetButtonDown("Some Action") that is bound to the Custom Controller button will only return true for the first frame it is pressed, so that may be easier if you don't want to make a more complex touch button control that accounts for this itself.
     
    Last edited: Jan 31, 2016
    AVOlight likes this.
  23. MuffinArray

    MuffinArray

    Joined:
    Jan 30, 2016
    Posts:
    6
    Thanks for the info. I was able to change the "Done" to "Back".

    I tried to change font size by using the prefabs like Window Title Text and Window Content Text (putting copies in my main folder and linking them) but that did not seem to work when I set the color to red or increased the size.

    I also wanted to try moving Done / Restore Default below the keybind grid. Can I just do this in the hierarchy or will that get erased when Rewired is updated? The player using the controller should be able to hit his default UICancel button to escape the keybinding menu.. but to do that I would need to put something link if (Player.GetButton("UICancel")) {windowManager.CloseWindow(windowId);} in ControlMapper.cs. If it could account for when the player has opened the bind key pop ups .. say like if cancel is pressed and no other sub menu windows are open then close the keybinding window .. it might work.
     
  24. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    Thank you,

    forgot to mention that i get this issue on IL2CPP builds on both iOS and Windows Store targets

    Unity 5.3.1p4 on IL2CPP windows store target with Rewired 1.0.0.78.U5 it works great, but when i upgraded unity to patch 5.3.2p1 i get that with the latest Rewired and the version mentioned
     
  25. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    The latest version of Rewired is 1.0.0.79. Have you tried 1.0.0.79 and see if the problem still exists? Does this problem also happen with Unity 5.3.2 (the normal version that is not patched)?
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    1. Color is always overridden by the Theme. Changing the color in the root prefab will do nothing because it will just be overwritten when the Theme is applied based on your settings unless you disable theming in the options.
    2. Changing settings on the prefabs for items that already exist in the hierarchy at start will do nothing. For those objects, you must change their settings in the scene hierarchy. (See below.)

    You have to thoroughly understand Unity's prefab and GameObject system to do this.

    #1: There are two types of GameObject instances in Control Mapper.
    1. Instances that exist in the Control Mapper GameObject hierarchy at start.
    2. Runtime instances that are instantiated from the prefabs on disk.
    Section titles are #1 because they exist in the Control Mapper object hierarchy at start.

    Buttons and other dynamically generated elements are #2. Anything that is created with Object.Instantiate() will be created from the prefabs on disk. Anything that already exists in the scene hierarchy will not.

    All objects in Control Mapper are prefabs, but NOT all are instantiated at runtime. By copying the prefab on disk to another location, then changing the Prefab references Control Mapper uses to instantiate its objects, you are only changing items that fall under #2. None of the pre-existing instances in the scene hierarchy will be automatically changed. This is just how Unity works. Those scene instance prefabs are not tied in any way to the new prefabs you coped, so changes you make to those prefabs will not affect them at all. Since you cannot change a scene hierarchy GameObject's prefab root to point it to your new items, you will have to make changes to those in-scene GameObjects manually or replace them with your new prefab copies manually.

    Did you see my warning in the previous post against doing this? It will break joystick-only control, which is important if you want to publish on Steam Big Picture.

    Again, this is simply a matter of how Unity works.

    As prefabs, they are tied to their project folder roots. Any changes to the prefabs that were made in the scene will be bolded and saved as field overrides. Overridden fields will not be reverted if the root prefab is changed. Any field that was not overridden (field is not bold) _will_ be changed when the root prefab is changed. If your change to the scene objects override settings or break the prefab reference, they will not be reverted when Rewired is updated. When you update Rewired, it overwrites all the files in the Rewired/Internal folder, and therefore if you were to have made any changes to those core files, those changes would be lost. That is why I told you to copy the prefabs you wanted to modify, move them to a new folder, then change the prefab references in the Control Mapper -- so it would instantiate buttons and other dynamic elements from your copies which would never be overwritten by updating Rewired because they have different GUIDs.

    Control Mapper's main prefab is the top-level GameObject called ControlMapper. This is a prefab that contains all the other static GameObjects and the layout. This is a single prefab with many GameObject children. Unity does not support saving a prefab with other nested prefabs inside it. Therefore, the entire ControlMapper structure is a single prefab. The buttons within the hierarchy that exist at start are not tied to the Button prefabs on disk -- they are tied to the top-level Control Mapper prefab on disk.

    Moving elements around in the hierarchy within a GameObject usually will break the containing prefab, so it will no longer be tied to the original root prefab. Changes to the root will no longer affect the object.
    1. Overridden fields will not be reverted when the prefab root is changed.
    2. If the prefab is broken, no changes will ever be reverted.
    This information is not specific to Rewired or Control Mapper. For more details on prefabs, see the Unity Documentation on Prefabs: http://docs.unity3d.com/Manual/Prefabs.html

    You do not have to modify the scripts to do this. This is already an option built into Control Mapper.



    Set either "Screen Toggle Action", "Screen Close Action", or "Universal Cancel Action" + "Universal Cancel Closes Screen" to assign a button to open/close the UI.

    See the documentation: http://guavaman.com/projects/rewired/docs/ControlMapper.html#inspector-options

    That is exactly what "Screen Close Action" does. It will not close the UI if other popups are active. "Universal Cancel Action" will cancel any popups. If pressed again on the main screen, it will close the UI.
     
    Last edited: Jan 31, 2016
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Thank you for the report. IL2CPP bugs are due to the implementation of IL2CPP by Unity. It is choking on some specific data structure or some other part of the code. This is a bug on Unity's end because the code runs perfectly well as true IL code. I will look into it, but I cannot guarantee that I can find a workaround for their bug. If I can identify exactly what structurally is causing it, I will report it as a bug to Unity so they can fix it.

    In addition, as you mentioned, this error occurred after a Unity update, so it means they introduced a new bug into IL2CPP.
     
    Last edited: Jan 31, 2016
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    As a followup, two things:

    Windows 10 Universal build:

    You didn't mention it in either of your posts, but to build IL2CPP for Windows, you have to be building to Windows 10 Universal. Rewired is not compatible with Windows 10 Universal yet. This is not a supported platform listed on the website. The Windows Store libraries provided only support 8.0 and 8.1. This simply isn't going to work until I make a Windows 10 specific DLL for Rewired. Windows 8 Store DLLs are not compatible with Windows 10 Universal.

    iOS:

    I cannot reproduce any IL2CPP error on iOS builds in 5.3.2f1. I will try downloading 5.3.2p1 to test, but as a matter of general policy, I do not support Unity patch versions.
     
  29. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    @guavaman all my Rewired 1.0.0.78.U5 controls work with Windows 10 Universal IL2CPP in 5.3.1p4
    Touch, Mouse, Keyboard, Xbox 360 Controller


    @longroadhwy havent tried 5.3.2, going to stick with 5.3.1p4 till the next patch
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Hi, thanks for letting me know. As you explained in the other thread, the key was that you excluded the Windows 8 Store libraries to build. In IL2CPP mode without the Win 8 Store libs, it will be using UnityEngine.Input as the input source. I actually didn't realize that it would work that way, but it makes sense because of IL2CPP. Good to know! However, there are no controller definitions specifically made for Win 10 Universal yet, so I believe many joysticks won't be recognized. This is definitely something I will look into though as it allows you to build to Win 10 Universal now with the current version before I make the native input library for it (which is half-way done but waiting to be finished after some other core changes I have coming in 1.0.0.80.)
     
    Last edited: Jan 31, 2016
    AVOlight likes this.
  31. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    @guavaman Thank you for the active support! :)
     
    guavaman likes this.
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Glad to help!
     
  33. MuffinArray

    MuffinArray

    Joined:
    Jan 30, 2016
    Posts:
    6
    Thanks for the explanation. I have gone through some of the Unity tutorials but I can see I have more learn.

    That Screen Control Action setting, I tried it and it works. I went to Screen Close Action and set it to Button B and in game I press button B on the controller and it closes the screen. However if I set the Screen Control Actions to my UICancel action nothing happens. The UIHorizontal UIVertical UISubmit UICancel are all in my Rewired Standalone Input Modual component. I have those actions Assigned with the same names to a separate map category for UI only. I selected Use All Players to try to get it to work. I think it may just be using my Default map category instead of the UI map category.

    How does rewired know when the player is using the UI vs In game or how do I tell it to switch map categories. I looked around in the documentation maybe I missed it.
     
  34. MuffinArray

    MuffinArray

    Joined:
    Jan 30, 2016
    Posts:
    6
    ah.. I found it, it was on http://guavaman.com/projects/rewired/docs/HowTos.html#enabling-disabling-controller-maps My system player had Default map category selected instead of my UI category. I got the UICancel keyboard to work.. my controller button is messed up but I can figure it out. um just one other question, for a joystick. xbox controller what would the be the best buttons to set to UISubmit / UICancel ? I was thinking "Bottom Row 1 / 2" .. but some times it's those tiny Start / Select buttons.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Joysticks are never auto-assigned to the System Player as the documentation states here:
    http://guavaman.com/projects/rewired/docs/Players.html

    Even if you assign a Joystick Map to the System Player that binds your UI actions to it, the System Player will not automatically get the Joysticks assigned to it so it won't return input for joysticks. (Per the docs, Joysticks must be assigned to a Player before they will return input value: http://guavaman.com/projects/rewired/docs/Controllers.html).

    You do not have to use the System Player to control your UI. Assign the maps to each Player and any game Player can control it. If you must use the System Player for UI joystick control, you'll have to either disable joystick auto-assignment and assign them yourself, or use the events to assign every joystick to the System Player on Start and on controller connected: http://guavaman.com/projects/rewired/docs/HowTos.html#connect-disconnect-events

    That's subjective. I've never seen Cancel assigned to Back or Start. Usually A is Confirm and B is cancel on an Xbox 360 controller.
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    I downloaded 5.3.2p1 and tested several iOS builds with various build options (.NET 2.0, Subset, stripping, etc.) and have not been able to get any kind of error while compiling. Is this error reported in Unity when doing the build or in XCode when building to the device?
     
  38. MuffinArray

    MuffinArray

    Joined:
    Jan 30, 2016
    Posts:
    6
    I noticed that in Rewired Input Manager when I make my first action it assigns it "action id 0", If I delete that and make a new action it assigns it "action id 1". I have been deleting actions and noticed a warning "Rewired Control Mapper: 1 is not a valid Action id". Possibly because I have deleted action id's with no assigned action? I fix it by replacing Rewired Input manager with a new one and making new actions, just thought delete might be acting weird.. unless I missed something in documentation once again.
     
    Last edited: Feb 1, 2016
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Id's in Rewired are not indices. They are unique ids. It is correct that Rewired is incrementing this ID as you delete and create new Actions.

    With regard to Control Mapper throwing warnings, that is working correctly. You need to understand what is happening when you use Control Mapper with the optional UserDataStore_PlayerPrefs component.

    The Control Mapper demo scene includes the UserDataStore_PlayerPrefs component on the Rewired Input Manager. Control Mapper saves the modified user controller mappings to the registry in XML format when you close it. Every time the UserDataStore is initialized or when a controller is attached, it loads the XML data that's saved in the registry for that controller. When you then go back and delete Actions, your saved registry data still contains mappings to those Actions which no longer exist because you deleted them. The next time you open it, Control Mapper loads outdated data from the registry containing mappings to Actions that no longer exist. You need to clear the Unity PlayerPrefs to get rid of all the old save data and clear the registry. The UserDataStore_PlayerPrefs component inspector has an option to clear Player Prefs from it.

    While Rewired provides the UserDataStore_PlayerPrefs component, it is only one way you could choose to store the data. It is by no means the best way because of the huge limitations of the Unity Player Prefs system. The UserDataStore documentation mentions this and tells you how you can replace this component with your own system in which you can store the data however you like (to a databse, etc.) If you don't want to use the Player Prefs system, it's up to you to decide how to store and manage the data. This is all open-ended so that you can make it work for your needs no matter how complex. For example, Rewired can be easily extended to save separate control configurations for an unlimited number of controllers based on different user profiles.

    The UserDataStore_PlayerPrefs component was provided as a convenience for developers who don't want to implement their own system, but it is not 100% automatic and requires some management of the data on the developer's part. Clear the Player Prefs data and you will no longer see these warnings.
     
    Last edited: Feb 1, 2016
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    I have been able to reproduce the error in Windows 10 Universal using IL2CPP. The error is not generated when Unity builds the project. The error is in the CPP code output by IL2CPP and will only show you the error when you try to build the final project in Visual Studio. Based on the error, there is no possible workaround I can come up with for this. Unity is generating bad C++ code that won't compile, trying to use a variable that was never declared anywhere. I have filed a bug report. More details here.

    I haven't tested iOS, but I'm assuming the error is the same. No error on building from Unity, but generation of invalid C++ code that will not compile in XCode.
     
    Last edited: Feb 1, 2016
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Excellent news! They've fixed the bug (already!) and IL2CPP will work again as of version 5.3.2p3.
     
  42. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
    Hello,

    Is it possible to get a long press for a button? I think a workaround could be this:
    Code (CSharp):
    1. public bool LongPress(string actionID)
    2. {
    3. return player.GetButtonTimePressed(actionID) > longPressTime;
    4. }
    But maybe there is a more direct way that I didn't find.

    And can I know how many time a button has been pressed when it is released?

    Something like:
    Thank you
     
    Last edited: Feb 2, 2016
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    That is the correct way to do it. There isn't a function built in to evaluate every kind of "gesture" you might want. That's what these functions like GetButtonTimePressed were created for -- so you can evaluate that information and make some kind of decision. If there were a convenience function for long press, it would work internally exactly as you wrote it.

    Not without recording the times into a history and making the determination that way, which is how I would do it. Rewired does not currently maintain a running history of active/inactive times.

    Upcoming changes to Rewired in a future release will include complete event histories, but this is a ways away. I will consider adding histories to the active/inactive timers.

    However, I would question whether some intended uses of this may actually be a game logic issue and not an input system issue. Take this example:

    Mega Man charge weapon:
    User must press and hold for 1 second and then release to fire charge blast.

    I consider this a game logic decision, not the responsibility of the input system because it involves player state management. If Mega Man is in a getting hit state and you start holding the button, this should _not_ initiate the charge blast timer or count toward the current charge time. The game logic must check the player state first to determine if he should be allowed to charge the weapon. If the player enters a state at any point during the charge that doesn't allow the Charge action, the charge would be canceled. You would want to code this detection in your game logic, recording the time pressed while currently allowed to Charge, then then upon release, evaluating whether the time requirement was met. Using Rewired's timers for the above would lead to problems because you could not incorporate state permissions into the equation.
     
    Last edited: Feb 4, 2016
    Maeslezo likes this.
  44. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    331
    So I will do it as you say. You are right about it could be a design decision, but in this case I think it is not. We are simulating a behaviour. We you release the button, if it was a long press do actionA and if it was a press do actionB. But I could do it storing the time when it was hold with GetButtonTimePressed.


    Thank you for your answer!
     
    Last edited: Feb 3, 2016
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Rewired 1.0.0.80 is ready for download for registered users on my website. Please contact me here to register. The update should appear on the Asset Store in 3-7 days.

    1.0.0.80:

    Changes:
    - RewiredStandaloneInputModule: Added workaround for Unity issue causing Unity UI navigation to intermittently fail when using the Siri Remote touchpad on tvOS.


    New Controller Definitions:
    - P.I. Engineering XK-24
    - 8Bitdo NES30 Pro / FC30 Pro (Wired)
    - 8Bitdo NES30 Pro / FC30 Pro (Bluetooth, Mode 1)
    - Logitech G29 Driving Force Racing Wheel

    Modified Controller Definitions:
    - Changed 8Bitdo NES30 (wired) definition for button layout changes in firmware 2.65, all platforms.
    - Changed 8Bitdo NES30 (Joy Mode) definition for button layout changes in firmware 2.65, all platforms.
    - Unity 5+: Changed Samsung EI-GP20 definition on Android, Amazon Fire TV to correct for different Right Stick axis mappings in Unity 5.0+.
    - Added Linux Native mapping to Logitech G27 definition.


    Bug Fixes:
    - Windows App Store (8.0, 8.1): Fixed issue causing exception on initialization.
    - Windows Raw Input: Fixed hot-plugging issue on Windows 10 with certain HID devices.
    - Windows Raw Input: Steam Raw Input fix now works if Steam is initialized after Rewired.
    - Linux Native: Axis -> button hardware definitions mappings no longer fail when source is Axis 0.
    - Fixed bug in Saitek X55 Throttle definition on Direct Input.
     
  46. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551

    This is great news to see more Racing Wheels being added to your controller list. The XK-24 looks like a interesting USB device too. By far the best asset with support for the best flight controllers and by far the greatest variety of controllers.

    Keep up the good work.
     
    guavaman likes this.
  47. vivalavida

    vivalavida

    Joined:
    Feb 26, 2014
    Posts:
    85
    hi @guavaman , are different controller different in behaviour?
    I'm mainly designed my game around the xbox one controller.
    But ive had to map it to other input options as well. what i noticed is that the xbox one give an absolute value but other inputs (logitech f310, and a regular keyboard) give additive input, so these values take time to fall back to zero. this gives an undesired 'lag' in my player controls.
    Is there a way to get around this issue? Everything works beautifully with the xbox one controller.
    Hope I've been clear enough.


    edit: never mind, the digital axis gravity was low, after setting it to a high value in the input behaviour the problem was solved. (thought that the f310 joystick would have been absolute)
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Logitech F310's joystick is absolute. The only way it would be applying digital axis gravity is if the joystick is set to digital mode, which makes the stick be treated as a digital D-Pad. There's a button in the center of the F310 labeled "Mode", just like most older PC gamepads, that switches the function of the analog stick between digital and analog mode. Press that button and it will put the stick back to analog mode.
     
    vivalavida likes this.
  49. Galaks

    Galaks

    Joined:
    Feb 8, 2016
    Posts:
    12
    Hi, I would like to know if it’s possible to create a custom element to add and detect a swipe movement on appleTVRemote or touch device? Because I need some values as time and direction to detect a swipe.

    Thank you.
     
    Last edited: Feb 8, 2016
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,625
    Rewired does not provide any built-in tracking or interpretation of touch gestures at this time. Touch controls and gestures can be bound to Actions using the Custom Controller system by creating a script to track and detect the gestures and then piping in the result into a Custom Controller's buttons or axes, then binding those to Actions. Custom Controllers can also be used to bridge a dedicated touch input plugin with Rewired's Action system by piping in the results.

    To get touch information from the remote, you will need to use UnityEngine.Input.touchCount and UnityEngine.Input.GetTouch as the joystick does not return nearly as much information as Unity Touch structs and only returns current axis and button values. To change the DPad mode, set UnityEngine.Apple.TV.Remote.reportAbsoluteDpadValues.

    If you can do what you want without the extra Touch data, you could get the Siri Remote Joystick so you could read axis x/y (0/1) values directly with the following code:

    Code (csharp):
    1. private Guid SiriRemoteGuid = new Guid("bc043dba-df07-4135-929c-5b4398d29579");
    2.  
    3. private Joystick FindSiriRemote() {
    4.    for(int i = 0; i < ReInput.controllers.joystickCount; i++) {
    5.         if(ReInput.controllers.Joysticks[i].hardwareTypeGuid == SiriRemoteGuid) return ReInput.controllers.Joysticks[i];
    6.     }
    7.     return null;
    8. }
     
    Last edited: Feb 8, 2016