aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/wnd/keyboard.h
blob: 1aa4034c611185cc12b49eed2778d566e3cfcc84 (plain) (blame)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef __KEYBOARD_H
#define __KEYBOARD_H

#include <bfc/string/StringW.h>
#include <bfc/ptrlist.h>
#include <bfc/depview.h>

#ifdef WIN32
#define MAX_KEY 256
#else
#define MAX_KEY 65536
#endif

class ifc_window;

class AccSec {
public:
  AccSec(const wchar_t *pname, ifc_window *pwnd, int pglobal=0) : name(pname), wnd(pwnd), global(pglobal) { }
  StringW name;
  ifc_window *wnd;
  int global;
};

#include <api/wnd/api_window.h>
class AccSecViewer : public DependentViewerTPtr<ifc_window> {
public:
  void viewItem(ifc_window *i) { viewer_addViewItem(i); }
  virtual int viewer_onItemDeleted(ifc_window *item);
};

class Keyboard {

public:

  static int onForwardOnChar(ifc_window *from, unsigned int c, int kd);
  static int onForwardOnKeyDown(ifc_window *from, int k, int kd, int nomsg=0);
  static int onForwardOnKeyUp(ifc_window *from, int k, int kd);
  static int onForwardOnSysKeyDown(ifc_window *from, int k, int kd);
  static int onForwardOnSysKeyUp(ifc_window *from, int k, int kd);
  static int onForwardOnKillFocus();

  static int interceptOnChar(unsigned int c);
  static int interceptOnKeyDown(int k);
  static int interceptOnKeyUp(int k);
  static int interceptOnSysKeyDown(int k, int kd);
  static int interceptOnSysKeyUp(int k, int kd);

  static void hookKeyboard(ifc_window *hooker);
  static void unhookKeyboard(ifc_window *hooker);

  static void reset();
  
  static void registerAcceleratorSection(const wchar_t *name, ifc_window *wnd, int pglobal);

  static PtrList<AccSec> accSecEntries;

private:
  static int forwardKbdMessage(ifc_window *from, int msg, int wp, int lp);
  static wchar_t *getVkName(int vkey);
  static void syncKeyTable();

  // special keys
  typedef struct {
    int vk;
    wchar_t *trans;
  } vkEntry;
  static vkEntry vkEntries[];

  static wchar_t pressedKeys[MAX_KEY];

  static AccSecViewer viewer;
  static PtrList<ifc_window> hookers;
  static int infw;
  static int lastwasreset;
};

#endif