// Copyright (c) 2024 Augie R. Maddox, Guavaman Enterprises. All rights reserved.
#pragma warning disable 0649 // disable warnings about unused variables
namespace Rewired.Demos.CustomPlatform {
///
/// Example custom platform manager.
/// Add this component to the Rewired Input Manager GameObject or a child GameObject and Rewired
/// will set the custom platform during initialization.
/// The first active and enabled component that implements
/// found that returns a non-null will be used by
/// Rewired during initialization to set the custom platform.
///
public sealed class CustomPlatformManager : UnityEngine.MonoBehaviour, Rewired.Platforms.Custom.ICustomPlatformInitializer {
///
/// Provides custom platform joystick definition maps.
///
public CustomPlatformHardwareJoystickMapProvider mapProvider;
///
/// Gets the custom platform options to initialize a custom platform.
/// Called during Rewired initialization.
/// Return null to not use a custom platform.
///
/// Custom platform init options
public Rewired.Platforms.Custom.CustomPlatformInitOptions GetCustomPlatformInitOptions() {
// You can use #if conditionals or other means to determine which custom platform to initialize, if any.
// Create platform options
var options = new Rewired.Platforms.Custom.CustomPlatformInitOptions();
// Set the platform id
options.platformId = (int)CustomPlatformType.MyPlatform;
// Set the platform identifier string
options.platformIdentifierString = "MyPlatform";
// Set the map provider
options.hardwareJoystickMapCustomPlatformMapProvider = mapProvider;
// Create platform configuration values
var configVars = new Rewired.Platforms.Custom.CustomPlatformConfigVars() {
ignoreInputWhenAppNotInFocus = true,
useNativeKeyboard = true,
useNativeMouse = true
};
// Create and set the input source
options.inputSource = new MyPlatformInputSource(configVars);
return options;
}
}
}