Recent

Author Topic: Haiku:How to receive information about pressing/releasing a key on the keyboard?  (Read 2444 times)

CandyMan30

  • New Member
  • *
  • Posts: 17
How to receive information about pressing/releasing a key on the keyboard in Haiku OS? My code is:
Code: Pascal  [Select][+][-]
  1. type
  2.   {$PACKRECORDS C}
  3.   TRawKeyInfo = record
  4.     TimeStamp : Int64;
  5.     KeyCode   : DWord;
  6.     IsKeyDown : Boolean;
  7.   end;
  8.  
  9. const
  10.   KB_READ = 9999;
  11.  
  12. var
  13.   fd:LongInt;
  14.   S:TRawKeyInfo;
  15. begin
  16.   fd:=fpopen('/dev/input/keyboard/at/0',O_RDWR);
  17.   if fd>=0 then
  18.   repeat
  19.     if LnxIoCtl(fd,KB_READ,@S)=0 then
  20.       WriteLn(S.TimeStamp,' ',S.IsKeyDown,' ',S.KeyCode)
  21.   until False;
  22. end.
My code is not working. What am I doing wrong?

[Edited title to add Haiku.]
« Last Edit: January 07, 2022, 09:51:43 pm by trev »

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Do you need to use it in console mode? If no, that can be done easily using Lazarus. Here has a demo:
https://forum.lazarus.freepascal.org/index.php/topic,57229.msg425440.html#msg425440

 

TinyPortal © 2005-2018