wincekeyboardi.inc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
  4. Original C++ version by Glenn Fiedler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. }
  17. Constructor TWinCEKeyboard.Create(EventQueue : TEventQueue);
  18. Begin
  19. // m_monitor := Nil;
  20. // m_event := Nil;
  21. // Inherited Create(window, thread);
  22. // m_monitor := TWin32Monitor.Create;
  23. // m_event := TWin32Event.Create;
  24. { setup defaults }
  25. m_alt := False;
  26. m_shift := False;
  27. m_control := False;
  28. { setup data }
  29. FEventQueue := EventQueue;
  30. // m_multithreaded := multithreaded;
  31. { enable buffering }
  32. m_enabled := True;
  33. End;
  34. Procedure TWinCEKeyboard.enable;
  35. Begin
  36. { enable buffering }
  37. m_enabled := True;
  38. End;
  39. Procedure TWinCEKeyboard.disable;
  40. Begin
  41. { disable buffering }
  42. m_enabled := False;
  43. End;
  44. Function TWinCEKeyboard.WndProc(hWnd : HWND; message : DWord; wParam : WPARAM; lParam : LPARAM) : LRESULT;
  45. Var
  46. i : Integer;
  47. scancode : Integer;
  48. KeyStateArray : Array[0..255] Of Byte;
  49. AsciiBuf : Word;
  50. press : Boolean;
  51. uni : Integer;
  52. tmp : Integer;
  53. Begin
  54. WndProc := 0;
  55. { check enabled flag }
  56. If Not m_enabled Then
  57. Exit;
  58. { process key message }
  59. If (message = WM_KEYDOWN) Or (message = WM_KEYUP) {Or ((message = WM_SYSKEYDOWN) And ((lParam And (1 Shl 29)) <> 0))} Then
  60. Begin
  61. If message = WM_KEYUP Then
  62. press := False
  63. Else
  64. press := True;
  65. { update modifiers }
  66. If wParam = VK_MENU Then
  67. { alt }
  68. m_alt := press
  69. Else
  70. If wParam = VK_SHIFT Then
  71. { shift }
  72. m_shift := press
  73. Else
  74. If wParam = VK_CONTROL Then
  75. { control }
  76. m_control := press;
  77. { enter monitor if multithreaded }
  78. (* If m_multithreaded Then
  79. m_monitor.enter;*)
  80. uni := -1;
  81. (* If GetKeyboardState(@KeyStateArray) Then
  82. Begin
  83. scancode := (lParam Shr 16) And $FF;
  84. {todo: ToUnicode (Windows NT)}
  85. tmp := ToAscii(wParam, scancode, @KeyStateArray, @AsciiBuf, 0);
  86. If (tmp = 1) Or (tmp = 2) Then
  87. Begin
  88. If tmp = 2 Then
  89. Begin
  90. // Writeln('[', AsciiBuf, ']'); {???? todo: dead keys ????}
  91. End
  92. Else
  93. Begin
  94. // Write(Chr(AsciiBuf));
  95. {todo: codepage -> unicode}
  96. If AsciiBuf <= 126 Then
  97. uni := AsciiBuf;
  98. End;
  99. End;
  100. End;*)
  101. { handle key repeat count }
  102. For i := 1 To lParam And $FFFF Do
  103. { create and insert key object }
  104. FEventQueue.AddEvent(TPTCKeyEvent.Create(wParam, uni, m_alt, m_shift, m_control, press));
  105. { check multithreaded flag }
  106. (* If m_multithreaded Then
  107. Begin
  108. { set event }
  109. m_event._set;
  110. { leave monitor }
  111. m_monitor.leave;
  112. End;*)
  113. End;
  114. End;