MobiFlight-Connector: Spacemouse compact left/right button click causes .net exception

Describe the bug I use this device (https://3dconnexion.com/uk/product/spacemouse-compact/) to control views. When I click on left/right mouse button I get an exception (see attached txt file) bug_spacemouse_exception.txt

Issue is 100% reproducible.

I have installed VS and tried to debug code. In UpdateButtons method in joystick.cs the Buttons list is empty (DeviceId = Buttons[i].Label).

private void UpdateButtons(JoystickState newState)
        {
            for (int i = 0; i != newState.Buttons.Length; i++)
            {
                if (!StateExists() || state.Buttons.Length < i || state.Buttons[i] != newState.Buttons[i])
                {
                    if (newState.Buttons[i] || (state != null))

                            OnButtonPressed?.Invoke(this, new InputEventArgs()
                            {
                                DeviceId = Buttons[i].Label,
                                Serial = SerialPrefix + joystick.Information.InstanceGuid.ToString(),
                                Type = DeviceType.Button,
                                Value = newState.Buttons[i] ? 0 : 1
                            });
                }
            }
        }

I have checkedout main/ 582465a322be48d5505773c4cdaf768da50dcb08

I initialy found the bug in version 9.4.0 download here https://www.mobiflight.com/en/download.html

Further details: I have single stepped in EnumerateDevices to get more details bug_mobiflight

Method never finds IsAxis, IsButton, IsPOV. It finds a single “DeviceObjectTypeFlags.RelativeAxis”.

private void EnumerateDevices()
        {
            foreach (DeviceObjectInstance device in this.joystick.GetObjects())
            {

                this.joystick.GetObjectInfoById(device.ObjectId);


                int offset = device.Offset;
                int usage = device.Usage;
                ObjectAspect aspect = device.Aspect;
                String name = device.Name;

                bool IsAxis = (device.ObjectId.Flags & DeviceObjectTypeFlags.AbsoluteAxis) > 0;
                bool IsButton = (device.ObjectId.Flags & DeviceObjectTypeFlags.Button) > 0;
                bool IsPOV = (device.ObjectId.Flags & DeviceObjectTypeFlags.PointOfViewController) > 0;

Please let me know if I shall do some more debugging to solve this issue.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15

Most upvoted comments

Tested it and it works. LGTM 😃 thanks. @DocMoebiuz

One note. With the solution that you have implemented I guess that the buttons on the spacemouse will not work in Mobiflight, right?