Skip to content

Commit

Permalink
Make StateTranslator logging verbose-only
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNathannator committed Feb 14, 2024
1 parent a08691d commit 7988c0d
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ private static bool TranslateState(InputDevice device, InputEventPtr eventPtr,
{
if (eventPtr.type != StateEvent.Type)
{
#if UNITY_EDITOR || PLASTICBAND_VERBOSE_LOGGING
Debug.LogError($"Non-state event {eventPtr.type} received on translating device {device}!");
#endif
return false;
}

Expand All @@ -66,16 +68,21 @@ private static bool TranslateState(InputDevice device, InputEventPtr eventPtr,
if (stateEvent->stateFormat == ToStateFormat)
return true;

// Ensure the format matches and the buffer is big enough for each state type
// Ensure that the state format matches
if (stateEvent->stateFormat != FromStateFormat)
{
#if UNITY_EDITOR || PLASTICBAND_VERBOSE_LOGGING
Debug.LogError($"Wrong state format {stateEvent->stateFormat} for translating device {device}! Expected {FromStateFormat}");
#endif
return false;
}

// ...and that the buffer is big enough for each state type
if (stateEvent->stateSizeInBytes < sizeof(TFromState) || stateEvent->stateSizeInBytes < sizeof(TToState))
{
#if UNITY_EDITOR || PLASTICBAND_VERBOSE_LOGGING
Debug.LogError($"State size {stateEvent->stateSizeInBytes} for translating device {device} is too small for input size {sizeof(TFromState)} and output size {sizeof(TToState)}!");
#endif
return false;
}

Expand Down

0 comments on commit 7988c0d

Please sign in to comment.