pkgsrc/emulators/xcopilot/patches/patch-ag
wiz 26d51239d9 Add three patches supplied by Dieter Baron <dillo@giga.or.at>:
- When pilot is off, don't redraw contents of screen, clear it
- bind hardware buttons to keys (F9-F12 Applications, pgup/pgdown,
  ESC (power))
- make cursor keys work (left/right, next/previous field)
XXX: homepage (== main download site) doesn't seem to exist any more.
2001-02-12 14:09:24 +00:00

141 lines
3.9 KiB
Text

$NetBSD: patch-ag,v 1.1 2001/02/12 14:09:25 wiz Exp $
--- display.c.orig Tue Aug 25 15:56:02 1998
+++ display.c Tue Feb 6 15:02:19 2001
@@ -272,8 +272,13 @@
}
static int xcpHandleExpose(XEvent *event) {
- xcpPutImage(event->xexpose.x, event->xexpose.y, event->xexpose.width,
- event->xexpose.height);
+ if (shared->LcdPower == lcdOff) {
+ XClearWindow (xcpDisplay, xcpLCDWindow);
+ XFlush(xcpDisplay);
+ }
+ else
+ xcpPutImage(event->xexpose.x, event->xexpose.y, event->xexpose.width,
+ event->xexpose.height);
return event->xexpose.count;
}
@@ -360,15 +365,26 @@
typedef struct _Key {
const char *name;
XRectangle bounds;
+ KeySym key;
} Key;
-static Key keys[] = {{"power", {0, 281, 16, 22}},
- {"up", {100, 280, 25, 12}},
- {"down", {100, 302, 25, 12}},
- {"datebook", {24, 277, 28, 29}},
- {"phone", {63, 277, 28, 29}},
- {"todo", {134, 277, 28, 29}},
- {"memo", {173, 277, 28, 29}}};
+typedef struct _NonprintKey {
+ KeySym sym;
+ int code;
+} NonprintKey;
+
+static Key keys[] = {{"power", {0, 281, 16, 22}, XK_Escape},
+ {"up", {100, 280, 25, 12}, XK_Page_Up},
+ {"down", {100, 302, 25, 12}, XK_Page_Down},
+ {"datebook", {24, 277, 28, 29}, XK_F9},
+ {"phone", {63, 277, 28, 29}, XK_F10},
+ {"todo", {134, 277, 28, 29}, XK_F11},
+ {"memo", {173, 277, 28, 29}, XK_F12}};
+
+static NonprintKey nonprint_keys[] = {{XK_Left, 0x1c /* chrLeftArrow */},
+ {XK_Right, 0x1d /* chrRightArrow */},
+ {XK_Down, 0x103 /* vchrNextField */},
+ {XK_Up, 0x10c /* vchrPrevField */}};
static void HandleKey(Widget w, XtPointer client_data, XEvent *event,
Boolean *continue_to_dispatch)
@@ -502,7 +518,7 @@
{
static KeySym keysym;
static XComposeStatus compose;
- int count, bufsize, in;
+ int count, bufsize, in, i, code;
char buffer[8];
bufsize = 8;
@@ -511,16 +527,55 @@
bufsize,
&keysym,
&compose);
+
+ for (i = 0; i < XtNumber(keys); i++)
+ if (keysym == keys[i].key) {
+ xcpKeyEvent(1, i);
+ return;
+ }
+
+ if (count > 0) {
+ if (buffer[0] == '\r')
+ code = '\n';
+ else
+ code = buffer[0];
+ }
+ else {
+ for (i = 0; i < XtNumber(nonprint_keys); i++)
+ if (keysym == nonprint_keys[i].sym) {
+ count = 1;
+ code = nonprint_keys[i].code;
+ }
+ }
+
if (count > 0) {
- if (buffer[0] == '\r') {
- buffer[0] = '\n';
- }
in = shptr->kbin;
- shptr->kb[in] = buffer[0];
+ shptr->kb[in] = code;
shptr->kbin = (in + 1) & 7;
}
}
+static void xcpKBKey(XEvent *event)
+{
+ static KeySym keysym;
+ static XComposeStatus compose;
+ int count, bufsize, in, i;
+ char buffer[8];
+
+ bufsize = 8;
+ count = XLookupString((XKeyEvent *) event,
+ buffer,
+ bufsize,
+ &keysym,
+ &compose);
+
+ for (i = 0; i < XtNumber(keys); i++)
+ if (keysym == keys[i].key) {
+ xcpKeyEvent(0, i);
+ return;
+ }
+}
+
static void HandleClientMessage(Widget w, XtPointer client_data, XEvent *event,
Boolean *continue_to_dispatch)
{
@@ -542,6 +597,8 @@
case KeyPress:
xcpKBtoASCII(shptr, event);
break;
+ case KeyRelease:
+ xcpKBKey(event);
case ButtonPress: /* a mouse button was pressed */
if (event->xbutton.button == 3)
do_menu(event->xbutton.x_root, event->xbutton.y_root);
@@ -623,7 +680,7 @@
XtNborder, BlackPixel(xcpDisplay, xcpScreenNum), NULL);
XtAddEventHandler(topWidget, ButtonPressMask | KeyPressMask |
- OwnerGrabButtonMask, False, HandleXEvents,
+ KeyReleaseMask | OwnerGrabButtonMask, False, HandleXEvents,
(XtPointer)shptr);
/*