Thanks for the driver!
I've committed it to CVS

On 2002.01.10 06:25 Arnd Bergmann wrote:
> Hi,
> 
> I've just finished writing an input driver for dynapro/sc3 style touch
> screen
> drivers. As you might have guessed, that's the one we're using for our
> 
> devices.
> 
> As it is largely identical to at least the serial mouse driver and the
> palmax
> touch screen driver (which seems to use a newer version of the same
> protocol), it might be nice to put the shared code in another file,
> but I'm
> not sure if that's worth the effort.
> 
> For now, the driver is working nicely and does not touch other parts
> of the
> server.
> 
> Arnd <><
> diff -ur --new-file pgui-dev20020109/pgserver/config.in
> pgui-dev20020109-sc3/pgserver/config.in
> --- pgui-dev20020109/pgserver/config.in       Sun Jan  6 04:25:16
> 2002
> +++ pgui-dev20020109-sc3/pgserver/config.in   Thu Jan 10 14:08:31
> 2002
> @@ -108,6 +108,7 @@
>  bool 'Touchscreen calibration'               CONFIG_TOUCHSCREEN
>  if [ "$CONFIG_TOUCHSCREEN" = "y" ]; then
>     bool 'Palmax touchscreen driver'         DRIVER_PALMAXTS
> +   bool 'SC3 compatible touchscreen input driver'    DRIVER_SC3TS
>  fi
>  bool 'SDL input driver'                    DRIVER_SDLINPUT
>  bool 'X Window System input driver'        DRIVER_X11INPUT
> diff -ur --new-file pgui-dev20020109/pgserver/gcore/inputdrivers.inc
> pgui-dev20020109-sc3/pgserver/gcore/inputdrivers.inc
> --- pgui-dev20020109/pgserver/gcore/inputdrivers.inc  Sun Jan  6
> 02:28:45 2002
> +++ pgui-dev20020109-sc3/pgserver/gcore/inputdrivers.inc      Thu
> Jan 10 14:08:31 2002
> @@ -41,6 +41,10 @@
>    DRV("ucb1x00",&ucb1x00_regfunc)
>  #endif
> 
> +#ifdef DRIVER_SC3TS
> +  DRV("sc3ts",&sc3_regfunc)
> +#endif
> +
>  #ifdef DRIVER_TTYKB
>    DRV("ttykb",&ttykb_regfunc)
>  #endif
> diff -ur --new-file pgui-dev20020109/pgserver/include/pgserver/input.h
> pgui-dev20020109-sc3/pgserver/include/pgserver/input.h
> --- pgui-dev20020109/pgserver/include/pgserver/input.h        Mon Jan
> 7 19:26:12 2002
> +++ pgui-dev20020109-sc3/pgserver/include/pgserver/input.h    Thu
> Jan 10 14:08:31 2002
> @@ -135,6 +135,7 @@
>  g_error vr3ts_regfunc(struct inlib *i);
>  g_error tuxts_regfunc(struct inlib *i);
>  g_error ucb1x00_regfunc(struct inlib *i);
> +g_error sc3_regfunc(struct inlib *i);
>  g_error ttykb_regfunc(struct inlib *i);
>  g_error remorakb_regfunc(struct inlib *i);
>  g_error serialmouse_regfunc(struct inlib *i);
> diff -ur --new-file pgui-dev20020109/pgserver/input/sc3ts.c
> pgui-dev20020109-sc3/pgserver/input/sc3ts.c
> --- pgui-dev20020109/pgserver/input/sc3ts.c   Thu Jan  1 01:00:00
> 1970
> +++ pgui-dev20020109-sc3/pgserver/input/sc3ts.c       Thu Jan 10
> 14:13:16 2002
> @@ -0,0 +1,173 @@
> +/* $Id:$
> + *
> + * sc3ts.c - input driver for sc3 compatible touch screens
> + *
> + * (C) 2001 SSV Embedded Systems GmbH, Arnd Bergmann <[EMAIL PROTECTED]>
> + *
> + * Based on serial mouse driver, see serialmouse.c for complete
> + * changelog
> + *
> + *     ---------------------------
> + *
> + * PicoGUI small and efficient client/server GUI
> + * Copyright (C) 2000,2001 Micah Dowty
> <[EMAIL PROTECTED]>
> + *
> + * 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
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
> 02111-1307, USA.
> + *
> + 
> ***************************************************************************/
> +
> +#include <pgserver/common.h>
> +#include <pgserver/input.h>
> +#include <pgserver/widget.h>
> +#include <pgserver/configfile.h>
> +#include <pgserver/touchscreen.h>
> +
> +#include <stdio.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +#include <sys/termios.h>
> +
> +int sc3_fd;
> +int btnstate;
> +struct termios options;
> +
> +struct sc3_event {
> +  u8 y_high    : 3;    /* lower half of horizontal position */
> +  u8 x_high    : 3;    /* lower half of vertical position */
> +  u8 pressure  : 1;    /* button state */
> +  u8 sync      : 1;    /* set to 1 on first byte, 0 otherwise */
> +  u8 x_low;            /* upper half of horizontal position */
> +  u8 y_low;            /* upper half of vertical position */
> +  u8 pad;              /* pad to 32 bit */
> +};
> 
> +
> +static int minx = 76;
> +static int miny = 86;
> +static int maxx = 950;
> +static int maxy = 935;
> +
> +int sc3_fd_activate(int fd) {
> +  u8 buttons;
> +  static u8 packet[3];
> +  static int pos;
> +  struct sc3_event *event = (struct sc3_event *)packet;
> +  int cursorx,cursory;
> +
> +  if (fd != sc3_fd)
> +    return 0;
> +
> +  /* Read a correctly-aligned sc3 packet. If the first byte isn't
> 0x80,
> +   * it isn't correctly aligned. The sc3 packet is 3 bytes long.
> +   */
> +
> +  if (read(sc3_fd,packet+pos,1) != 1)
> +    return 1;
> +  if (!(packet[0] & 0x80))
> +    return 1;
> +  if (pos++ < 2)
> +    return 1;
> +  pos = 0;
> +
> +  buttons = event->pressure;
> +  cursorx = event->x_high << 7 | event->x_low;
> +  cursory = event->y_high << 7 | event->y_low;
> +
> +#ifdef DEBUG_EVENT
> +  {
> +    int a,b,c;
> +
> +    a = packet[0];
> +    b = packet[1];
> +    c = packet[2];
> +    printf("fd=%d, x=%4d, y=%4d, buttons=%2d packet = %02X %02X
> %02X\n",
> +        sc3_fd,cursorx,cursory,buttons,a,b,c);
> +  }
> +#endif
> +
> +  touchscreen_pentoscreen(&cursorx, &cursory);
> +
> +  if ((buttons!=0)&&(btnstate==0)){
> +    dispatch_pointing(TRIGGER_DOWN,cursorx,cursory,buttons);
> +    btnstate=1;
> +  }
> +  if ((buttons==0)&&(btnstate==1)){
> +    dispatch_pointing(TRIGGER_UP,cursorx,cursory,buttons);
> +    btnstate=0;
> +  }
> +  if(buttons)
> +    dispatch_pointing(TRIGGER_MOVE,cursorx,cursory,buttons);
> +
> +  return 1;
> +}
> +
> +g_error sc3_init(void) {
> +
> +  g_error ret;
> +
> +  ret=touchscreen_init();
> +  if(ret!=success)
> +       return ret;
> +
> +
> +
> + sc3_fd = open(get_param_str("input-sc3ts","device","/dev/ttyS1"),
> +         O_RDONLY | O_NOCTTY | O_NDELAY);
> +
> +  if(sc3_fd < 0)
> +    return mkerror(PG_ERRT_IO,43);   /* Error opening sc3 device */
> +
> +  tcgetattr(sc3_fd, &options);
> +  cfsetispeed(&options, B2400); /* baud rate 2400 */
> +  options.c_cflag |= (CLOCAL | CREAD); /* Enable
> +                                       receiver and set the local 
> mode
> */
> +  options.c_cflag &= ~PARENB; /* None parity */
> +  options.c_cflag &= ~CSIZE; /* Mask the character bit
> +                             size */
> +  options.c_cflag |= CS8; /* 8 data bits */
> +  options.c_cflag &= ~CSTOPB; /* 1 stop bits */
> +  options.c_cflag &= ~CRTSCTS;/* Disable hardware flow
> +                              control */
> +  options.c_iflag &= ~(IXON | IXOFF | IXANY);/* Disable
> +                                             software flow control */
> +  /* Set raw input and output */
> +  options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
> +  options.c_oflag &= ~OPOST;
> +
> +  tcsetattr(sc3_fd, TCSANOW, &options); /* set parameters */
> +  return success;
> +}
> +
> +void sc3_fd_init(int *n,fd_set *readfds,struct
> +                  timeval *timeout) {
> +   if ((*n)<(sc3_fd+1))
> +     *n = sc3_fd+1;
> +   if (sc3_fd>0)
> +     FD_SET(sc3_fd,readfds);
> +}
> +
> +void sc3_close(void){
> +  close(sc3_fd);
> +}
> +
> +g_error sc3_regfunc(struct inlib *i) {
> +  i->init = &sc3_init;
> +  i->fd_activate = &sc3_fd_activate;
> +  i->fd_init = &sc3_fd_init;
> +  i->message = &touchscreen_message;
> +  i->close = &sc3_close;
> +  return success;
> +}
> diff -ur --new-file pgui-dev20020109/pgserver/input/sc3ts.c~
> pgui-dev20020109-sc3/pgserver/input/sc3ts.c~
> --- pgui-dev20020109/pgserver/input/sc3ts.c~  Thu Jan  1
> 01:00:00 1970
> +++ pgui-dev20020109-sc3/pgserver/input/sc3ts.c~      Thu Jan 10
> 14:09:02 2002
> @@ -0,0 +1,173 @@
> +/* $Id: sc3ts.c,v 1.4 2001/12/14 22:56:43 micahjd Exp $
> + *
> + * sc3ts.c - input driver for sc3 compatible touch screens
> + *
> + * (C) 2001 SSV Embedded Systems GmbH, Arnd Bergmann <[EMAIL PROTECTED]>
> + *
> + * Based on serial mouse driver, see serialmouse.c for complete
> + * changelog
> + *
> + *     ---------------------------
> + *
> + * PicoGUI small and efficient client/server GUI
> + * Copyright (C) 2000,2001 Micah Dowty
> <[EMAIL PROTECTED]>
> + *
> + * 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
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
> 02111-1307, USA.
> + *
> + 
> ***************************************************************************/
> +
> +#include <pgserver/common.h>
> +#include <pgserver/input.h>
> +#include <pgserver/widget.h>
> +#include <pgserver/configfile.h>
> +#include <pgserver/touchscreen.h>
> +
> +#include <stdio.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +#include <sys/termios.h>
> +
> +int sc3_fd;
> +int btnstate;
> +struct termios options;
> +
> +struct sc3_event {
> +  u8 y_high    : 3;    /* lower half of horizontal position */
> +  u8 x_high    : 3;    /* lower half of vertical position */
> +  u8 pressure  : 1;    /* button state */
> +  u8 sync      : 1;    /* set to 1 on first byte, 0 otherwise */
> +  u8 x_low;            /* upper half of horizontal position */
> +  u8 y_low;            /* upper half of vertical position */
> +  u8 pad;              /* pad to 32 bit */
> +};
> 
> +
> +static int minx = 76;
> +static int miny = 86;
> +static int maxx = 950;
> +static int maxy = 935;
> +
> +int sc3_fd_activate(int fd) {
> +  u8 buttons;
> +  static u8 packet[3];
> +  static int pos;
> +  struct sc3_event *event = (struct sc3_event *)packet;
> +  int cursorx,cursory;
> +
> +  if (fd != sc3_fd)
> +    return 0;
> +
> +  /* Read a correctly-aligned sc3 packet. If the first byte isn't
> 0x80,
> +   * it isn't correctly aligned. The sc3 packet is 3 bytes long.
> +   */
> +
> +  if (read(sc3_fd,packet+pos,1) != 1)
> +    return 1;
> +  if (!(packet[0] & 0x80))
> +    return 1;
> +  if (pos++ < 2)
> +    return 1;
> +  pos = 0;
> +
> +  buttons = event->pressure;
> +  cursorx = event->x_high << 7 | event->x_low;
> +  cursory = event->y_high << 7 | event->y_low;
> +
> +#ifdef DEBUG_EVENT
> +  {
> +    int a,b,c;
> +
> +    a = packet[0];
> +    b = packet[1];
> +    c = packet[2];
> +    printf("fd=%d, x=%4d, y=%4d, buttons=%2d packet = %02X %02X
> %02X\n",
> +        sc3_fd,cursorx,cursory,buttons,a,b,c);
> +  }
> +#endif
> +
> +  touchscreen_pentoscreen(&cursorx, &cursory);
> +
> +  if ((buttons!=0)&&(btnstate==0)){
> +    dispatch_pointing(TRIGGER_DOWN,cursorx,cursory,buttons);
> +    btnstate=1;
> +  }
> +  if ((buttons==0)&&(btnstate==1)){
> +    dispatch_pointing(TRIGGER_UP,cursorx,cursory,buttons);
> +    btnstate=0;
> +  }
> +  if(buttons)
> +    dispatch_pointing(TRIGGER_MOVE,cursorx,cursory,buttons);
> +
> +  return 1;
> +}
> +
> +g_error sc3_init(void) {
> +
> +  g_error ret;
> +
> +  ret=touchscreen_init();
> +  if(ret!=success)
> +       return ret;
> +
> +
> +
> + sc3_fd = open(get_param_str("input-sc3ts","device","/dev/ttyS1"),
> +         O_RDONLY | O_NOCTTY | O_NDELAY);
> +
> +  if(sc3_fd < 0)
> +    return mkerror(PG_ERRT_IO,43);   /* Error opening sc3 device */
> +
> +  tcgetattr(sc3_fd, &options);
> +  cfsetispeed(&options, B2400); /* baud rate 2400 */
> +  options.c_cflag |= (CLOCAL | CREAD); /* Enable
> +                                       receiver and set the local 
> mode
> */
> +  options.c_cflag &= ~PARENB; /* None parity */
> +  options.c_cflag &= ~CSIZE; /* Mask the character bit
> +                             size */
> +  options.c_cflag |= CS8; /* 8 data bits */
> +  options.c_cflag &= ~CSTOPB; /* 1 stop bits */
> +  options.c_cflag &= ~CRTSCTS;/* Disable hardware flow
> +                              control */
> +  options.c_iflag &= ~(IXON | IXOFF | IXANY);/* Disable
> +                                             software flow control */
> +  /* Set raw input and output */
> +  options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
> +  options.c_oflag &= ~OPOST;
> +
> +  tcsetattr(sc3_fd, TCSANOW, &options); /* set parameters */
> +  return success;
> +}
> +
> +void sc3_fd_init(int *n,fd_set *readfds,struct
> +                  timeval *timeout) {
> +   if ((*n)<(sc3_fd+1))
> +     *n = sc3_fd+1;
> +   if (sc3_fd>0)
> +     FD_SET(sc3_fd,readfds);
> +}
> +
> +void sc3_close(void){
> +  close(sc3_fd);
> +}
> +
> +g_error sc3_regfunc(struct inlib *i) {
> +  i->init = &sc3_init;
> +  i->fd_activate = &sc3_fd_activate;
> +  i->fd_init = &sc3_fd_init;
> +  i->message = &touchscreen_message;
> +  i->close = &sc3_close;
> +  return success;
> +}
> diff -ur --new-file pgui-dev20020109/pgserver/select.in
> pgui-dev20020109-sc3/pgserver/select.in
> --- pgui-dev20020109/pgserver/select.in       Sun Jan  6 02:28:45
> 2002
> +++ pgui-dev20020109-sc3/pgserver/select.in   Thu Jan 10 14:08:31
> 2002
> @@ -97,6 +97,7 @@
>  add_if_true serialmouse.c  $DRIVER_SERIALMOUSE
>  add_if_true x11input.c     $DRIVER_X11INPUT
>  add_if_true palmaxts.c          $DRIVER_PALMAXTS
> +add_if_true sc3ts.c        $DRIVER_SC3TS
>  add_if_true mgl2input.c    $DRIVER_MGL2INPUT
> 
>  close_section
> 

_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel

Reply via email to