Blob Blame Raw
#ifndef KEYBOARD_H
#define KEYBOARD_H


#include "graph.h"
#include "input.h"


struct Keyboard;
typedef struct Keyboard Keyboard;


typedef struct Key {
  // keep these filds at the begining for easyest static initialization
  int x, y, w, h;
  unsigned int keySym;
  const char *label;
  const char *label2;
  
  // these fields will be set while initialization
  Keyboard *kbd;
  TextLayout tl;
  TextLayout tl2;
  
  // dynamic fields
  int down;
} Key;


struct Keyboard {
  // keep these filds at the begining for easyest static initialization
  Key *keys;
  int keysCount;
  int w, h;
  
  // these fields will be set while initialization
  App *app;
  
  // dynamic fields
  Key *downKey;
};


int keyInit(Key *k, Keyboard *kbd);
void keyDeinit(Key *k);
void keyDraw(Key *k, int cx, int cy, int cw, int ch);
void keyDown(Key *k);
void keyUp(Key *k);

int keyboardInit(Keyboard *kbd, App *app);
void keyboardDeinit(Keyboard *kbd);
void keyboardDraw(Keyboard *kbd, int cx, int cy, int cw, int ch);
void keyboardMouseDown(Keyboard *kbd, int x, int y);
void keyboardMouseUp(Keyboard *kbd);


#endif