コード例 #1
0
        public static bool TryParse(string keysource, out KeySourceTypes type, out int index)
        {
            var tokens = keysource.Split(SourceSplitter, StringSplitOptions.RemoveEmptyEntries);

            if (tokens.Length != 2)
            {
                type  = KeySourceTypes.UNDEF;
                index = -1;
                return(false);
            }
            if (!Enum.TryParse <KeySourceTypes>(tokens[0], out type))
            {
                type = KeySourceTypes.UNDEF;
            }
            if (!int.TryParse(tokens[1], out index))
            {
                index = 0;
            }
            return(true);
        }
コード例 #2
0
 /// <summary>
 /// Combine KeySourceTypes + number of input or axis as:
 /// - RAW_INPUT:1 = first raw digital input
 /// - RAW_AXIS:1 = first raw analog value
 /// - VJOY_BUTTON:1 = first vjoy button
 /// - VJOY_AXIS:1 = first vjoy axis (X)
 /// Axis values are usually indexed as: X, Y, Z, RX, RY, RZ, ... see vJoy's definition
 /// </summary>
 public static string ConvertKeySourceToString(KeySourceTypes type, int index)
 {
     return(type.ToString() + SourceSplitter[0] + index.ToString());
 }