This commit is contained in:
2025-05-10 18:06:44 +08:00
parent e010759358
commit dea9a4f58e
47 changed files with 421 additions and 359 deletions

View File

@@ -10,6 +10,6 @@ namespace Rewired.Demos.CustomPlatform {
[System.Serializable]
public class CustomPlatformHardwareJoystickMapPlatformDataSet : UnityEngine.ScriptableObject {
public System.Collections.Generic.List<Platforms.Custom.HardwareJoystickMapCustomPlatformMapSO> platformMaps;
public System.Collections.Generic.List<Rewired.Platforms.Custom.HardwareJoystickMapCustomPlatformMapSO> platformMaps;
}
}

View File

@@ -9,14 +9,14 @@ namespace Rewired.Demos.CustomPlatform {
/// Finds the matching platform map for the controller in question for the current custom platform.
/// </summary>
[System.Serializable]
public class CustomPlatformHardwareJoystickMapProvider : Platforms.Custom.IHardwareJoystickMapCustomPlatformMapProvider {
public class CustomPlatformHardwareJoystickMapProvider : Rewired.Platforms.Custom.IHardwareJoystickMapCustomPlatformMapProvider {
/// <summary>
/// The list of Platform joystick data sets.
/// </summary>
public System.Collections.Generic.List<PlatformDataSet> platformJoystickDataSets;
public Data.Mapping.HardwareJoystickMap.Platform GetPlatformMap(int customPlatformId, System.Guid hardwareTypeGuid) {
public Rewired.Data.Mapping.HardwareJoystickMap.Platform GetPlatformMap(int customPlatformId, System.Guid hardwareTypeGuid) {
var platformDataSet = GetPlatformDataSet(customPlatformId);
if (platformDataSet == null) return null;
return GetPlatformMap(platformDataSet, hardwareTypeGuid);
@@ -32,7 +32,7 @@ namespace Rewired.Demos.CustomPlatform {
return null;
}
static private Data.Mapping.HardwareJoystickMap.Platform GetPlatformMap(CustomPlatformHardwareJoystickMapPlatformDataSet platformDataSet, System.Guid hardwareTypeGuid) {
static private Rewired.Data.Mapping.HardwareJoystickMap.Platform GetPlatformMap(CustomPlatformHardwareJoystickMapPlatformDataSet platformDataSet, System.Guid hardwareTypeGuid) {
if (platformDataSet == null || platformDataSet.platformMaps == null) return null;
int count = platformDataSet.platformMaps.Count;
for (int i = 0; i < count; i++) {

View File

@@ -12,7 +12,7 @@ namespace Rewired.Demos.CustomPlatform {
/// found that returns a non-null <see cref="Rewired.Platforms.Custom.CustomPlatformInitOptions"/> will be used by
/// Rewired during initialization to set the custom platform.
/// </summary>
public sealed class CustomPlatformManager : UnityEngine.MonoBehaviour, Platforms.Custom.ICustomPlatformInitializer {
public sealed class CustomPlatformManager : UnityEngine.MonoBehaviour, Rewired.Platforms.Custom.ICustomPlatformInitializer {
/// <summary>
/// Provides custom platform joystick definition maps.
@@ -25,12 +25,12 @@ namespace Rewired.Demos.CustomPlatform {
/// Return null to not use a custom platform.
/// </summary>
/// <returns>Custom platform init options</returns>
public Platforms.Custom.CustomPlatformInitOptions GetCustomPlatformInitOptions() {
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 Platforms.Custom.CustomPlatformInitOptions();
var options = new Rewired.Platforms.Custom.CustomPlatformInitOptions();
// Set the platform id
options.platformId = (int)CustomPlatformType.MyPlatform;
@@ -42,7 +42,7 @@ namespace Rewired.Demos.CustomPlatform {
options.hardwareJoystickMapCustomPlatformMapProvider = mapProvider;
// Create platform configuration values
var configVars = new Platforms.Custom.CustomPlatformConfigVars() {
var configVars = new Rewired.Platforms.Custom.CustomPlatformConfigVars() {
ignoreInputWhenAppNotInFocus = true,
useNativeKeyboard = true,
useNativeMouse = true

View File

@@ -7,7 +7,7 @@ namespace Rewired.Demos.CustomPlatform {
/// This allows supporting special features such as vibration and other custom functionality.
/// Implementing Rewired.Interfaces.IControllerVibrator allows Rewired's Controller and Player vibration function calls to work.
/// </summary>
public sealed class MyPlatformControllerExtension : ControllerExtensions.CustomControllerExtension, Interfaces.IControllerVibrator {
public sealed class MyPlatformControllerExtension : ControllerExtensions.CustomControllerExtension, Rewired.Interfaces.IControllerVibrator {
/// <summary>
/// Constructor.
@@ -62,7 +62,7 @@ namespace Rewired.Demos.CustomPlatform {
((Source)GetSource()).sourceJoystick.StopVibration();
}
class Source : Interfaces.IControllerExtensionSource {
class Source : Rewired.Interfaces.IControllerExtensionSource {
public readonly MyPlatformInputSource.Joystick sourceJoystick;

View File

@@ -19,7 +19,7 @@ namespace Rewired.Demos.CustomPlatform {
/// This requires no code. Simply create an instance from the right-click menu:
/// Create -> Rewired -> Custom Platform -> Simple Joystick Platform Map
/// </summary>
public sealed class MyPlatformHardwareJoystickMapPlatformMap : Platforms.Custom.HardwareJoystickMapCustomPlatformMapSO {
public sealed class MyPlatformHardwareJoystickMapPlatformMap : Rewired.Platforms.Custom.HardwareJoystickMapCustomPlatformMapSO {
/// <summary>
/// The platform map.
@@ -33,7 +33,7 @@ namespace Rewired.Demos.CustomPlatform {
/// Returns the Platform Map.
/// </summary>
/// <returns>Platform Map</returns>
public override Data.Mapping.HardwareJoystickMap.Platform GetPlatformMap() {
public override Rewired.Data.Mapping.HardwareJoystickMap.Platform GetPlatformMap() {
return platformMap;
}
@@ -46,7 +46,7 @@ namespace Rewired.Demos.CustomPlatform {
/// Variants must be serialized in the child class below to avoid infinite recursion.
/// </summary>
[System.Serializable]
public class PlatformMapBase : Platforms.Custom.HardwareJoystickMapCustomPlatformMap<MatchingCriteria> {
public class PlatformMapBase : Rewired.Platforms.Custom.HardwareJoystickMapCustomPlatformMap<MatchingCriteria> {
/// <summary>
/// Creates a new instance of this object.
@@ -79,7 +79,7 @@ namespace Rewired.Demos.CustomPlatform {
/// This function must be implemented if using variants.
/// </summary>
/// <returns></returns>
public override System.Collections.Generic.IList<Data.Mapping.HardwareJoystickMap.Platform> GetVariants() { return variants; }
public override System.Collections.Generic.IList<Rewired.Data.Mapping.HardwareJoystickMap.Platform> GetVariants() { return variants; }
/// <summary>
/// Creates a new instance of this object.

View File

@@ -13,7 +13,7 @@ namespace Rewired.Demos.CustomPlatform {
/// If multi-threaded input is required, input should be read on a separate thread, enqueued,
/// and consumed by the Joystick/Controller on Update in a thread-safe manner (mutex).
/// </summary>
public sealed class MyPlatformInputSource : Platforms.Custom.CustomPlatformInputSource {
public sealed class MyPlatformInputSource : Rewired.Platforms.Custom.CustomPlatformInputSource {
/// <summary>
/// Source of joysticks. This is just for this example.
@@ -40,7 +40,7 @@ namespace Rewired.Demos.CustomPlatform {
/// Constructor.
/// </summary>
/// <param name="configVars">Custom platform configuration variables</param>
public MyPlatformInputSource(Platforms.Custom.CustomPlatformConfigVars configVars) :
public MyPlatformInputSource(Rewired.Platforms.Custom.CustomPlatformConfigVars configVars) :
base(
configVars,
new InitOptions() {
@@ -184,7 +184,7 @@ namespace Rewired.Demos.CustomPlatform {
/// <summary>
/// Example Joystick implementation that supports vibration.
/// </summary>
new public sealed class Joystick : Rewired.Platforms.Custom.CustomPlatformInputSource.Joystick, Interfaces.IControllerVibrator {
new public sealed class Joystick : Rewired.Platforms.Custom.CustomPlatformInputSource.Joystick, Rewired.Interfaces.IControllerVibrator {
private UnityInputJoystickSource.Joystick _sourceJoystick;

View File

@@ -5,9 +5,9 @@ namespace Rewired.Demos.CustomPlatform {
/// <summary>
/// An example custom keyboard input source that wraps UnityEngine.Input.
/// </summary>
public class MyPlatformUnifiedKeyboardSource : Platforms.Custom.CustomPlatformUnifiedKeyboardSource {
public class MyPlatformUnifiedKeyboardSource : Rewired.Platforms.Custom.CustomPlatformUnifiedKeyboardSource {
private static readonly KeyboardKeyCode[] keyCodes = (KeyboardKeyCode[])System.Enum.GetValues(typeof(KeyboardKeyCode));
private static readonly Rewired.KeyboardKeyCode[] keyCodes = (Rewired.KeyboardKeyCode[])System.Enum.GetValues(typeof(Rewired.KeyboardKeyCode));
protected override void OnInitialize() {
base.OnInitialize();
@@ -24,7 +24,7 @@ namespace Rewired.Demos.CustomPlatform {
// Set a single key label
map.Set(
new KeyPropertyMap.Key() {
keyCode = KeyboardKeyCode.A,
keyCode = Rewired.KeyboardKeyCode.A,
label = "[A]"
}
);
@@ -32,9 +32,9 @@ namespace Rewired.Demos.CustomPlatform {
// Set multiple of key labels at the same time
map.Set(
new [] {
new KeyPropertyMap.Key() { keyCode = KeyboardKeyCode.B, label = "[B]" },
new KeyPropertyMap.Key() { keyCode = KeyboardKeyCode.C, label = "[C]" },
new KeyPropertyMap.Key() { keyCode = KeyboardKeyCode.D, label = "[D]" }
new KeyPropertyMap.Key() { keyCode = Rewired.KeyboardKeyCode.B, label = "[B]" },
new KeyPropertyMap.Key() { keyCode = Rewired.KeyboardKeyCode.C, label = "[C]" },
new KeyPropertyMap.Key() { keyCode = Rewired.KeyboardKeyCode.D, label = "[D]" }
}
);

View File

@@ -5,7 +5,7 @@ namespace Rewired.Demos.CustomPlatform {
/// <summary>
/// An example custom mouse input source that wraps UnityEngine.Input.
/// </summary>
public class MyPlatformUnifiedMouseSource : Platforms.Custom.CustomPlatformUnifiedMouseSource {
public class MyPlatformUnifiedMouseSource : Rewired.Platforms.Custom.CustomPlatformUnifiedMouseSource {
/// <summary>
/// Mouse screen position in pixels.

View File

@@ -37,7 +37,7 @@ namespace Rewired.Demos.CustomPlatform {
}
private void CheckForJoystickChanges() {
double time = ReInput.time.unscaledTime;
double time = Rewired.ReInput.time.unscaledTime;
if (time >= _nextJoystickCheckTime) {
_nextJoystickCheckTime = time + joystickCheckInterval;
if (DidJoysticksChange()) {
@@ -159,7 +159,7 @@ namespace Rewired.Demos.CustomPlatform {
/// A represenatation of low-level system joystick.
/// This could provide an interface to a native input API, for example.
/// </summary>
public class Joystick : Interfaces.IControllerVibrator {
public class Joystick : Rewired.Interfaces.IControllerVibrator {
private const int maxJoysticks = 8;
private const int maxAxes = 10;