本文整理汇总了C#中MyJoystickAxesEnum类的典型用法代码示例。如果您正苦于以下问题:C# MyJoystickAxesEnum类的具体用法?C# MyJoystickAxesEnum怎么用?C# MyJoystickAxesEnum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyJoystickAxesEnum类属于命名空间,在下文中一共展示了MyJoystickAxesEnum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeJoystickAxisState
private float ComputeJoystickAxisState(XB1Interface.XB1Interface.GamepadState padState, MyJoystickAxesEnum axis)
{
float value = 0.0f;
if (IsJoystickConnected() && IsJoystickAxisSupported(axis))
{
switch (axis)
{
case MyJoystickAxesEnum.RotationXpos:
case MyJoystickAxesEnum.RotationXneg: value = padState.rx; break;
case MyJoystickAxesEnum.RotationYpos:
case MyJoystickAxesEnum.RotationYneg: value = -padState.ry; break;
case MyJoystickAxesEnum.Xpos:
case MyJoystickAxesEnum.Xneg: value = padState.lx; break;
case MyJoystickAxesEnum.Ypos:
case MyJoystickAxesEnum.Yneg: value = -padState.ly; break;
}
}
return value;
}
示例2: IsJoystickAxisNewPressed
// Check to see if a specific button on the joystick is currently pressed and was not pressed during the last update.
bool ModAPI.IMyInput.IsJoystickAxisNewPressed(MyJoystickAxesEnum axis) { return IsJoystickAxisNewPressed(axis); }
示例3: IsJoystickAxisValid
// Return true if joystick axis is valid for user controls
bool ModAPI.IMyInput.IsJoystickAxisValid(MyJoystickAxesEnum axis) { return IsJoystickAxisValid(axis); }
示例4:
float IMyInput.GetJoystickAxisStateForGameplay(MyJoystickAxesEnum axis) { return 0; }
示例5: IsJoystickAxisValid
// Return true if joystick axis is valid for user controls
public bool IsJoystickAxisValid(MyJoystickAxesEnum axis)
{
foreach (var item in m_validJoystickAxes)
{
if (item == axis) return true;
}
return false;
}
示例6: NullControl
public static void NullControl(MyStringId context, MyJoystickAxesEnum axis)
{
MyStringId key = MyStringId.NullOrEmpty;
foreach (var pair in m_bindings[context].Bindings)
{
if (pair.Value is JoystickAxis && pair.Value.Code == (byte)axis)
{
key = pair.Key;
break;
}
}
if (key != MyStringId.NullOrEmpty)
m_bindings[context][key] = m_nullControl;
}
示例7: GetPreviousJoystickAxisStateRaw
// Find out how much a specific joystick axis was pressed.
// Return a raw number between 0 and 65535. 32768 is the middle value.
public float GetPreviousJoystickAxisStateRaw(MyJoystickAxesEnum axis)
{
int value = 32768;
if (m_joystickConnected && axis != MyJoystickAxesEnum.None && m_previousJoystickState != null && IsJoystickAxisSupported(axis))
{
switch (axis)
{
case MyJoystickAxesEnum.RotationXpos:
case MyJoystickAxesEnum.RotationXneg: value = m_previousJoystickState.RotationX; break;
case MyJoystickAxesEnum.RotationYpos:
case MyJoystickAxesEnum.RotationYneg: value = m_previousJoystickState.RotationY; break;
case MyJoystickAxesEnum.RotationZpos:
case MyJoystickAxesEnum.RotationZneg: value = m_previousJoystickState.RotationZ; break;
case MyJoystickAxesEnum.Xpos:
case MyJoystickAxesEnum.Xneg: value = m_previousJoystickState.X; break;
case MyJoystickAxesEnum.Ypos:
case MyJoystickAxesEnum.Yneg: value = m_previousJoystickState.Y; break;
case MyJoystickAxesEnum.Zpos:
case MyJoystickAxesEnum.Zneg: value = m_previousJoystickState.Z; break;
case MyJoystickAxesEnum.Slider1pos:
case MyJoystickAxesEnum.Slider1neg:
{
var array = m_previousJoystickState.Sliders;
value = (array.Length < 1) ? 32768 : array[0];
}
break;
case MyJoystickAxesEnum.Slider2pos:
case MyJoystickAxesEnum.Slider2neg:
{
var array = m_previousJoystickState.Sliders;
value = (array.Length < 2) ? 32768 : array[1];
}
break;
}
}
return value;
}
示例8: JoystickAxis
public JoystickAxis(MyJoystickAxesEnum axis) { Axis = axis; }
示例9: AddControl
public static void AddControl(MyStringId context, MyStringId stringId, MyJoystickAxesEnum axis)
{
m_bindings[context][stringId] = new JoystickAxis(axis);
}
示例10: GetPreviousJoystickAxisStateForGameplay
// Find out how much a specific joystick half-axis is pressed.
// Return a number between 0 and 1 (taking deadzone, sensitivity and non-linearity into account).
public float GetPreviousJoystickAxisStateForGameplay(MyJoystickAxesEnum axis)
{
return ComputeJoystickAxisStateForGameplay(m_previousJoystickState, axis);
}
示例11: GetJoystickAxisStateForGameplay
// Find out how much a specific joystick half-axis is pressed.
// Return a number between 0 and 1 (taking deadzone, sensitivity and non-linearity into account).
public float GetJoystickAxisStateForGameplay(MyJoystickAxesEnum axis)
{
return ComputeJoystickAxisStateForGameplay(m_actualJoystickState, axis);
}
示例12: ComputeJoystickAxisStateForGameplay
private float ComputeJoystickAxisStateForGameplay(XB1Interface.XB1Interface.GamepadState padState, MyJoystickAxesEnum axis)
{
if (IsJoystickConnected() && IsJoystickAxisSupported(axis))
{
// Input position scaled to (-1..1).
float position = ComputeJoystickAxisState(padState, axis);
float distance = (((int)axis) % 2 != 0) ? position : -position; // even -> neg axis
if (distance > m_joystickDeadzone)
{
distance = (distance - m_joystickDeadzone) / (1 - m_joystickDeadzone); // Rescale distance to (0..1) outside the deadzone.
return m_joystickSensitivity * (float)Math.Pow(distance, m_joystickExponent);
}
}
return 0.0f;
}
示例13: WasJoystickAxisReleased
// Check to see if a specific button on the joystick was released.
public bool WasJoystickAxisReleased(MyJoystickAxesEnum axis)
{
bool isPressed = false;
//if (m_joystickConnected && axis != MyJoystickAxesEnum.None && m_previousJoystickState != null)
if (IsJoystickConnected() && axis != MyJoystickAxesEnum.None)
{
isPressed = GetPreviousJoystickAxisStateForGameplay(axis) <= MyJoystickConstants.ANALOG_PRESSED_THRESHOLD;
}
if (!isPressed && axis == MyJoystickAxesEnum.None)
{
return true;
}
if (!IsJoystickAxisSupported(axis)) return false;
return isPressed;
}
示例14: IsJoystickAxisPressed
public bool IsJoystickAxisPressed(MyJoystickAxesEnum axis)
{
bool isPressed = false;
if (m_joystickConnected && axis != MyJoystickAxesEnum.None && m_actualJoystickState != null)
{
isPressed = GetJoystickAxisStateForGameplay(axis) > MyJoystickConstants.ANALOG_PRESSED_THRESHOLD;
}
if (!isPressed && axis == MyJoystickAxesEnum.None)
{
return true;
}
if (!IsJoystickAxisSupported(axis)) return false;
return isPressed;
}
示例15: IsJoystickAxisSupported
public bool IsJoystickAxisSupported(MyJoystickAxesEnum axis)
{
if (m_joystick.IsConnected == false)
{
return false;
}
switch (axis)
{
case MyJoystickAxesEnum.RotationZpos:
case MyJoystickAxesEnum.RotationZneg:
case MyJoystickAxesEnum.Zneg:
case MyJoystickAxesEnum.Slider1pos:
case MyJoystickAxesEnum.Slider1neg:
case MyJoystickAxesEnum.Slider2pos:
case MyJoystickAxesEnum.Slider2neg:
case MyJoystickAxesEnum.None:
return false;
default:
return true;
}
}