import gpm from unix.schottelius.org

Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
Nico Schottelius 2009-10-08 22:52:35 +02:00
commit 95a46c5577
5930 changed files with 755263 additions and 0 deletions

View file

@ -0,0 +1,4 @@
- read cconfig-directory
- create mouse structures
- use cconfig-protocol-options as base for each protocol
char *fullpath?

View file

@ -0,0 +1,18 @@
The files in this directory should built up the client interface.
Some ideas:
struct gpm2_conn *gpm2_connect():
client connects to gpm2-daemon
gpm2_get_mice(struct gpm2_conn *g2c):
get list of devices, including protocols and ids
struct *mouseinfo gpm2_open_mouse(int mouse_id, int type);
returns set of descriptors:
- to read mousedata
int gpm2_close_mouse(struct *mouseinfo mi);

View file

@ -0,0 +1,11 @@
This is the conf/ directory Nico Schottelius uses to configure his
software projects. They evolve with every project and the aim is
to replace autoconf once.
In general, the idea is to create extremly simply configuration files,
that are editable by non-interactive programs (distributor friendly).
In most cases only the first line is important and the other lines are
simply the description.
programs/ - contains definitions of programs we need in our built process

View file

@ -0,0 +1,3 @@
ps2
List of protocols to enable (at built time: not expandable later).

View file

@ -0,0 +1,3 @@
gcc
The program used to link

View file

@ -0,0 +1,3 @@
gcc
The c-compiler to use.

View file

@ -0,0 +1,3 @@
-pipe -W -Wall -Werror -I. -Iinclude -g
flags to pass to the c-compiler.

View file

@ -0,0 +1,3 @@
gcc
The linker to use.

View file

@ -0,0 +1,44 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* main: Where life of gpm2 begins.
********/
#include "gpm2-daemon.h"
int main(int argc, char **argv)
{
set_defaults();
if(!commandline(argc,argv)) return 1;
if(!read_config(opts.cconfig)) return 1;
/* creates a fork() */
if(!mice_handler()) return 1;
/* listen to messages: exits only on failure or shutdown */
// listen_ipc();
// shutdown_gpm2();
return 0;
}

View file

@ -0,0 +1,34 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* read cconfig
********/
#include "gpm2-daemon.h"
int read_config(char *cconfig)
{
/* open cconfig-dir (FIXME: write small framework for reuse) */
if(!cconfig) return 0; /* remove, just to make gcc happy */
/* set options */
return 1;
}

View file

@ -0,0 +1,31 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* set the default options
********/
#include "gpm2-daemon.h"
void set_defaults()
{
/* options */
opts.cconfig = GPM2_CCONFIG;
}

View file

@ -0,0 +1,7 @@
core/main.o
core/read_config.o
core/set_defaults.o
generic/commandline.o
generic/daemon-usage.o
generic/mini_printf.o
mice/mice_handler.o

View file

@ -0,0 +1 @@
include/gpm2-daemon.h

View file

@ -0,0 +1,17 @@
Configuration:
/etc/gpm2/
mice/
default/
mice-userid: userid of person reading/writing mice devices
mice-groupid: groupid of person reading/writing mice devices
<name>/
device: link or device to use
protocol: one line, containing protocol
userid: overwrites default/mice-userid
groupid: overwrites default/mice-groupid
options/: options for that protocol
<protocol specific configuration>
clients/

View file

