Announcement

Collapse
No announcement yet.

reading input when using a scaleform window

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Ok. You still seem to be forging off down the "get scaleform to capture the keys route". I did try that, but found that what scaleform captured wasn't the same name that UnrealEngine needed to do its binding, therefore I think the only way to do key capture is have the engine do it (not the scaleform interface). I think you are seeing that too with your last few comments.

    Are you using the same method for GUI as epic have?

    If so, the chances are you have a MenuManager, A keybind displayer page, and a dialog box telling the user to press a button. If you don't the following concept will still work, but you'll need to come up with your own "start capture/stop capture" hook. I just use some variables around the push and pop of the dialog to achieve a hook.

    So heres how I capture any keypress apart from escape (including mouse buttons) using a scaleform interface.

    Put this in your menu manager. It's the thing in charge and so is the ONLY one that can capture keybinds -

    Code:
    /* In order to capture keybinds the MenuManager needs to be told to watch, and remember
     * the key that was captured. Its then read by the KeyBindView for binding */
    var bool bCaptureForBind;
    var name CapturedKey;
    
    
    event bool FilterButtonInput(int ControllerId, name ButtonName, EInputEvent InputEvent)
    {
    	if (self.bCaptureForBind == true && InputEvent == IE_Pressed && ButtonName != 'Escape')
    	{
    		`log ("FilterButtonInput"$ ControllerId @ ButtonName @ InputEvent);
    		self.CapturedKey = ButtonName;
    		self.bCaptureForBind = false;
    		self.PopView();
    
    		return true;
    	}
    
    	self.CapturedKey = '';
    	return false;
    	
    }
    The above code listens for any keybind (apart from escape) if the bCaptureForBind flag is set. When it gets it it stores in in the MenuManager

    Then in your "keybind displaying" page - when you activate your dialog box -

    Code:
    function ListenForNewBind(int SelectedIndex)
    {
    Dialog = FFGFx_FrontEnd_KeybindDialog(MenuManager.SpawnDialog('KeybindDialog'));
    	Dialog.SetTitle("Choose a new key for "$ Caps(BindingList[SelectedIndex].FriendlyName));
    	Dialog.SetInfo("Press the key you wish to bind to this command, or press [esc] to cancel");
    	Dialog.SetBackButtonListener(Select_Back);
    
    	MenuManager.bCaptureForBind = true;
    }
    The above code displays a dialog box, and tells the MenuManager that it should start listening for a capture. The dialog will be visible until the user presses escape, or the MenuManager caught something

    Code:
    function OnTopMostView(optional bool bPlayOpenAnimation = false)
    {
        local int i;
    
        Super.OnTopMostView(bPlayOpenAnimation);                   
       
        if (bWaitingForBind && MenuManager.CapturedKey != '')
        {
                `log ("I was waiting and I got what I always wanted. A "$ MenuManager.CapturedKey $" for "$ CommandName $" to replace "$ OldKeyBind,,'DevUI');
                 BindKey(MenuManager.CapturedKey, CommandName, OldKeyBind);
        }
    }
    This final bit of code waits for the view to be popped (because the menumanager captured a key, or the user pressed escape). If the MenuManager key isn't empty, it unbinds the old key, and binds the new one. Otherwise, the user must have pushed escape and the entire bind thing is forgotten.

    Now for bonus points go and implement the system using the PlayerControllers PlayerInput and the UTUIDataProvider_KeyBinding datastore to get a language specific friendly name for your key command

    Comment


      #32
      funny part is i already done the bonus part.

      heres my implementation for it - be nice to know how you did your filtering.

      Code:
      var array<UTUIDataProvider_KeyBinding> KeyB;
      
      function UpdateListDataProvider()
      {
      	local int i, BindingIdx;
      	local GFxObject TempObj;
      	local GFxObject DataProvider;
      	local string strGBA_BindName, strGBA_BindValue;
      
          local array<UDKUIResourceDataProvider> ProviderList;  
      	local TAPlayerInput TAInput;
      
      	class'UDKUIDataStore_MenuItems'.static.GetAllResourceDataProviders(class'UTUIDataProvider_KeyBinding', ProviderList);
      	for (i = 0; i < ProviderList.Length; i++)
      	{
      	    KeyB.InsertItem(0, UTUIDataProvider_KeyBinding(ProviderList[i]));        
      	}
      
      	DataProvider = Outer.CreateArray();
      
      	TAInput = TAPlayerInput(GetUDKPlayerOwner().PlayerInput);
      
      	for (i = 0; i <  KeyB.Length; i++)
      	{
      		strGBA_BindName = KeyB[i].FriendlyName;	
      
      		for(BindingIdx = 0;BindingIdx < TAInput.Bindings.Length;BindingIdx++)
      		{
      			if(TAInput.Bindings[BindingIdx].Command == KeyB[i].Command)
      			{
      				strGBA_BindValue = String(TAInput.Bindings[BindingIdx].Name);
      			}
      		}
      
      		//`Log("KeyB[i].FriendlyName =" $KeyB[i].FriendlyName $ " CMD=" $ KeyB[i].Command $ " NAME=" $ KeyB[i].Name);
      
      
      		
      		TempObj = CreateObject("Object");  
      		TempObj.SetString("label", strGBA_BindName);
      		TempObj.SetString("valuelabel", strGBA_BindValue);
      		DataProvider.SetElementObject(i, TempObj);
      	}
      
          ListMC.SetObject("dataProvider", DataProvider);   
          ListDataProvider = ListMC.GetObject("dataProvider");
      }
      and my dialog is

      Code:
      function Open_BindKeyDialog(int index)
      {
         local GFxTAFrontEnd_BindKey DialogMC;
                         
         DialogMC = GFxTAFrontEnd_BindKey(MenuManager.SpawnDialog('BindKeyDialog'));
         DialogMC.SetTitle("Set New Key");
         DialogMC.SetInfo("Press the key you want to use for " $ GetBindName(index));		        
         DialogMC.SetButtonLabel("CANCEL");
         DialogMC.SetBackButton_OnPress(Select_Cancel);
      }
      do i get my bonus points?? i take cookies as payment! (and thanks! - wish i checked FilterButtonInput - the name of the method isnt obvious but the params it handles are DOH!!)

      Comment


        #33
        I have cookies. I've added one to your browser cache

        I added that to get other people who need to implement this to follow the same route, with the naive idea that if lots of us do this there will be big complaints if epic removed that datastore . It took me ages to figure out that I needed to use the UTDataProvider_Keybinding datastore.

        I did mine in pretty much the same way except I wrote a function so I could get back the ALT binding value too, and I store my binding list when the menu is loaded rather than when the list provider is updated.

        Code:
        function GetBoundKeys(string InCommand, out string PrimaryKey, out string AltKey)
        {
                local int i;
        
                for (i = 0; i < PInput.Bindings.Length; i++)
                {
                        if (PInput.Bindings[i].Command == InCommand)
                        {
                                AltKey = string(PInput.Bindings[i].Name);
                                break;
                        }                       
                }
        
                for (i++; i < PInput.Bindings.Length; i++)
                {
                    if (PInput.Bindings[i].Command == InCommand)
                    {
                        PrimaryKey = string(PInput.Bindings[i].Name);
                    }               
                }
        
                if (PrimaryKey == "")
                {
                        PrimaryKey = AltKey;
                        AltKey = "";
                }
        }
        
        function UpdateListDataProvider()
        {
            local byte i;
        
            local GFxObject DataProvider;
            local GFxObject TempObj;
                local string PrimaryKey, AltKey;
           
                // Get the list of what has already been bound
                BoundList = GetPC().PlayerInput.Bindings;
        
            DataProvider = Outer.CreateArray();
            for (i = 0; i < BindingList.Length; i++)
            {
                // Create a AS object to hold the data for SettingsList[i].
                TempObj = CreateObject("Object");   
                // Parse SettingsList[i] into TempObj.
                TempObj.SetString("label", Caps(BindingList[i].FriendlyName));
                TempObj.SetString("control", "button");
                PrimaryKey = "";
                AltKey = "";
                GetBoundKeys(BindingList[i].Command, PrimaryKey, AltKey);
                TempObj.SetString("text", CAPS(PrimaryKey @ AltKey));
                DataProvider.SetElementObject(i, TempObj);
            }
        
            ListMC.SetObject("dataProvider", DataProvider);   
            ListDataProvider = ListMC.GetObject("dataProvider");
        }

        Comment


          #34
          i plugged your code in, and great so far.

          how did you get it to ignore the console open calls on Tilde and Quote?

          Comment


            #35
            Actually, I don't know if it does. I didn't try to bind them as most people will use them for entering commands. My thought was "I'm using the unreal engine - don't break its core functionality"

            Most developers who see a game developed in the unreal engine knows that` and ~ are bound to the console.

            Comment


              #36
              I can't recognize the numbers (1-9) and some letters when I key-in the keyboard in my keypad map I made.

              In Flash Movie I have :

              var keyboardInput:Object = new Object();
              Key.addListener(keyboardInput);

              keyboardInput.onKeyDown = function()

              {
              var keypressed:Number=Key.getCode();

              switch(keypressed)
              {
              case 49:
              fscommand("1");
              break;
              case 50:
              fscommand("2");
              break;
              case 51:
              fscommand("3");
              break;
              case 52:
              fscommand("4");
              break;
              }


              }
              In Kismet I have OpenGfxMovie which includes under CaptureKeys in Properties all 9 numbers and I have Set Capture = true
              Also in Kismet the Set Fx Capture keys I have included the 9 numbers in the slots Properties.

              If I use letters like A, B, C (but not D) they are fully recognized (using those instead of numbers in both Flash and Kismet) but no numbers which means numbers and some letters are "swallowed".
              I tried inserting the AddCaptureKey('1'), and '2' etc in GFxMoviePlayer.uc but the compiler reports an error "missing variable type"

              Please help !!

              Comment


                #37
                Try using the numbers spelled out in Kismet - one, two, three, four, etc. instead of the digits.

                Comment


                  #38
                  I too am having difficulty getting the key captures to work.

                  in previous builds of the UDK, my flash movies would capture all input with bCaptureInput = true; however in the latest build (we skipped a few) it will only capture keys specifically added to the AddCaptureKey() command.

                  my problem is, I cannot get it to accept alpha-numeric keys. however backspace works.

                  so has the ability to capture all input been removed, or is there a way to add alpha-numeric keys that I am missing?

                  note, in the movie in question, a textfield is selected and active, so letters need to be passed to it.

                  Comment


                    #39
                    Input still works. Instead of using a Flash textfield, use a CLIK component called TextInput. You'll find it here:

                    C:\UDK\UDK-2010-10\Development\Flash\CLIK\components\TextInput.fla

                    When this text input field has focus, it will accept all your input, assuming you have bCaputerInput=true in the default properties.

                    Comment


                      #40
                      I've tried using the CLIK widget TextInput, but I still have the same problem.

                      is there a special way I need to instantiate or load the CLIK widget?

                      currently, it is embedded within several movie clips, and I am manually setting the focus with "Selection.setFocus("_root.JoinWindow.infield.inpu t.textField");" or "Selection.setFocus("_root.JoinWindow.infield.inpu t");"

                      the box gets focus, and the input cursor can be seen, but nothing I type is passed into it.

                      Comment


                        #41
                        That should be all you need to do. Just putting the TextInput widget in your menu should work. If you use arrow keys or tab to give it focus, you should be able to type into it.

                        I confirm it works on my end. Just dragged and dropped the widget into my menu tutorial file, reimported into UDK, ran the game - text input field works as expected.

                        Comment


                          #42
                          well, I've solved the problem by writing my own key event handler within Actionscript, and then controlling the field directly from code. used in conjunction with
                          CaptureKeys=("backspace", "one","two","three","four","five","six","seven","e ight","nine","zero", "period")

                          does anyone know the CaptureKEey codes for the number pad numerals?

                          Comment


                            #43
                            Where are you using this text field? In a menu? In the HUD? In a render to texture on a bsp or static mesh?

                            Comment


                              #44
                              Originally posted by Matt Doyle View Post
                              Where are you using this text field? In a menu? In the HUD? In a render to texture on a bsp or static mesh?
                              as I understand it, it shouldn't matter where the object is rendered to.

                              but I am loading the scaleform object in my UI_Game class, rendering it to a texture, using the texture in a decal, and projecting the decal onto a static mesh.

                              Comment


                                #45
                                I was watching Scaleform UDK Tutorial - 4 of 9 - Capturing Input, and I saw that the key input was a number value. what is the number value map, and do we have to use it?

                                Comment

                                Working...
                                X