From a6bda59de270728809e2e1444e4b5d44cf724c65 Mon Sep 17 00:00:00 2001 From: Vladde Nordholm Date: Sun, 19 Feb 2017 00:55:51 +0100 Subject: [PATCH] minor tweaks --- examples/example_3.d | 13 ++++++------- source/scone/os.d | 29 ++++++++++++++++------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/examples/example_3.d b/examples/example_3.d index eae60c4..ebfc071 100644 --- a/examples/example_3.d +++ b/examples/example_3.d @@ -1,21 +1,21 @@ -/* import scone; void main() { bool loop = true; - while (loop) - { - foreach(input; getInputs()) + while(loop) + { + foreach(input; window.getInputs()) { - if(input.key == SK.escape || input.key == SK.c && input.hasControlKey(SCK.ctrl)) + if((input.key == SK.c && input.hasControlKey(SCK.ctrl)) || input.key == SK.escape) { loop = false; break; } window.clear(); + window.write ( 0,0, @@ -27,5 +27,4 @@ void main() window.print(); } -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/source/scone/os.d b/source/scone/os.d index 5a655db..c9d8980 100644 --- a/source/scone/os.d +++ b/source/scone/os.d @@ -280,7 +280,7 @@ struct OS private HANDLE _hConsoleOutput, _hConsoleInput; private DWORD _inputsRead, _mode = ENABLE_WINDOW_INPUT | ENABLE_WINDOW_INPUT, _oldMode; - private INPUT_RECORD _inputBuffer; + private INPUT_RECORD[128] _inputBuffer; private CONSOLE_SCREEN_BUFFER_INFO _consoleScreenBufferInfo; ushort attributesFromCell(Cell cell) @@ -410,20 +410,23 @@ struct OS InputEvent[] _inputEvents; - ReadConsoleInputA(_hConsoleInput, &_inputBuffer, 1, &_inputsRead); - switch(_inputBuffer.EventType) + ReadConsoleInputA(_hConsoleInput, _inputBuffer.ptr, 128, &_inputsRead); + for(size_t e = 0; e < read; ++e) { - case KEY_EVENT: - _inputEvents ~= InputEvent - ( - getKeyFromKeyEventRecord(_inputBuffer.KeyEvent), - getControlKeyFromKeyEventRecord(_inputBuffer.KeyEvent), - cast(bool) _inputBuffer.KeyEvent.bKeyDown - ); - break; + switch(_inputBuffer[e].EventType) + { + case KEY_EVENT: + _inputEvents ~= InputEvent + ( + getKeyFromKeyEventRecord(_inputBuffer[e].KeyEvent), + getControlKeyFromKeyEventRecord(_inputBuffer[e].KeyEvent), + cast(bool) _inputBuffer[e].KeyEvent.bKeyDown + ); + break; - default: - break; + default: + break; + } } return _inputEvents;