public void setAxis(uint rID, int value, HID_USAGES axis) { if (isAxisSupported(axis)) { switch (axis) { case (HID_USAGES.HID_USAGE_X): currentState[rID].AxisX = value; break; case (HID_USAGES.HID_USAGE_Y): currentState[rID].AxisY = value; break; case (HID_USAGES.HID_USAGE_Z): currentState[rID].AxisZ = value; break; case (HID_USAGES.HID_USAGE_RX): currentState[rID].AxisXRot = value; break; case (HID_USAGES.HID_USAGE_RY): currentState[rID].AxisYRot = value; break; case (HID_USAGES.HID_USAGE_RZ): currentState[rID].AxisZRot = value; break; case (HID_USAGES.HID_USAGE_SL0): currentState[rID].Slider = value; break; case (HID_USAGES.HID_USAGE_SL1): currentState[rID].Dial = value; break; case (HID_USAGES.HID_USAGE_WHL): currentState[rID].Wheel = value; break; } } else { throw new Exception("Axis " + axis.ToString() + " not supported by vJoy 1, use vJoy config to add axis :" + axis.ToString()); } }
int ConvertAxisRatioToAxisInt(float axisRatio, HID_USAGES hid) { long min = 0, max = 0; var gotMin = vjoy.GetVJDAxisMin(deviceId, HID_USAGES.HID_USAGE_X, ref min); var gotMax = vjoy.GetVJDAxisMax(deviceId, HID_USAGES.HID_USAGE_X, ref max); if (!gotMin || !gotMax) { Debug.LogWarningFormat("Error getting min/max of HID axis {0}", hid.ToString()); return(0); } // Get an absolute ratio where 0 is -Max, .5 is 0, and 1 is +Max float absRatio = axisRatio / 2f + .5f; long range = max - min; return((int)((long)(range * absRatio) + min)); }
public vJoyFeeder() { // Create one joystick object and a position structure. Joystick = new vJoy(); Report = new vJoy.JoystickState(); FFBReceiver = new vJoyFFBReceiver(); // vJoy has a maximum of 8 axes for (int i = 0; i < MAX_AXES_VJOY; i++) { var axisinfo = new vJoyAxisInfos(); HID_USAGES toBeTested = (HID_USAGES)HID_USAGES.HID_USAGE_X + i; var name = toBeTested.ToString().Replace("HID_USAGE_", ""); axisinfo.HID_Usage = toBeTested; axisinfo.Name = name; axisinfo.ResetCorrectionFactors(); AxesInfo.Add(axisinfo); } }
public static string AxisToFriendlyName(HID_USAGES Axis) { switch (Axis) { case HID_USAGES.HID_USAGE_X: return("X"); case HID_USAGES.HID_USAGE_Y: return("Y"); case HID_USAGES.HID_USAGE_Z: return("Z"); case HID_USAGES.HID_USAGE_RX: return("RX"); case HID_USAGES.HID_USAGE_RY: return("RY"); case HID_USAGES.HID_USAGE_RZ: return("RZ"); case HID_USAGES.HID_USAGE_SL0: return("Slider"); case HID_USAGES.HID_USAGE_SL1: return("Dial/Slider 2"); case HID_USAGES.HID_USAGE_WHL: return("Wheel"); case HID_USAGES.HID_USAGE_POV: return("PoV"); default: return(Axis.ToString()); } }
public override string ToString() { return(Name + " (HID:" + HID_Usage.ToString() + ") min=" + MinValue + " max=" + MaxValue); }