-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6229 from Susko3/refactor-keycombination
Refactor `KeyCombination.ContainsKey()` and `.ContainsKeyPermissive()` for better extensibility
- Loading branch information
Showing
5 changed files
with
110 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using osu.Framework.Input.Bindings; | ||
|
||
namespace osu.Framework.Extensions | ||
{ | ||
public static class InputKeyExtensions | ||
{ | ||
public static bool IsPhysical(this InputKey key) | ||
{ | ||
if (!Enum.IsDefined(key) || IsVirtual(key)) | ||
return false; | ||
|
||
switch (key) | ||
{ | ||
case InputKey.None: | ||
case InputKey.LastKey: | ||
return false; | ||
|
||
default: | ||
return true; | ||
} | ||
} | ||
|
||
public static bool IsVirtual(this InputKey key) | ||
{ | ||
switch (key) | ||
{ | ||
case InputKey.Shift: | ||
case InputKey.Control: | ||
case InputKey.Alt: | ||
case InputKey.Super: | ||
return true; | ||
|
||
default: | ||
return false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters