2009-01-22 19:59:59 +01:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009, Simon Kagstrom
|
|
|
|
*
|
|
|
|
* Filename: VirtualKeyboard.c
|
|
|
|
* Author: Simon Kagstrom <simon.kagstrom@gmail.com>
|
|
|
|
* Description: A virtual keyboard
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <SDL_ttf.h>
|
|
|
|
|
2009-01-24 09:36:47 +01:00
|
|
|
struct virtkey;
|
|
|
|
|
2009-01-22 19:59:59 +01:00
|
|
|
class VirtualKeyboard
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VirtualKeyboard(SDL_Surface *screen, TTF_Font *font);
|
2009-01-23 19:29:09 +01:00
|
|
|
int get_key();
|
2009-01-23 21:49:00 +01:00
|
|
|
const char *get_string();
|
2009-01-22 22:05:04 +01:00
|
|
|
const char *keycode_to_string(int kc);
|
2009-04-13 09:44:27 +02:00
|
|
|
const char keycode_to_char(int kc);
|
2009-04-13 09:01:51 +02:00
|
|
|
|
2009-01-24 08:30:06 +01:00
|
|
|
int char_to_keycode(char c);
|
2009-01-22 19:59:59 +01:00
|
|
|
|
|
|
|
private:
|
2009-01-24 09:36:47 +01:00
|
|
|
struct virtkey *get_key_internal();
|
2009-01-22 19:59:59 +01:00
|
|
|
void draw();
|
|
|
|
void select_next(int dx, int dy);
|
|
|
|
void toggle_shift();
|
|
|
|
|
|
|
|
SDL_Surface *screen;
|
|
|
|
TTF_Font *font;
|
|
|
|
int sel_x;
|
|
|
|
int sel_y;
|
|
|
|
bool shift_on;
|
2009-01-23 21:49:00 +01:00
|
|
|
|
|
|
|
char buf[255];
|
2009-01-22 19:59:59 +01:00
|
|
|
};
|
2009-04-13 09:44:27 +02:00
|
|
|
|
|
|
|
extern VirtualKeyboard *virtual_keyboard;
|
|
|
|
|