Ejemplo n.º 1
0
        private void OnButtonEvent(JA.IDevice device, JA.ButtonEvent button, bool value)
        {
            try {
                switch (button)
                {
                case JA.ButtonEvent.HookSwitch:
                    if (value)
                    {
                        if (!hook_enabled)
                        {
                            StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Talk));
                        }
                        hook_enabled = true;
                    }
                    else
                    {
                        if (hook_enabled)
                        {
                            StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup));
                            device.SetHookState(false);
                        }
                        hook_enabled = false;
                    }
                    break;

                case JA.ButtonEvent.MicMute:
                    if (!ignore_next_mute)
                    {
                        StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.ToggleMute));
                    }
                    ignore_next_mute = false;
                    break;

                case JA.ButtonEvent.Flash:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Flash));
                    break;

                case JA.ButtonEvent.RejectCall:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup));
                    break;

                case JA.ButtonEvent.FireAlarm:
                    throw new Exception("WTF");

                case JA.ButtonEvent.Redial:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Redial));
                    break;
                }
            }
            catch (Exception) {}
        }
Ejemplo n.º 2
0
        private void OnButtonEvent(JA.IDevice device, JA.ButtonEvent button, bool value)
        {
            try {
                var now = DateTime.Now;
                Debug.WriteLine($"Jabra::OnButtonEvent {now}.{now.Millisecond} {button} {value} is muted: {device.MicrophoneMuted}");                //this gets called twice, at least for bluetooth devices for each event, second event does have right mute state microphone muted, with the
                var diff = DateTime.UtcNow - last_event;
                last_event = DateTime.UtcNow;
                if (diff.TotalMilliseconds < 300)
                {
                    var hash = "" + device.DeviceHandle + button + value;
                    if (hash == last_event_hash)
                    {
                        Debug.WriteLine("Ignoring dupe event within 300 ms of last");
                        return;
                    }
                    last_event_hash = hash;
                }

                switch (button)
                {
                case JA.ButtonEvent.HookSwitch:
                    if (value)
                    {
                        if (!hook_enabled)
                        {
                            StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Talk));
                        }
                        hook_enabled = true;
                    }
                    else
                    {
                        if (hook_enabled)
                        {
                            StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup));
                            device.SetHookState(false);
                        }
                        hook_enabled = false;
                    }
                    break;

                case JA.ButtonEvent.MicMute:
                    if (!ignore_next_mute)                            //only done on startup event
                    {
                        StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.ToggleMute));
                    }
                    ignore_next_mute = false;
                    break;

                case JA.ButtonEvent.Flash:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Flash));
                    break;

                case JA.ButtonEvent.RejectCall:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup));
                    break;

                case JA.ButtonEvent.FireAlarm:
                    throw new Exception("WTF");

                case JA.ButtonEvent.Redial:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Redial));
                    break;
                }
            } catch (Exception) { }
        }