@ -0,0 +1,65 @@
Possible design of gpm2:
gpm2-starter:
- reads configuration
- starts daemons
* first gpm2-daemon
- connects daemons
* connects them through stdin and stdout?
- perhaps a job of gpm2-daemon?
* stderr is relayed to the log console
- which can log to syslog
gpm2-daemon:
- main daemon
- starts mice handlers
- listens for ipc
- relays input data abstracted to clients
- does *NOT* draw a cursor or something like that
- can be used by x.org (see below)
- opens mice devices?
- should be portable
gpm2-io:
- gets list of opened fds or of devices
- uses poll() / select() on mice devices
- retrieves data packets
- forwards raw data packets to gpm2-daemon from devices
- either
- forwards raw data packets from gpm2-daemon to devices??
- decodes mice packets: does protocol handling and
forwards decoded packages to gpm2_daemon
- has a mouse - fd_in - fd_out list
- has *NO* root priviliges
gpm2-decode:
- forwards raw data packets from gpm2-daemon
- forwards decoded packages to clients (like gpm2-cdisplay)
gpm2-raw-relay:
- reads data from gpm2-daemon
- writes raw data to clients
- a client needs to connect n times for n mice
gpm2-cdisplay:
- Console DISPLAYS: displays mouse cursor on console
- reads input from gpm2-daemon
- reads mouse information
- perhaps os-specific versions
gpm2-ccandp:
- Console Copy AND Paste daemon
- reads input from gpm2-daemon
- copies selected text into own buffer
- pastes buffer to console
- perhaps os-specific versions
gpm2-xorg:
- interface between gpm2 and x.org
- could make mouse support unecessary in x.org
- should be portable
gpm2-syslog:
- connects to the gpm2-daemon logging port
- reads messages
- relays them to syslog

View file

@ -0,0 +1,42 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* handle command line arguments
********/
#include <unistd.h> /* getopt() */
#include "gpm2-daemon.h"
int commandline(int argc, char **argv)
{
int opt;
while((opt = getopt(argc,argv,GPM2_ARGS)) != -1) {
switch(opt) {
default:
usage();
break;
}
}
return 1;
}

View file

@ -0,0 +1,32 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* Print out, how to use gpm2-daemon
********/
#include "gpm2-generic.h"
void usage()
{
mini_printf("gpm2-daemon: written by Nico Schottelius\n",1);
mini_printf("\n",1);
mini_printf(" -c <cconfig>: specify configuration directory\n",1);
mini_printf(" -f: fork into background after startup \n",1);
}

View file

@ -0,0 +1,24 @@
/***********************************************************************
*
* 2005-2007 Nico Schottelius (nico-cinit at schottelius.org)
*
* part of cLinux/cinit
*
* Print the world!
*
*/
#include <unistd.h>
void mini_printf(char *str,int fd)
{
char *p;
/* don't get fooled by bad pointers */
if(str == NULL) return;
p = str;
while(*p) p++;
write(fd,str,(size_t) (p - str));
}

View file

@ -0,0 +1,44 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* read one mouse packet and return it
********/
#include <unistd.h> /* read() */
#include <stdio.h> /* NULL */
#include <stdlib.h> /* malloc() */
#include <errno.h> /* errno */
char *read_packet(int fd, int len)
{
char *packet;
errno = 0; /* no library function ever sets errno to 0, so we do */
packet = malloc(len);
if(packet == NULL) return NULL;
if(read(fd,&packet,len) == -1) {
free(packet);
return NULL;
}
return packet;
}

View file

@ -0,0 +1,28 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* client information
********/
/* functions */

View file

@ -0,0 +1,24 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* values shared by daemon and clients
********/

View file

@ -0,0 +1,50 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* daemon specific include file
********/
#ifndef GPM2_DAEMON
#define GPM2_DAEMON
/* parameters and options */
#define GPM2_ARGS "c:f"
#define GPM2_CCONFIG "/etc/gpm2"
struct gpm2_options {
char *cconfig; /* configuration directory */
} opts;
/* functions */
int commandline(int argc, char **argv);
int mice_handler();
int read_config(char *cconfig);
void set_defaults();
void usage();
/* structs */
struct mouse {
/* pointer to init and decode functions */
int (*open)(int fd);
};
#endif

View file

@ -0,0 +1,59 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* data definitions used by clients and daemon
********/
/* structs */
struct gpm2_mouse {
char *name;
char *dev;
int fd;
};
struct gpm2_me { /* mouse element */
struct gpm2_mouse mouse;
struct gpm2_me *next;
struct gpm2_me *prev;
};
struct gpm2_packet_raw() { /* raw mouse packets */
char *data;
int len;
};
/* must contain everything a mouse can do */
struct gpm2_packet() { /* decoded mouse packets */
int nr_buttons;
int *buttons;
int pos_type; /* absolute or relativ */
};
/* structure */
struct gpm2_mic
/* gpm2-daemon needs a list of mice, containing:
* - name of mouse
* - device used
* - filedescriptor
* - mouse configuration as found in cconfig
*/

