コード例 #1
0
 private static bool IsHatX(SDLFeatureDescriptor feature)
 {
     return(feature.featureType == JoystickFeatureType.Hat &&
            (feature.usageHint == (int)SDLAxisUsage.Hat0X ||
             feature.usageHint == (int)SDLAxisUsage.Hat1X ||
             feature.usageHint == (int)SDLAxisUsage.Hat2X ||
             feature.usageHint == (int)SDLAxisUsage.Hat3X));
 }
コード例 #2
0
        private static void BuildHatFeature(ref InputControlLayout.Builder builder, SDLFeatureDescriptor xFeature, SDLFeatureDescriptor yFeature)
        {
            Debug.Assert(xFeature.offset < yFeature.offset, "Order of features must be X followed by Y");

            var hat     = HatNumber(xFeature);
            var hatName = hat > 1 ? $"Hat{hat}" : "Hat";

            builder.AddControl(hatName)
            .WithLayout("Dpad")
            .WithByteOffset((uint)xFeature.offset)
            .WithSizeInBits((uint)xFeature.featureSize * 8 + (uint)yFeature.featureSize * 8)
            .WithUsages(CommonUsages.Hatswitch);

            builder.AddControl(hatName + "/up")
            .WithFormat(InputStateBlock.FormatInt)
            .WithParameters("scale,scaleFactor=2147483647,clamp,clampMin=-1,clampMax=0,invert")
            .WithByteOffset(4)
            .WithBitOffset(0)
            .WithSizeInBits((uint)yFeature.featureSize * 8);

            builder.AddControl(hatName + "/down")
            .WithFormat(InputStateBlock.FormatInt)
            .WithParameters("scale,scaleFactor=2147483647,clamp,clampMin=0,clampMax=1")
            .WithByteOffset(4)
            .WithBitOffset(0)
            .WithSizeInBits((uint)yFeature.featureSize * 8);

            builder.AddControl(hatName + "/left")
            .WithFormat(InputStateBlock.FormatInt)
            .WithParameters("scale,scaleFactor=2147483647,clamp,clampMin=-1,clampMax=0,invert")
            .WithByteOffset(0)
            .WithBitOffset(0)
            .WithSizeInBits((uint)xFeature.featureSize * 8);

            builder.AddControl(hatName + "/right")
            .WithFormat(InputStateBlock.FormatInt)
            .WithParameters("scale,scaleFactor=2147483647,clamp,clampMin=0,clampMax=1")
            .WithByteOffset(0)
            .WithBitOffset(0)
            .WithSizeInBits((uint)xFeature.featureSize * 8);
        }
コード例 #3
0
        private static void BuildStickFeature(ref InputControlLayout.Builder builder, SDLFeatureDescriptor xFeature, SDLFeatureDescriptor yFeature)
        {
            int byteOffset;

            if (xFeature.offset <= yFeature.offset)
            {
                byteOffset = xFeature.offset;
            }
            else
            {
                byteOffset = yFeature.offset;
            }

            const string stickName = "Stick";

            builder.AddControl(stickName)
            .WithLayout("Stick")
            .WithByteOffset((uint)byteOffset)
            .WithSizeInBits((uint)xFeature.featureSize * 8 + (uint)yFeature.featureSize * 8)
            .WithUsages(CommonUsages.Primary2DMotion);

            builder.AddControl(stickName + "/x")
            .WithFormat(InputStateBlock.FormatInt)
            .WithByteOffset(0)
            .WithSizeInBits((uint)xFeature.featureSize * 8)
            .WithParameters("clamp=1,clampMin=-1,clampMax=1,scale,scaleFactor=65538");

            builder.AddControl(stickName + "/y")
            .WithFormat(InputStateBlock.FormatInt)
            .WithByteOffset(4)
            .WithSizeInBits((uint)xFeature.featureSize * 8)
            .WithParameters("clamp=1,clampMin=-1,clampMax=1,scale,scaleFactor=65538,invert");

            builder.AddControl(stickName + "/up")
            .WithParameters("clamp=1,clampMin=-1,clampMax=0,scale,scaleFactor=65538,invert");

            builder.AddControl(stickName + "/down")
            .WithParameters("clamp=1,clampMin=0,clampMax=1,scale,scaleFactor=65538,invert=false");

            builder.AddControl(stickName + "/left")
            .WithParameters("clamp=1,clampMin=-1,clampMax=0,scale,scaleFactor=65538,invert");

            builder.AddControl(stickName + "/right")
            .WithParameters("clamp=1,clampMin=0,clampMax=1,scale,scaleFactor=65538");
        }
コード例 #4
0
 private static bool IsAxis(SDLFeatureDescriptor feature, SDLAxisUsage axis)
 {
     return(feature.featureType == JoystickFeatureType.Axis &&
            feature.usageHint == (int)axis);
 }
コード例 #5
0
 private static int HatNumber(SDLFeatureDescriptor feature)
 {
     Debug.Assert(feature.featureType == JoystickFeatureType.Hat);
     return(1 + (feature.usageHint - (int)SDLAxisUsage.Hat0X) / 2);
 }