Announcement

Collapse
No announcement yet.

reading input when using a scaleform window

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

    #16
    In the end, a full explanation would be beneficial, but a quick how to capture keys would do. I am actually working on a basic settings menu and am not using any of the current UDK Scaleform stuff so just perusing the actual script source would be more beneficial to us than a step by step "how to make it work with UDK menus" sort of thing.

    Comment


      #17
      I believe details.navEquivalent will return 'undefined' if the key pressed is not a navigation key, such as left arrow, right arrow, up arrow, down arrow, enter key, space, tab key, end, home, page up, page down, or backspace.

      In the case of any other key, you would need to do a conversion of the details.code value in UnrealScript after passing it from ActionScript or in ActionScript before passing it to UnrealScript.

      For instance - 70 = F, 80 = P, etc.

      Comment


        #18
        I currently have this little gem in my defaultproperties:

        Code:
        CaptureKeys=("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","_","+","[","]","\\","{","}","|",";","'",":","\"",",",".","/","<",">","?","`","~"," ")
        Works for everything except the ~ key (which opens the console).

        Is this how it's supposed to be done? Feels odd having to manually add every single key to the array.

        I cannot get Backspace, Delete, Left, Right, Home or End to work either. I tried various things including AddCaptureKey('Backspace');

        Any tips?

        Comment


          #19
          Originally posted by Xyx View Post
          I currently have this little gem in my defaultproperties:

          Code:
          CaptureKeys=("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","=","_","+","[","]","\\","{","}","|",";","'",":","\"",",",".","/","<",">","?","`","~"," ")
          Works for everything except the ~ key (which opens the console).

          Is this how it's supposed to be done? Feels odd having to manually add every single key to the array.

          I cannot get Backspace, Delete, Left, Right, Home or End to work either. I tried various things including AddCaptureKey('Backspace');

          Any tips?
          this is why im asking the best way to do this, it does seem crazy to have to make your own array of keys when quite simply the uscript input was bloody fine. best case secenario is to let flash handle only a few keys (escape for example) and then have the rest of the keys handled by uscript.

          i can see the key function in code but its only the cpp header for it and its in GFxInteraction class...

          cpptext
          {
          #if WITH_GFx
          /** Initializes this interaction, allocates the GFxEngine */
          ...
          /** Set the Engine's viewport to the viewport specified */
          virtual void SetRenderViewport(class FViewport* InViewport);

          virtual UBOOL InputKey(INT ControllerId,FName Key,EInputEvent Event,FLOAT AmountDepressed,UBOOL bGamepad);
          virtual UBOOL InputAxis(INT ControllerId,FName Key,FLOAT Delta,FLOAT DeltaTime, UBOOL bGamepad);
          virtual UBOOL InputChar(INT ControllerId,TCHAR Character);



          maybe if i can read that in my movie i can read the keys properly.

          Comment


            #20
            The other issue that will come up with building your own array is multi-national keyboards. How is that handled.

            Comment


              #21
              i hope its becomming a little more obvious why this isnt so easy to program in place. im **** sure i could program this about 5 different ways to get it to work, but unless i use the actual keyvalues when i come to keybind them the conversion code isnt going to work.

              I understand that the navEquivilant is only for a few keys.
              I understand that flash handles every key using a code - is this a ASCII code?? does this match exactly to uscript? can i do Flash code 22 = uscript code 22 which is a E??? (for example)

              can i read uscript keys from inputkey in my movie class?? (thats the best way then unreals handing this in its entirity)

              Im struggling to see why we need to pass input to the flash movies in the first place, if it was all handled though inputkey we could just create uscript to AS delegates.

              Comment


                #22
                Have a look at the AddCaptureKeys function in GFxProjectedUI.uc. (line 136). I don't know if this is the best way to handle it or not though.

                Comment


                  #23
                  I'm not sure if its ascii code or not, and whether it maps to Unreal one to one. Best I can say is you should do some tests to see if that is the case. Trace the codes for a group of keys when they are pressed, then compare.

                  Some input obviously needs to go to Flash movies - such as navigation keystrokes, otherwise you couldn't navigate a menu by keyboard input.

                  I think the best route would be to capture the key you want to bind in UnrealScript, then simply pass that info to Flash for display, rather than getting it from Flash.

                  Comment


                    #24
                    the problem is i want to allow the player to keybind every key on the keyboard (not all at once but you know what i mean) - in any language with the exception of using the escape key - this is just a normal requirement thats in most games.


                    So far even if i build an array of keys that can be pressed, this will only work for uk keyboards. How can i say setbind to key (findkeybycode(code))....


                    in fact i think the only way this is going to be possible is to bring up a drawing of a keyboard and give the player the option to press the keyboard key.... that way i will know what keys being used... it just seems way overkill.

                    I will look deeply at the hints afforded above and attempt to look into it with greater depth - but at the end of the day if i cant figure this out im going to have to write an ini parser and set the keys using an external program to edit the config files. It does not seem like its possible with whats being thrown about at the moment to do this "properly" to work fully.

                    please post source anyone who has done this / or part solutions - maybe we can work this out.

                    Comment


                      #25
                      ok i have just confirmed the codes do use the ascii keyset.

                      my reference is http://www.asciitable.com/

                      and from this i modified my actionscript.

                      Code:
                      import flash.external.ExternalInterface;
                      import gfx.events.EventDispatcher;
                      import gfx.ui.InputDetails;
                      import gfx.ui.NavigationCode;
                      
                      class com.scaleform.TA.view.BindKeyDialog extends com.scaleform.udk.dialogs.InfoDialog
                      {
                      	
                      	public function BindKeyDialog() 
                      	{
                              super();   
                      	}
                      
                          // Custom handleInput to handle standard input + unique cases.
                          function handleInput(details:InputDetails, pathToFocus:Array):Boolean 
                      	{          
                      		if(details.navEquivalent == undefined)
                      		{
                      			details.navEquivalent = String.fromCharCode(details.code);
                      		}
                      		
                      		trace(details.code + " | " + details.navEquivalent + " | " + details.value + "\n");
                              
                              // Maps Escape-KeyUp to _global.OnEscapeKeyPress(), a function object defined in UnrealScript
                              // and set by each view which calls some method. Generally this pops a view from the view stack.
                              if (details.navEquivalent == NavigationCode.ESCAPE && details.value == "keyUp") {            
                                  _global.OnEscapeKeyPress();
                                  return true;
                              }		        		
                      
                      		ExternalInterface.call("OnhandleInput", details);
                              return false; 
                          }   
                      }

                      The key line being details.navEquivalent = String.fromCharCode(details.code); that allows you to convert a character ascii code into the corresponding ASCII character.

                      Now with the exception of some strange keypresses (F1 for example is code 112 which maps to p) (which i will look into and post the fix for ((http://people.uncw.edu/tompkinsj/112...t/keycodes.htm))) my delegate back in uscript now has access to the right keys being pressed!!!

                      Comment


                        #26
                        tracked the bug. fromCharCode is a conversion to unicode. looking for a solution now.

                        Comment


                          #27
                          ok im very happy with how this is turning out. i do need to have a small switch statement in my uscript to map the codes for non alphanumeric keys.

                          so far it looks like

                          Code:
                          function OnhandleInput(GFxObject myInputObject)
                          {
                          	local int intCode;
                          	local string strKey, strKeyState;
                          
                          	strKey = myInputObject.GetString("navEquivalent");
                          	intCode = Int(myInputObject.GetFloat("code"));
                          	strKeyState = myInputObject.GetString("value");
                          
                          	if(strKeyState == "keyDown")
                          	{
                          		switch (intCode)
                          		{
                          			case 112:
                          				strKey = "F1";
                          				break;
                          		}
                          
                          		`Log("strKeyState " $ strKeyState $ " strKey " $strKey $ " intCode "$intCode);
                          	}
                          }
                          and i am using UTProfileSettings thats got a nice keybind section in

                          Code:
                          KeyMappingArray[UTBND_F1]="F1";
                          	KeyMappingArray[UTBND_F2]="F2";
                          	KeyMappingArray[UTBND_F3]="F3";
                          	KeyMappingArray[UTBND_F4]="F4";
                          	KeyMappingArray[UTBND_F5]="F5";
                          	KeyMappingArray[UTBND_F6]="F6";
                          	KeyMappingArray[UTBND_F7]="F7";
                          	KeyMappingArray[UTBND_F8]="F8";
                          	KeyMappingArray[UTBND_F9]="F9";
                          	KeyMappingArray[UTBND_F10]="F10";
                          	KeyMappingArray[UTBND_F11]="F11";
                          	KeyMappingArray[UTBND_F12]="F12";
                          	KeyMappingArray[UTBND_NumLock]="NumLock";
                          	KeyMappingArray[UTBND_ScrollLock]="ScrollLock";
                          	KeyMappingArray[UTBND_LeftShift]="LeftShift";
                          	KeyMappingArray[UTBND_RightShift]="RightShift";
                          	KeyMappingArray[UTBND_LeftControl]="LeftControl";
                          	KeyMappingArray[UTBND_RightControl]="RightControl";
                          	KeyMappingArray[UTBND_LeftAlt]="LeftAlt";
                          	KeyMappingArray[UTBND_RightAlt]="RightAlt";
                          	KeyMappingArray[UTBND_Semicolon]="Semicolon";
                          	KeyMappingArray[UTBND_Equals]="Equals";
                          	KeyMappingArray[UTBND_Comma]="Comma";
                          and using that i can map the code to the string name in my case statement.

                          I hope this works with most keyboards. It should definately work for any countries using a 102 key keyboard (standard QWERTY) but may not work for countries like japan/china... we will see.

                          For now i am happy with this. One last post in here will be my full source code for this.

                          Comment


                            #28
                            Good work so far..... It appears that UTProfileSettings was removed in the October release, but UDKProfileSettings is still there. And looking at UTProfileSettings.uc, it should be able to be brought over to October UDK pretty much as is if need be, but I didn't look into it extensively.

                            Comment


                              #29
                              just to clarify im not using the class UTProfileSettings - but im using the information in it to know what to use in setbind.

                              a normal command would be setbind Q Fire

                              but in cases where its a shift key or tab etc you have to do a setbind tab ShowScores and you need to know what unreal calls the shift key etc... the only thing im taking is what unreal called the key

                              Comment


                                #30
                                ok code so far

                                AS - used to push the object details to uscript - once the object values are set and its pushed to uscript we can handle whatever button code was sent though.
                                Code:
                                import flash.external.ExternalInterface;
                                import gfx.events.EventDispatcher;
                                import gfx.ui.InputDetails;
                                import gfx.ui.NavigationCode;
                                
                                class com.scaleform.TA.view.BindKeyDialog extends com.scaleform.udk.dialogs.InfoDialog
                                {
                                	
                                	public function BindKeyDialog() 
                                	{
                                        super();   
                                	}
                                
                                    // Custom handleInput to handle standard input + unique cases.
                                    function handleInput(details:InputDetails, pathToFocus:Array):Boolean 
                                	{          
                                		if(details.navEquivalent == undefined)
                                		{	
                                			details.navEquivalent = String.fromCharCode(details.code);
                                		}
                                		
                                		trace(details.code + " | " + details.navEquivalent + " | " + details.value + "\n");
                                        
                                        // Maps Escape-KeyUp to _global.OnEscapeKeyPress(), a function object defined in UnrealScript
                                        // and set by each view which calls some method. Generally this pops a view from the view stack.
                                        if (details.navEquivalent == NavigationCode.ESCAPE && details.value == "keyUp") {            
                                            _global.OnEscapeKeyPress();
                                            return true;
                                        }
                                		        		
                                		ExternalInterface.call("OnhandleInput", details);
                                        return false; 
                                    }   
                                }

                                uscript - the other end of it is one method.

                                Code:
                                function OnhandleInput(GFxObject myInputObject)
                                {
                                	local int intCode;
                                	local string strKey, strKeyState;
                                
                                	strKey = myInputObject.GetString("navEquivalent");
                                	intCode = Int(myInputObject.GetFloat("code"));
                                	strKeyState = myInputObject.GetString("value");
                                
                                	if(strKeyState == "keyDown")
                                	{
                                		switch (intCode)
                                		{
                                		// Keymapping array - Maps enum to unreal key names.
                                		//KeyMappingArray[UTBND_MouseX]="MouseX";
                                		//KeyMappingArray[UTBND_MouseY]="MouseY";
                                		//KeyMappingArray[UTBND_MouseScrollUp]="MouseScrollUp";
                                		//KeyMappingArray[UTBND_MouseScrollDown]="MouseScrollDown";
                                		//KeyMappingArray[UTBND_LeftMouseButton]="LeftMouseButton";
                                		//KeyMappingArray[UTBND_RightMouseButton]="RightMouseButton";
                                		//KeyMappingArray[UTBND_MiddleMouseButton]="MiddleMouseButton";
                                		//KeyMappingArray[UTBND_ThumbMouseButton]="ThumbMouseButton";
                                		//KeyMappingArray[UTBND_ThumbMouseButton2]="ThumbMouseButton2";
                                
                                			case 8:
                                				strKey = "BackSpace";
                                				break;
                                			//case ???:
                                			//	strKey = "Tab";
                                			//	break;
                                			case 13:
                                				strKey = "Enter";
                                				break;
                                			//case ???:
                                			//	strKey = "Pause";
                                			//	break;
                                			case 20:
                                				strKey = "CapsLock";
                                				break;
                                			case 27:
                                				strKey = "Escape";
                                				break;
                                			case 32:
                                				strKey = "SpaceBar";
                                				break;
                                			case 33:
                                				strKey = "PageUp";
                                				break;
                                			case 34:
                                				strKey = "PageDown";
                                				break;
                                			case 35:
                                				strKey = "End";
                                				break;
                                			case 36:
                                				strKey = "Home";
                                				break;
                                			case 37:
                                				strKey = "Left";
                                				break;
                                			case 38:
                                				strKey = "Up";
                                				break;
                                			case 39:
                                				strKey = "Right";
                                				break;
                                			case 40:
                                				strKey = "Down";
                                				break;
                                			case 45:
                                				strKey = "Insert";
                                				break;
                                			case 46:
                                				strKey = "Delete";
                                				break;
                                			case 96:
                                				strKey = "NumPadZero";
                                				break;
                                			case 97:
                                				strKey = "NumPadOne";
                                				break;
                                			case 98:
                                				strKey = "NumPadTwo";
                                				break;
                                			case 99:
                                				strKey = "NumPadThree";
                                				break;
                                			case 100:
                                				strKey = "NumPadFour";
                                				break;
                                			case 101:
                                				strKey = "NumPadFive";
                                				break;
                                			case 102:
                                				strKey = "NumPadSix";
                                				break;
                                			case 103:
                                				strKey = "NumPadSeven";
                                				break;
                                			case 104:
                                				strKey = "NumPadEight";
                                				break;
                                			case 105:
                                				strKey = "NumPadNine";
                                				break;
                                			case 106:
                                				strKey = "Multiply";
                                				break;
                                			case 107:
                                				strKey = "Add";
                                				break;
                                			case 109:
                                				strKey = "Subtract";
                                				break;
                                			case 110:
                                				strKey = "Decimal";
                                				break;
                                			case 111:
                                				strKey = "Divide";
                                				break;
                                			case 112:
                                				strKey = "F1";
                                				break;
                                			case 113:
                                				strKey = "F2";
                                				break;
                                			case 114:
                                				strKey = "F3";
                                				break;
                                			case 115:
                                				strKey = "F4";
                                				break;
                                			case 116:
                                				strKey = "F5";
                                				break;
                                			case 117:
                                				strKey = "F6";
                                				break;
                                			case 118:
                                				strKey = "F7";
                                				break;
                                			case 119:
                                				strKey = "F8";
                                				break;
                                			case 120:
                                				strKey = "F9";
                                				break;
                                			case 121:
                                				strKey = "F10";
                                				break;
                                			case 122:
                                				strKey = "F11";
                                				break;
                                			case 123:
                                				strKey = "F12";
                                				break;
                                			case 144:
                                				strKey = "NumLock";
                                				break;
                                			case 145:
                                				strKey = "ScrollLock";
                                				break;
                                			case 16:
                                				strKey = "LeftShift"; // SAME FOR RIGHT SHIFT
                                				break;
                                			case 17:
                                				strKey = "LeftControl"; //SAME FOR RIGHT CONTROL
                                				break;
                                			case 18:
                                				strKey = "LeftAlt"; // SAME FOR RIGHT ALT
                                				break;
                                			case 186:
                                				strKey = "Semicolon";
                                				break;
                                			//case ???:
                                			//	strKey = "Equals";
                                			//	break;
                                			case 188:
                                				strKey = "Comma";
                                				break;
                                			//case ???:
                                			//	strKey = "Underscore";
                                			//	break;
                                			case 190:
                                				strKey = "Period";
                                				break;
                                			case 191:
                                				strKey = "Slash";
                                				break;
                                			case 222:
                                				strKey = "Tilde";
                                				break;
                                			case 219:
                                				strKey = "LeftBracket";
                                				break;
                                			case 220:
                                				strKey = "Backslash";
                                				break;			
                                			case 221:
                                				strKey = "RightBracket";
                                				break;			
                                			//case ???:
                                			//	strKey = "Quote";
                                			//	break;
                                		}
                                
                                		`Log("strKeyState " $ strKeyState $ " strKey " $strKey $ " intCode "$intCode);
                                	}
                                }

                                now its not perfect.

                                problem 1. - Some keys cant be intercepted?? tab, the '=' sign, the pause button ... i have no idea why, but if anyone knows how to fix this then please post the code

                                problem 2 - How do we handle mouse input?? i need to accept the left / right mouse keypresses, the scrollwheel up/down and if possible the side buttons on a mouse.

                                Comment

                                Working...
                                X