本文整理汇总了C#中Effect.GetDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.GetDirection方法的具体用法?C# Effect.GetDirection怎么用?C# Effect.GetDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Effect
的用法示例。
在下文中一共展示了Effect.GetDirection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connect
//.........这里部分代码省略.........
device.Properties.AutoCenter = false;
}
//Set axis mode absolute.
device.Properties.AxisModeAbsolute = true;
//Acquire joystick for capturing.
device.Acquire();
//Configure axes
int[] axis = null;
foreach (DeviceObjectInstance doi in device.Objects)
{
//Set axes ranges.
if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
{
device.Properties.SetRange(
ParameterHow.ById,
doi.ObjectId,
new InputRange(-5000, 5000));
}
int[] temp;
// Get info about first two FF axii on the device
if ((doi.Flags & (int)ObjectInstanceFlags.Actuator) != 0)
{
if (axis != null)
{
temp = new int[axis.Length + 1];
axis.CopyTo(temp, 0);
axis = temp;
}
else
{
axis = new int[1];
}
// Store the offset of each axis.
axis[axis.Length - 1] = doi.Offset;
if (axis.Length == 2)
{
break;
}
}
}
//See if joystick supports ConstantForce and set it.
foreach (EffectInformation ei in device.GetEffects(EffectType.All))
{
//If the joystick supports ConstantForce, then apply it.
if (DInputHelper.GetTypeCode(ei.EffectType)
== (int)EffectType.ConstantForce)
{
// Fill in some generic values for the effect.
e = new Effect();
e.SetDirection(new int[axis.Length]);
e.SetAxes(new int[axis.Length]);
e.ConditionStruct = new Condition[axis.Length];
e.EffectType = EffectType.ConstantForce;
e.Constant = new ConstantForce();
e.Constant.Magnitude = 10000;
e.Duration = (int)DI.Infinite;
e.Gain = 10000;
e.SamplePeriod = 0;
e.TriggerButton = (int)Microsoft.DirectX.DirectInput.Button.NoTrigger;
e.TriggerRepeatInterval = (int)DI.Infinite;
e.Flags = EffectFlags.ObjectOffsets | EffectFlags.Cartesian;
e.SetAxes(axis);
var dd = e.GetDirection();
dd[0] = -100;
dd[1] = 100;
e.SetDirection(dd);
// Create the effect, using the passed in guid.
eo = new EffectObject(ei.EffectGuid, e, device);
eo.Start(1, EffectStartFlags.NoDownload);
force_ei = ei;
break;
}
}
if (eo == null)
{
return JOYSTICK_TYPE.NO_FORCE_FEEDBACK;
}
return JOYSTICK_TYPE.FORCE_FEEDBACK;
}