public override void OnConnectionStateChange(BluetoothDevice device, [GeneratedEnum] ProfileState status, [GeneratedEnum] ProfileState newState) { if (status == ProfileState.Connected) { OnDeviceAdded?.Invoke(device); } base.OnConnectionStateChange(device, status, newState); }
private void Update() { if (SDL_Installed && !SDL_Initialized) { InitSDL(); } if (!SDL_Initialized) { return; } SDL.SDL_Event e; while (SDL.SDL_PollEvent(out e) > 0) { switch (e.type) { case SDL.SDL_EventType.SDL_KEYDOWN: OnKey?.Invoke(e, true); break; case SDL.SDL_EventType.SDL_KEYUP: OnKey?.Invoke(e, false); break; case SDL.SDL_EventType.SDL_CONTROLLERAXISMOTION: OnAxisMotion?.Invoke(e); break; case SDL.SDL_EventType.SDL_CONTROLLERBUTTONDOWN: OnButton?.Invoke(e, true); break; case SDL.SDL_EventType.SDL_CONTROLLERBUTTONUP: OnButton?.Invoke(e, false); break; case SDL.SDL_EventType.SDL_CONTROLLERDEVICEADDED: Controller.AddDevice(e.cdevice.which); OnDeviceAdded?.Invoke(e); break; case SDL.SDL_EventType.SDL_CONTROLLERDEVICEREMOVED: Controller.RemoveDisconnected(); OnDeviceRemoved?.Invoke(e); break; case SDL.SDL_EventType.SDL_CONTROLLERDEVICEREMAPPED: OnDeviceRemapped?.Invoke(e); break; case SDL.SDL_EventType.SDL_JOYAXISMOTION: OnAxisMotion?.Invoke(e); break; case SDL.SDL_EventType.SDL_JOYBALLMOTION: OnBallMotion?.Invoke(e); break; case SDL.SDL_EventType.SDL_JOYHATMOTION: OnHatMotion?.Invoke(e); break; case SDL.SDL_EventType.SDL_JOYBUTTONDOWN: OnButton?.Invoke(e, true); break; case SDL.SDL_EventType.SDL_JOYBUTTONUP: OnButton?.Invoke(e, false); break; case SDL.SDL_EventType.SDL_JOYDEVICEADDED: Controller.AddDevice(e.jdevice.which); OnDeviceAdded?.Invoke(e); break; case SDL.SDL_EventType.SDL_JOYDEVICEREMOVED: Controller.RemoveDisconnected(); OnDeviceRemoved?.Invoke(e); break; default: break; } } }
/// <summary> /// Операция добавления устройства /// </summary> /// <param name="parDevice">Физическое устройство OpenTK</param> private void DeviceAdd(MDeviceOpenTk parDevice) { AvailableDevices.Add(parDevice); OnDeviceAdded?.Invoke(parDevice); }