Download

Detecting ActionMappings within c++?

Still re-building my old game in c++ and wondered if something like this is still possible but linked straight to ActionMappings?



class MyInput extends PlayerInput;
var MainPlayer CurrentController;

function bool InputKey(int ControllerId, name Key, EInputEvent Event, optional float AmountDepressed = 1.f, optional bool bGamepad = false)
{
	local MainPlayer TempController;
       
     if(CurrentController != none)
     {
    		if(Event == IE_Pressed)
    		{
        		CurrentController.ButtonPressed(string(Key));
    		}
    		else if(Event == IE_Released)
    		{
        		CurrentController.ButtonReleased(string(Key)); 
    		}
     }
     else
     {
		foreach WorldInfo.LocalPlayerControllers(class'MainPlayer', TempController)
		{
			CurrentController = tempController;
    		if(Event == IE_Pressed)
    		{
        		CurrentController.ButtonPressed(string(Key));
    		}
    		else
    		{
        		CurrentController.ButtonReleased(string(Key));    		    
    		}
      		break;
		}   
     }
    return false;
}


I just haven’t found any examples of this yet.


Quick

You can just use

(player controller functions)



```

WasInputKeyJustPressed
WasInputKeyJustReleased
IsInputKeyDown

```



using the EKeys struct!

Like



```

EKeys::Home

```



Action Mappings (for double key press event especially)

.h


/** sets up input */
virtual void SetupInputComponent() OVERRIDE;

.cpp


void AVictoryGamePlayerController::SetupInputComponent()
{
	Super::SetupInputComponent();

	BIND_ACTION(InputComponent, "KeyDownX", IE_Pressed, &AVictoryGamePlayerController::KeyXPressed);
	BIND_ACTION(InputComponent, "KeyUpX", IE_Released, &AVictoryGamePlayerController::KeyXReleased);
	BIND_ACTION(InputComponent, "KeyDownY", IE_Pressed, &AVictoryGamePlayerController::KeyYPressed);
	BIND_ACTION(InputComponent, "KeyUpY", IE_Released, &AVictoryGamePlayerController::KeyYReleased);
	BIND_ACTION(InputComponent, "KeyDownZ", IE_Pressed, &AVictoryGamePlayerController::KeyZPressed);
	BIND_ACTION(InputComponent, "KeyUpZ", IE_Released, &AVictoryGamePlayerController::KeyZReleased);
	
	//LMB Double Click
	BIND_ACTION(InputComponent, "LeftMouseDoubleClick", IE_DoubleClick , & AVictoryGamePlayerController::LMB_DoubleClick);
	
	//A Double Click
	BIND_ACTION(InputComponent, "MiddleMouseDoubleClick", IE_DoubleClick , & AVictoryGamePlayerController::MMB_DoubleClick);
	
	//A Double Click
	BIND_ACTION(InputComponent, "ADoubleClick", IE_DoubleClick , & AVictoryGamePlayerController::A_DoubleClick);
	
	//D Double Click
	BIND_ACTION(InputComponent, "DDoubleClick", IE_DoubleClick , & AVictoryGamePlayerController::D_DoubleClick);
	
	//S Double Click
	BIND_ACTION(InputComponent, "SDoubleClick", IE_DoubleClick , &AVictoryGamePlayerController::S_DoubleClick);
	
	//W Double Click
	BIND_ACTION(InputComponent, "WDoubleClick", IE_DoubleClick , & AVictoryGamePlayerController::W_DoubleClick);
	
	//F1 Double Click
	BIND_ACTION(InputComponent, "F1DoubleClick", IE_DoubleClick , &AVictoryGamePlayerController::F1_DoubleClick);	
}


**DefaultInput.ini**



```

;~~~~~~~ Double Clicks ~~~~~~~~~~
+ActionMappings=(ActionName="LeftMouseDoubleClick", Key=LeftMouseButton)
+ActionMappings=(ActionName="MiddleMouseDoubleClick", Key=MiddleMouseButton)
+ActionMappings=(ActionName="ADoubleClick", Key=A)
+ActionMappings=(ActionName="DDoubleClick", Key=D)
+ActionMappings=(ActionName="SDoubleClick", Key=S)
+ActionMappings=(ActionName="WDoubleClick", Key=W)

+ActionMappings=(ActionName="F1DoubleClick", Key=F1)

;etc

```



:)

Rama

Thanks, i’ll give it a go :smiley: