summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/libndsfpc/examples/input/keyboard/keyboard_stdin/keyboardStdin.pp
blob: 55c5d2da4c24982875a0972005bf0148bd850fc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
program keyboardStdin;

{$mode objfpc}

uses
  ctypes, nds9;
  
procedure OnKeyPressed(key: cint);
begin
  if (key > 0) then
    iprintf('%c', key);
end;

var
  kbd: pKeyboard;
  myName: array [0..255] of char;
begin
  consoleDemoInit();

  kbd :=  keyboardDemoInit();

  kbd^.OnKeyPressed := @OnKeyPressed;

  while true do
  begin
    iprintf('What is your name?'#10);
    
    scanf('%s', myName);
    
    iprintf(#10'Hello %s', myName);
    
    scanKeys();
    while (keysDown() = 0)do 
      scanKeys();
    
    swiWaitForVBlank();
    consoleClear();
   end;

end.