How do I call INPUTCORE_API FName GetKeyName(EKey Key)

Update:

When I try to do this,

FName TheKeyName = EKeys::GetKeyName(EKeys::LeftControl);
ClientMessage(TheKeyName.ToString());
KeyActions[CurKeyBindAction] = EKeys::GetKeyFromName(TheKeyName);

compiler says:

'GetKeyName' : is not a member of 'EKeys'
 error C2039: 'GetKeyFromName' : is not a member of 'EKeys'

I really need to get this working for my custom keybinding saving/loading process, please help :slight_smile:

This is because I cant figure out how to Archive an EKey::Type directly :slight_smile:

like

Ar << EKeys::LeftControl;


Dear Friends at Epic,

In the context of my own player controller class:

How do I call the function:

extern INPUTCORE_API EKey GetKeyFromName(FName KeyName);

stored in

source → runtime inputcore->InputCoreTypes.h"

For example if I want to call absolute value function, I use

FMath::Abs()

But I am not sure of how to call GetKeyFromName or GetKeyName(EKey Key)

Goal: I am trying to convert an array of EKeys to Strings to print to the screen.

so here’s pseudo code:

TArray AllKeys;

//loop
ClientMessage(
  (TheSyntax I need Here)GetKeyName(AllKeys[itr]);
);

And a related question,

What is the exact code I would use to call these static functions from my controller class:


    // Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
    
    /*=============================================================================
    	CoreMisc.h: General-purpose file utilities.
    =============================================================================*/
    	static bool LoadANSITextFileToStrings(const TCHAR* InFilename, IFileManager* InFileManager, TArray& OutStrings);
    
    	static bool SaveStringToFile( const FString& String, const TCHAR* Filename, EEncodingOptions::Type EncodingOptions=EEncodingOptions::AutoDetect, IFileManager* FileManager=GFileManager );

Goal: I am trying to implement a simple save system to save files, and I am not sure how to write JSON's to hard disk.

:)

***I thoroughly enjoyed using BasicSaveObject in UE3, is there an equivalent in UE4?***

:)

thanks for the help!

:)

:)

:)

Rama

GetKeyFromName and its friends are in the EKeys namespace. So you want to do EKeys::GetKeyFromName.

I’m not terribly familiar with the other statics that you mention but from searching the code you would probably be doing something like FFileHelper::LoadANSI…(Filename, GFileManager, LinesToWrite)

oooh nice! thank you for this answer Marc!

:slight_smile:

Rama

When I try to do this,

ClientMessage(EKeys::GetKeyName(EKeys::LeftControl).ToString());

compiler says:

 'GetKeyName' : is not a member of 'EKeys'

If GetKeyFromName worked for you before I can only assume that in the context that you are trying to use the function now you are missing a #include . InputCoreTypes.h is usually going to get pulled in through Engine.h I believe.

“GetKeyFromName worked for you before”

Always happy to hear from you Marc!

I dont recall saying that GetKeyFromName ever worked for me, I’ve not been able to get either one to work

and I’ve had to write my own conversion in meantime

But I would love to get these two functions working!

I tried including

#include "InputCoreTypes.h"

but the compiler error is the same as in my updated first post

EKeys themselves work fine, EKeys::R, EKeys::LeftControl, etc

In fact I am using entire keyboard of EKeys for my chat and user input system

with the function usage in my controller class:

WasInputKeyJustPressed(EKeys::S)

This is quite baffling to me since it seems so simple to you

perhaps there is some symbol not exposed to us rocket beta testers? (some phrasing like that was mentioned to me in the past about stuff like this)


The reason this is important is that

  1. the functions have never worked for me, at all, and would be quite useful if I could get them to work
  2. I actually need this FName conversion for my keybinding save file where I want to put them in an Archive and need to retrieve the EKey::Type from the FName stored in the archive (since I dont know how to archive EKey::Type directly

Sorry I misunderstood. When you previously had thanks for the information and not mentioned it not working for you I had assumed it did work.

The move to put it in the EKeys namespace may have been before the last Rocket beta was put out (it is always fun to look at perforce revision history and try to make that determination). Prior to that they were in global namespace so you could try just GetKeyName/GetKeyFromName without the EKeys:: in front of it.

I tried using the global version initially,

and got this compiler error:

1>Module.VictoryGame.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class FName __cdecl GetKeyName(enum EKeys::Type)" (__imp_?GetKeyName@@YA?AVFName@@W4Type@EKeys@@@Z)


 referenced in function "protected: void __cdecl AVictoryGamePlayerController::DoTest(void)" (?DoTest@AVictoryGamePlayerController@@IEAAXXZ)
    1>E:\RocketVictory\VictoryGame\Binaries\Win64\RocketEditor-VictoryGame.dll : fatal error LNK1120: 1 unresolved externals
    1>  -------- End Detailed Actions Stats -----------------------------------------------------------

I just confirmed I get this error even if I

#include "InputCoreTypes.h"

Sounds like I need to wait for the new Rocket version?

Any way to call the global version right now?

If it’s too complicated for you to look into I will just wait for the next Rocket version (or right my own conversion to FName and be done with it)


Thanks for the investigative help Marc!

Rama

I think you need to add “InputCore” to either the Public or Private DependencyModuleNames in VictoryGame.Build.cs.

Woohooo!

That did it!

public class VictoryGame : ModuleRules
{
	public VictoryGame(TargetInfo Target)
	{
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem" });

You just saved me a lot of time

and also confusion for when next build comes out and the functions are in EKeys::


thanks so much Marc!

Yay!

Rama