fixed code indents and quote marks in text files

This commit is contained in:
2021-08-18 21:46:19 -06:00
parent 79a777b22d
commit a0993bceca
18 changed files with 494 additions and 495 deletions

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -66,7 +66,7 @@ static void run_exit_funcs(void)
{
int i;
PEXITFUNCBLOCK p;
while (exitfuncs)
{
p = exitfuncs;
@@ -109,36 +109,36 @@ static HRESULT parse_cmdline(int argc, char *argv[], GLOBAL_CONFIG *parsed)
switch (c)
{
case 'F': /* frame buffer device name */
pstr = strdup(optarg);
if (!pstr)
{
Log(LERROR, "Out of memory in parse_cmdline");
return E_OUTOFMEMORY;
}
if (parsed->framebuffer_device)
free((PVOID)(parsed->framebuffer_device));
parsed->framebuffer_device = pstr;
break;
pstr = strdup(optarg);
if (!pstr)
{
Log(LERROR, "Out of memory in parse_cmdline");
return E_OUTOFMEMORY;
}
if (parsed->framebuffer_device)
free((PVOID)(parsed->framebuffer_device));
parsed->framebuffer_device = pstr;
break;
case 'h': /* show help */
help = TRUE;
break;
help = TRUE;
break;
case 'T': /* touchscreen device name */
pstr = strdup(optarg);
if (!pstr)
{
Log(LERROR, "Out of memory in parse_cmdline");
return E_OUTOFMEMORY;
}
if (parsed->touchscreen_device)
free((PVOID)(parsed->touchscreen_device));
parsed->touchscreen_device = pstr;
break;
pstr = strdup(optarg);
if (!pstr)
{
Log(LERROR, "Out of memory in parse_cmdline");
return E_OUTOFMEMORY;
}
if (parsed->touchscreen_device)
free((PVOID)(parsed->touchscreen_device));
parsed->touchscreen_device = pstr;
break;
default:
fprintf(stderr, "%s: unexpected option -%c\n", argv[0], c);
return E_UNEXPECTED;
fprintf(stderr, "%s: unexpected option -%c\n", argv[0], c);
return E_UNEXPECTED;
}
}
if (help)
@@ -167,17 +167,17 @@ static HRESULT parse_cmdline(int argc, char *argv[], GLOBAL_CONFIG *parsed)
pargs = (PPCSTR)malloc(sizeof(PCSTR) * parsed->script_arg_count);
if (!pargs)
{
Log(LERROR, "Out of memory in parse_cmdline");
return E_OUTOFMEMORY;
Log(LERROR, "Out of memory in parse_cmdline");
return E_OUTOFMEMORY;
}
for (c = 0; c < parsed->script_arg_count; c++)
{
pargs[c] = strdup(argv[optind++]);
if (!(pargs[c]))
{
Log(LERROR, "Out of memory in parse_cmdline");
return E_OUTOFMEMORY;
}
pargs[c] = strdup(argv[optind++]);
if (!(pargs[c]))
{
Log(LERROR, "Out of memory in parse_cmdline");
return E_OUTOFMEMORY;
}
}
parsed->script_args = pargs;
}
@@ -187,7 +187,7 @@ static HRESULT parse_cmdline(int argc, char *argv[], GLOBAL_CONFIG *parsed)
fprintf(stderr, "%s: no script specified\n", argv[0]);
return UPIWIN_E_NOSCRIPT;
}
return S_OK;
}
@@ -207,13 +207,13 @@ HRESULT Config_setup(int argc, char *argv[])
{
HRESULT hr;
GLOBAL_CONFIG from_commandline;
if (geteuid() != 0)
{
Log(LFATAL, "upiwin must be run with root privileges");
return E_ACCESSDENIED;
Log(LFATAL, "upiwin must be run with root privileges");
return E_ACCESSDENIED;
}
if (atexit(run_exit_funcs))
{
Log(LFATAL, "Unable to set up exit function mechanism");
@@ -236,7 +236,7 @@ HRESULT Config_setup(int argc, char *argv[])
HRESULT Config_exitfunc(PEXITFUNC pfn)
{
PEXITFUNCBLOCK p;
if (!exitfuncs || (exitfuncs->num_funcs == EXITFUNCBLOCK_FUNCCOUNT))
{
p = (PEXITFUNCBLOCK)malloc(sizeof(EXITFUNCBLOCK));

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -41,42 +41,42 @@ inline static COLORREF COLORREF_from_native(UINT16 cr)
return (COLORREF)(((tmp << 19) & 0xF80000) | ((tmp << 5) & 0xFC00) | ((tmp >> 8) & 0xF800));
}
static inline UINT16 apply_rop2(INT32 op, UINT16 disp, UINT16 pen)
inline static UINT16 apply_rop2(INT32 op, UINT16 disp, UINT16 pen)
{
switch (op)
{
case R2_BLACK:
return 0;
case R2_NOTMERGEPEN:
return ~(disp | pen);
case R2_MASKNOTPEN:
return disp & (~pen);
case R2_NOTCOPYPEN:
return ~pen;
case R2_MASKPENNOT:
return (~disp) & pen;
case R2_NOT:
return ~disp;
return 0;
case R2_NOTMERGEPEN:
return ~(disp | pen);
case R2_MASKNOTPEN:
return disp & (~pen);
case R2_NOTCOPYPEN:
return ~pen;
case R2_MASKPENNOT:
return (~disp) & pen;
case R2_NOT:
return ~disp;
case R2_XORPEN:
return disp ^ pen;
case R2_NOTMASKPEN:
return ~(disp & pen);
case R2_MASKPEN:
return disp & pen;
case R2_NOTXORPEN:
return ~(disp ^ pen);
return disp ^ pen;
case R2_NOTMASKPEN:
return ~(disp & pen);
case R2_MASKPEN:
return disp & pen;
case R2_NOTXORPEN:
return ~(disp ^ pen);
case R2_NOP:
return disp;
case R2_MERGENOTPEN:
return disp | (~pen);
return disp;
case R2_MERGENOTPEN:
return disp | (~pen);
case R2_COPYPEN:
return pen;
case R2_MERGEPENNOT:
return (~disp) | pen;
case R2_MERGEPEN:
return disp | pen;
case R2_WHITE:
return (UINT16)(-1);
return pen;
case R2_MERGEPENNOT:
return (~disp) | pen;
case R2_MERGEPEN:
return disp | pen;
case R2_WHITE:
return (UINT16)(-1);
}
return pen; /* last ditch default */
}
@@ -99,7 +99,7 @@ static BOOL screen_line(PVOID privdata, INT32 x1, INT32 y1, INT32 x2, INT32 y2,
INT32 dy = y2 - y1;
INT32 tmp;
PUINT16 loc;
ASSERT(x1 >= 0);
ASSERT(x1 < Fb_Info->width);
ASSERT(y1 >= 0);
@@ -108,67 +108,67 @@ static BOOL screen_line(PVOID privdata, INT32 x1, INT32 y1, INT32 x2, INT32 y2,
ASSERT(x2 < Fb_Info->width);
ASSERT(y2 >= 0);
ASSERT(y2 < Fb_Info->height);
/* uses Bresenham's line algorithm with 16-bit fixed-point arithmetic */
if (ABS(dx) < ABS(dy))
{
if (y1 > y2)
{
tmp = x1;
x1 = x2;
x2 = tmp;
tmp = y1;
y1 = y2;
y2 = tmp;
dx = -dx;
dy = -dy;
}
loc = loc_from_coords(priv, x1, y1);
tmp = x1;
x1 <<= 16;
dx = (dx << 16) / dy;
while (y1 <= y2)
{
*loc = apply_rop2(op, *loc, pencolor);
x1 += dx;
++y1;
loc += priv->pix_per_row;
if (tmp != (x1 >> 16))
{
loc += ((x1 >> 16) - tmp);
tmp = x1 >> 16;
}
}
{
tmp = x1;
x1 = x2;
x2 = tmp;
tmp = y1;
y1 = y2;
y2 = tmp;
dx = -dx;
dy = -dy;
}
loc = loc_from_coords(priv, x1, y1);
tmp = x1;
x1 <<= 16;
dx = (dx << 16) / dy;
while (y1 <= y2)
{
*loc = apply_rop2(op, *loc, pencolor);
x1 += dx;
++y1;
loc += priv->pix_per_row;
if (tmp != (x1 >> 16))
{
loc += ((x1 >> 16) - tmp);
tmp = x1 >> 16;
}
}
}
else
{
if (x1 > x2)
{
tmp = x1;
x1 = x2;
x2 = tmp;
tmp = y1;
y1 = y2;
y2 = tmp;
dx = -dx;
dy = -dy;
}
loc = loc_from_coords(priv, x1, y1);
tmp = y1;
{
tmp = x1;
x1 = x2;
x2 = tmp;
tmp = y1;
y1 = y2;
y2 = tmp;
dx = -dx;
dy = -dy;
}
loc = loc_from_coords(priv, x1, y1);
tmp = y1;
y1 <<= 16;
dy = dx ? (dy << 16) / dx : 0;
while (x1 <= x2)
{
*loc = apply_rop2(op, *loc, pencolor);
y1 += dy;
++x1;
++loc;
if (tmp != (y1 >> 16))
{
loc += (((y1 >> 16) - tmp) * priv->pix_per_row);
tmp = y1 >> 16;
}
}
while (x1 <= x2)
{
*loc = apply_rop2(op, *loc, pencolor);
y1 += dy;
++x1;
++loc;
if (tmp != (y1 >> 16))
{
loc += (((y1 >> 16) - tmp) * priv->pix_per_row);
tmp = y1 >> 16;
}
}
}
return TRUE;
}
@@ -179,17 +179,17 @@ static BOOL screen_solid_rect(PVOID privdata, PRECT rect, COLORREF color, INT32
UINT16 pencolor = native_from_COLORREF(color);
PUINT16 ps, p;
int y, x;
ps = loc_from_coords(priv, rect->left, rect->top);
for (y = rect->top; y < rect->bottom; y++)
{
p = ps;
for (x = rect->left; x < rect->right; x++)
{
*p = apply_rop2(op, *p, pencolor);
++p;
}
ps += priv->pix_per_row;
for (x = rect->left; x < rect->right; x++)
{
*p = apply_rop2(op, *p, pencolor);
++p;
}
ps += priv->pix_per_row;
}
return TRUE;
}
@@ -202,7 +202,7 @@ static PDCTXT screen_create_compat(PVOID privdata)
PSCREENPRIVDATA priv_new;
PBITMAP pbmp;
PDCTXT rc;
pbmp = BMP_Create(1, 1, NULL);
if (!pbmp)
return NULL;
@@ -214,22 +214,22 @@ static PDCTXT screen_create_compat(PVOID privdata)
}
priv_new->pix_per_row = pbmp->width;
priv_new->pdata = pbmp->bits;
rc = _DC_Allocate(&screen_funtable, priv_new);
if (rc)
{
rc->hdr.dtor = screen_context_destroy;
rc->flags = DCFLG_IS_MEMORY;
rc->baserect.left = rc->baserect.top = 0;
rc->baserect.right = pbmp->width;
rc->baserect.bottom = pbmp->height;
memcpy(&(rc->cliprect), &(rc->baserect), sizeof(RECT));
rc->cur_bitmap = pbmp;
rc->flags = DCFLG_IS_MEMORY;
rc->baserect.left = rc->baserect.top = 0;
rc->baserect.right = pbmp->width;
rc->baserect.bottom = pbmp->height;
memcpy(&(rc->cliprect), &(rc->baserect), sizeof(RECT));
rc->cur_bitmap = pbmp;
}
else
{
free(priv_new);
Go_release(&(pbmp->hdr));
Go_release(&(pbmp->hdr));
}
return rc;
}
@@ -248,7 +248,7 @@ BOOL screen_bitblt(PVOID p_dest, PRECT r_dest, PVOID p_src, PRECT r_src, UINT32
PSCREENPRIVDATA src = (PSCREENPRIVDATA)p_src;
PUINT16 pd, ps;
INT32 width, i;
pd = loc_from_coords(dest, r_dest->left, r_dest->top);
ps = loc_from_coords(src, r_src->left, r_src->top);
width = r_src->right - r_src->left;
@@ -256,7 +256,7 @@ BOOL screen_bitblt(PVOID p_dest, PRECT r_dest, PVOID p_src, PRECT r_src, UINT32
{
memcpy(pd, ps, width * sizeof(UINT16));
pd += dest->pix_per_row;
ps += src->pix_per_row;
ps += src->pix_per_row;
}
return TRUE;
}
@@ -281,22 +281,22 @@ PDCTXT DC_CreateScreenContext(void)
{
PDCTXT rc;
PSCREENPRIVDATA priv;
priv = (PSCREENPRIVDATA)malloc(sizeof(SCREENPRIVDATA));
if (!priv)
return NULL;
priv->pix_per_row = Fb_Info->width;
priv->pdata = Fb_Ptr;
rc = _DC_Allocate(&screen_funtable, priv);
if (rc)
{
rc->hdr.dtor = screen_context_destroy;
rc->flags = DCFLG_IS_SCREEN;
rc->baserect.left = rc->baserect.top = 0;
rc->baserect.right = Fb_Info->width;
rc->baserect.bottom = Fb_Info->height;
memcpy(&(rc->cliprect), &(rc->baserect), sizeof(RECT));
rc->flags = DCFLG_IS_SCREEN;
rc->baserect.left = rc->baserect.top = 0;
rc->baserect.right = Fb_Info->width;
rc->baserect.bottom = Fb_Info->height;
memcpy(&(rc->cliprect), &(rc->baserect), sizeof(RECT));
}
else
free(priv);

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -53,51 +53,51 @@ static BOOL line_clip(PINT32 output, INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT
BYTE outcode1, outcode2;
INT32 tmp;
int nloop = 0;
/* Cohen-Sutherland line-clipping algorithm (see Foley & Van Dam, pp. 145-149) */
for (;;)
{
if (++nloop == 20)
{
Log(LDEBUG, "POSSIBLE INFINITE LOOP DETECTED - REJECTING");
return FALSE;
}
{
Log(LDEBUG, "POSSIBLE INFINITE LOOP DETECTED - REJECTING");
return FALSE;
}
outcode1 = line_clip_outcode(x1, y1, xmin, ymin, xmax, ymax);
outcode2 = line_clip_outcode(x2, y2, xmin, ymin, xmax, ymax);
if ((outcode1 & outcode2) != 0)
return FALSE; /* trivial rejection */
else if ((outcode1 == 0) && (outcode2 == 0))
break; /* trivial acceptance */
if (outcode1 == 0)
{
tmp = x1;
x1 = x2;
x2 = tmp;
tmp = y1;
y1 = y2;
y2 = tmp;
outcode1 = outcode2; /* we don't reference outcode2 in the rest of the loop */
}
if (outcode1 & 0x8)
{
x1 += M(x2 - x1, D(ymin - y1, y2 - y1));
y1 = ymin;
}
else if (outcode1 & 0x4)
{
x1 += M(x2 - x1, D(ymax - ONE - y1, y2 - y1));
y1 = ymax - ONE;
}
else if (outcode1 & 0x2)
{
y1 += M(y2 - y1, D(xmax - ONE - x1, x2 - x1));
x1 = xmax - ONE;
}
else if (outcode1 & 0x1)
{
y1 += M(y2 - y1, D(xmin - x1, x2 - x1));
x1 = xmin;
}
outcode2 = line_clip_outcode(x2, y2, xmin, ymin, xmax, ymax);
if ((outcode1 & outcode2) != 0)
return FALSE; /* trivial rejection */
else if ((outcode1 == 0) && (outcode2 == 0))
break; /* trivial acceptance */
if (outcode1 == 0)
{
tmp = x1;
x1 = x2;
x2 = tmp;
tmp = y1;
y1 = y2;
y2 = tmp;
outcode1 = outcode2; /* we don't reference outcode2 in the rest of the loop */
}
if (outcode1 & 0x8)
{
x1 += M(x2 - x1, D(ymin - y1, y2 - y1));
y1 = ymin;
}
else if (outcode1 & 0x4)
{
x1 += M(x2 - x1, D(ymax - ONE - y1, y2 - y1));
y1 = ymax - ONE;
}
else if (outcode1 & 0x2)
{
y1 += M(y2 - y1, D(xmax - ONE - x1, x2 - x1));
x1 = xmax - ONE;
}
else if (outcode1 & 0x1)
{
y1 += M(y2 - y1, D(xmin - x1, x2 - x1));
x1 = xmin;
}
}
output[0] = x1;
output[1] = y1;
@@ -137,7 +137,7 @@ void _DC_FinalizeCommon(PDCTXT pdctxt)
COLORREF DC_SetPixel(PDCTXT pdctxt, INT32 x, INT32 y, COLORREF color)
{
if (!G_coords_in_rect(&(pdctxt->cliprect), x, y))
return (COLORREF)(-1);
return (COLORREF)(-1);
return (*(pdctxt->funcs->set_pixel))(pdctxt->privdata, x, y, color, pdctxt->rop2);
}
@@ -147,7 +147,7 @@ BOOL DC_LineTo(PDCTXT pdctxt, INT32 x, INT32 y)
if (rc)
{
pdctxt->pos.x = x;
pdctxt->pos.y = y;
pdctxt->pos.y = y;
}
return rc;
}
@@ -227,22 +227,22 @@ PGFXOBJECT DC_SelectObject(PDCTXT pdctxt, PGFXOBJECT pobj)
if (pobj->sig == BMP_SIG_WORD)
{
if ((pdctxt->flags & DCFLG_TYPES) == DCFLG_IS_MEMORY)
{
RECT rtmp;
{
RECT rtmp;
PBITMAP rbmp = pdctxt->cur_bitmap;
Go_addref(pobj);
if ((*(pdctxt->funcs->new_bitmap))(pdctxt->privdata, (PBITMAP)pobj))
{
pdctxt->cur_bitmap = (PBITMAP)pobj;
pdctxt->baserect.left = pdctxt->baserect.top = 0;
pdctxt->baserect.right = ((PBITMAP)pobj)->width;
pdctxt->baserect.bottom = ((PBITMAP)pobj)->height;
G_rect_intersect(&rtmp, &(pdctxt->baserect), &(pdctxt->cliprect));
memcpy(&(pdctxt->cliprect), &rtmp, sizeof(RECT));
return (PGFXOBJECT)rbmp;
}
Go_release(pobj);
}
if ((*(pdctxt->funcs->new_bitmap))(pdctxt->privdata, (PBITMAP)pobj))
{
pdctxt->cur_bitmap = (PBITMAP)pobj;
pdctxt->baserect.left = pdctxt->baserect.top = 0;
pdctxt->baserect.right = ((PBITMAP)pobj)->width;
pdctxt->baserect.bottom = ((PBITMAP)pobj)->height;
G_rect_intersect(&rtmp, &(pdctxt->baserect), &(pdctxt->cliprect));
memcpy(&(pdctxt->cliprect), &rtmp, sizeof(RECT));
return (PGFXOBJECT)rbmp;
}
Go_release(pobj);
}
}
return NULL;
}
@@ -250,7 +250,7 @@ PGFXOBJECT DC_SelectObject(PDCTXT pdctxt, PGFXOBJECT pobj)
BOOL DC_BitBlt(PDCTXT dest, INT32 x, INT32 y, INT32 width, INT32 height, PDCTXT source, INT32 x1, INT32 y1, UINT32 rop)
{
RECT destrect, actualdest, srcrect, actualsrc;
G_set_rect(&destrect, x, y, x + width, y + height);
if (!G_rect_intersect(&actualdest, &destrect, &(dest->cliprect)))
return TRUE; /* no-op */

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -63,18 +63,18 @@ static int bitmap_init(BitmapObject *self, PyObject *args, PyObject *kwds)
static char *kwlist[] = { "stock", "width", "height", NULL };
const char *stock;
int width = 0, height = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|$sii", kwlist, &stock, &width, &height))
return -1;
if (stock)
{
self->pbmp = _BMP_GetStock(stock);
if (!(self->pbmp))
{
PyErr_Format(PyExc_RuntimeError, "no such stock bitmap: '%s'", stock);
return -1;
}
self->pbmp = _BMP_GetStock(stock);
if (!(self->pbmp))
{
PyErr_Format(PyExc_RuntimeError, "no such stock bitmap: '%s'", stock);
return -1;
}
}
else
{
@@ -83,8 +83,8 @@ static int bitmap_init(BitmapObject *self, PyObject *args, PyObject *kwds)
self->pbmp = BMP_Create(width, height, NULL);
if (!(self->pbmp))
{
PyErr_SetString(PyExc_RuntimeError, "unable to create bitmap");
return -1;
PyErr_SetString(PyExc_RuntimeError, "unable to create bitmap");
return -1;
}
}
return 0;
@@ -114,12 +114,12 @@ PyTypeObject BitmapType = {
HRESULT Epython_register_bitmap(PyObject *module)
{
if (PyType_Ready(&BitmapType) < 0)
return E_FAIL;
return E_FAIL;
Py_INCREF(&BitmapType);
if (PyModule_AddObject(module, "Bitmap", (PyObject *)(&BitmapType)) < 0)
{
Py_DECREF(&BitmapType);
return E_FAIL;
return E_FAIL;
}
return S_OK;
}
@@ -128,26 +128,26 @@ PyObject *Epython_wrap_bitmap(PBITMAP pbmp)
{
PyObject *rc = NULL, *args, *kwargs;
BitmapObject *pbitmapobj;
args = PyTuple_New(0);
if (args)
{
kwargs = PyDict_New();
if (kwargs)
{
rc = PyType_GenericNew(&BitmapType, args, kwargs);
if (rc)
{
pbitmapobj = (BitmapObject *)rc;
if (pbitmapobj->pbmp)
BMP_Delete(pbitmapobj->pbmp);
pbitmapobj->pbmp = pbmp;
}
Py_DECREF(kwargs);
}
kwargs = PyDict_New();
if (kwargs)
{
rc = PyType_GenericNew(&BitmapType, args, kwargs);
if (rc)
{
pbitmapobj = (BitmapObject *)rc;
if (pbitmapobj->pbmp)
BMP_Delete(pbitmapobj->pbmp);
pbitmapobj->pbmp = pbmp;
}
Py_DECREF(kwargs);
}
Py_DECREF(args);
}
if (!rc)
PyErr_SetString(PyExc_RuntimeError, "unable to create bitmap");
return rc;

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -32,7 +32,7 @@ static PyObject *devctxt_set_pixel(DevCtxtObject *self, PyObject *args)
{
INT32 x, y;
COLORREF color, rc;
if (!PyArg_ParseTuple(args, "iik", &x, &y, &color))
return NULL;
if (!(self->pdctxt))
@@ -80,7 +80,7 @@ static PyObject *devctxt_rectangle(DevCtxtObject *self, PyObject *args)
{
INT32 left, top, right, bottom;
BOOL rc;
if (!PyArg_ParseTuple(args, "iiii", &left, &top, &right, &bottom))
return NULL;
if (!(self->pdctxt))
@@ -96,7 +96,7 @@ static PyObject *devctxt_solid_rectangle(DevCtxtObject *self, PyObject *args)
{
INT32 left, top, right, bottom;
BOOL rc;
if (!PyArg_ParseTuple(args, "iiii", &left, &top, &right, &bottom))
return NULL;
if (!(self->pdctxt))
@@ -114,7 +114,7 @@ static PyObject *devctxt_bitblt(DevCtxtObject *self, PyObject *args)
UINT32 rop;
DevCtxtObject *source;
BOOL rc;
if (!PyArg_ParseTuple(args, "iiiiO!iik", &x, &y, &width, &height, &DevCtxtType, &source, &x1, &y1, &rop))
return NULL;
if (!(self->pdctxt) || !(source->pdctxt))
@@ -130,7 +130,7 @@ static PyObject *devctxt_bitblt(DevCtxtObject *self, PyObject *args)
static PyObject *devctxt_get_clip_rect(DevCtxtObject *self, PyObject *args)
{
RECT rect;
if (!PyArg_ParseTuple(args, ""))
return NULL;
if (!(self->pdctxt))
@@ -146,7 +146,7 @@ static PyObject *devctxt_set_clip_rect(DevCtxtObject *self, PyObject *args)
{
RECT rect;
BOOL rc;
if (!PyArg_ParseTuple(args, "iiii", &(rect.left), &(rect.top), &(rect.right), &(rect.bottom)))
return NULL;
if (!(self->pdctxt))
@@ -162,27 +162,27 @@ static PyObject *devctxt_select_bitmap(DevCtxtObject *self, BitmapObject *newbmp
{
BitmapObject *old_bitmap = NULL;
PBITMAP old_pbmp;
if ((self->pdctxt->flags & DCFLG_TYPES) != DCFLG_IS_MEMORY)
{
PyErr_SetString(PyExc_RuntimeError, "must select bitmap into memory device context");
return NULL;
return NULL;
}
old_bitmap = self->selected_bitmap;
old_bitmap = self->selected_bitmap;
old_pbmp = (PBITMAP)DC_SelectObject(self->pdctxt, (PGFXOBJECT)(newbmp->pbmp));
if (!old_bitmap)
{
old_bitmap = (BitmapObject *)Epython_wrap_bitmap(old_pbmp);
if (!old_bitmap)
{
DC_SelectObject(self->pdctxt, (PGFXOBJECT)old_pbmp);
return NULL;
}
else
{
Py_INCREF(old_bitmap);
self->selected_bitmap = old_bitmap;
}
if (!old_bitmap)
{
DC_SelectObject(self->pdctxt, (PGFXOBJECT)old_pbmp);
return NULL;
}
else
{
Py_INCREF(old_bitmap);
self->selected_bitmap = old_bitmap;
}
}
ASSERT(old_bitmap);
ASSERT(self->selected_bitmap);
@@ -202,7 +202,7 @@ static PyObject *devctxt_select_object(DevCtxtObject *self, PyObject *args)
if (!obj)
{
PyErr_SetString(PyExc_RuntimeError, "bad object selected");
return NULL;
return NULL;
}
if (PyObject_TypeCheck(obj, &BitmapType))
return devctxt_select_bitmap(self, (BitmapObject *)obj);
@@ -245,7 +245,7 @@ static PyObject *devctxt_get_rop2(DevCtxtObject *self, void *closure)
static int devctxt_set_rop2(DevCtxtObject *self, PyObject *value, void *closure)
{
UINT32 v;
if (!(self->pdctxt))
{
PyErr_SetString(PyExc_RuntimeError, "bad device context");
@@ -276,7 +276,7 @@ static PyObject *devctxt_get_text_color(DevCtxtObject *self, void *closure)
static int devctxt_set_text_color(DevCtxtObject *self, PyObject *value, void *closure)
{
COLORREF v;
if (!(self->pdctxt))
{
PyErr_SetString(PyExc_RuntimeError, "bad device context");
@@ -313,31 +313,31 @@ static int devctxt_init(DevCtxtObject *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = { "type", NULL };
const char *type;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "$s", kwlist, &type))
return -1;
if (strcmp(type, "screen") == 0)
{
self->pdctxt = DC_CreateScreenContext();
if (!(self->pdctxt))
if (!(self->pdctxt))
{
PyErr_SetString(PyExc_RuntimeError, "unable to create screen context");
return -1;
}
PyErr_SetString(PyExc_RuntimeError, "unable to create screen context");
return -1;
}
}
else if (strcmp(type, "memory") == 0)
{
self->pdctxt = _DC_CreateScreenCompatibleContext();
if (!(self->pdctxt))
if (!(self->pdctxt))
{
PyErr_SetString(PyExc_RuntimeError, "unable to create memory context");
return -1;
}
PyErr_SetString(PyExc_RuntimeError, "unable to create memory context");
return -1;
}
}
else
{
PyErr_Format(PyExc_RuntimeError, "invalid type '%s'", type);
return -1;
return -1;
}
return 0;
}
@@ -364,7 +364,7 @@ HRESULT Epython_register_devctxt(PyObject *module)
if (PyModule_AddObject(module, "DevCtxt", (PyObject *)(&DevCtxtType)) < 0)
{
Py_DECREF(&DevCtxtType);
return E_FAIL;
return E_FAIL;
}
return S_OK;
}

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -131,29 +131,29 @@ HRESULT Epython_run(void)
{
for (i=0; i<Gconfig.script_arg_count; i++)
{
args[i + 1] = Py_DecodeLocale(Gconfig.script_args[i], NULL);
if (!(args[i + 1]))
{
hr = E_OUTOFMEMORY;
break;
}
args[i + 1] = Py_DecodeLocale(Gconfig.script_args[i], NULL);
if (!(args[i + 1]))
{
hr = E_OUTOFMEMORY;
break;
}
}
if (SUCCEEDED(hr))
{
PySys_SetArgvEx(Gconfig.script_arg_count + 1, args, 1);
PyRun_SimpleFile(fp, Gconfig.script_name);
PySys_SetArgvEx(Gconfig.script_arg_count + 1, args, 1);
PyRun_SimpleFile(fp, Gconfig.script_name);
}
else
Log(LERROR, "out of memory running script %s", Gconfig.script_name);
Log(LERROR, "out of memory running script %s", Gconfig.script_name);
}
else
{
{
Log(LERROR, "out of memory running script %s", Gconfig.script_name);
hr = E_OUTOFMEMORY;
}
for (i = 0; i<(Gconfig.script_arg_count + 1); i++)
if (args[i])
PyMem_RawFree(args[i]);
PyMem_RawFree(args[i]);
fclose(fp);
}
else

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -29,29 +29,29 @@
static HRESULT convert_msg(PyObject *target, PMSG source)
{
PyObject *attr;
ASSERT(PyDict_CheckExact(target));
PyDict_Clear(target);
attr = PyLong_FromUnsignedLong(source->target);
if (!attr)
return E_FAIL;
if (PyDict_SetItemString(target, "target", attr))
return E_FAIL;
return E_FAIL;
attr = PyLong_FromUnsignedLong(source->message);
if (!attr)
return E_FAIL;
if (PyDict_SetItemString(target, "message", attr))
return E_FAIL;
return E_FAIL;
attr = Py_BuildValue("[k,k]", source->attrs[0], source->attrs[1]);
if (!attr)
return E_FAIL;
if (PyDict_SetItemString(target, "attrs", attr))
return E_FAIL;
return E_FAIL;
attr = PyLong_FromUnsignedLongLong(source->timestamp);
if (!attr)
return E_FAIL;
if (PyDict_SetItemString(target, "timestamp", attr))
return E_FAIL;
return E_FAIL;
return S_OK;
}
@@ -59,20 +59,20 @@ PyObject *Epython_get_message(PyObject *self, PyObject *args)
{
PyObject *out;
MSG msg;
if (!PyArg_ParseTuple(args, "O!", &PyDict_Type, &out))
return NULL;
/* release the GIL to allow us to block waiting for input if necessary */
Py_BEGIN_ALLOW_THREADS
while (!Mq_peek(Sys_Queue, &msg, PEEK_REMOVE))
Sys_wait_for_input();
Py_END_ALLOW_THREADS
if (FAILED(convert_msg(out, &msg)))
{
PyErr_SetString(PyExc_RuntimeError, "could not convert received message");
return NULL;
return NULL;
}
return PyBool_FromLong(msg.message != WM_QUIT);
}
@@ -80,11 +80,10 @@ PyObject *Epython_get_message(PyObject *self, PyObject *args)
PyObject *Epython_post_quit_message(PyObject *self, PyObject *args)
{
INT32 exitcode;
if (!PyArg_ParseTuple(args, "i", &exitcode))
return NULL;
Sys_Exit_Code = exitcode;
Mq_post1(Sys_Queue, 0, WM_QUIT, exitcode);
Py_RETURN_NONE;
}

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -94,33 +94,33 @@ PyObject *Epython_init_upiwin_module(void)
{
PyObject *module;
PUPIWIN_STATE pstate;
module = PyModule_Create(&DefUPIWIN);
if (!module)
return NULL;
if (FAILED(Epython_register_constants(module, UPIWINConstants)))
{
Py_DECREF(module);
return NULL;
Py_DECREF(module);
return NULL;
}
if (FAILED(Epython_register_bitmap(module)))
{
Py_DECREF(module);
return NULL;
return NULL;
}
if (FAILED(Epython_register_devctxt(module)))
{
Py_DECREF(module);
return NULL;
Py_DECREF(module);
return NULL;
}
/* set up the module state */
pstate = (PUPIWIN_STATE)PyModule_GetState(module);
pstate->backlight_on = TRUE;
pstate->backlight_level = GSB_BACKLIGHT_DEFAULT;
return module;
}

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -119,15 +119,15 @@ END_CONSTANT_TABLE
PyObject *Epython_init_upiwin_tmp_module(void)
{
PyObject *module;
module = PyModule_Create(&DefUPIWIN_tmp);
if (module)
{
if (FAILED(Epython_register_constants(module, UPIWIN_tmpConstants)))
{
Py_DECREF(module);
module = NULL;
}
if (FAILED(Epython_register_constants(module, UPIWIN_tmpConstants)))
{
Py_DECREF(module);
module = NULL;
}
}
return module;
}

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -46,7 +46,7 @@ void Epython_log_object(int level, const char *label, PyObject *object)
HRESULT Epython_trace_exception(void)
{
HRESULT hr = E_FAIL;
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
if (!type)
@@ -66,29 +66,29 @@ HRESULT Epython_register_constants(PyObject *module, PCREGCONSTANT const_table)
{
HRESULT hr = S_OK;
int i = 0, rc;
while (const_table[i].name)
{
switch (const_table[i].regtype)
{
case 'i':
rc = PyModule_AddIntConstant(module, const_table[i].name, const_table[i].value.ival);
break;
case 's':
rc = PyModule_AddStringConstant(module, const_table[i].name, const_table[i].value.sval);
break;
default:
Log(LERROR, "register_constants type '%c' unknown", const_table[i].regtype);
return E_UNEXPECTED;
}
if (rc)
{
Log(LERROR, "Failed to register constant %s", const_table[i].name);
hr = E_FAIL;
break;
}
++i;
{
case 'i':
rc = PyModule_AddIntConstant(module, const_table[i].name, const_table[i].value.ival);
break;
case 's':
rc = PyModule_AddStringConstant(module, const_table[i].name, const_table[i].value.sval);
break;
default:
Log(LERROR, "register_constants type '%c' unknown", const_table[i].regtype);
return E_UNEXPECTED;
}
if (rc)
{
Log(LERROR, "Failed to register constant %s", const_table[i].name);
hr = E_FAIL;
break;
}
++i;
}
return hr;
}

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -52,9 +52,9 @@ static void do_cleanup(void)
{
/* black out the display */
memset(Fb_Ptr, 0, local_info.screenbytes);
munmap((void *)Fb_Ptr, local_info.screenbytes);
Fb_Ptr = NULL;
Fb_Ptr = NULL;
close(fb_fd);
fb_fd = -1;
}
@@ -64,7 +64,7 @@ HRESULT Fb_setup(void)
HRESULT hr = S_OK;
struct fb_fix_screeninfo fixed;
struct fb_var_screeninfo var;
fb_fd = open(Gconfig.framebuffer_device, O_RDWR);
if (fb_fd == -1)
{

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -32,7 +32,7 @@ void _Go_init(PGFXOBJECT obj, UINT32 sig, UINT32 size)
void Go_unchain(PGFXOBJECT obj)
{
if (!(obj->next || obj->prev))
return;
return;
if (obj->next)
obj->next->prev = obj->prev;
if (obj->prev)
@@ -50,9 +50,9 @@ INT32 Go_release(PGFXOBJECT obj)
int rc = --(obj->refcnt);
if (rc == 0)
{
if (obj->dtor)
(*(obj->dtor))(obj);
free(obj);
if (obj->dtor)
(*(obj->dtor))(obj);
free(obj);
}
return rc;
}

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -67,9 +67,9 @@ static const STOCKBITMAPDESC stock_bitmaps[] = {
PBITMAP _BMP_GetStock(PCSTR name)
{
INT32 i;
for (i = 0; stock_bitmaps[i].name; ++i)
if (strcmp(name, stock_bitmaps[i].name) == 0)
return BMP_Create(stock_bitmaps[i].width, stock_bitmaps[i].height, stock_bitmaps[i].data);
return BMP_Create(stock_bitmaps[i].width, stock_bitmaps[i].height, stock_bitmaps[i].data);
return NULL;
}

View File

@@ -1,12 +1,12 @@
/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
*
* This program is free software; you can redistribute it and/or modify
* it 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.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -74,22 +74,22 @@ static BOOL poll_buttons(void)
for (attr = 1, mask = GRB_STATE_BUTTON1; attr <= GPIO_BUTTON_COUNT; attr++, mask <<= 1)
{
if (now < button_event_ok[attr - 1])
continue; /* this is a "contact bounce" event, don't bother */
continue; /* this is a "contact bounce" event, don't bother */
if (up & mask)
{
/* reset contact bounce timer - only seems to happen after button releases */
button_event_ok[attr - 1] = now + Gconfig.button_debounce;
Mq_post1(Sys_Queue, 0, WM_HWBUTTONUP, attr);
if ((now - button_down_time[attr - 1]) <= Gconfig.click_time)
Mq_post1(Sys_Queue, 0, WM_HWBUTTONCLICK, attr);
posted = TRUE;
/* reset contact bounce timer - only seems to happen after button releases */
button_event_ok[attr - 1] = now + Gconfig.button_debounce;
Mq_post1(Sys_Queue, 0, WM_HWBUTTONUP, attr);
if ((now - button_down_time[attr - 1]) <= Gconfig.click_time)
Mq_post1(Sys_Queue, 0, WM_HWBUTTONCLICK, attr);
posted = TRUE;
}
else if (down & mask)
{
Mq_post1(Sys_Queue, 0, WM_HWBUTTONDOWN, attr);
button_down_time[attr - 1] = now;
posted = TRUE;
}
{
Mq_post1(Sys_Queue, 0, WM_HWBUTTONDOWN, attr);
button_down_time[attr - 1] = now;
posted = TRUE;
}
}
last_bstate = st;
}
@@ -116,55 +116,55 @@ static BOOL poll_touchscreen(void)
Log(LERROR, "Unexpected end of file reading from touchscreen device");
return FALSE;
}
nev = nb / sizeof(struct input_event);
xerrno = nev * sizeof(struct input_event);
if (nb > xerrno)
Log(LERROR, "read %d bytes from touchscreen but we can only use %d", nb, xerrno);
for (i=0; i<nev; i++)
{
switch (buffer[i].type)
{
case EV_SYN:
if (buffer[i].code == SYN_REPORT)
{
now = Time_since_start();
Mq_post2(Sys_Queue, 0, touch_nextmsg, touch_x, touch_y);
if (touch_nextmsg == WM_TOUCHDOWN)
{
touch_down_x = touch_x;
touch_down_y = touch_y;
touch_down_time = now;
}
else if (touch_nextmsg == WM_TOUCHUP)
{
if ( ((now - touch_down_time) <= Gconfig.click_time)
&& (ABS((INT32)touch_x - (INT32)touch_down_x) <= Gconfig.click_radius)
&& (ABS((INT32)touch_y - (INT32)touch_down_y) <= Gconfig.click_radius))
Mq_post2(Sys_Queue, 0, WM_TOUCHCLICK, touch_x, touch_y);
}
touch_nextmsg = WM_TOUCHMOVE;
posted = TRUE;
}
break;
if (buffer[i].code == SYN_REPORT)
{
now = Time_since_start();
Mq_post2(Sys_Queue, 0, touch_nextmsg, touch_x, touch_y);
if (touch_nextmsg == WM_TOUCHDOWN)
{
touch_down_x = touch_x;
touch_down_y = touch_y;
touch_down_time = now;
}
else if (touch_nextmsg == WM_TOUCHUP)
{
if ( ((now - touch_down_time) <= Gconfig.click_time)
&& (ABS((INT32)touch_x - (INT32)touch_down_x) <= Gconfig.click_radius)
&& (ABS((INT32)touch_y - (INT32)touch_down_y) <= Gconfig.click_radius))
Mq_post2(Sys_Queue, 0, WM_TOUCHCLICK, touch_x, touch_y);
}
touch_nextmsg = WM_TOUCHMOVE;
posted = TRUE;
}
break;
case EV_ABS:
/* Note that the touchscreen driver assumes the screen is "vertical," so swap the x and y axes */
/* Also it thinks origin is lower left with up = +y */
if (buffer[i].code == ABS_X)
touch_y = Fb_Info->height - buffer[i].value;
else if (buffer[i].code == ABS_Y)
touch_x = buffer[i].value;
break;
/* Note that the touchscreen driver assumes the screen is "vertical," so swap the x and y axes */
/* Also it thinks origin is lower left with up = +y */
if (buffer[i].code == ABS_X)
touch_y = Fb_Info->height - buffer[i].value;
else if (buffer[i].code == ABS_Y)
touch_x = buffer[i].value;
break;
case EV_KEY:
if (buffer[i].code == BTN_TOUCH)
touch_nextmsg = (buffer[i].value ? WM_TOUCHDOWN : WM_TOUCHUP);
break;
if (buffer[i].code == BTN_TOUCH)
touch_nextmsg = (buffer[i].value ? WM_TOUCHDOWN : WM_TOUCHUP);
break;
default:
break;
break;
}
}
return posted;
@@ -173,23 +173,23 @@ static BOOL poll_touchscreen(void)
static void *input_thread(void *arg)
{
BOOL gotinput;
/* clear all state at startup */
last_bstate = 0;
memset(button_event_ok, 0, GPIO_BUTTON_COUNT * sizeof(TIMESTAMP));
touch_x = touch_y = 0;
touch_nextmsg = WM_TOUCHMOVE;
while (running)
{
gotinput = poll_buttons();
gotinput = poll_buttons();
gotinput = poll_touchscreen() || gotinput;
if (gotinput)
{
pthread_mutex_lock(&wait_mutex);
pthread_cond_signal(&wait_cond);
pthread_mutex_unlock(&wait_mutex);
}
if (gotinput)
{
pthread_mutex_lock(&wait_mutex);
pthread_cond_signal(&wait_cond);
pthread_mutex_unlock(&wait_mutex);
}
}
return NULL;
}
@@ -208,7 +208,7 @@ HRESULT Sys_enable_input(void)
{
HRESULT rc = S_OK;
int threadrc;
Sys_Queue = Mq_alloc(Gconfig.sys_mq_length);
if (!Sys_Queue)
{
@@ -223,22 +223,22 @@ HRESULT Sys_enable_input(void)
Log(LFATAL, "Unable to open touchscreen device %s (%08X).", Gconfig.touchscreen_device, rc);
goto error_0;
}
running = 1;
threadrc = pthread_create(&ithread, NULL, input_thread, NULL);
if (threadrc != 0)
{
rc = SCODE_FROM_ERRNO(threadrc);
Log(LFATAL, "Unable to start system input thread (%08X).", rc);
goto error_1;
goto error_1;
}
rc = Config_exitfunc(do_disable_input);
if (FAILED(rc))
do_disable_input();
do_disable_input();
return rc;
error_1:
error_1:
close(ts_fd);
ts_fd = -1;
error_0:
@@ -250,6 +250,6 @@ void Sys_wait_for_input(void)
{
pthread_mutex_lock(&wait_mutex);
while (Mq_is_empty(Sys_Queue))
pthread_cond_wait(&wait_cond, &wait_mutex);
pthread_cond_wait(&wait_cond, &wait_mutex);
pthread_mutex_unlock(&wait_mutex);
}