From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/Wasabi/api/wnd/keyboard.h | 77 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Src/Wasabi/api/wnd/keyboard.h (limited to 'Src/Wasabi/api/wnd/keyboard.h') diff --git a/Src/Wasabi/api/wnd/keyboard.h b/Src/Wasabi/api/wnd/keyboard.h new file mode 100644 index 00000000..1aa4034c --- /dev/null +++ b/Src/Wasabi/api/wnd/keyboard.h @@ -0,0 +1,77 @@ +#ifndef __KEYBOARD_H +#define __KEYBOARD_H + +#include +#include +#include + +#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 +class AccSecViewer : public DependentViewerTPtr { +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 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 hookers; + static int infw; + static int lastwasreset; +}; + +#endif -- cgit