aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcmay <>2006-07-19 01:35:31 +0000
committercmay <>2006-07-19 01:35:31 +0000
commitd88b8d7fa804d3eee4cc3e0739a0a5a29541fe3e (patch)
tree2a0e3802df41dbc6f5044fce4b49206e03c79163
parentde297ad8d83417c67ee6d309830ed998ba848882 (diff)
downloadlcd4linux-d88b8d7fa804d3eee4cc3e0739a0a5a29541fe3e.tar.gz
[lcd4linux @ 2006-07-19 01:35:31 by cmay]
Renamed keypad direction names to avoid conflict with Curses library defs. Added keypad support to Curses display driver.
-rw-r--r--drv_Crystalfontz.c24
-rw-r--r--drv_Curses.c69
-rw-r--r--drv_LCD2USB.c16
-rw-r--r--widget_keypad.c22
-rw-r--r--widget_keypad.h17
5 files changed, 118 insertions, 30 deletions
diff --git a/drv_Crystalfontz.c b/drv_Crystalfontz.c
index 4585b49..db7b6cc 100644
--- a/drv_Crystalfontz.c
+++ b/drv_Crystalfontz.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Crystalfontz.c,v 1.43 2006/07/14 20:15:11 reinelt Exp $
+/* $Id: drv_Crystalfontz.c,v 1.44 2006/07/19 01:35:31 cmay Exp $
*
* new style driver for Crystalfontz display modules
*
@@ -23,6 +23,10 @@
*
*
* $Log: drv_Crystalfontz.c,v $
+ * Revision 1.44 2006/07/19 01:35:31 cmay
+ * Renamed keypad direction names to avoid conflict with Curses library defs.
+ * Added keypad support to Curses display driver.
+ *
* Revision 1.43 2006/07/14 20:15:11 reinelt
* buffer too small (thanks to anonymous)
*
@@ -693,33 +697,33 @@ static int drv_CF_keypad(const int num)
break;
case 3:
if (num < 8)
- val = KEY_PRESSED;
+ val = WIDGET_KEY_PRESSED;
else
- val = KEY_RELEASED;
+ val = WIDGET_KEY_RELEASED;
switch (num) {
case 1:
case 8:
- val += KEY_UP;
+ val += WIDGET_KEY_UP;
break;
case 2:
case 9:
- val += KEY_DOWN;
+ val += WIDGET_KEY_DOWN;
break;
case 3:
case 10:
- val += KEY_LEFT;
+ val += WIDGET_KEY_LEFT;
break;
case 4:
case 11:
- val += KEY_RIGHT;
+ val += WIDGET_KEY_RIGHT;
break;
case 5:
case 12:
- val += KEY_CONFIRM;
+ val += WIDGET_KEY_CONFIRM;
break;
case 7:
case 13:
- val += KEY_CANCEL;
+ val += WIDGET_KEY_CANCEL;
break;
}
break;
@@ -1116,7 +1120,7 @@ int drv_CF_init(const char *section, const int quiet)
WIDGET_CLASS wc;
int ret;
- info("%s: %s", Name, "$Revision: 1.43 $");
+ info("%s: %s", Name, "$Revision: 1.44 $");
/* start display */
if ((ret = drv_CF_start(section)) != 0) {
diff --git a/drv_Curses.c b/drv_Curses.c
index fd8aac9..8b83aa6 100644
--- a/drv_Curses.c
+++ b/drv_Curses.c
@@ -1,4 +1,4 @@
-/* $Id: drv_Curses.c,v 1.11 2006/01/30 06:25:49 reinelt Exp $
+/* $Id: drv_Curses.c,v 1.12 2006/07/19 01:35:31 cmay Exp $
*
* pure ncurses based text driver
*
@@ -26,6 +26,10 @@
*
*
* $Log: drv_Curses.c,v $
+ * Revision 1.12 2006/07/19 01:35:31 cmay
+ * Renamed keypad direction names to avoid conflict with Curses library defs.
+ * Added keypad support to Curses display driver.
+ *
* Revision 1.11 2006/01/30 06:25:49 reinelt
* added CVS Revision
*
@@ -91,12 +95,15 @@
#include "debug.h"
#include "cfg.h"
#include "qprintf.h"
+#include "timer.h"
#include "plugin.h"
#include "widget.h"
#include "widget_text.h"
#include "widget_bar.h"
+#include "widget_keypad.h"
#include "drv.h"
#include "drv_generic_text.h"
+#include "drv_generic_keypad.h"
static char Name[] = "Curses";
@@ -214,8 +221,11 @@ static int drv_Curs_start(const char *section, const int quiet)
free(s);
initscr();
+ noecho();
debug("%s: curses thinks that COLS=%d LINES=%d", Name, COLS, LINES);
w = newwin(DROWS + 2, DCOLS + 2, 0, 0);
+ keypad(w, TRUE);
+ nodelay(w, TRUE);
EROWS = LINES - DROWS - 3;
if (EROWS > 99)
@@ -245,6 +255,51 @@ static int drv_Curs_start(const char *section, const int quiet)
return 0;
}
+static void drv_Curs_timer(void __attribute__ ((unused)) * notused)
+{
+ int c;
+ while(1) {
+ c = wgetch(w);
+ if(c <= 0 )
+ break;
+ drv_generic_keypad_press(c);
+ }
+}
+
+static int drv_Curs_keypad(const int num)
+{
+ int val = 0;
+
+ switch(num)
+ {
+ case KEY_UP:
+ debug("Key Up");
+ val += WIDGET_KEY_PRESSED;
+ val += WIDGET_KEY_UP;
+ break;
+ case KEY_DOWN:
+ debug("Key Down");
+ val += WIDGET_KEY_PRESSED;
+ val += WIDGET_KEY_DOWN;
+ break;
+ case KEY_LEFT:
+ debug("Key Left");
+ val += WIDGET_KEY_PRESSED;
+ val += WIDGET_KEY_LEFT;
+ break;
+ case KEY_RIGHT:
+ debug("Key Right");
+ val += WIDGET_KEY_PRESSED;
+ val += WIDGET_KEY_RIGHT;
+ break;
+ default:
+ debug("Unbound Key '%d'", num);
+ break;
+ }
+
+ return val;
+}
+
/****************************************/
/*** plugins ***/
@@ -259,6 +314,7 @@ static int drv_Curs_start(const char *section, const int quiet)
/* using drv_generic_text_draw(W) */
/* using drv_generic_text_bar_draw(W) */
+/* using drv_generic_keypad_draw(W) */
/****************************************/
@@ -280,7 +336,7 @@ int drv_Curs_init(const char *section, const int quiet)
WIDGET_CLASS wc;
int ret;
- info("%s: %s", Name, "$Revision: 1.11 $");
+ info("%s: %s", Name, "$Revision: 1.12 $");
/* display preferences */
XRES = 1; /* pixel width of one char */
@@ -292,6 +348,10 @@ int drv_Curs_init(const char *section, const int quiet)
/* real worker functions */
drv_generic_text_real_write = drv_Curs_write;
drv_generic_text_real_defchar = drv_Curs_defchar;
+ drv_generic_keypad_real_press = drv_Curs_keypad;
+
+ /* regularly process display answers */
+ timer_add(drv_Curs_timer, NULL, 100, 0);
/* start display */
if ((ret = drv_Curs_start(section, quiet)) != 0) {
@@ -306,6 +366,10 @@ int drv_Curs_init(const char *section, const int quiet)
if ((ret = drv_generic_text_bar_init(1)) != 0)
return ret;
+ /* initialize generic key pad driver */
+ if ((ret = drv_generic_keypad_init(section, Name)) != 0)
+ return ret;
+
/* add fixed chars to the bar driver */
drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */
drv_generic_text_bar_add_segment(255, 255, 255, '*'); /* asterisk */
@@ -334,6 +398,7 @@ int drv_Curs_quit(const int quiet)
info("%s: shutting down.", Name);
drv_generic_text_quit();
+ drv_generic_keypad_quit();
/* clear display */
drv_Curs_clear();
diff --git a/drv_LCD2USB.c b/drv_LCD2USB.c
index fd48c2e..0c4b6bc 100644
--- a/drv_LCD2USB.c
+++ b/drv_LCD2USB.c
@@ -1,4 +1,4 @@
-/* $Id: drv_LCD2USB.c,v 1.10 2006/04/09 14:17:50 reinelt Exp $
+/* $Id: drv_LCD2USB.c,v 1.11 2006/07/19 01:35:31 cmay Exp $
*
* driver for USB2LCD display interface
* see http://www.harbaum.org/till/lcd2usb for schematics
@@ -24,6 +24,10 @@
*
*
* $Log: drv_LCD2USB.c,v $
+ * Revision 1.11 2006/07/19 01:35:31 cmay
+ * Renamed keypad direction names to avoid conflict with Curses library defs.
+ * Added keypad support to Curses display driver.
+ *
* Revision 1.10 2006/04/09 14:17:50 reinelt
* autoconf/library fixes, image and graphic display inversion
*
@@ -481,15 +485,15 @@ static int drv_L2U_keypad(const int num)
/* check for key press event */
if (num & 0x80)
- val = KEY_PRESSED;
+ val = WIDGET_KEY_PRESSED;
else
- val = KEY_RELEASED;
+ val = WIDGET_KEY_RELEASED;
if ((num & 0x7f) == 0)
- val += KEY_UP;
+ val += WIDGET_KEY_UP;
if ((num & 0x7f) == 1)
- val += KEY_DOWN;
+ val += WIDGET_KEY_DOWN;
return val;
}
@@ -613,7 +617,7 @@ int drv_L2U_init(const char *section, const int quiet)
int asc255bug;
int ret;
- info("%s: %s", Name, "$Revision: 1.10 $");
+ info("%s: %s", Name, "$Revision: 1.11 $");
/* display preferences */
XRES = 5; /* pixel width of one char */
diff --git a/widget_keypad.c b/widget_keypad.c
index d0de69f..fbda930 100644
--- a/widget_keypad.c
+++ b/widget_keypad.c
@@ -1,4 +1,4 @@
-/* $Id: widget_keypad.c,v 1.2 2006/02/21 15:55:59 cmay Exp $
+/* $Id: widget_keypad.c,v 1.3 2006/07/19 01:35:31 cmay Exp $
*
* keypad widget handling
*
@@ -21,6 +21,10 @@
*
*
* $Log: widget_keypad.c,v $
+ * Revision 1.3 2006/07/19 01:35:31 cmay
+ * Renamed keypad direction names to avoid conflict with Curses library defs.
+ * Added keypad support to Curses display driver.
+ *
* Revision 1.2 2006/02/21 15:55:59 cmay
* removed new update function for keypad, consolidated it with draw
*
@@ -108,24 +112,24 @@ int widget_keypad_init(WIDGET * Self)
/* state: pressed (default), released */
c = cfg_get(section, "state", "pressed");
if (!strcasecmp(c, "released"))
- keypad->key = KEY_RELEASED;
+ keypad->key = WIDGET_KEY_RELEASED;
else
- keypad->key = KEY_PRESSED;
+ keypad->key = WIDGET_KEY_PRESSED;
/* position: confirm (default), up, down, left, right, cancel */
c = cfg_get(section, "position", "confirm");
if (!strcasecmp(c, "up"))
- keypad->key += KEY_UP;
+ keypad->key += WIDGET_KEY_UP;
else if (!strcasecmp(c, "down"))
- keypad->key += KEY_DOWN;
+ keypad->key += WIDGET_KEY_DOWN;
else if (!strcasecmp(c, "left"))
- keypad->key += KEY_LEFT;
+ keypad->key += WIDGET_KEY_LEFT;
else if (!strcasecmp(c, "right"))
- keypad->key += KEY_RIGHT;
+ keypad->key += WIDGET_KEY_RIGHT;
else if (!strcasecmp(c, "cancel"))
- keypad->key += KEY_CANCEL;
+ keypad->key += WIDGET_KEY_CANCEL;
else
- keypad->key += KEY_CONFIRM;
+ keypad->key += WIDGET_KEY_CONFIRM;
free(section);
Self->data = keypad;
diff --git a/widget_keypad.h b/widget_keypad.h
index 049cdc3..5918ede 100644
--- a/widget_keypad.h
+++ b/widget_keypad.h
@@ -1,4 +1,4 @@
-/* $Id: widget_keypad.h,v 1.2 2006/02/25 13:36:33 geronet Exp $
+/* $Id: widget_keypad.h,v 1.3 2006/07/19 01:35:31 cmay Exp $
*
* keypad widget handling
*
@@ -23,6 +23,10 @@
*
*
* $Log: widget_keypad.h,v $
+ * Revision 1.3 2006/07/19 01:35:31 cmay
+ * Renamed keypad direction names to avoid conflict with Curses library defs.
+ * Added keypad support to Curses display driver.
+ *
* Revision 1.2 2006/02/25 13:36:33 geronet
* updated indent.sh, applied coding style
*
@@ -36,8 +40,15 @@
#ifndef _WIDGET_KEYPAD_H_
#define _WIDGET_KEYPAD_H_
-typedef enum { KEY_UP = 1, KEY_DOWN = 2, KEY_LEFT = 4, KEY_RIGHT = 8, KEY_CONFIRM = 16, KEY_CANCEL = 32, KEY_PRESSED =
- 64, KEY_RELEASED = 128
+typedef enum {
+ WIDGET_KEY_UP = 1,
+ WIDGET_KEY_DOWN = 2,
+ WIDGET_KEY_LEFT = 4,
+ WIDGET_KEY_RIGHT = 8,
+ WIDGET_KEY_CONFIRM = 16,
+ WIDGET_KEY_CANCEL = 32,
+ WIDGET_KEY_PRESSED = 64,
+ WIDGET_KEY_RELEASED = 128
} KEYPADKEY;
typedef struct WIDGET_KEYPAD {