|
|
452870 |
#ifndef KEYBOARD_H
|
|
|
452870 |
#define KEYBOARD_H
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
#include "graph.h"
|
|
|
452870 |
#include "input.h"
|
|
|
452870 |
|
|
|
452870 |
|
|
|
dbe1a1 |
#define K_LBL_SIZE LABEL_MAXLEN
|
|
|
63daec |
|
|
|
63daec |
|
|
|
843e7a |
// key flags
|
|
|
843e7a |
enum {
|
|
|
63daec |
KF_HOLD = 1 << 0, // key will be hold until it will pressed again or non-hold key will pressed
|
|
|
63daec |
KF_MOD = 1 << 1, // visible value depends on modifier state (using optValue field)
|
|
|
63daec |
KF_LAYOUT = 1 << 2, // key to switch layout (using optValue field);
|
|
|
63daec |
KF_MOVE = 1 << 3, // handle to move the window
|
|
|
63daec |
KF_SIZE = 1 << 4, // key to resize the window
|
|
|
63daec |
KF_CLOSE = 1 << 5 }; // key to close the window
|
|
|
843e7a |
|
|
|
843e7a |
// special layout indices
|
|
|
843e7a |
enum {
|
|
|
843e7a |
LI_PREV = -1, // switch to previous layout in the list
|
|
|
843e7a |
LI_NEXT = -2, // switch to next layout in the list
|
|
|
843e7a |
LI_REVERT = -3 }; // switch to previously used layout
|
|
|
843e7a |
|
|
|
843e7a |
|
|
|
843e7a |
|
|
|
843e7a |
struct Key;
|
|
|
843e7a |
struct Layout;
|
|
|
452870 |
struct Keyboard;
|
|
|
843e7a |
typedef struct Key Key;
|
|
|
843e7a |
typedef struct Layout Layout;
|
|
|
452870 |
typedef struct Keyboard Keyboard;
|
|
|
452870 |
|
|
|
452870 |
|
|
|
843e7a |
struct Key {
|
|
|
452870 |
// keep these filds at the begining for easyest static initialization
|
|
|
061fcf |
int ox, oy, ow, oh;
|
|
|
452870 |
unsigned int keySym;
|
|
|
843e7a |
unsigned int keySym2;
|
|
|
63daec |
char label[K_LBL_SIZE];
|
|
|
63daec |
char label2[K_LBL_SIZE];
|
|
|
843e7a |
unsigned int flags;
|
|
|
63daec |
int optValue;
|
|
|
452870 |
|
|
|
452870 |
// these fields will be set while initialization
|
|
|
843e7a |
Layout *l;
|
|
|
63daec |
int isLetter;
|
|
|
63daec |
int isKeypad;
|
|
|
452870 |
TextLayout tl;
|
|
|
452870 |
TextLayout tl2;
|
|
|
452870 |
|
|
|
452870 |
// dynamic fields
|
|
|
061fcf |
int x, y, w, h;
|
|
|
452870 |
int down;
|
|
|
5b6cfc |
int longDown;
|
|
|
843e7a |
int downKeycode;
|
|
|
63daec |
int mx, my; // values for move and size buttons
|
|
|
843e7a |
Key *nextHeld, *prevHeld;
|
|
|
d942fc |
Key *orig, *clone;
|
|
|
843e7a |
};
|
|
|
452870 |
|
|
|
452870 |
|
|
|
843e7a |
struct Layout {
|
|
|
452870 |
// keep these filds at the begining for easyest static initialization
|
|
|
452870 |
Key *keys;
|
|
|
452870 |
int keysCount;
|
|
|
061fcf |
int ow, oh;
|
|
|
452870 |
|
|
|
452870 |
// these fields will be set while initialization
|
|
|
843e7a |
Keyboard *kbd;
|
|
|
843e7a |
|
|
|
843e7a |
// dynamic fields
|
|
|
061fcf |
int w, h;
|
|
|
843e7a |
Layout *prev; // previously used layout
|
|
|
843e7a |
Key *downKey; // key that received the last mouse down event
|
|
|
843e7a |
};
|
|
|
843e7a |
|
|
|
843e7a |
|
|
|
843e7a |
struct Keyboard {
|
|
|
843e7a |
// keep these filds at the begining for easyest static initialization
|
|
|
843e7a |
Layout *layouts;
|
|
|
843e7a |
int layoutsCount;
|
|
|
061fcf |
int ow, oh;
|
|
|
843e7a |
|
|
|
843e7a |
// these fields will be set while initialization
|
|
|
452870 |
App *app;
|
|
|
452870 |
|
|
|
452870 |
// dynamic fields
|
|
|
061fcf |
unsigned int lastModifiers;
|
|
|
843e7a |
Layout *current;
|
|
|
843e7a |
Key *firstHeld;
|
|
|
452870 |
};
|
|
|
452870 |
|
|
|
452870 |
|
|
|
843e7a |
int keyInit(Key *k, Layout *l);
|
|
|
452870 |
void keyDeinit(Key *k);
|
|
|
d942fc |
void keyInvalidateRect(Key *k);
|
|
|
452870 |
void keyDraw(Key *k, int cx, int cy, int cw, int ch);
|
|
|
843e7a |
void keyDown(Key *k, int x, int y);
|
|
|
843e7a |
void keyMotion(Key *k, int x, int y);
|
|
|
5b6cfc |
void keyLongDown(Key *k);
|
|
|
843e7a |
void keyUp(Key *k, int force);
|
|
|
843e7a |
|
|
|
843e7a |
int layoutInit(Layout *l, Keyboard *kbd);
|
|
|
843e7a |
void layoutDeinit(Layout *l);
|
|
|
061fcf |
void layoutResize(Layout *l);
|
|
|
843e7a |
void layoutDraw(Layout *l, int cx, int cy, int cw, int ch);
|
|
|
843e7a |
void layoutMouseDown(Layout *l, int x, int y);
|
|
|
843e7a |
void layoutMouseMotion(Layout *l, int x, int y);
|
|
|
5b6cfc |
void layoutMouseLongDown(Layout *l);
|
|
|
843e7a |
void layoutMouseUp(Layout *l);
|
|
|
452870 |
|
|
|
452870 |
int keyboardInit(Keyboard *kbd, App *app);
|
|
|
452870 |
void keyboardDeinit(Keyboard *kbd);
|
|
|
843e7a |
void keyboardResize(Keyboard *kbd);
|
|
|
061fcf |
void keyboardUpdateModifiers(Keyboard *kbd);
|
|
|
452870 |
void keyboardDraw(Keyboard *kbd, int cx, int cy, int cw, int ch);
|
|
|
452870 |
void keyboardMouseDown(Keyboard *kbd, int x, int y);
|
|
|
843e7a |
void keyboardMouseMotion(Keyboard *kbd, int x, int y);
|
|
|
5b6cfc |
void keyboardMouseLongDown(Keyboard *kbd);
|
|
|
452870 |
void keyboardMouseUp(Keyboard *kbd);
|
|
|
843e7a |
void keyboardSwitchLayout(Keyboard *kbd, int index);
|
|
|
843e7a |
void keyboardRelaseHeld(Keyboard *kbd);
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
#endif
|