private void InitMouseReports() { StaticData.MouseAxisBindingReports[0].Blockable = _blockingEnabled; StaticData.MouseAxisBindingReports[1].Blockable = _blockingEnabled; _mouseReports = new ConcurrentDictionary <BindingDescriptor, BindingReport>(); _mouseButtonList = new DeviceReportNode { Title = "Buttons" }; for (var i = 0; i < 9; i++) { var bd = new BindingDescriptor { Index = i, Type = BindingType.Button }; var report = BuildMouseBindingReport(bd); _mouseReports.TryAdd(bd, report); _mouseButtonList.Bindings.Add(report); } for (var i = 0; i < 2; i++) { _mouseReports.TryAdd(StaticData.MouseAxisBindingReports[i].BindingDescriptor, StaticData.MouseAxisBindingReports[i]); } }
private void BuildOutputDeviceReportTemplate() { var node = new DeviceReportNode(); for (var channel = 0; channel < 16; channel++) { var channelInfo = new DeviceReportNode { Title = $"CH {channel + 1}" }; //var notesInfo = new DeviceReportNode //{ // Title = "Notes" //}; //for (var octave = 0; octave < 10; octave++) //{ // var octaveInfo = new DeviceReportNode // { // Title = $"Octave {octave}" // }; // for (var noteIndex = 0; noteIndex < NoteNames.Length; noteIndex++) // { // var noteName = NoteNames[noteIndex]; // octaveInfo.Bindings.Add(new BindingReport // { // Title = $"{noteName}", // Category = BindingCategory.Signed, // BindingDescriptor = BuildNoteDescriptor(channel, octave, noteIndex) // }); // } // notesInfo.Nodes.Add(octaveInfo); //} //channelInfo.Nodes.Add(notesInfo); var controlChangeInfo = new DeviceReportNode { Title = "CtrlChange" }; for (var controllerId = 0; controllerId < 128; controllerId++) { controlChangeInfo.Bindings.Add(new BindingReport { Title = $"ID {controllerId}", Category = BindingCategory.Signed, Path = $"CH:{channel}, CC:{controllerId}", BindingDescriptor = BuildControlChangeDescriptor(channel, controllerId) }); } channelInfo.Nodes.Add(controlChangeInfo); node.Nodes.Add(channelInfo); } _outputDeviceReportTemplate = node; }
private List <DeviceReportNode> GetReportNodes() { var deviceReportNodes = new List <DeviceReportNode>(); var axesNode = new DeviceReportNode { Title = "Axes" }; for (int a = 0; a < axes.Count; a++) { axesNode.Bindings.Add(new BindingReport { Title = axes[a].Name, Category = axes[a].Category, BindingDescriptor = new BindingDescriptor { Index = a, Type = BindingType.Axis } }); } deviceReportNodes.Add(axesNode); var buttonsNode = new DeviceReportNode { Title = "Buttons" }; for (int b = 0; b < buttons.Count; b++) { buttonsNode.Bindings.Add(new BindingReport { Title = buttons[b].Name, Category = buttons[b].Category, BindingDescriptor = new BindingDescriptor { Index = b, Type = BindingType.Button } }); } deviceReportNodes.Add(buttonsNode); return(deviceReportNodes); }
public DeviceReport GetInputDeviceReport(DeviceDescriptor deviceDescriptor) { var deviceReport = new DeviceReport { DeviceDescriptor = _spaceMouseProDescriptor, DeviceName = "SpaceMouse Pro" }; // ----- Axes ----- var axisInfo = new DeviceReportNode { Title = "Axes" }; for (var i = 0; i < 6; i++) { var bd = new BindingDescriptor { Index = i, Type = BindingType.Axis }; axisInfo.Bindings.Add(GetInputBindingReport(deviceDescriptor, bd)); } deviceReport.Nodes.Add(axisInfo); // ----- Buttons ----- var buttonInfo = new DeviceReportNode { Title = "Buttons" }; foreach (var button in _buttonNames) { var bd = new BindingDescriptor { Index = button.Key, Type = BindingType.Button }; buttonInfo.Bindings.Add(GetInputBindingReport(deviceDescriptor, bd)); } deviceReport.Nodes.Add(buttonInfo); return(deviceReport); }
public static void BuildInputList() { _buttonInfo = new DeviceReportNode { Title = "Buttons" }; for (var b = 0; b < 10; b++) { _buttonInfo.Bindings.Add(new BindingReport { Title = buttonNames[b], Category = BindingCategory.Momentary, BindingDescriptor = new BindingDescriptor(BindingType.Button, b) }); } _axisInfo = new DeviceReportNode { Title = "Axes" }; for (var a = 0; a < 6; a++) { _axisInfo.Bindings.Add(new BindingReport { Title = axisNames[a], Category = (a < 4 ? BindingCategory.Signed : BindingCategory.Unsigned), BindingDescriptor = new BindingDescriptor(BindingType.Axis, a) }); } _povInfo = new DeviceReportNode { Title = "DPad" }; for (var d = 0; d < 4; d++) { _povInfo.Bindings.Add(new BindingReport { Title = povNames[d], Category = BindingCategory.Momentary, BindingDescriptor = new BindingDescriptor(BindingType.POV, 0, d) }); } }
private void InitKeyReports() { _keyboardReports = new ConcurrentDictionary <BindingDescriptor, BindingReport>(); _keyboardList = new DeviceReportNode { Title = "Keys" }; for (var i = 0; i < 256; i++) { BindingReport report = null; var bd = new BindingDescriptor { Type = BindingType.Button, Index = i, SubIndex = 0 }; report = BuildKeyboardBindingReport(bd); if (report != null) { _keyboardList.Bindings.Add(report); _keyboardReports.TryAdd(bd, report); } // Check if this button has an extended (Right) variant var altBd = new BindingDescriptor { Type = BindingType.Button, Index = i + 256, SubIndex = 0 }; var altReport = BuildKeyboardBindingReport(altBd); if (altReport != null && (report == null || report.Title != altReport.Title)) // If the alReport is not null, and is not the same as the report (if it exists) { _keyboardList.Bindings.Add(altReport); _keyboardReports.TryAdd(altBd, altReport); } } _keyboardList.Bindings.Sort((x, y) => string.Compare(x.Title, y.Title, StringComparison.Ordinal)); }
protected DeviceReportNode GetButtonReport() { var report = new DeviceReportNode { Title = "Buttons" }; for (int i = 0; i < buttonNames.Count; i++) { report.Bindings.Add(new BindingReport { Title = buttonNames[i], Category = BindingCategory.Momentary, BindingDescriptor = new BindingDescriptor { Index = i, Type = BindingType.Button } }); } return(report); }
protected DeviceReportNode GetAxisReport() { var report = new DeviceReportNode { Title = "Axes" }; for (int i = 0; i < axisNames.Count; i++) { report.Bindings.Add(new BindingReport { Title = axisNames[i], Category = axisCategories[i], BindingDescriptor = new BindingDescriptor { Index = i, Type = BindingType.Axis } }); } return(report); }
protected DeviceReportNode GetPovReport() { var report = new DeviceReportNode { Title = "DPad" }; for (int i = 0; i < povDirectionNames.Count; i++) { report.Bindings.Add(new BindingReport { Title = povDirectionNames[i], Category = BindingCategory.Momentary, BindingDescriptor = new BindingDescriptor { Index = i, SubIndex = 0, Type = BindingType.POV } }); } return(report); }
private void BuildInputList() { _buttonInfo = new DeviceReportNode { Title = "Buttons" }; _bindingReports = new ConcurrentDictionary <BindingDescriptor, BindingReport>(); for (var b = 0; b < 10; b++) { var bd = new BindingDescriptor { Index = b, Type = BindingType.Button }; var name = Utilities.buttonNames[bd.Index]; var br = new BindingReport { Title = name, Path = $"Button: {name}", Category = BindingCategory.Momentary, BindingDescriptor = bd }; _bindingReports.TryAdd(bd, br); _buttonInfo.Bindings.Add(br); } _axisInfo = new DeviceReportNode { Title = "Axes" }; for (var a = 0; a < 6; a++) { var bd = new BindingDescriptor { Index = a, Type = BindingType.Axis }; var name = Utilities.axisNames[bd.Index]; var br = new BindingReport { Title = name, Path = $"Axis: {name}", Category = (bd.Index < 4 ? BindingCategory.Signed : BindingCategory.Unsigned), BindingDescriptor = bd }; _bindingReports.TryAdd(bd, br); _axisInfo.Bindings.Add(br); } _povInfo = new DeviceReportNode { Title = "DPad" }; for (var d = 0; d < 4; d++) { var bd = new BindingDescriptor { Index = 0, SubIndex = d, Type = BindingType.POV }; var name = Utilities.povNames[bd.SubIndex]; var br = new BindingReport { Title = name, Path = $"DPad: {name}", Category = BindingCategory.Momentary, BindingDescriptor = bd }; _bindingReports.TryAdd(bd, br); _povInfo.Bindings.Add(br); } }
public DeviceReport GetInputDeviceReport(DeviceDescriptor deviceDescriptor, Guid deviceGuid) { var joystick = new Joystick(DiInstance, deviceGuid); joystick.Acquire(); var deviceReport = new DeviceReport { DeviceDescriptor = deviceDescriptor, DeviceName = $"{joystick.Information.ProductName}{(deviceDescriptor.DeviceInstance > 0 ? $" # {deviceDescriptor.DeviceInstance + 1}" : "")}", HidPath = joystick.Properties.InterfacePath }; // ----- Axes ----- if (joystick.Capabilities.AxeCount > 0) { var axisInfo = new DeviceReportNode { Title = "Axes" }; // SharpDX tells us how many axes there are, but not *which* axes. // Enumerate all possible DI axes and check to see if this stick has each axis for (var i = 0; i < Utilities.OffsetsByType[BindingType.Axis].Count; i++) { try { var offset = Utilities.OffsetsByType[BindingType.Axis][i]; // this will throw if invalid offset var deviceInfo = joystick.GetObjectInfoByName(offset // this bit will throw if the stick does not have that axis .ToString()); axisInfo.Bindings.Add(GetInputBindingReport(deviceDescriptor, new BindingDescriptor { //Index = i, Index = (int)offset, //Name = axisNames[i], Type = BindingType.Axis })); } catch { // axis does not exist } } deviceReport.Nodes.Add(axisInfo); // ----- Buttons ----- var length = joystick.Capabilities.ButtonCount; if (length > 0) { var buttonInfo = new DeviceReportNode { Title = "Buttons" }; for (var btn = 0; btn < length; btn++) { buttonInfo.Bindings.Add(GetInputBindingReport(deviceDescriptor, new BindingDescriptor { //Index = btn, Index = (int)Utilities.OffsetsByType[BindingType.Button][btn], Type = BindingType.Button })); } deviceReport.Nodes.Add(buttonInfo); } // ----- POVs ----- var povCount = joystick.Capabilities.PovCount; if (povCount > 0) { var povsInfo = new DeviceReportNode { Title = "POVs" }; for (var p = 0; p < povCount; p++) { var povInfo = new DeviceReportNode { Title = "POV #" + (p + 1), Bindings = PovBindingInfos[p] }; povsInfo.Nodes.Add(povInfo); } deviceReport.Nodes.Add(povsInfo); } } return(deviceReport); }
private void BuildDeviceReports() { var gazeDevice = new DeviceReport { DeviceName = "Tobii Gaze Point", DeviceDescriptor = new DeviceDescriptor { DeviceHandle = "GazePoint" } }; var gazeNode = new DeviceReportNode { Title = "Axes" }; for (int i = 0; i < 3; i++) { gazeNode.Bindings.Add(new BindingReport { Title = _sixDofAxisNames[i], Category = BindingCategory.Signed, BindingDescriptor = new BindingDescriptor { Index = i, Type = BindingType.Axis } }); } gazeDevice.Nodes.Add(gazeNode); _deviceReports.TryAdd("GazePoint", gazeDevice); var poseDevice = new DeviceReport { DeviceName = "Tobii Head Pose", DeviceDescriptor = new DeviceDescriptor { DeviceHandle = "HeadPose" } }; var poseNode = new DeviceReportNode { Title = "Axes" }; for (int i = 0; i < 2; i++) { poseNode.Bindings.Add(new BindingReport { Title = _sixDofAxisNames[i], Category = BindingCategory.Signed, BindingDescriptor = new BindingDescriptor { Index = i, Type = BindingType.Axis } }); } poseDevice.Nodes.Add(poseNode); _deviceReports.TryAdd("HeadPose", poseDevice); }
private void QueryDevices() { _deviceReports = new List <DeviceReport>(); for (uint i = 0; i < 16; i++) { var id = i + 1; if (vJ.isVJDExists(id)) { var handle = i.ToString(); var device = new DeviceReport { DeviceName = $"vJoy Stick {id}", DeviceDescriptor = new DeviceDescriptor { DeviceHandle = handle } }; var axisNode = new DeviceReportNode { Title = "Axes" }; var axisCount = 0; for (var ax = 0; ax < 8; ax++) { if (vJ.GetVJDAxisExist(id, AxisIdToUsage[ax])) { axisNode.Bindings.Add(new BindingReport { Title = AxisNames[ax], Category = BindingCategory.Signed, BindingDescriptor = new BindingDescriptor { Index = ax, Type = BindingType.Axis } }); axisCount++; } } if (axisCount > 0) { device.Nodes.Add(axisNode); } // ------ Buttons ------ var buttonCount = vJ.GetVJDButtonNumber(id); if (buttonCount > 0) { var buttonNode = new DeviceReportNode { Title = "Buttons" }; for (int btn = 0; btn < buttonCount; btn++) { buttonNode.Bindings.Add(new BindingReport { Title = (btn + 1).ToString(), Category = BindingCategory.Momentary, BindingDescriptor = new BindingDescriptor { Index = btn, Type = BindingType.Button } }); } device.Nodes.Add(buttonNode); } // ------ POVs ------ var povCount = vJ.GetVJDContPovNumber(id); if (povCount > 0) { var povsNode = new DeviceReportNode { Title = "POVs" }; for (var p = 0; p < povCount; p++) { var povNode = new DeviceReportNode { Title = "POV #" + (p + 1) }; povNode.Bindings = PovBindingInfos[p]; povsNode.Nodes.Add(povNode); } device.Nodes.Add(povsNode); } _deviceReports.Add(device); } } }
private void BuildInputDeviceReportTemplate() { _bindingReports = new ConcurrentDictionary <BindingDescriptor, BindingReport>(); var node = new DeviceReportNode(); for (var channel = 0; channel < 16; channel++) { var channelInfo = new DeviceReportNode { Title = $"CH {channel + 1}" }; // Notes - Keys, Pads var notesInfo = new DeviceReportNode { Title = "Notes" }; for (var octave = -2; octave < 9; octave++) { var octaveInfo = new DeviceReportNode { Title = $"Octave {octave}" }; for (var noteIndex = 0; noteIndex < NoteNames.Length; noteIndex++) { if (octave == 8 && noteIndex > 7) { continue; // MIDI ends at G8, Skip G# to B } var noteName = NoteNames[noteIndex]; var bd = BuildNoteDescriptor(channel, octave, noteIndex); var br = new BindingReport { Title = $"{noteName}", Path = $"CH{channel + 1} {noteName}{octave}", Category = BindingCategory.Signed, BindingDescriptor = bd }; _bindingReports.TryAdd(bd, br); octaveInfo.Bindings.Add(br); } notesInfo.Nodes.Add(octaveInfo); } channelInfo.Nodes.Add(notesInfo); // ControlChange (CC) - Dials, Sliders etc var controlChangeInfo = new DeviceReportNode { Title = "CtrlChange" }; for (var controllerId = 0; controllerId < 128; controllerId++) { var bd = BuildControlChangeDescriptor(channel, controllerId); var br = new BindingReport { Title = $"ID {controllerId}", Path = $"CH{channel} CC{controllerId}", Category = BindingCategory.Signed, BindingDescriptor = bd }; _bindingReports.TryAdd(bd, br); controlChangeInfo.Bindings.Add(br); } channelInfo.Nodes.Add(controlChangeInfo); // Pitch Wheel var pwbd = new BindingDescriptor { Index = (int)MidiCommandCode.PitchWheelChange, SubIndex = 0 }; var pwbr = new BindingReport { Title = "Pitch Wheel", Path = $"CH{channel + 1} PW", Category = BindingCategory.Signed, BindingDescriptor = pwbd }; _bindingReports.TryAdd(pwbd, pwbr); channelInfo.Bindings.Add(pwbr); // Add the channel node.Nodes.Add(channelInfo); } _inputDeviceReportTemplate = node; }
private void QueryDevices() { _devicesList = new Dictionary <string, List <DeviceInstance> >(); _deviceReports = new List <DeviceReport>(); //// ToDo: device list should be returned in handle order for duplicate devices //var diDeviceInstances = DirectInput.GetDevices(); //var unsortedInstances = new Dictionary<string, List<DeviceInstance>>(); //foreach (var device in diDeviceInstances) //{ // if (!Lookups.IsStickType(device)) // continue; // var joystick = new Joystick(DirectInput, device.InstanceGuid); // joystick.Acquire(); // var handle = Lookups.JoystickToHandle(joystick); // if (!unsortedInstances.ContainsKey(handle)) // { // unsortedInstances[handle] = new List<DeviceInstance>(); // } // unsortedInstances[handle].Add(device); // joystick.Unacquire(); //} //foreach (var diDeviceInstance in unsortedInstances) //{ // _devicesList.Add(diDeviceInstance.Key, Lookups.OrderDevices(diDeviceInstance.Key, diDeviceInstance.Value)); //} foreach (var deviceList in DiWrapper.Instance.ConnectedDevices) { var deviceHandle = deviceList.Key; for (var index = 0; index < deviceList.Value.Count; index++) { var deviceGuid = deviceList.Value[index]; var joystick = new Joystick(DirectInput, deviceGuid); joystick.Acquire(); var device = new DeviceReport { DeviceName = joystick.Information.ProductName, DeviceDescriptor = new DeviceDescriptor(deviceHandle, index) }; // ----- Axes ----- if (joystick.Capabilities.AxeCount > 0) { var axisInfo = new DeviceReportNode { Title = "Axes" }; // SharpDX tells us how many axes there are, but not *which* axes. // Enumerate all possible DI axes and check to see if this stick has each axis for (var i = 0; i < directInputMappings[BindingType.Axis].Count; i++) { try { var deviceInfo = joystick.GetObjectInfoByName(directInputMappings[BindingType.Axis][i] // this bit will go boom if the axis does not exist .ToString()); axisInfo.Bindings.Add(new BindingReport { Title = deviceInfo.Name, Category = BindingCategory.Signed, BindingDescriptor = new BindingDescriptor(BindingType.Axis, i, 0) }); } catch { // axis does not exist } } device.Nodes.Add(axisInfo); } // ----- Buttons ----- var length = joystick.Capabilities.ButtonCount; if (length > 0) { var buttonInfo = new DeviceReportNode { Title = "Buttons" }; for (var btn = 0; btn < length; btn++) { buttonInfo.Bindings.Add(new BindingReport { Title = (btn + 1).ToString(), Category = BindingCategory.Momentary, BindingDescriptor = new BindingDescriptor(BindingType.Button, btn, 0) }); } device.Nodes.Add(buttonInfo); } // ----- POVs ----- var povCount = joystick.Capabilities.PovCount; if (povCount > 0) { var povsInfo = new DeviceReportNode { Title = "POVs" }; for (var p = 0; p < povCount; p++) { var povInfo = new DeviceReportNode { Title = "POV #" + (p + 1), Bindings = PovBindingInfos[p] }; povsInfo.Nodes.Add(povInfo); } device.Nodes.Add(povsInfo); } _deviceReports.Add(device); joystick.Unacquire(); } } }