How to handle platform specific logic

I’m developing a game that ideally would be released to multiple platforms, starting by desktop (Windows, Mac, Linux) and then porting to mobile (iOS and Android) and finally to consoles if the opportunity arises.

Given that there’s custom logic like different input methods between desktop, mobile and console and also each one might have their own specific way of presenting things like menus or even their own monetization options or whatever, how would I best handle this?

So far I’ve got three ideas:

  1. Identify the current platform and execute logic based on that
  2. Create platform specific branches in my VCS and make the changes on them to avoid having useless code and blueprints logic
  3. Finish one platform first (ie PC) and then move onto the next, creating a copy of the whole project and replace assets and logic as I see fit

Problem I see with identifying the current platform is that I’d probably leave a lot of dead weight blueprints and code, adding to package size and probably performance overhead doing all these checks, unless there’s some kind of macros that I can use both in blueprints and C++ to ignore certain parts of the code in the building process

Problem I see with branching is that my game is really simple and managing all these branches and merge-backs and all that would be cumbersome since I’d need to maintain several branches with only little differences

3rd option is the one that seems easier if there’s not that much custom logic, but this idea doesn’t really seem like a good solution, it seems like a workaround

You should check out LE Extended Standard Library by Low Entry, they have Alot of usefull blueprint nodes including stuff like IsWindows, IsXbox etc.

According to the plugin documentation it detects the platform but what I’m looking for is to detect input type because in one platform, let’s say Windows, you can have either mouse/keyboard or ps4 controller or xbox controller or even switch controllers or whatever, so I’d like to show icons depending on the input type

oh okay now i understand. I actually made something like that for a game before where our tutorial UI changed depending on if you played with controller or keyboard.

  1. Setup Axis in Project Settings

  1. Check if those axis gets over a certain value, if so set using contrller vs keyboard etc. If you add like IsXbox, IsPlaystation etc. here if controller axis is true then you can specify which console as well so you know if they are using keyboard on a console.

  1. Hook up Dispatchers to things that you want to change.