harmonize coding style and messages; add more checks; little fixes
This commit is contained in:
+125
-103
@@ -38,7 +38,7 @@
|
|||||||
#define GLK_DEFAULT_CONTRAST 560
|
#define GLK_DEFAULT_CONTRAST 560
|
||||||
|
|
||||||
|
|
||||||
static GLKDisplay * PortFD ;
|
static GLKDisplay * PortFD = NULL;
|
||||||
/* Initialize pseudo-CGRAM to empty */
|
/* Initialize pseudo-CGRAM to empty */
|
||||||
static unsigned char CGRAM[8] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
|
static unsigned char CGRAM[8] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
|
||||||
|
|
||||||
@@ -82,22 +82,25 @@ glk_init(Driver *drvthis)
|
|||||||
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
|
strncpy(device, drvthis->config_get_string(drvthis->name, "Device", 0,
|
||||||
GLK_DEFAULT_DEVICE), sizeof(device));
|
GLK_DEFAULT_DEVICE), sizeof(device));
|
||||||
device[sizeof(device)-1] = '\0';
|
device[sizeof(device)-1] = '\0';
|
||||||
|
report(RPT_INFO, "%s: using Device %s", drvthis->name, device);
|
||||||
|
|
||||||
/* What speed to use */
|
/* What speed to use */
|
||||||
speed = drvthis->config_get_int(drvthis->name, "Speed", 0, 9600);
|
speed = drvthis->config_get_int(drvthis->name, "Speed", 0, 19200);
|
||||||
|
|
||||||
if (speed == 9600) speed = B9600;
|
if (speed == 9600) speed = B9600;
|
||||||
else if (speed == 19200) speed = B19200;
|
else if (speed == 19200) speed = B19200;
|
||||||
else if (speed == 38400) speed = B38400;
|
else if (speed == 38400) speed = B38400;
|
||||||
else {
|
else {
|
||||||
report(RPT_WARNING, "glk: Illegal speed: %d. Must be one of 9600, 19200 or 38400. Using default.\n", speed);
|
report(RPT_WARNING, "%s: illegal Speed: %d; must be one of 9600, 19200 or 38400; using default %d",
|
||||||
|
drvthis->name, 19200);
|
||||||
speed = B19200;
|
speed = B19200;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Which contrast */
|
/* Which contrast */
|
||||||
contrast = drvthis->config_get_int(drvthis->name, "Contrast" , 0 , GLK_DEFAULT_CONTRAST);
|
contrast = drvthis->config_get_int(drvthis->name, "Contrast" , 0 , GLK_DEFAULT_CONTRAST);
|
||||||
if ((contrast < 0) || (contrast > 1000)) {
|
if ((contrast < 0) || (contrast > 1000)) {
|
||||||
report (RPT_WARNING, "glk: Contrast must be between 0 and 1000. Using default value.\n");
|
report(RPT_WARNING, "%s: Contrast must be between 0 and 1000. Using default %d",
|
||||||
|
drvthis->name, GLK_DEFAULT_CONTRAST);
|
||||||
contrast = GLK_DEFAULT_CONTRAST;
|
contrast = GLK_DEFAULT_CONTRAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,48 +109,60 @@ glk_init(Driver *drvthis)
|
|||||||
/* open device */
|
/* open device */
|
||||||
PortFD = glkopen(device, speed);
|
PortFD = glkopen(device, speed);
|
||||||
if (PortFD == NULL) {
|
if (PortFD == NULL) {
|
||||||
|
report(RPT_ERR, "%s: unable to open device %s", drvthis->name, device);
|
||||||
return -1;
|
return -1;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Query the module for a device type
|
// Query the module for a device type
|
||||||
glkputl(PortFD, GLKCommand, 0x37, EOF);
|
glkputl(PortFD, GLKCommand, 0x37, EOF);
|
||||||
i = glkget(PortFD);
|
i = glkget(PortFD);
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
report(RPT_ERR, "glk: GLK did not respond to READ MODULE TYPE.\n" );
|
report(RPT_ERR, "%s: GLK did not respond to READ MODULE TYPE", drvthis->name);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0x10 : // GLC12232
|
case 0x10 : // GLC12232
|
||||||
width = 20 ; height = 4 ; break ;
|
width = 20; height = 4;
|
||||||
|
break;
|
||||||
case 0x11 : // GLC12864
|
case 0x11 : // GLC12864
|
||||||
width = 20 ; height = 8 ; break ;
|
width = 20; height = 8;
|
||||||
|
break;
|
||||||
case 0x12 : // GLC128128
|
case 0x12 : // GLC128128
|
||||||
width = 20 ; height = 16 ; break ;
|
width = 20; height = 16;
|
||||||
|
break;
|
||||||
case 0x13 : // GLC24064
|
case 0x13 : // GLC24064
|
||||||
width = 40 ; height = 8 ; gpo_count = 1 ; break ;
|
width = 40; height = 8; gpo_count = 1;
|
||||||
|
break;
|
||||||
case 0x14 : // GLK12864-25
|
case 0x14 : // GLK12864-25
|
||||||
width = 20 ; height = 8 ; break ;
|
width = 20; height = 8;
|
||||||
|
break;
|
||||||
case 0x15 : // GLK24064-25
|
case 0x15 : // GLK24064-25
|
||||||
width = 40 ; height = 8 ; gpo_count = 1 ; break ;
|
width = 40; height = 8; gpo_count = 1;
|
||||||
|
break;
|
||||||
case 0x21 : // GLK128128-25
|
case 0x21 : // GLK128128-25
|
||||||
width = 20 ; height = 16 ; break ;
|
width = 20; height = 16;
|
||||||
|
break;
|
||||||
case 0x22 : // GLK12232-25
|
case 0x22 : // GLK12232-25
|
||||||
width = 20 ; height = 4 ; gpo_count = 2 ; break ;
|
width = 20; height = 4; gpo_count = 2;
|
||||||
|
break;
|
||||||
case 0x23 : // GLK12232-25SM
|
case 0x23 : // GLK12232-25SM
|
||||||
width = 20 ; height = 4 ; gpo_count = 2 ; break ;
|
width = 20; height = 4; gpo_count = 2;
|
||||||
|
break;
|
||||||
case 0x24 : // GLK12232-25SM-Penguin
|
case 0x24 : // GLK12232-25SM-Penguin
|
||||||
width = 20 ; height = 4 ; gpo_count = 2 ; break ;
|
width = 20; height = 4; gpo_count = 2;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
report(RPT_ERR, "glk: Unrecognized module type: 0x%02x\n", i );
|
report(RPT_ERR, "%s: unrecognized module type: 0x%02X", drvthis->name, i);
|
||||||
return( -1 );
|
return -1;
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
framebuf = malloc(width * height);
|
framebuf = malloc(width * height);
|
||||||
screen_contents = malloc(width * height);
|
screen_contents = malloc(width * height);
|
||||||
|
|
||||||
if (framebuf == NULL || screen_contents == NULL) {
|
if (framebuf == NULL || screen_contents == NULL) {
|
||||||
report(RPT_ERR, "glk: Unable to allocate memory for screen buffers\n" );
|
report(RPT_ERR, "%s: Unable to allocate memory for screen buffers", drvthis->name);
|
||||||
glk_close(drvthis);
|
glk_close(drvthis);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -174,7 +189,9 @@ glk_init(Driver *drvthis)
|
|||||||
// Set contrast
|
// Set contrast
|
||||||
glk_set_contrast(drvthis, contrast);
|
glk_set_contrast(drvthis, contrast);
|
||||||
|
|
||||||
return 0;
|
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,10 +201,17 @@ glk_init(Driver *drvthis)
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_close(Driver *drvthis)
|
glk_close(Driver *drvthis)
|
||||||
{
|
{
|
||||||
|
if (PortFD != NULL)
|
||||||
glkclose(PortFD);
|
glkclose(PortFD);
|
||||||
|
PortFD = NULL;
|
||||||
|
|
||||||
if(framebuf) free(framebuf);
|
if (framebuf != NULL)
|
||||||
|
free(framebuf);
|
||||||
framebuf = NULL;
|
framebuf = NULL;
|
||||||
|
|
||||||
|
if (screen_contents != NULL)
|
||||||
|
free(screen_contents);
|
||||||
|
screen_contents = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -216,6 +240,7 @@ glk_height (Driver *drvthis)
|
|||||||
//
|
//
|
||||||
#define CLEARCOUNT (1000000)
|
#define CLEARCOUNT (1000000)
|
||||||
static int clearcount = 0;
|
static int clearcount = 0;
|
||||||
|
|
||||||
void glk_clear_forced(Driver *drvthis)
|
void glk_clear_forced(Driver *drvthis)
|
||||||
{
|
{
|
||||||
// puts("REALLY CLEARING the display");
|
// puts("REALLY CLEARING the display");
|
||||||
@@ -223,14 +248,15 @@ void glk_clear_forced(Driver *drvthis)
|
|||||||
glkputl(PortFD, GLKCommand, 0x58, EOF);
|
glkputl(PortFD, GLKCommand, 0x58, EOF);
|
||||||
memset(screen_contents, ' ', width*height);
|
memset(screen_contents, ' ', width*height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_clear(Driver *drvthis)
|
glk_clear(Driver *drvthis)
|
||||||
{
|
{
|
||||||
// puts("glk_clear()");
|
// puts("glk_clear()");
|
||||||
memset(framebuf, ' ', width * height);
|
memset(framebuf, ' ', width * height);
|
||||||
if( --clearcount < 0 ) {
|
if (--clearcount < 0)
|
||||||
glk_clear_forced(drvthis);
|
glk_clear_forced(drvthis);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -247,7 +273,7 @@ glk_flush(Driver *drvthis)
|
|||||||
int xs;
|
int xs;
|
||||||
unsigned char * ps = NULL;
|
unsigned char * ps = NULL;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "flush()\n" );
|
debug(RPT_DEBUG, "flush()");
|
||||||
|
|
||||||
p = framebuf;
|
p = framebuf;
|
||||||
q = screen_contents;
|
q = screen_contents;
|
||||||
@@ -255,29 +281,27 @@ glk_flush(Driver *drvthis)
|
|||||||
for (y = 0; y < height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
xs = -1; /* XStart not set */
|
xs = -1; /* XStart not set */
|
||||||
for (x = 0; x < width; ++x) {
|
for (x = 0; x < width; ++x) {
|
||||||
if( *q == *p && xs >= 0 ) {
|
if ((*q == *p) && (xs >= 0)) {
|
||||||
/* Write accumulated string */
|
/* Write accumulated string */
|
||||||
glkputl(PortFD, GLKCommand, 0x79, xs * 6 + 1, y * 8, EOF);
|
glkputl(PortFD, GLKCommand, 0x79, xs * 6 + 1, y * 8, EOF);
|
||||||
glkputa(PortFD, x - xs, ps);
|
glkputa(PortFD, x - xs, ps);
|
||||||
debug(RPT_DEBUG, "draw_frame: Writing at (%d,%d) for %d\n", xs, y, x-xs );
|
debug(RPT_DEBUG, "draw_frame: Writing at (%d,%d) for %d", xs, y, x - xs);
|
||||||
xs = -1;
|
xs = -1;
|
||||||
} else if( *q != *p && xs < 0 ) {
|
} else if ((*q != *p) && (xs < 0)) {
|
||||||
/* Start new string of changes */
|
/* Start new string of changes */
|
||||||
ps = p;
|
ps = p;
|
||||||
xs = x;
|
xs = x;
|
||||||
};
|
}
|
||||||
*q++ = *p++; /* Update screen_contents from framebuf */
|
*q++ = *p++; /* Update screen_contents from framebuf */
|
||||||
};
|
}
|
||||||
if (xs >= 0) {
|
if (xs >= 0) {
|
||||||
/* Write accumulated line */
|
/* Write accumulated line */
|
||||||
glkputl(PortFD, GLKCommand, 0x79, xs * 6 + 1, y * 8, EOF);
|
glkputl(PortFD, GLKCommand, 0x79, xs * 6 + 1, y * 8, EOF);
|
||||||
glkputa(PortFD, width - xs, ps);
|
glkputa(PortFD, width - xs, ps);
|
||||||
debug(RPT_DEBUG, "draw_frame: Writing at (%d,%d) for %d\n", xs, y, width-xs );
|
debug(RPT_DEBUG, "draw_frame: Writing at (%d,%d) for %d", xs, y, width - xs);
|
||||||
};
|
}
|
||||||
|
|
||||||
}; /* For y */
|
} /* For y */
|
||||||
|
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -290,18 +314,18 @@ glk_string(Driver *drvthis, int x, int y, char string[])
|
|||||||
{
|
{
|
||||||
char * p;
|
char * p;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "glk_string( %d, %d, \"%s\" )\n", x, y, string );
|
debug(RPT_DEBUG, "glk_string(%d, %d, \"%s\")", x, y, string);
|
||||||
|
|
||||||
if( x > width || y > height ) {
|
if ((x > width) || (y > height)) {
|
||||||
return;
|
return;
|
||||||
};
|
|
||||||
|
|
||||||
for( p = string ; *p && x <= width ; ++x, ++p ) {
|
|
||||||
glk_chr( drvthis, x, y, *p );
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (p = string; (*p != '\0') && (x <= width); ++x, ++p) {
|
||||||
|
glk_chr(drvthis, x, y, *p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// Prints a character on the lcd display, at position (x,y). The
|
// Prints a character on the lcd display, at position (x,y). The
|
||||||
// upper-left is (1,1), and the lower right should be (20,4).
|
// upper-left is (1,1), and the lower right should be (20,4).
|
||||||
@@ -322,22 +346,21 @@ glk_chr(Driver *drvthis, int x, int y, char c)
|
|||||||
glkputl(PortFD, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF);
|
glkputl(PortFD, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF);
|
||||||
/* Clear the screen */
|
/* Clear the screen */
|
||||||
glk_clear_forced(drvthis);
|
glk_clear_forced(drvthis);
|
||||||
};
|
}
|
||||||
|
|
||||||
if( myc >= 0 && myc <= 15 ) {
|
if ((myc >= 0) && (myc <= 15)) {
|
||||||
/* CGRAM */
|
/* CGRAM */
|
||||||
debug(RPT_DEBUG, "CGRAM changing %d => %d\n", myc, CGRAM[myc&7] );
|
debug(RPT_DEBUG, "CGRAM changing %d => %d", myc, CGRAM[myc & 7]);
|
||||||
myc = CGRAM[myc & 7];
|
myc = CGRAM[myc & 7];
|
||||||
} else if( myc == 255 || myc == -1 ) {
|
} else if ((myc == 255) || (myc == -1)) {
|
||||||
/* Solid block */
|
/* Solid block */
|
||||||
myc = 133;
|
myc = 133;
|
||||||
} else if( (myc > 15 && myc < 32) || myc > 143 ) {
|
} else if (((myc > 15) && (myc < 32)) || (myc > 143)) {
|
||||||
debug(RPT_DEBUG, "Attempt to write %d to (%d,%d)\n", myc, x, y );
|
debug(RPT_DEBUG, "Attempt to write %d to (%d,%d)", myc, x, y);
|
||||||
myc = 133;
|
myc = 133;
|
||||||
};
|
}
|
||||||
|
|
||||||
framebuf[(y * width) + x] = myc;
|
framebuf[(y * width) + x] = myc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -362,14 +385,14 @@ MODULE_EXPORT void
|
|||||||
glk_set_contrast(Driver *drvthis, int promille)
|
glk_set_contrast(Driver *drvthis, int promille)
|
||||||
{
|
{
|
||||||
// Check it
|
// Check it
|
||||||
if( contrast < 0 || contrast > 1000 )
|
if ((promille < 0) || (promille > 1000))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Store it
|
// Store it
|
||||||
contrast = promille;
|
contrast = promille;
|
||||||
|
|
||||||
// Do it
|
// Do it
|
||||||
debug(RPT_DEBUG, "Contrast: %i\n", contrast);
|
debug(RPT_DEBUG, "Contrast: %d", contrast);
|
||||||
glkputl(PortFD, GLKCommand, 0x50, (int) ((long) promille * 255 / 1000), EOF);
|
glkputl(PortFD, GLKCommand, 0x50, (int) ((long) promille * 255 / 1000), EOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,10 +403,10 @@ MODULE_EXPORT void
|
|||||||
glk_backlight(Driver *drvthis, int on)
|
glk_backlight(Driver *drvthis, int on)
|
||||||
{
|
{
|
||||||
if (on) {
|
if (on) {
|
||||||
debug(RPT_DEBUG, "Backlight ON\n");
|
debug(RPT_DEBUG, "Backlight ON");
|
||||||
glkputl(PortFD, GLKCommand, 0x42, 0, EOF);
|
glkputl(PortFD, GLKCommand, 0x42, 0, EOF);
|
||||||
} else {
|
} else {
|
||||||
debug(RPT_DEBUG, "Backlight OFF\n");
|
debug(RPT_DEBUG, "Backlight OFF");
|
||||||
glkputl(PortFD, GLKCommand, 0x46, EOF);
|
glkputl(PortFD, GLKCommand, 0x46, EOF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -394,19 +417,15 @@ MODULE_EXPORT void
|
|||||||
glk_output(Driver *drvthis, int on)
|
glk_output(Driver *drvthis, int on)
|
||||||
{
|
{
|
||||||
if (gpo_count < 2) {
|
if (gpo_count < 2) {
|
||||||
if( on ) { glkputl( PortFD, GLKCommand, 'W', EOF );
|
glkputl(PortFD, GLKCommand, ((on) ? 'W' : 'V'), EOF);
|
||||||
} else { glkputl( PortFD, GLKCommand, 'V', EOF );
|
}
|
||||||
};
|
else {
|
||||||
} else {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i <= gpo_count; ++i, on >>= 1) {
|
for (i = 1; i <= gpo_count; ++i, on >>= 1) {
|
||||||
if( on & 1 ) {
|
glkputl(PortFD, GLKCommand, ((on & 1) ? 'W' : 'V'), i, EOF);
|
||||||
glkputl( PortFD, GLKCommand, 'W', i, EOF );
|
}
|
||||||
} else {
|
}
|
||||||
glkputl( PortFD, GLKCommand, 'V', i, EOF );
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -415,7 +434,7 @@ glk_output(Driver *drvthis, int on)
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_init_vbar(Driver *drvthis)
|
glk_init_vbar(Driver *drvthis)
|
||||||
{
|
{
|
||||||
debug(RPT_DEBUG, "glk_init_vbar()\n");
|
debug(RPT_DEBUG, "glk_init_vbar()");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -424,7 +443,7 @@ glk_init_vbar(Driver *drvthis)
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_init_hbar(Driver *drvthis)
|
glk_init_hbar(Driver *drvthis)
|
||||||
{
|
{
|
||||||
debug(RPT_DEBUG, "glk_init_hbar()\n");
|
debug(RPT_DEBUG, "glk_init_hbar()");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -433,7 +452,7 @@ glk_init_hbar(Driver *drvthis)
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_init_num(Driver *drvthis)
|
glk_init_num(Driver *drvthis)
|
||||||
{
|
{
|
||||||
debug(RPT_DEBUG, "glk_init_num()\n");
|
debug(RPT_DEBUG, "glk_init_num()");
|
||||||
if (fontselected != 3) {
|
if (fontselected != 3) {
|
||||||
/* Select Big Numbers font */
|
/* Select Big Numbers font */
|
||||||
glkputl(PortFD, GLKCommand, 0x31, 3, EOF);
|
glkputl(PortFD, GLKCommand, 0x31, 3, EOF);
|
||||||
@@ -442,7 +461,7 @@ glk_init_num(Driver *drvthis)
|
|||||||
glkputl(PortFD, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF);
|
glkputl(PortFD, GLKCommand, 0x32, 1, 0, 1, 1, 32, EOF);
|
||||||
/* Clear the screen */
|
/* Clear the screen */
|
||||||
glk_clear_forced(drvthis);
|
glk_clear_forced(drvthis);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -451,7 +470,7 @@ glk_init_num(Driver *drvthis)
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_num(Driver *drvthis, int x, int num)
|
glk_num(Driver *drvthis, int x, int num)
|
||||||
{
|
{
|
||||||
debug(RPT_DEBUG, "glk_num(%i, %i)\n", x, num);
|
debug(RPT_DEBUG, "glk_num(%d, %d)", x, num);
|
||||||
framebuf[x-1] = num + '0';
|
framebuf[x-1] = num + '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +480,7 @@ glk_num(Driver *drvthis, int x, int num)
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_set_char(Driver *drvthis, int n, char *dat)
|
glk_set_char(Driver *drvthis, int n, char *dat)
|
||||||
{
|
{
|
||||||
debug(RPT_DEBUG, "glk_set_char( %i )\n", n);
|
debug(RPT_DEBUG, "glk_set_char(%d)", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
@@ -472,15 +491,17 @@ glk_old_vbar(Driver *drvthis, int x, int len)
|
|||||||
{
|
{
|
||||||
int y = height;
|
int y = height;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "glk_old_vbar( %d, %d )\n", x, len );
|
debug(RPT_DEBUG, "glk_old_vbar(%d, %d)", x, len);
|
||||||
|
|
||||||
while (len > cellheight) {
|
while (len > cellheight) {
|
||||||
glk_chr(drvthis, x, y, 255);
|
glk_chr(drvthis, x, y, 255);
|
||||||
--y;
|
--y;
|
||||||
len -= cellheight;
|
len -= cellheight;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (y >= 0) {
|
if (y >= 0) {
|
||||||
int lastc;
|
int lastc;
|
||||||
|
|
||||||
switch (len) {
|
switch (len) {
|
||||||
case 0 : return; break; /* Don't output a char */
|
case 0 : return; break; /* Don't output a char */
|
||||||
case 1 : lastc = 138; break; /* One bar */
|
case 1 : lastc = 138; break; /* One bar */
|
||||||
@@ -490,9 +511,9 @@ glk_old_vbar(Driver *drvthis, int x, int len)
|
|||||||
case 5 : lastc = 142; break;
|
case 5 : lastc = 142; break;
|
||||||
case 6 : lastc = 143; break;
|
case 6 : lastc = 143; break;
|
||||||
default: lastc = 133; break;
|
default: lastc = 133; break;
|
||||||
};
|
}
|
||||||
glk_chr(drvthis, x, y, lastc);
|
glk_chr(drvthis, x, y, lastc);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
@@ -501,15 +522,17 @@ glk_old_vbar(Driver *drvthis, int x, int len)
|
|||||||
MODULE_EXPORT void
|
MODULE_EXPORT void
|
||||||
glk_old_hbar(Driver *drvthis, int x, int y, int len)
|
glk_old_hbar(Driver *drvthis, int x, int y, int len)
|
||||||
{
|
{
|
||||||
debug(RPT_DEBUG, "glk_old_hbar( %d, %d, %d )\n", x, y, len );
|
debug(RPT_DEBUG, "glk_old_hbar(%d, %d, %d)", x, y, len);
|
||||||
|
|
||||||
while (len > cellwidth) {
|
while (len > cellwidth) {
|
||||||
glk_chr(drvthis, x, y, 255);
|
glk_chr(drvthis, x, y, 255);
|
||||||
++x;
|
++x;
|
||||||
len -= cellwidth;
|
len -= cellwidth;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (x <= width) {
|
if (x <= width) {
|
||||||
int lastc;
|
int lastc;
|
||||||
|
|
||||||
switch (len) {
|
switch (len) {
|
||||||
case 0 : lastc = ' '; break;
|
case 0 : lastc = ' '; break;
|
||||||
case 1 : lastc = 134; break; /* One bar */
|
case 1 : lastc = 134; break; /* One bar */
|
||||||
@@ -517,9 +540,9 @@ glk_old_hbar(Driver *drvthis, int x, int y, int len)
|
|||||||
case 3 : lastc = 136; break;
|
case 3 : lastc = 136; break;
|
||||||
case 4 : lastc = 137; break;
|
case 4 : lastc = 137; break;
|
||||||
default: lastc = 133; break;
|
default: lastc = 133; break;
|
||||||
};
|
}
|
||||||
glk_chr(drvthis, x, y, lastc);
|
glk_chr(drvthis, x, y, lastc);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -537,12 +560,12 @@ glk_old_icon(Driver *drvthis, int which, int dest)
|
|||||||
unsigned char * q;
|
unsigned char * q;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "glk_old_icon( %i, %i )\n", which, dest);
|
debug(RPT_DEBUG, "glk_old_icon(%i, %i)", which, dest);
|
||||||
|
|
||||||
if( dest < 0 || dest > 7 ) {
|
if ((dest < 0) || (dest > 7)) {
|
||||||
/* Illegal custom character */
|
/* Illegal custom character */
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
/* which == 0 => empty heart => 131
|
/* which == 0 => empty heart => 131
|
||||||
* which == 1 => filled heart => 132
|
* which == 1 => filled heart => 132
|
||||||
@@ -553,7 +576,7 @@ glk_old_icon(Driver *drvthis, int which, int dest)
|
|||||||
case 1: new = 132; break;
|
case 1: new = 132; break;
|
||||||
case 2: new = 128; break;
|
case 2: new = 128; break;
|
||||||
default: return; /* ERROR */
|
default: return; /* ERROR */
|
||||||
};
|
}
|
||||||
|
|
||||||
old = CGRAM[(int) dest];
|
old = CGRAM[(int) dest];
|
||||||
CGRAM[(int) dest] = new;
|
CGRAM[(int) dest] = new;
|
||||||
@@ -561,15 +584,13 @@ glk_old_icon(Driver *drvthis, int which, int dest)
|
|||||||
q = screen_contents;
|
q = screen_contents;
|
||||||
|
|
||||||
/* Replace all old icons with new icon in new frame */
|
/* Replace all old icons with new icon in new frame */
|
||||||
for( count = width * height ; count ; --count ) {
|
for (count = width * height; count > 0; --count) {
|
||||||
if (*q == old) {
|
if (*q == old) {
|
||||||
debug(RPT_DEBUG, "icon %d to %d at %d\n", old, new, q - screen_contents );
|
debug(RPT_DEBUG, "icon %d to %d at %d", old, new, q - screen_contents);
|
||||||
*p = new;
|
*p = new;
|
||||||
};
|
}
|
||||||
++q; ++p;
|
++q; ++p;
|
||||||
};
|
}
|
||||||
|
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -587,18 +608,18 @@ glk_get_key(Driver *drvthis)
|
|||||||
struct timeval now;
|
struct timeval now;
|
||||||
const char *key = NULL;
|
const char *key = NULL;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "glk_getkey()" );
|
debug(RPT_DEBUG, "glk_get_key()");
|
||||||
|
|
||||||
c = glkgetc(PortFD);
|
c = glkgetc(PortFD);
|
||||||
|
|
||||||
if( c >= 'A' && c <= 'Z' ) {
|
if ((c >= 'A') && (c <= 'Z')) {
|
||||||
/* Key down event */
|
/* Key down event */
|
||||||
keycode = c;
|
keycode = c;
|
||||||
gettimeofday(&lastkey, NULL);
|
gettimeofday(&lastkey, NULL);
|
||||||
debug(RPT_DEBUG, "KEY %c at %ld.%06ld\n", c, lastkey.tv_sec, lastkey.tv_usec );
|
debug(RPT_DEBUG, "KEY %c at %ld.%06ld", c, lastkey.tv_sec, lastkey.tv_usec);
|
||||||
} else if( c >= 'a' && c <= 'z' ) {
|
} else if ((c >= 'a') && (c <= 'z')) {
|
||||||
/* Key up event */
|
/* Key up event */
|
||||||
debug(RPT_DEBUG, "KEY %c UP\n", c );
|
debug(RPT_DEBUG, "KEY %c UP", c);
|
||||||
keycode = -1;
|
keycode = -1;
|
||||||
c = 0;
|
c = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -606,19 +627,20 @@ glk_get_key(Driver *drvthis)
|
|||||||
c = 0;
|
c = 0;
|
||||||
if (keycode > 0) {
|
if (keycode > 0) {
|
||||||
int msec_diff;
|
int msec_diff;
|
||||||
|
|
||||||
/* A key is down */
|
/* A key is down */
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
msec_diff = (now.tv_sec - lastkey.tv_sec) * 1000;
|
msec_diff = (now.tv_sec - lastkey.tv_sec) * 1000;
|
||||||
msec_diff += (now.tv_usec - lastkey.tv_usec) / 1000;
|
msec_diff += (now.tv_usec - lastkey.tv_usec) / 1000;
|
||||||
debug(RPT_DEBUG, "KEY %c down for %d msec\n", keycode, msec_diff );
|
debug(RPT_DEBUG, "KEY %c down for %d msec", keycode, msec_diff);
|
||||||
if (msec_diff > 1000) {
|
if (msec_diff > 1000) {
|
||||||
/* Generate repeat event */
|
/* Generate repeat event */
|
||||||
c = keycode | 0x20; /* Upper case to lower case */
|
c = keycode | 0x20; /* Upper case to lower case */
|
||||||
++lastkey.tv_sec; /* HACK HACK. repeat at 1 sec intervals */
|
++lastkey.tv_sec; /* HACK HACK. repeat at 1 sec intervals */
|
||||||
debug(RPT_DEBUG, "KEY %c REPEAT\n", c );
|
debug(RPT_DEBUG, "KEY %c REPEAT", c);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/* Remap keys according to what LCDproc expects */
|
/* Remap keys according to what LCDproc expects */
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@@ -643,7 +665,7 @@ glk_get_key(Driver *drvthis)
|
|||||||
//case 'l' : c = 'Q'; break;
|
//case 'l' : c = 'Q'; break;
|
||||||
//case 'u' : c = 'R'; break;
|
//case 'u' : c = 'R'; break;
|
||||||
//case 'k' : c = 'S'; break;
|
//case 'k' : c = 'S'; break;
|
||||||
};
|
}
|
||||||
|
|
||||||
debug(RPT_DEBUG, "%s_ get_key() returns %s", drvthis->name, (key != NULL) ? key : "<null>");
|
debug(RPT_DEBUG, "%s_ get_key() returns %s", drvthis->name, (key != NULL) ? key : "<null>");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user