View file

@ -0,0 +1,25 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* generic functions: used by daemon and clients
********/
/* generic functions */
void mini_printf(char *str,int fd);

View file

@ -0,0 +1,31 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* data definitions used by clients and daemon
********/
#ifndef GPM2_IO_H
#define GPM2_IO_H
char *read_packet(int fd, int len); /* needed? */
#endif

View file

@ -0,0 +1,63 @@
This directory should contain the mice-protocol implementations.
Each file (or if bigger: directory) implements one protocol.
You have to create three functions:
gpm2_open_<protocol>();
gpm2_handle_<protocol>();
gpm2_close_<protocol>();
It's not yet clear, how to register protocols to gpm2.
First idea of inclusion:
- create deps/mouse-<protocol> containging all dependencies
- conf/built-options/mice specifies which mice protocols to include
- a script generates include/gpm2-daemon-mice.h containg a struct-array
that looks like:
struct mice_protos {
char *name;
int (*open)();
int (*handle)();
int (*open)();
};
--------------------------------------------------------------------------------
More design ideas for using mice:
- The gpm2_handle function gets a pointer to a char array containing the
data packet.
- The gpm2_handle function returns what the packet means
- gpm2_daemon may then decide what todo with this information
--------------------------------------------------------------------------------
It would be nice to have a read_config_<proto> that reads and verifies
the protocol specific options.
For this, it would be nice to have a libcconfig() like this:
struct cconfig_fd *cconfig_open(char *dir);
struct cconfig_tree *cconfig_read_tree(struct cconfig_fd *which);
struct cconfig_element *cconfig_select_below(char *basepath, struct cconfig_fd *which, ...);
The tree, cconfig_read_tree creates could consist of elements
of the following definition:
struct cconfig_element {
char *path;
struct stat sbuf;
};
--------------------------------------------------------------------------------
gpm2_open_*:
- needs fd
- needs options
--------------------------------------------------------------------------------
struct datapacket *gpm2_read_*(int fd)
- reads one packet
- returns it
--------------------------------------------------------------------------------

View file

@ -0,0 +1 @@
mice/ps2.o

View file

@ -0,0 +1,39 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* handle mice
********/
/* unclean headers */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h> /* close */
#include "gpm2-daemon.h"
#include "tmp/protocols.h"
int init_mice_handler()
{
/* open connections: pipes */
return 1;
}

View file

@ -0,0 +1,65 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* handle mice
********/
/* unclean headers */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h> /* close */
#include "gpm2-daemon.h"
#include "tmp/protocols.h"
int mice_handler()
{
/* init_mice_handler();
* open connections to gpm2_daemon:
* - one for each mouse:
* * raw channel (unidirectional)
* * decoded channel (unidirectional)
* * control channel (bidirectional)
*/
init_mice_handler();
/* init_mice:
*
* - open mousedev
* - drop priviliges after that
*/
//init_mice();
//handle_mice(); /* forks and maintains mice */
/* dirty hack */
int ps2test = open("/dev/psaux",O_RDWR);
gpm2_open_ps2(ps2test);
gpm2_decode_ps2(ps2test);
close(ps2test);
return 0;
}

View file

