#define MAX_KEYBOARDS 2 /* maximum number of keyboards to we have */
#define MAX_KEYS 64 /* maximum number of keys per keyboard */
-#define MAX_KEY_LINES 16 /* maximum number of lines on each key */
+#define MAX_KEY_LINES 32 /* maximum number of lines on each key */
#define TILT_KEYBOARD /* keyboard is tilted up from horzontal x-z-plane to vertical x-y-plane */
/*
static const char *keyboard_layout[] = {
"1 2 3 4 5 6 7 8 9 0 G",
- " fh e ",
+ " fh fr ",
" f1 f2 f0 7 8 9 * ",
" 4 5 6 - ",
" u 1 2 3 + ",
/* lines to be drawn ontop of the key (see layout in the description above) */
l = 0;
/* up to 4 letters/digits are displayed on key */
- for (d = 0; d < 4; d++) {
+ for (d = 0; d < 6; d++) {
if (!key_def->fkey) {
/* render regular key */
if (d == 0)
font_offset = -0.25;
if (key_def->key == 'h')
key = 'H';
+ else if (key_def->key == 'r')
+ key = 'R';
else
key = 'F';
}
font_offset += 2.5;
if (key_def->key == 'h')
key = 'E';
+ else if (key_def->key == 'r')
+ key = 'E';
else if (key_def->key != '0')
key = key_def->key;
else
font_offset += 2.5;
if (key_def->key == 'h')
key = 'L';
+ else if (key_def->key == 'r')
+ key = 'T';
else if (key_def->key != '0')
break;
else
font_offset += 2.5;
if (key_def->key == 'h')
key = 'P';
+ else if (key_def->key == 'r')
+ key = 'U';
+ else
+ break;
+ }
+ else if (d == 4) {
+ font_offset += 2.5;
+ if (key_def->key == 'r')
+ key = 'R';
+ else
+ break;
+ }
+ else if (d == 5) {
+ font_offset += 2.5;
+ if (key_def->key == 'r')
+ key = 'N';
else
break;
}
if (keyboard_layout[l][x + 1] == 'h')
width = 2.0; /* help key */
else
+ if (keyboard_layout[l][x + 1] == 'r')
+ width = 2.5; /* return key */
+ else
width = 1.5; /* f-key */
key = keyboard_layout[l][x + 1];
fkey = 1;
static int highlight_k;
static double from_x, from_y, from_z;
static double to_x, to_y, to_z;
+static int pointer_valid;
/* calculate pointer and to what key it points to */
void handle_vr_keyboard(int keyboard, double pointer_x, double pointer_y, double pointer_z, double pointer_yaw, double pointer_pitch, enum keycode *key)
to_x = from_x - sin(pointer_yaw) * cos(pointer_pitch) * 20;
to_y = from_y + sin(pointer_pitch) * 20;
to_z = from_z - cos(pointer_yaw) * cos(pointer_pitch) * 20;
+ pointer_valid = 0;
/* if pointer points down, intersect with keyboard */
highlight_k = -1;
#ifdef TILT_KEYBOARD
if (from_z - 1.0 > keyboard_dist && to_z < from_z - 1.0) {
+ pointer_valid = 1;
to_x = (to_x - from_x) / (from_z - to_z) * (from_z - keyboard_dist) + from_x;
to_y = (to_y - from_y) / (from_z - to_z) * (from_z - keyboard_dist) + from_y;
to_z = keyboard_dist;
}
#else
if (from_y - 1.0 > keyboard_height && to_y < from_y - 1.0) {
+ pointer_valid = 1;
to_x = (to_x - from_x) / (from_y - to_y) * (from_y - keyboard_height) + from_x;
to_z = (to_z - from_z) / (from_y - to_y) * (from_y - keyboard_height) + from_z;
to_y = keyboard_height;
glDisable(GL_CULL_FACE);
- /* render pointer */
+ if (!pointer_valid)
+ return;
+ if (to_x > 25 || to_x < -25 || to_y > 20 || to_y < -20)
+ return;
+#if 0
+ /* render pointer as a line from pose to keyboard */
glColor4f(1.0, 0.0, 0.0, 1.0);
glBegin(GL_LINES);
glVertex3f(from_x, from_y, from_z);
glVertex3f(to_x, to_y, to_z);
glEnd();
+#endif
+
+#if 0
+ /* render dot where pose points to */
+ double delta = 0.20;
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBegin(GL_POLYGON);
+ glColor4f(1.0, 0.0, 0.0, 0.7);
+ glVertex3f(to_x - delta / 2, to_y + delta, to_z);
+ glVertex3f(to_x + delta / 2, to_y + delta, to_z);
+ glVertex3f(to_x + delta, to_y + delta / 2, to_z);
+ glVertex3f(to_x + delta, to_y - delta / 2, to_z);
+ glVertex3f(to_x + delta / 2, to_y - delta, to_z);
+ glVertex3f(to_x - delta / 2, to_y - delta, to_z);
+ glVertex3f(to_x - delta, to_y - delta / 2, to_z);
+ glVertex3f(to_x - delta, to_y + delta / 2, to_z);
+ glEnd();
+ glDisable(GL_BLEND);
+#endif
+
+#if 1
+ /* render a 'shot' */
+ double delta = 0.50;
+ glBegin(GL_LINES);
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ glVertex3f(to_x - delta / 2, to_y + delta, to_z - delta / 2 + delta);
+ glVertex3f(to_x + delta / 2, to_y - delta, to_z + delta / 2 + delta);
+ glVertex3f(to_x + delta / 2, to_y + delta, to_z - delta / 2 + delta);
+ glVertex3f(to_x - delta / 2, to_y - delta, to_z + delta / 2 + delta);
+ glVertex3f(to_x - delta / 2, to_y + delta, to_z + delta / 2 + delta);
+ glVertex3f(to_x + delta / 2, to_y - delta, to_z - delta / 2 + delta);
+ glVertex3f(to_x + delta / 2, to_y + delta, to_z + delta / 2 + delta);
+ glVertex3f(to_x - delta / 2, to_y - delta, to_z - delta / 2 + delta);
+
+ glVertex3f(to_x - delta, to_y + delta / 2, to_z - delta / 2 + delta);
+ glVertex3f(to_x + delta, to_y - delta / 2, to_z + delta / 2 + delta);
+ glVertex3f(to_x - delta, to_y - delta / 2, to_z - delta / 2 + delta);
+ glVertex3f(to_x + delta, to_y + delta / 2, to_z + delta / 2 + delta);
+ glVertex3f(to_x - delta, to_y + delta / 2, to_z + delta / 2 + delta);
+ glVertex3f(to_x + delta, to_y - delta / 2, to_z - delta / 2 + delta);
+ glVertex3f(to_x - delta, to_y - delta / 2, to_z + delta / 2 + delta);
+ glVertex3f(to_x + delta, to_y + delta / 2, to_z - delta / 2 + delta);
+
+ glVertex3f(to_x - delta / 2, to_y + delta / 2, to_z + delta + delta);
+ glVertex3f(to_x + delta / 2, to_y - delta / 2, to_z - delta + delta);
+ glVertex3f(to_x + delta / 2, to_y + delta / 2, to_z + delta + delta);
+ glVertex3f(to_x - delta / 2, to_y - delta / 2, to_z - delta + delta);
+ glVertex3f(to_x - delta / 2, to_y - delta / 2, to_z + delta + delta);
+ glVertex3f(to_x + delta / 2, to_y + delta / 2, to_z - delta + delta);
+ glVertex3f(to_x + delta / 2, to_y - delta / 2, to_z + delta + delta);
+ glVertex3f(to_x - delta / 2, to_y + delta / 2, to_z - delta + delta);
+ glEnd();
+#endif
}