mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 12:07:41 +02:00
heavy rework of our input system
- implement the InputController abstract class, an adapter class for any HID interface to use common controller methods relevant to Heaven Studio - implement InputKeyboard and InputJoyshock classes, for keyboard input and controllers driven by JoyShockLibrary respectively - add Linux compile of JoyShockLibrary
This commit is contained in:
50
Assets/Scripts/Util/BitwiseUtils.cs
Normal file
50
Assets/Scripts/Util/BitwiseUtils.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HeavenStudio.Util
|
||||
{
|
||||
public static class BitwiseUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the value of the lowest set bit in the given integer.
|
||||
/// </summary>
|
||||
/// <param name="num">The integer to check.</param>
|
||||
public static int FirstSetBit(int num)
|
||||
{
|
||||
return num & (-num);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the wanted bit is set in the given integer.
|
||||
/// </summary>
|
||||
/// <param name="num">The integer to check.</param>
|
||||
/// <param name="want">The bit(s) to check for.</param>
|
||||
public static bool WantCurrent(int num, int want)
|
||||
{
|
||||
return (num & want) == want;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the wanted bit is set in the first integer, and not in the second.
|
||||
/// </summary>
|
||||
/// <param name="num1">The first integer to check.</param>
|
||||
/// <param name="num2">The second integer to check.</param>
|
||||
/// <param name="want">The bit(s) to check for.</param>
|
||||
public static bool WantCurrentAndNotLast(int num1, int num2, int want)
|
||||
{
|
||||
return ((num1 & want) == want) && ((num2 & want) != want);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the wanted bit is not set in the first integer, but set in the second.
|
||||
/// </summary>
|
||||
/// <param name="num1">The first integer to check.</param>
|
||||
/// <param name="num2">The second integer to check.</param>
|
||||
/// <param name="want">The bit(s) to check for.</param>
|
||||
public static bool WantNotCurrentAndLast(int num1, int num2, int want)
|
||||
{
|
||||
return ((num1 & want) != want) && ((num2 & want) == want);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Util/BitwiseUtils.cs.meta
Normal file
11
Assets/Scripts/Util/BitwiseUtils.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18f088a4c3c17b143a1985f3cee5d90a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user