@ -0,0 +1,121 @@
/*
* gpm2 - mouse driver for the console
*
* Copyright (c) 2007 Nico Schottelius <nico-gpm2 () schottelius.org>
*
* 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.
*
*
* handle standard ps2
********/
#include <unistd.h> /* usleep() */
#include <termios.h> /* tcflush() */
#include <stdio.h>
#include "gpm2-daemon.h"
#include "gpm2-generic.h"
/* protocol handler stolen from gpm1/mice.c */
/* ps2 protocol description
*
* 3 Bytes per packet
*
* first bit of data[0]: Left Button
* second bit of data[0]: Right Button
* third bit of data[0]: Middle Button
* fourth bit of data[0]: Always 1
* fifth bit of data[0]: X Sign
* sixth bit of data[0]: Y Sign
* seventh bit of data[0]: X Overflow
* eighth bit of data[0]: Y Overflow
*
* data[1]: X Movement
* data[2]: Y Movement
*/
/* standard ps2 */
/* FIXME: implement error handling and options as described on
* http://www.computer-engineering.org/ps2mouse/
*/
int gpm2_open_ps2(int fd)
{
//static unsigned char s[] = { 246, 230, 244, 243, 100, 232, 3, };
// write(fd, s, sizeof (s));
// static unsigned char s[] = { 246, 230, 244, 243, 100, 232, 3, };
char obuf, ibuf;
/* FIXME: check return */
obuf = 0xff; /* reset mouse */
write(fd, &obuf, 1);
read(fd,&ibuf,1);
printf("RX: %#hhx\n",ibuf);
// if(ibuf != 0xfa) return 0;
// obuf = 0xf6; /* set mouse to default */
// write(fd, &obuf, 1);
// read(fd,&ibuf,1);
// printf("DF: %#hhx\n",ibuf);
obuf = 0xf2; /* device id */
write(fd, &obuf, 1);
read(fd,&ibuf,1);
printf("ST: %#hhx\n",ibuf);
read(fd,&ibuf,1);
printf("DI: %#hhx\n",ibuf);
/* set resolution: 0xe8 */
//if(scaling = 2) { e7h
//
// 0xe6 scaling =1
/* do 0xf2, get device id and print it out */
/* do 0xe9 and print out values as status */
/* FIXME: time correct? */
usleep (30000);
tcflush (fd, TCIFLUSH);
return 0;
}
/* returs gpm2-readable data */
//int *gpm2_decode_ps2(char *data, struct mousedata *decoded)
int gpm2_decode_ps2(int fd)
{
char data[3];
data[0] = 0;
data[1] = 0;
data[2] = 0;
read(fd,data,3);
if(data[0] & 0x01) mini_printf("left!\n",1);
if(data[0] & 0x02) mini_printf("right!\n",1);
if(data[0] & 0x04) mini_printf("middle!\n",1);
/* decoded->button_left = data[0] & 0x01;
decoded->button_right = data[0] & 0x02;
decoded->button_middle = data[0] & 0x04;
decoded-> */
return 1;
}

View file

@ -0,0 +1,48 @@
#!/bin/sh
# Nico Schottelius
# 2007-05-11
# First script to generate built environment from
# a standard cconfig directory for building.
[ "$#" -eq 1 ] || exit 23
set -e
# args
confdir="$1"
# paths below the configuration directory
programs="programs"
progdir="$confdir/$programs"
# paths directly in the srcdir
tmpdir="tmp"
#
# generate built programs
#
for tmp in "${progdir}"/*; do
prog=""
params=""
baseprog="$(basename "$tmp")"
destprog="$tmpdir/$baseprog"
# ignore *.params, those are parameters, not programs
if [ "${tmp%.params}" != "${tmp}" ]; then
continue
fi
# check for params
pfile="${tmp}.params"
if [ -f "$pfile" ]; then
params="$(head -n1 "$pfile")"
fi
prog=$(head -n1 "$tmp")
echo "Creating $destprog: $prog $params"
echo '#!/bin/sh' > "${destprog}"
echo "\"${prog}\" $params \"\$@\"" >> "${destprog}"
chmod 0700 "${destprog}"
done

View file

@ -0,0 +1,29 @@
#!/bin/sh
# Nico Schottelius
# 2007-05-13
# Create protocol related files
[ "$#" -eq 1 ] || exit 23
set -e
# args
confdir="$1"
# paths below the configuration directory
builtopts="built-options"
builtoptsdir="$confdir/$builtopts"
# paths directly in the srcdir
tmpdir="tmp"
#
# generate built programs
#
: > "${tmpdir}/protocols.h"
for proto in $(head -n1 ${builtoptsdir}/protocols); do
echo "int gpm2_open_${proto}(int fd);" > "${tmpdir}/protocols.h"
echo "int gpm2_decode_${proto}(int fd);" >> "${tmpdir}/protocols.h"
done