area: extract windows related keymaps to separate file to reuse in the entry
This commit is contained in:
parent
a0a980712e
commit
7bce5e41cf
11
ui.h
11
ui.h
|
@ -45,6 +45,12 @@ _UI_ENUM(uiForEach) {
|
||||||
uiForEachStop,
|
uiForEachStop,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct uiArea uiArea;
|
||||||
|
typedef struct uiAreaHandler uiAreaHandler;
|
||||||
|
typedef struct uiAreaDrawParams uiAreaDrawParams;
|
||||||
|
typedef struct uiAreaMouseEvent uiAreaMouseEvent;
|
||||||
|
typedef struct uiAreaKeyEvent uiAreaKeyEvent;
|
||||||
|
|
||||||
typedef struct uiInitOptions uiInitOptions;
|
typedef struct uiInitOptions uiInitOptions;
|
||||||
|
|
||||||
struct uiInitOptions {
|
struct uiInitOptions {
|
||||||
|
@ -297,11 +303,6 @@ _UI_EXTERN char *uiSaveFile(uiWindow *parent);
|
||||||
_UI_EXTERN void uiMsgBox(uiWindow *parent, const char *title, const char *description);
|
_UI_EXTERN void uiMsgBox(uiWindow *parent, const char *title, const char *description);
|
||||||
_UI_EXTERN void uiMsgBoxError(uiWindow *parent, const char *title, const char *description);
|
_UI_EXTERN void uiMsgBoxError(uiWindow *parent, const char *title, const char *description);
|
||||||
|
|
||||||
typedef struct uiArea uiArea;
|
|
||||||
typedef struct uiAreaHandler uiAreaHandler;
|
|
||||||
typedef struct uiAreaDrawParams uiAreaDrawParams;
|
|
||||||
typedef struct uiAreaMouseEvent uiAreaMouseEvent;
|
|
||||||
typedef struct uiAreaKeyEvent uiAreaKeyEvent;
|
|
||||||
|
|
||||||
typedef struct uiDrawContext uiDrawContext;
|
typedef struct uiDrawContext uiDrawContext;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// 8 september 2015
|
// 8 september 2015
|
||||||
#include "uipriv_windows.hpp"
|
#include "uipriv_windows.hpp"
|
||||||
#include "area.hpp"
|
#include "area.hpp"
|
||||||
|
#include "keyboard.hpp"
|
||||||
|
|
||||||
// TODO https://github.com/Microsoft/Windows-classic-samples/blob/master/Samples/Win7Samples/multimedia/DirectWrite/PadWrite/TextEditor.cpp notes on explicit RTL handling under MirrorXCoordinate(); also in areadraw.cpp too?
|
// TODO https://github.com/Microsoft/Windows-classic-samples/blob/master/Samples/Win7Samples/multimedia/DirectWrite/PadWrite/TextEditor.cpp notes on explicit RTL handling under MirrorXCoordinate(); also in areadraw.cpp too?
|
||||||
|
|
||||||
|
@ -177,81 +178,6 @@ static void onMouseLeft(uiArea *a)
|
||||||
uiprivClickCounterReset(&(a->cc));
|
uiprivClickCounterReset(&(a->cc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// we use VK_SNAPSHOT as a sentinel because libui will never support the print screen key; that key belongs to the user
|
|
||||||
struct extkeymap {
|
|
||||||
WPARAM vk;
|
|
||||||
uiExtKey extkey;
|
|
||||||
};
|
|
||||||
|
|
||||||
// all mappings come from GLFW - https://github.com/glfw/glfw/blob/master/src/win32_window.c#L152
|
|
||||||
static const struct extkeymap numpadExtKeys[] = {
|
|
||||||
{ VK_HOME, uiExtKeyN7 },
|
|
||||||
{ VK_UP, uiExtKeyN8 },
|
|
||||||
{ VK_PRIOR, uiExtKeyN9 },
|
|
||||||
{ VK_LEFT, uiExtKeyN4 },
|
|
||||||
{ VK_CLEAR, uiExtKeyN5 },
|
|
||||||
{ VK_RIGHT, uiExtKeyN6 },
|
|
||||||
{ VK_END, uiExtKeyN1 },
|
|
||||||
{ VK_DOWN, uiExtKeyN2 },
|
|
||||||
{ VK_NEXT, uiExtKeyN3 },
|
|
||||||
{ VK_INSERT, uiExtKeyN0 },
|
|
||||||
{ VK_DELETE, uiExtKeyNDot },
|
|
||||||
{ VK_SNAPSHOT, 0 },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct extkeymap extKeys[] = {
|
|
||||||
{ VK_ESCAPE, uiExtKeyEscape },
|
|
||||||
{ VK_INSERT, uiExtKeyInsert },
|
|
||||||
{ VK_DELETE, uiExtKeyDelete },
|
|
||||||
{ VK_HOME, uiExtKeyHome },
|
|
||||||
{ VK_END, uiExtKeyEnd },
|
|
||||||
{ VK_PRIOR, uiExtKeyPageUp },
|
|
||||||
{ VK_NEXT, uiExtKeyPageDown },
|
|
||||||
{ VK_UP, uiExtKeyUp },
|
|
||||||
{ VK_DOWN, uiExtKeyDown },
|
|
||||||
{ VK_LEFT, uiExtKeyLeft },
|
|
||||||
{ VK_RIGHT, uiExtKeyRight },
|
|
||||||
{ VK_F1, uiExtKeyF1 },
|
|
||||||
{ VK_F2, uiExtKeyF2 },
|
|
||||||
{ VK_F3, uiExtKeyF3 },
|
|
||||||
{ VK_F4, uiExtKeyF4 },
|
|
||||||
{ VK_F5, uiExtKeyF5 },
|
|
||||||
{ VK_F6, uiExtKeyF6 },
|
|
||||||
{ VK_F7, uiExtKeyF7 },
|
|
||||||
{ VK_F8, uiExtKeyF8 },
|
|
||||||
{ VK_F9, uiExtKeyF9 },
|
|
||||||
{ VK_F10, uiExtKeyF10 },
|
|
||||||
{ VK_F11, uiExtKeyF11 },
|
|
||||||
{ VK_F12, uiExtKeyF12 },
|
|
||||||
// numpad numeric keys and . are handled in common/areaevents.c
|
|
||||||
// numpad enter is handled in code below
|
|
||||||
{ VK_ADD, uiExtKeyNAdd },
|
|
||||||
{ VK_SUBTRACT, uiExtKeyNSubtract },
|
|
||||||
{ VK_MULTIPLY, uiExtKeyNMultiply },
|
|
||||||
{ VK_DIVIDE, uiExtKeyNDivide },
|
|
||||||
{ VK_SNAPSHOT, 0 },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct {
|
|
||||||
WPARAM vk;
|
|
||||||
uiModifiers mod;
|
|
||||||
} modKeys[] = {
|
|
||||||
// even if the separate left/right aren't necessary, have them here anyway, just to be safe
|
|
||||||
{ VK_CONTROL, uiModifierCtrl },
|
|
||||||
{ VK_LCONTROL, uiModifierCtrl },
|
|
||||||
{ VK_RCONTROL, uiModifierCtrl },
|
|
||||||
{ VK_MENU, uiModifierAlt },
|
|
||||||
{ VK_LMENU, uiModifierAlt },
|
|
||||||
{ VK_RMENU, uiModifierAlt },
|
|
||||||
{ VK_SHIFT, uiModifierShift },
|
|
||||||
{ VK_LSHIFT, uiModifierShift },
|
|
||||||
{ VK_RSHIFT, uiModifierShift },
|
|
||||||
// there's no combined Windows key virtual-key code as there is with the others
|
|
||||||
{ VK_LWIN, uiModifierSuper },
|
|
||||||
{ VK_RWIN, uiModifierSuper },
|
|
||||||
{ VK_SNAPSHOT, 0 },
|
|
||||||
};
|
|
||||||
|
|
||||||
static int areaKeyEvent(uiArea *a, int up, WPARAM wParam, LPARAM lParam)
|
static int areaKeyEvent(uiArea *a, int up, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
uiAreaKeyEvent ke;
|
uiAreaKeyEvent ke;
|
||||||
|
@ -261,9 +187,7 @@ static int areaKeyEvent(uiArea *a, int up, WPARAM wParam, LPARAM lParam)
|
||||||
ke.Key = 0;
|
ke.Key = 0;
|
||||||
ke.ExtKey = 0;
|
ke.ExtKey = 0;
|
||||||
ke.Modifier = 0;
|
ke.Modifier = 0;
|
||||||
|
|
||||||
ke.Modifiers = getModifiers();
|
ke.Modifiers = getModifiers();
|
||||||
|
|
||||||
ke.Up = up;
|
ke.Up = up;
|
||||||
|
|
||||||
// the numeric keypad keys when Num Lock is off are considered left-hand keys as the separate navigation buttons were added later
|
// the numeric keypad keys when Num Lock is off are considered left-hand keys as the separate navigation buttons were added later
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// we use VK_SNAPSHOT as a sentinel because libui will never support the print screen key; that key belongs to the user
|
||||||
|
struct extkeymap {
|
||||||
|
WPARAM vk;
|
||||||
|
uiExtKey extkey;
|
||||||
|
};
|
||||||
|
|
||||||
|
// all mappings come from GLFW - https://github.com/glfw/glfw/blob/master/src/win32_window.c#L152
|
||||||
|
static const struct extkeymap numpadExtKeys[] = {
|
||||||
|
{ VK_HOME, uiExtKeyN7 },
|
||||||
|
{ VK_UP, uiExtKeyN8 },
|
||||||
|
{ VK_PRIOR, uiExtKeyN9 },
|
||||||
|
{ VK_LEFT, uiExtKeyN4 },
|
||||||
|
{ VK_CLEAR, uiExtKeyN5 },
|
||||||
|
{ VK_RIGHT, uiExtKeyN6 },
|
||||||
|
{ VK_END, uiExtKeyN1 },
|
||||||
|
{ VK_DOWN, uiExtKeyN2 },
|
||||||
|
{ VK_NEXT, uiExtKeyN3 },
|
||||||
|
{ VK_INSERT, uiExtKeyN0 },
|
||||||
|
{ VK_DELETE, uiExtKeyNDot },
|
||||||
|
{ VK_SNAPSHOT, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct extkeymap extKeys[] = {
|
||||||
|
{ VK_ESCAPE, uiExtKeyEscape },
|
||||||
|
{ VK_INSERT, uiExtKeyInsert },
|
||||||
|
{ VK_DELETE, uiExtKeyDelete },
|
||||||
|
{ VK_HOME, uiExtKeyHome },
|
||||||
|
{ VK_END, uiExtKeyEnd },
|
||||||
|
{ VK_PRIOR, uiExtKeyPageUp },
|
||||||
|
{ VK_NEXT, uiExtKeyPageDown },
|
||||||
|
{ VK_UP, uiExtKeyUp },
|
||||||
|
{ VK_DOWN, uiExtKeyDown },
|
||||||
|
{ VK_LEFT, uiExtKeyLeft },
|
||||||
|
{ VK_RIGHT, uiExtKeyRight },
|
||||||
|
{ VK_F1, uiExtKeyF1 },
|
||||||
|
{ VK_F2, uiExtKeyF2 },
|
||||||
|
{ VK_F3, uiExtKeyF3 },
|
||||||
|
{ VK_F4, uiExtKeyF4 },
|
||||||
|
{ VK_F5, uiExtKeyF5 },
|
||||||
|
{ VK_F6, uiExtKeyF6 },
|
||||||
|
{ VK_F7, uiExtKeyF7 },
|
||||||
|
{ VK_F8, uiExtKeyF8 },
|
||||||
|
{ VK_F9, uiExtKeyF9 },
|
||||||
|
{ VK_F10, uiExtKeyF10 },
|
||||||
|
{ VK_F11, uiExtKeyF11 },
|
||||||
|
{ VK_F12, uiExtKeyF12 },
|
||||||
|
// numpad numeric keys and . are handled in common/areaevents.c
|
||||||
|
// numpad enter is handled in code below
|
||||||
|
{ VK_ADD, uiExtKeyNAdd },
|
||||||
|
{ VK_SUBTRACT, uiExtKeyNSubtract },
|
||||||
|
{ VK_MULTIPLY, uiExtKeyNMultiply },
|
||||||
|
{ VK_DIVIDE, uiExtKeyNDivide },
|
||||||
|
{ VK_SNAPSHOT, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
WPARAM vk;
|
||||||
|
uiModifiers mod;
|
||||||
|
} modKeys[] = {
|
||||||
|
// even if the separate left/right aren't necessary, have them here anyway, just to be safe
|
||||||
|
{ VK_CONTROL, uiModifierCtrl },
|
||||||
|
{ VK_LCONTROL, uiModifierCtrl },
|
||||||
|
{ VK_RCONTROL, uiModifierCtrl },
|
||||||
|
{ VK_MENU, uiModifierAlt },
|
||||||
|
{ VK_LMENU, uiModifierAlt },
|
||||||
|
{ VK_RMENU, uiModifierAlt },
|
||||||
|
{ VK_SHIFT, uiModifierShift },
|
||||||
|
{ VK_LSHIFT, uiModifierShift },
|
||||||
|
{ VK_RSHIFT, uiModifierShift },
|
||||||
|
// there's no combined Windows key virtual-key code as there is with the others
|
||||||
|
{ VK_LWIN, uiModifierSuper },
|
||||||
|
{ VK_RWIN, uiModifierSuper },
|
||||||
|
{ VK_SNAPSHOT, 0 },
|
||||||
|
};
|
Loading…
Reference in New Issue