# Create a new local player/ new player controller on unassigned gamepad button press

**URL:** <https://forums.unrealengine.com/t/create-a-new-local-player-new-player-controller-on-unassigned-gamepad-button-press/2323642>\
**Category:** C++\
**Tags:** controller, unreal-engine, local-multiplayer, Blueprint, CPP, question\
**Created:** [February 9, 2025, 12:27am UTC](https://forums.unrealengine.com/t/create-a-new-local-player-new-player-controller-on-unassigned-gamepad-button-press/2323642 "2025-02-09T00:27:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edorion\_tlg](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/edorion_tlg/32/465183_2.png) [@Edorion\_tlg](https://forums.unrealengine.com/u/Edorion_tlg)\
**Post date:** [February 9, 2025, 12:27am UTC](https://forums.unrealengine.com/t/create-a-new-local-player-new-player-controller-on-unassigned-gamepad-button-press/2323642/1 "2025-02-09T00:27:38Z")

</div>

Hi, I am trying to give a way for my players to join the lobby in a local multiplayer game (non splitscreen) with the press of a button. The end goal is to have a menu like smash bros (for example). However I cannot find a way to do that.

Should I create player controllers for each player, and then simply let them be spectators if they didn’t join ? If so what should I do ?

My initial goal was to only create ULocalPlayer for players who wanna join. I have a way of detecting button pressed for unassigned controllers (through the UEnhancedInputWorldSubsystem), but I cannot find the controller id that pressed the button.

If you have a solution I would appreciate it.  
Thanks a lot

---

<div class="post-metadata">

**Author:** ![Edorion\_tlg](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/edorion_tlg/32/465183_2.png) [@Edorion\_tlg](https://forums.unrealengine.com/u/Edorion_tlg)\
**Post date:** [February 11, 2025, 4:33am UTC](https://forums.unrealengine.com/t/create-a-new-local-player-new-player-controller-on-unassigned-gamepad-button-press/2323642/2 "2025-02-11T04:33:58Z")

</div>

So I found a workaround that is kinda ugly and invasive (in my opinion) but it works :

You should create a custom engine subsystem, who’s single purpose is to send an event on key press (you can add this feature on any subsystem really, in my case I didn’t have one so I created it). This event is fired when an input preprocessor receives a key down.  
Relevant engine files :  
Engine\Source\Runtime\Engine\Classes\GameFramework\InputDeviceSubsystem.h  
Engine\Source\Runtime\Engine\Private\GameFramework\InputDeviceSubsystem.cpp  
Engine\Source\Runtime\Slate\Public\Framework\Application\IInputProcessor.h

Example :  
YourSubsystem.h

```c++
#pragma once

#include "CoreMinimal.h"
#include "Subsystems/EngineSubsystem.h"
#include "YourSubsystem.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAnyKeyPressSignature, FKeyEvent, KeyEvent);

class FYourSubsystemInputProcessor;

/**
 * 
 */
UCLASS()
class UYourSubsystem : public UEngineSubsystem
{
	GENERATED_BODY()

public:
	static UYourSubsystem* Get();

	UFUNCTION(BlueprintCallable, BlueprintPure)
	static FInputDeviceId GetInputDeviceIdFromKeyEvent(FKeyEvent KeyEvent);
	
	virtual void Initialize(FSubsystemCollectionBase& Collection) override;
	virtual void Deinitialize() override;

	UPROPERTY(BlueprintAssignable)
	FOnAnyKeyPressSignature OnAnyKeyPressDelegate;

private:
	friend class FYourSubsystemInputProcessor;
	
	void PreprocessorReceivedInput(const FKeyEvent& KeyEvent);

	TSharedPtr<FYourSubsystemInputProcessor> InputProcessor;
};

```

YourSubsystem.cpp

```c++
#include "YourSubsystem.h"

#include "Framework/Application/IInputProcessor.h"

class FYourSubsystemInputProcessor : public IInputProcessor
{
	friend class FYourSubsystem;

public:

	virtual void Tick(const float DeltaTime, FSlateApplication& SlateApp, TSharedRef<ICursor> Cursor) override
	{
		
	}
	
	void NotifySubsystemOfKeyPress(const FKeyEvent& KeyEvent)
	{
		if (UYourSubsystem* Subsystem = UYourSubsystem::Get())
		{
			Subsystem->PreprocessorReceivedInput(KeyEvent);
		}
	}
	
	virtual bool HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& InEvent) override
	{
		NotifySubsystemOfKeyPress(InEvent);
		return false;
	}
};

UYourSubsystem* UYourSubsystem::Get()
{
	return GEngine ? GEngine->GetEngineSubsystem<UYourSubsystem>() : nullptr;
}

FInputDeviceId UXpinEngineSubsystem::GetInputDeviceIdFromKeyEvent(FKeyEvent KeyEvent)
{
	return KeyEvent.GetInputDeviceId();
}

void UYourSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
	Super::Initialize(Collection);

	// We have to have a valid slate app to run this subsystem
	check(FSlateApplication::IsInitialized());
	
	InputProcessor = MakeShared<FYourSubsystemInputProcessor>();
	FSlateApplication::Get().RegisterInputPreProcessor(InputProcessor);
}

void UYourSubsystem::Deinitialize()
{
	Super::Deinitialize();
	
	if (FSlateApplication::IsInitialized())
	{
		FSlateApplication::Get().UnregisterInputPreProcessor(InputProcessor);
	}
	InputProcessor.Reset();
}

void UYourSubsystem::PreprocessorReceivedInput(const FKeyEvent& KeyEvent)
{
	OnAnyKeyPressDelegate.Broadcast(KeyEvent);
}

```

You can then use this event that is fired on EVERY KEY PRESS and check if the controller id stored in KeyEvent has a player. If not, create it.

I also added a little helper blueprint function that returns the Input device id since the function is not exposed in blueprints natively.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [March 13, 2025, 4:34am UTC](https://forums.unrealengine.com/t/create-a-new-local-player-new-player-controller-on-unassigned-gamepad-button-press/2323642/3 "2025-03-13T04:34:21Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
