Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdeSV committed Feb 18, 2017
1 parent c633478 commit a6bda59
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
13 changes: 6 additions & 7 deletions examples/example_3.d
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -27,5 +27,4 @@ void main()

window.print();
}
}
*/
}
29 changes: 16 additions & 13 deletions source/scone/os.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a6bda59

Please sign in to comment.