-
Notifications
You must be signed in to change notification settings - Fork 0
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 #28 from LegendaryB/develop
Release v1.4
- Loading branch information
Showing
9 changed files
with
65 additions
and
65 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...cation/System/Input/IInputActionMapper.cs → ...tem/InputProcessing/IInputActionMapper.cs
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
2 changes: 1 addition & 1 deletion
2
...pplication/System/Input/IInputListener.cs → .../System/InputProcessing/IInputListener.cs
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
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ructure/System/Input/InputActionMapper.cs → ...stem/InputProcessing/InputActionMapper.cs
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
57 changes: 57 additions & 0 deletions
57
src/Kirei.Infrastructure/System/InputProcessing/InputListener.cs
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,57 @@ | ||
using Kirei.Application.System.InputProcessing; | ||
using Kirei.Infrastructure.Configuration; | ||
|
||
using NeatInput; | ||
using NeatInput.Domain.Processing; | ||
|
||
using System; | ||
using System.Threading; | ||
|
||
namespace Kirei.Infrastructure.System.InputProcessing | ||
{ | ||
public class InputListener : | ||
IInputListener | ||
{ | ||
private InputProvider _inputProvider; | ||
private IInputActionMapper _inputActionMapper; | ||
|
||
private DateTime lastInputReceivedAt; | ||
private bool hasIconsBeenHidden = false; | ||
|
||
public void Listen(IInputActionMapper inputActionMapper) | ||
{ | ||
_inputProvider = new InputProvider(); | ||
_inputActionMapper = inputActionMapper; | ||
|
||
lastInputReceivedAt = DateTime.Now; | ||
|
||
_inputProvider.InputReceived += OnInputReceived; | ||
|
||
var inactiveAfterMs = ConfigurationProvider.Configuration.Application.InactiveAfterMs; | ||
var inputPollingRateMs = ConfigurationProvider.Configuration.Application.InputPollingRate; | ||
|
||
while (true) | ||
{ | ||
var lastInputInMilliseconds = DateTime.Now.Subtract(lastInputReceivedAt).TotalMilliseconds; | ||
|
||
if (lastInputInMilliseconds >= inactiveAfterMs && !hasIconsBeenHidden) | ||
{ | ||
_inputActionMapper.HandleInput(); | ||
hasIconsBeenHidden = true; | ||
} | ||
else if (lastInputInMilliseconds < inactiveAfterMs && hasIconsBeenHidden) | ||
{ | ||
_inputActionMapper.HandleInput(); | ||
hasIconsBeenHidden = false; | ||
} | ||
|
||
Thread.Sleep(inputPollingRateMs); | ||
} | ||
} | ||
|
||
private void OnInputReceived(Input input) | ||
{ | ||
lastInputReceivedAt = DateTime.Now; | ||
} | ||
} | ||
} |
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