1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/*
* BRLTTY - A background process providing access to the console screen (when in
* text mode) for a blind person using a refreshable braille display.
*
* Copyright (C) 1995-2010 by The BRLTTY Developers.
*
* BRLTTY comes with ABSOLUTELY NO WARRANTY.
*
* This is free software, placed under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any
* later version. Please see the file LICENSE-GPL for details.
*
* Web Page: http://mielke.cc/brltty/
*
* This software is maintained by Dave Mielke <dave@mielke.cc>.
*/
#include "prologue.h"
#include <stdio.h>
#include "log.h"
#include "touch.h"
#include "brltty.h"
static int touchLeft;
static int touchRight;
static int touchTop;
static int touchBottom;
int
touchGetRegion (int *left, int *right, int *top, int *bottom) {
if ((touchLeft > touchRight) || (touchTop > touchBottom)) return 0;
*left = touchLeft;
*right = touchRight;
*top = touchTop;
*bottom = touchBottom;
return 1;
}
static inline int
touchCheckColumn (BrailleDisplay *brl, const unsigned char *pressure, int column) {
int row;
for (row=touchTop; row<=touchBottom; ++row) {
if (pressure[(row * brl->textColumns) + column]) return 1;
}
return 0;
}
static inline int
touchCheckRow (BrailleDisplay *brl, const unsigned char *pressure, int row) {
int column;
for (column=touchLeft; column<=touchRight; ++column) {
if (pressure[(row * brl->textColumns) + column]) return 1;
}
return 0;
}
static inline int
touchCropLeft (BrailleDisplay *brl, const unsigned char *pressure) {
while (touchLeft <= touchRight) {
if (touchCheckColumn(brl, pressure, touchLeft)) return 1;
++touchLeft;
}
return 0;
}
static inline int
touchCropRight (BrailleDisplay *brl, const unsigned char *pressure) {
while (touchRight >= touchLeft) {
if (touchCheckColumn(brl, pressure, touchRight)) return 1;
--touchRight;
}
return 0;
}
static inline int
touchCropTop (BrailleDisplay *brl, const unsigned char *pressure) {
while (touchTop <= touchBottom) {
if (touchCheckRow(brl, pressure, touchTop)) return 1;
++touchTop;
}
return 0;
}
static inline int
touchCropBottom (BrailleDisplay *brl, const unsigned char *pressure) {
while (touchBottom >= touchTop) {
if (touchCheckRow(brl, pressure, touchBottom)) return 1;
--touchBottom;
}
return 0;
}
static inline int
touchCropWindow (BrailleDisplay *brl, const unsigned char *pressure) {
if (pressure) {
if (touchCropRight(brl, pressure)) {
touchCropLeft(brl, pressure);
touchCropTop(brl, pressure);
touchCropBottom(brl, pressure);
return 1;
}
}
touchBottom = touchTop - 1;
return 0;
}
static inline void
touchUncropWindow (BrailleDisplay *brl) {
touchLeft = textStart;
touchRight = textStart + textCount - 1;
touchTop = 0;
touchBottom = brl->textRows - 1;
}
static inline int
touchRecropWindow (BrailleDisplay *brl, const unsigned char *pressure) {
touchUncropWindow(brl);
return touchCropWindow(brl, pressure);
}
int
touchAnalyzePressure (BrailleDisplay *brl, const unsigned char *pressure) {
if (pressure) {
LogBytes(LOG_DEBUG, "Touch Pressure", pressure, brl->textColumns*brl->textRows);
} else {
LogPrint(LOG_DEBUG, "Touch Pressure off");
}
touchRecropWindow(brl, pressure);
brl->highlightWindow = 1;
return EOF;
}
void
touchAnalyzeCells (BrailleDisplay *brl, const unsigned char *cells) {
}
|