Sets the active keyboard device for this Actions class. The name of the keyboard device to set as active. A self-reference to this Actions class. If a device with this name exists but is not a keyboard.
(string name)
| 91 | /// <returns>A self-reference to this Actions class.</returns> |
| 92 | /// <exception cref="InvalidOperationException">If a device with this name exists but is not a keyboard.</exception> |
| 93 | [MemberNotNull(nameof(activeKeyboard))] |
| 94 | public Actions SetActiveKeyboard(string name) |
| 95 | { |
| 96 | InputDevice? device = FindDeviceById(name); |
| 97 | |
| 98 | this.activeKeyboard = device switch |
| 99 | { |
| 100 | null => new KeyInputDevice(name), |
| 101 | KeyInputDevice keyDevice => keyDevice, |
| 102 | _ => throw new InvalidOperationException($"Device under the name \"{name}\" is not a keyboard. Actual input type: {device.DeviceKind}"), |
| 103 | }; |
| 104 | |
| 105 | return this; |
| 106 | } |
| 107 | |
| 108 | /// <summary> |
| 109 | /// Sets the active wheel device for this Actions class. |
no outgoing calls