1
0

keyboard.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef __KEYBOARD_H
  2. #define __KEYBOARD_H
  3. #include <bfc/string/StringW.h>
  4. #include <bfc/ptrlist.h>
  5. #include <bfc/depview.h>
  6. #ifdef WIN32
  7. #define MAX_KEY 256
  8. #else
  9. #define MAX_KEY 65536
  10. #endif
  11. class ifc_window;
  12. class AccSec {
  13. public:
  14. AccSec(const wchar_t *pname, ifc_window *pwnd, int pglobal=0) : name(pname), wnd(pwnd), global(pglobal) { }
  15. StringW name;
  16. ifc_window *wnd;
  17. int global;
  18. };
  19. #include <api/wnd/api_window.h>
  20. class AccSecViewer : public DependentViewerTPtr<ifc_window> {
  21. public:
  22. void viewItem(ifc_window *i) { viewer_addViewItem(i); }
  23. virtual int viewer_onItemDeleted(ifc_window *item);
  24. };
  25. class Keyboard {
  26. public:
  27. static int onForwardOnChar(ifc_window *from, unsigned int c, int kd);
  28. static int onForwardOnKeyDown(ifc_window *from, int k, int kd, int nomsg=0);
  29. static int onForwardOnKeyUp(ifc_window *from, int k, int kd);
  30. static int onForwardOnSysKeyDown(ifc_window *from, int k, int kd);
  31. static int onForwardOnSysKeyUp(ifc_window *from, int k, int kd);
  32. static int onForwardOnKillFocus();
  33. static int interceptOnChar(unsigned int c);
  34. static int interceptOnKeyDown(int k);
  35. static int interceptOnKeyUp(int k);
  36. static int interceptOnSysKeyDown(int k, int kd);
  37. static int interceptOnSysKeyUp(int k, int kd);
  38. static void hookKeyboard(ifc_window *hooker);
  39. static void unhookKeyboard(ifc_window *hooker);
  40. static void reset();
  41. static void registerAcceleratorSection(const wchar_t *name, ifc_window *wnd, int pglobal);
  42. static PtrList<AccSec> accSecEntries;
  43. private:
  44. static int forwardKbdMessage(ifc_window *from, int msg, int wp, int lp);
  45. static wchar_t *getVkName(int vkey);
  46. static void syncKeyTable();
  47. // special keys
  48. typedef struct {
  49. int vk;
  50. wchar_t *trans;
  51. } vkEntry;
  52. static vkEntry vkEntries[];
  53. static wchar_t pressedKeys[MAX_KEY];
  54. static AccSecViewer viewer;
  55. static PtrList<ifc_window> hookers;
  56. static int infw;
  57. static int lastwasreset;
  58. };
  59. #endif