Added GLK12232-25SM support with glk driver.

Fixed lots of small problems in various places.
Added new protocol commands screen_add/del_key so screens
   can request keystrokes when they are being displayed.
Lots of work on CPU GRAPH and BIG NUMBER CLOCK screens.
Fixed 'output' function in MtxOrb.c
This commit is contained in:
ppokorny
2001-04-27 02:20:38 +00:00
parent bb10988d10
commit 877d8ac8e8
12 changed files with 247 additions and 75 deletions
+147 -2
View File
@@ -34,6 +34,8 @@ client_function commands[] = {
{"client_set", client_set_func},
{"client_add_key", client_add_key_func},
{"client_del_key", client_del_key_func},
{"screen_add_key", screen_add_key_func},
{"screen_del_key", screen_del_key_func},
{"screen_add", screen_add_func},
{"screen_del", screen_del_func},
{"screen_set", screen_set_func},
@@ -144,7 +146,7 @@ client_add_key_func (client * c, int argc, char **argv)
if (!c->data->ack)
return 1;
sock_send_string (c->sock, "huh? Not implemented yet.\n");
sock_send_string (c->sock, "huh? Not implemented yet. Try using screen_add_key.\n");
return 0;
}
@@ -160,7 +162,150 @@ client_del_key_func (client * c, int argc, char **argv)
if (!c->data->ack)
return 1;
sock_send_string (c->sock, "huh? Not implemented yet.\n");
sock_send_string (c->sock, "huh? Not implemented yet. Try using screen_del_key.\n");
return 0;
}
///////////////////////////////////////////////////////////////////////////
// Tells the server the client would like to accept keypresses
// of a particular type when the given screen is active on the display
//
int
screen_add_key_func (client * c, int argc, char **argv)
{
widget * w ; /* Keys are stored on a WID_KEYS widget */
screen * s ; /* Attached to a specific screen */
char * id ; /* Screen ID */
char * keys ; /* Keys wanted */
if (!c->data->ack)
return 1;
if (argc < 2) {
sock_send_string (c->sock, "huh? You must specify a screen id\n");
return 0;
}
if (argc < 3) {
sock_send_string (c->sock, "huh? You must specify a key list\n");
return 0;
}
if (argc > 3) {
sock_send_string (c->sock, "huh? Too many parameters...\n");
return 0;
}
id = argv[1];
keys = argv[2];
debug ("screen_add_key: Adding key(s) %s to screen %s\n", keys, id);
// Find the screen
s = screen_find (c, id);
if (!s) {
sock_send_string (c->sock, "huh? Invalid screen id\n");
return 0;
}
// Find the keys widget
w = widget_find( s, KEYS_WIDGETID );
if (!w) {
int err ;
// No keys widget, create a new one
err = widget_add (s, KEYS_WIDGETID, types[WID_KEYS], NULL, c->sock);
if (err < 0) {
fprintf (stderr, "screen_add_key: Error creating keys widget\n");
} else {
w = widget_find (s, KEYS_WIDGETID );
}
};
if (w) {
// Have a widget
if (!w->text) {
// Save supplied key list
w->text = strdup( keys );
} else {
// Add supplied keys to existing list
// NOTE: There could be duplicates in the resulting list
// That's OK, it's the existence of the key in the list
// that's important. We'll be more careful in the delete
// key function.
char * new ;
new = realloc( w->text, strlen(w->text) + strlen(keys) +1 );
if( new ) {
w->text = new ;
strcat( new, keys );
}
}
}
if (!w) {
sock_send_string(c->sock, "huh? failed\n");
} else
sock_send_string(c->sock, "success\n");
return 0;
}
///////////////////////////////////////////////////////////////////////////
// Tells the server the client would NOT like to accept keypresses
// of a particular type when the given screen is active on the display
//
int
screen_del_key_func (client * c, int argc, char **argv)
{
widget * w ; /* Keys are stored on a WID_KEYS widget */
screen * s ; /* Attached to a specific screen */
char * id ; /* Screen ID */
char * keys ; /* Keys wanted */
if (!c->data->ack)
return 1;
if (argc < 2) {
sock_send_string (c->sock, "huh? You must specify a screen id\n");
return 0;
}
if (argc < 3) {
sock_send_string (c->sock, "huh? You must specify a key list\n");
return 0;
}
if (argc > 3) {
sock_send_string (c->sock, "huh? Too many parameters...\n");
return 0;
}
id = argv[1] ;
keys = argv[2] ;
debug ("screen_del_key: Deleting key(s) %s from screen %s\n", keys, id);
// Find the screen
s = screen_find (c, id);
if (!s) {
sock_send_string (c->sock, "huh? Invalid screen id\n");
return 0;
}
// Find the keys widget
w = widget_find( s, KEYS_WIDGETID );
if (w && w->text) {
// Got the widget, remove keys from the text member
// NOTE: We let malloc/realloc remember the length
// of the allocated storage. If keys are later
// added, realloc (in add_key above) will make
// sure there is enough space at w->text
char * from ;
char * to ;
to = from = w->text ;
while( *from ) {
// Is this key to be deleted from the list?
if( strchr( keys, *from ) ) {
// Yes, skip it
++from ;
} else {
// No, save it
*to++ = *from++ ;
}
}
}
sock_send_string(c->sock, "success\n");
return 0;
}
+2
View File
@@ -17,6 +17,8 @@ int hello_func (client * c, int argc, char **argv);
int client_set_func (client * c, int argc, char **argv);
int client_add_key_func (client * c, int argc, char **argv);
int client_del_key_func (client * c, int argc, char **argv);
int screen_add_key_func (client * c, int argc, char **argv);
int screen_del_key_func (client * c, int argc, char **argv);
int screen_add_func (client * c, int argc, char **argv);
int screen_del_func (client * c, int argc, char **argv);
int screen_set_func (client * c, int argc, char **argv);
+2 -1
View File
@@ -10,6 +10,7 @@ EXTRA_libLCDdrivers_a_SOURCES = MtxOrb.c MtxOrb.h text.c text.h \
hd44780-low.h hd44780-drivers.h \
port.h joy.c joy.h irmanin.c irmanin.h \
bayrad.h bayrad.c \
CFontz.c CFontz.h lircin.c lircin.h debug.h
CFontz.c CFontz.h lircin.c lircin.h debug.h \
glk.c glk.h glkproto.c glkproto.h
libLCDdrivers_a_DEPENDENCIES = @DRIVERS@
libLCDdrivers_a_LIBADD = @DRIVERS@
+1 -1
View File
@@ -347,7 +347,7 @@ MtxOrb_output (int on)
if ( on & (1 << i) ) {
sprintf (out, "%cW%c", 254, i+1);
} else {
sprintf (out, "%cW%c", 254, i+1);
sprintf (out, "%cV%c", 254, i+1);
}
write (fd, out, 3);
}
+7
View File
@@ -64,6 +64,10 @@
#include "bayrad.h"
#endif
#ifdef GLK_DRV
#include "glk.h"
#endif
// TODO: Make a Windows server, and clients...?
lcd_logical_driver lcd;
@@ -105,6 +109,9 @@ lcd_physical_driver drivers[] = {
#endif
#ifdef BAYRAD_DRV
{"BayRAD", bayrad_init,},
#endif
#ifdef GLK_DRV
{"glk", glk_init,},
#endif
{NULL, NULL,},
+35 -12
View File
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../shared/sockets.h"
#include "../shared/debug.h"
@@ -35,6 +36,7 @@
#include "client_data.h"
#include "clients.h"
#include "screen.h"
#include "widget.h"
#include "screenlist.h"
#include "menus.h"
@@ -52,6 +54,7 @@ handle_input ()
char str[256];
int key;
screen *s;
widget *w;
client *c;
key = lcd.getkey ();
@@ -62,19 +65,39 @@ handle_input ()
debug ("handle_input(%c)\n", (char) key);
if (key) {
/* s = screenlist_current (); */
c = (client *)LL_GetFirst(clients);
while(c) {
// TODO: Interpret and translate keys!
// If the client should have this keypress...
// Send keypress to client
// TODO: Implement client "acceptable key" lists
// TODO: Interpret and translate keys!
// Give current screen a shot at the key first
s = screenlist_current ();
w = widget_find( s, KEYS_WIDGETID );
if( s->parent && w && w->text && strchr( w->text, key ) ) {
// This screen wants this key. Tell it we got one
sprintf(str, "key %c\n", key);
sock_send_string(c->sock, str);
c = (client *)LL_GetNext(clients);
sock_send_string(s->parent->sock, str);
// Nobody else gets this key
} else {
// Give key to anyone who wants it
c = (client *)LL_GetFirst(clients);
while(c) {
// If the client should have this keypress...
s = (screen *)LL_GetFirst(c->data->screenlist);
while(s) {
w = widget_find( s, KEYS_WIDGETID );
if( s->parent && w && w->text && strchr( w->text, key ) ) {
// Send keypress to client
sprintf(str, "key %c\n", key);
sock_send_string(c->sock, str);
break ; // Screen loop
}
s = (screen *)LL_GetNext(c->data->screenlist);
} // while screens
c = (client *)LL_GetNext(clients);
} // while clients
// Give server a shot at all keys
server_input (key);
}
server_input (key);
}
};
return 0;
}
@@ -104,7 +127,7 @@ server_input (int key)
server_menu ();
break;
default:
debug ("server_input: Invalid key \"%c\" (%i)\n", (char) key, key);
debug ("server_input: Unused key \"%c\" (%i)\n", (char) key, key);
break;
}
+2 -1
View File
@@ -422,7 +422,8 @@ draw_frame (LL * list, char fscroll, int left, int top, int right, int bottom, i
}
break;
case WID_NUM: // FIXME: doesn't work in frames...
if ((w->x > 0) && (w->y >= 0) && (w->y <= 9)) {
// NOTE: y=10 means COLON (:)
if ((w->x > 0) && (w->y >= 0) && (w->y <= 10)) {
if (reset) {
lcd.init_num ();
reset = 0;
+3 -3
View File
@@ -153,9 +153,6 @@ screen_remove (client * c, char *id)
// TODO: Check for errors here?
LL_Remove (c->data->screenlist, (void *) s);
// ... and here?
screen_destroy (s);
// Now, remove it from the screenlist...
if (screenlist_remove_all (s) < 0) {
// Not a serious error..
@@ -163,5 +160,8 @@ screen_remove (client * c, char *id)
return 0;
}
// TODO: Check for errors here too?
screen_destroy (s);
return 0;
}
+1
View File
@@ -17,6 +17,7 @@ char *types[] = { "none",
"scroller",
"frame",
"num",
"keys",
//"",
NULL,
};
+4
View File
@@ -26,11 +26,15 @@ typedef struct widget {
#define WID_SCROLLER 6
#define WID_FRAME 7
#define WID_NUM 8
#define WID_KEYS 9
#define WID_MAX_DIR 4
extern char *types[];
// RESERVED widget ID for keys active on a screen
#define KEYS_WIDGETID "screenkeys"
widget *widget_create ();
int widget_destroy (widget * w);