├── .exclude ├── .gitignore ├── COPYING ├── MANIFEST ├── Makefile.in ├── Makefile.include.in ├── README ├── README.gpm2 ├── README.versions ├── TODO ├── acinclude.m4 ├── autogen.sh ├── conf ├── gpm-root.conf ├── gpm-syn.conf └── gpm-twiddler.conf ├── configure.ac.footer ├── contrib ├── Makefile.in ├── emacs │ ├── exec.el │ └── t-mouse.el ├── init │ └── gpm.init ├── other │ ├── README │ └── TPdetect.cc └── scripts │ ├── create_vcs │ ├── debug_to_report │ ├── gpm_release │ ├── gunze-setup │ ├── make_diff │ ├── microtouch-setup │ ├── mkinstalldirs │ ├── replace_2_with_3_spaces │ ├── replace_tab_with_3_spaces │ └── test_gpm ├── doc ├── Announce ├── FAQ ├── HACK_GPM ├── Makefile.in ├── README.1.20.2 ├── README.etouch ├── README.gunze ├── README.microtouch ├── README.synaptics ├── README.twiddler ├── changelog ├── doc.gpm.in ├── infofilter ├── manpager ├── mktxt ├── specs │ └── synaptics │ │ └── www.synaptics.com │ │ └── decaf │ │ └── utilities │ │ ├── 511-000024-01a.pdf │ │ └── ACF126.pdf ├── support │ ├── README │ ├── logitech_1 │ ├── logitech_2 │ ├── logitech_3 │ ├── mouse-maintainer-XFree │ └── mouse-maintainer-XFree.status └── todo │ ├── 1.20.6 │ ├── 1.99.0 │ ├── 1.99.1 │ ├── 1.99.2 │ ├── 1.99.3 │ ├── 1.99.4 │ ├── 1.99.5 │ ├── 1.99.6 │ ├── 1.99.7 │ ├── 1.99.8 │ └── 1.99.9 ├── install-sh ├── scripts ├── git-archiv-tarbz2.sh ├── gpm.release └── report_success.sh └── src ├── Makefile.in ├── daemon ├── add_mouse.c ├── build_argv.c ├── check_kill.c ├── check_uniqueness.c ├── cmdline.c ├── disable_paste.c ├── do_client.c ├── do_selection.c ├── find_mouse_by_name.c ├── get_console_size.c ├── get_data.c ├── getmousedata.c ├── gpm-killed.c ├── gpm.c ├── gpm_exited.c ├── header.c ├── init_mice.c ├── loadlut.c ├── main.c ├── old_main.c ├── open_console.c ├── processconn.c ├── processmouse.c ├── processrequest.c ├── processspecial.c ├── reset_mice.c ├── selection_copy.c ├── selection_paste.c ├── startup.c ├── usage.c └── wait_text.c ├── drivers └── README ├── generic ├── getsym.c └── isodigit.c ├── gpm2 ├── Makefile ├── TODO ├── client │ └── README ├── conf │ ├── README │ ├── built-options │ │ └── protocols │ ├── built │ │ └── ld │ └── programs │ │ ├── cc │ │ ├── cc.params │ │ └── ld ├── core │ ├── main.c │ ├── read_config.c │ └── set_defaults.c ├── deps │ ├── gpm2-daemon │ └── gpm2-daemon-headers ├── doc │ ├── CONFIGURATION │ └── DESIGN ├── generic │ ├── commandline.c │ ├── daemon-usage.c │ ├── mini_printf.c │ └── read_packet.c ├── include │ ├── gpm2-client.h │ ├── gpm2-config.h │ ├── gpm2-daemon.h │ ├── gpm2-data.h │ ├── gpm2-generic.h │ └── gpm2-io.h ├── mice │ ├── README │ ├── deps │ │ └── ps2 │ ├── init_mice_handler.c │ ├── mice_handler.c │ └── ps2.c ├── scripts │ ├── generate_cbuiltconfig.sh │ └── include_protocols.sh └── tmp │ └── README ├── headers ├── daemon.h ├── gpm-proto.h ├── gpm.h ├── gpmCfg.h ├── gpmInt.h ├── message.h ├── synaptics.h └── twiddler.h ├── lib ├── libcurses.c ├── libhigh.c ├── liblow.c ├── libxtra.c └── report-lib.c ├── mice.c ├── prog ├── disable-paste.c ├── display-buttons.c ├── display-coords.c ├── get-versions.c ├── gpm-root.y ├── hltest.c ├── mev.c ├── mouse-test.c └── open_console.c ├── report.c ├── synaptics.c ├── tools.c └── twiddler.c /.exclude: -------------------------------------------------------------------------------- 1 | .git 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .depend 2 | *~ 3 | *.o 4 | *.lo 5 | *.a 6 | *.d 7 | *.P 8 | .*.swp 9 | 10 | Makefile 11 | Makefile.include 12 | /aclocal.m4 13 | /autom4te.cache 14 | /config.cache 15 | /config.log 16 | /config.status 17 | /configure 18 | /configure.ac 19 | /config 20 | /libtool 21 | 22 | /contrib/Makefile 23 | 24 | /src/headers/config.h 25 | /src/headers/config.h.in 26 | /src/headers/drivers.h 27 | /src/prog/gpm-root.c 28 | /src/subdirs-exist 29 | /src/headers/config.h.in 30 | /src/gpm 31 | /src/gpm2/tmp 32 | /src/gpm2/out 33 | /src/lib/libgpm.so* 34 | /src/prog/disable-paste 35 | /src/prog/display-buttons 36 | /src/prog/display-coords 37 | /src/prog/gpm-root.c 38 | /src/prog/gpm-root 39 | /src/prog/get-versions 40 | /src/prog/hltest 41 | /src/prog/mev 42 | /src/prog/mouse-test 43 | /src/Makefile.drivers.generated 44 | /src/subdirs-exist 45 | 46 | /doc/doc.gpm 47 | /doc/gpm-root.1 48 | /doc/gpm-types.7 49 | /doc/gpm.8 50 | /doc/gpm.info 51 | /doc/gpm.man 52 | /doc/mev.1 53 | /doc/mouse-test.1 54 | 55 | /.gitversion 56 | 57 | # gpm2 58 | /gpm2/out/* 59 | /gpm2/tmp/* 60 | /src/gpm2 61 | /.gitversion.m4 62 | /.releasedate 63 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- (gpm/main) 2 | # 3 | # Copyright 1994,1997 rubini@linux.it 4 | # Copyright 1997 dickey@clark.net 5 | # Copyright (C) 1998 Ian Zimmerman 6 | # Copyright (C) 2001-2012 Nico Schottelius 7 | # 8 | 9 | SHELL = /bin/sh 10 | srcdir = @srcdir@ 11 | top_srcdir = @top_srcdir@ 12 | top_builddir = . 13 | 14 | include Makefile.include 15 | 16 | # allow CFLAGS to be overriden from make command line 17 | # ideally one would never have to write this rule again, but the GNU 18 | # makefile standards are at cross-purposes: CFLAGS is reserved for 19 | # user-overridable flags, but it's also all the implicit rule looks at. 20 | # missing ? 21 | 22 | SUBDIRS = src doc contrib 23 | 24 | 25 | ### simple, but effective rules 26 | 27 | all: do-all 28 | 29 | src/$(DEPFILE): 30 | touch $@ # to prevent unecessary warnings 31 | 32 | dep: src/$(DEPFILE) 33 | $(MAKE) -C src dep 34 | 35 | check: all 36 | 37 | uninstall: do-uninstall 38 | 39 | clean: do-clean 40 | rm -f config.status.lineno 41 | 42 | aclocal.m4: acinclude.m4 43 | $(MKDIR) config 44 | aclocal -I config 45 | 46 | configure: configure.ac aclocal.m4 $(versionfiles) 47 | libtoolize --force --copy `libtoolize -n --install >/dev/null 2>&1 && echo --install` 48 | autoheader 49 | autoconf 50 | 51 | config.status: configure 52 | if [ -f config.status ]; then $(SHELL) ./config.status --recheck; \ 53 | else $(SHELL) ./configure; fi 54 | 55 | Makefile: config.status $(srcdir)/Makefile.in Makefile.include 56 | ./config.status 57 | Makefile.include: config.status $(srcdir)/Makefile.include.in 58 | ./config.status 59 | 60 | ### INSTALL 61 | 62 | install: check installdirs do-install 63 | 64 | install-strip: 65 | $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) $(STRIP)' install 66 | 67 | installdirs: 68 | $(MKDIR) $(libdir) $(bindir) $(sbindir) $(includedir) $(sysconfdir); \ 69 | if test "x$(ELISP)" != "x" ; then \ 70 | $(MKDIR) $(lispdir) ; \ 71 | fi 72 | 73 | ### GENERIC 74 | 75 | # do-all goes to all subdirectories and does all 76 | do-%: dep 77 | @target=`echo $@ | $(SED) -e 's/^do-//'`; \ 78 | for i in $(SUBDIRS) ; do \ 79 | if test -f ./$$i/Makefile ; then \ 80 | $(MAKE) -C ./$$i $${target} || exit 1 ;\ 81 | else \ 82 | true; \ 83 | fi; \ 84 | done 85 | 86 | 87 | # Configure & unconfigure 88 | 89 | # Maintainer portion, use at your own risk 90 | 91 | barf: 92 | @echo 'This command is intended for maintainers to use; it' 93 | @echo 'deletes files that may need special tools to rebuild.' 94 | @echo 'If you want to continue, please press return.' 95 | @echo -n "Hit Ctrl+C to abort." 96 | @read somevar 97 | 98 | 99 | # who / what does need tags 100 | TAGS: $(SRCS) $(HDRS) src/prog/gpm-root.y do-TAGS 101 | cd $(srcdir) && $(ETAGS) -o TAGS $(SRCS) $(HDRS) src/prog/gpm-root.y 102 | 103 | ### RELEASE STUFF 104 | TARS =../gpm-$(release).tar.gz 105 | TARS +=../gpm-$(release).tar.bz2 ../gpm-$(release).tar.xz 106 | 107 | M_HOST=arcana.linux.it 108 | M_DIR=gpm/ 109 | 110 | tars: $(TARS) 111 | chmod a+r $< 112 | 113 | # configure headers, produce new configure script 114 | distconf: Makefile.in Makefile.include.in configure acinclude.m4 $(versionfiles) 115 | 116 | ../gpm-$(release).tar: $(srcdir) distclean distconf 117 | # no exclude possible of .git with pax it seems, so the following is not possible: 118 | rm -rf "gpm-$(release)/" 119 | git archive --prefix "gpm-$(release)/" HEAD | tar xf - 120 | cd "gpm-$(release)/" && ./autogen.sh && rm -rf autom4te.cache 121 | tar cf $@ "gpm-$(release)/" 122 | rm -rf "gpm-$(release)/" 123 | 124 | ../gpm-$(release).tar.gz: ../gpm-$(release).tar 125 | gzip -9 -c $< > $@ 126 | 127 | ../gpm-$(release).tar.bz2: ../gpm-$(release).tar 128 | bzip2 -9 -c $< > $@ 129 | 130 | ../gpm-$(release).tar.xz: ../gpm-$(release).tar 131 | xz -9 -c $< > $@ 132 | 133 | # 3. Put package together into .tar.gz and .tar.bz2 134 | dist: disttest distclean distconf $(TARS) tars 135 | scp $(TARS) $(M_HOST):$(M_DIR) 136 | mv $(TARS) ~/niconetz/software/gpm/archives 137 | 138 | ### TEST: on nicos machine: not to be used anywhere else currently 139 | # create / update configure, delete other parts from earlier build 140 | disttest: distconf clean 141 | ./configure 142 | make all 143 | 144 | ### CLEANUP 145 | distclean: clean do-clean do-distclean 146 | rm -f config.log config.status* config.cache Makefile Makefile.include 147 | rm -rf autom4te.cache 148 | rm -f src/$(DEPFILE) 149 | 150 | allclean: do-allclean distclean 151 | rm -f configure aclocal.m4 152 | -------------------------------------------------------------------------------- /Makefile.include.in: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- (gpm/include) 2 | # 3 | # Copyright (C) 2001 Nico Schottelius 4 | # 5 | 6 | # set root, if you want to install to a virtual root 7 | ROOT = 8 | ifndef ROOT 9 | ROOT = $(DESTDIR) 10 | endif 11 | 12 | SHELL = /bin/sh 13 | 14 | prefix = @prefix@ 15 | exec_prefix = @exec_prefix@ 16 | 17 | # directories 18 | libdir = $(ROOT)@libdir@ 19 | datadir = $(ROOT)@datadir@ 20 | bindir = $(ROOT)@bindir@ 21 | sbindir = $(ROOT)@sbindir@ 22 | includedir = $(ROOT)@includedir@ 23 | sysconfdir = $(ROOT)@sysconfdir@ 24 | mandir = $(ROOT)@mandir@ 25 | man1dir = $(mandir)/man1 26 | man7dir = $(mandir)/man7 27 | man8dir = $(mandir)/man8 28 | infodir = $(ROOT)@infodir@ 29 | 30 | # autconf wants this, otherwise issues this warning: 31 | # config.status: WARNING: Makefile.include.in seems to ignore the --datarootdir setting 32 | datarootdir = @datarootdir@ 33 | 34 | # it would be nice to figure this out automatically, but the Emacs 35 | # load path often has many elements, most of them reserved for 36 | # specialised packages like w3 and auctex. 37 | lispdir = @lispdir@ 38 | 39 | # programs 40 | CC = @CC@ 41 | RANLIB = @RANLIB@ 42 | YACC = @YACC@ 43 | INSTALL = @INSTALL@ 44 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 45 | INSTALL_DATA = @INSTALL_DATA@ 46 | LN_S = @LN_S@ 47 | EMACS = @EMACS@ 48 | ELISP = @ELISP@ 49 | SHLIB = @SHLIB@ 50 | SED = @SED@ 51 | DIFF = @DIFF@ 52 | TEX = @TEX@ 53 | TEXINDEX = @TEXINDEX@ 54 | DVIPS = @DVIPS@ 55 | MAKEINFO = @MAKEINFO@ 56 | TEXI2HTML = texi2html 57 | STRIP = -s 58 | 59 | AR = ar 60 | ETAGS = etags 61 | AWK = awk 62 | CP = cp -a 63 | MKDIR = mkdir -p # linux specific, but who cares ? 64 | # gpm is linux specific, too. 65 | RM = rm 66 | 67 | 68 | DEPFILE = .depend 69 | 70 | release = @release@ 71 | -------------------------------------------------------------------------------- /README.gpm2: -------------------------------------------------------------------------------- 1 | I am thinking about restructing gpm, for the following reasons: 2 | 3 | - the code is old 4 | - the code is huge 5 | - the code is next to unmaintainable 6 | - the code is linux specific 7 | 8 | What I think one could reach: 9 | 10 | - create gpm, that runs on any Unix? 11 | - create gpm that is easy to extend 12 | - create gpm that is easy to maintain 13 | 14 | What ways are possible? 15 | 16 | - rewrite everything from scratch 17 | * takes a long time and much motivitation 18 | - migrate old code to clean codebase 19 | * takes some time to analyse old code 20 | * seems to me some way one could go 21 | 22 | How to do it? 23 | 24 | - new functions / code references 'gpm2' instead of gpm 25 | - perhaps some people want to sponsor me for creating a clean 26 | mouse driver for the console? 27 | => thus I got more time to focus on gpm2 28 | - motivate other foss developers to take part into it 29 | 30 | Let's see what happens! 31 | 32 | -- Nico Schottelius, 2007-05-11 2245 CEST in a train in Zurich 33 | -------------------------------------------------------------------------------- /README.versions: -------------------------------------------------------------------------------- 1 | Dear gpm README reader, 2 | 3 | this letter is to you, as I have to tell you about my idea of versioning 4 | of gpm. Traditionally, there were 1.19.x releases. That was, before the gpm 5 | source code and I met. After that, there was 1.20.x, indicating a new 6 | maintainer, but continuing with the old naming versioning. Today, on the 7 | 19th of February 2008, I decided to give gpm a real chance of getting a 8 | "second life" under the name of "gpm2" (as described in README.gpm2). It 9 | seems that the best effort for creating gpm2 is to rewrite everything, but 10 | to migrate the logic from the old code (as in: how to handle the individual 11 | mouse). 12 | 13 | So, how does that relate to the versions of gpm? Let us have a look at it: 14 | 15 | 1.19.x: old versions, not continued 16 | 1.20.x: current stable versions: no new features. 17 | 18 | 1.99.x: versions that move to 2.x, but contain much 1.20.x code. 19 | includes new features. 20 | 21 | 2.0.x: future stable versions 22 | 2.1.x: future testing versions 23 | 24 | Perhaps you have some comments to tell me? If so, just drop me a letter to 25 | nico-gpm-versions at schottelius.org. 26 | 27 | Yours, 28 | 29 | Nico 30 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | = /------\ /-----\ |----\ /-----\ = 3 | = || | | | | | | = 4 | = || | | | | | | thanks for every help. ;) = 5 | = || \-----/ |____/ \-----/ = 6 | ================================================================================ 7 | 8 | Tasks: 9 | 10 | 2012-10-26 Nico Schottelius 11 | * Fix buildprocess: add version to git and allow generated tar to be 12 | used for building 13 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl $Id: aclocal.m4,v 1.2 2002/05/28 19:13:50 nico Exp $ 2 | AC_DEFUN([ITZ_SYS_ELF], 3 | [AC_CACHE_CHECK([whether system is ELF],itz_cv_sys_elf, 4 | [AC_EGREP_CPP(win, 5 | [#ifdef __ELF__ 6 | win 7 | #else 8 | lose 9 | #endif 10 | ],[itz_cv_sys_elf=yes],[itz_cv_sys_elf=no])]) 11 | if test ${itz_cv_sys_elf} = yes && test x${ac_cv_prog_gcc} = xyes ; then 12 | PICFLAGS="-DPIC -fPIC" 13 | SOLDFLAGS="-fPIC -shared -Wl,-soname," 14 | else 15 | PICFLAGS= 16 | SOLDFLAGS= 17 | fi 18 | ]) 19 | AC_DEFUN([ITZ_PATH_SITE_LISP], 20 | [AC_CACHE_CHECK([where to install Emacs Lisp files],itz_cv_path_site_lisp, 21 | [eval itz_cv_path_site_lisp=`${EMACS} -batch -l ${srcdir}/exec.el -exec "(mapcar 'print load-path)" 2>/dev/null | 22 | sed -e '/^$/d' | sed -n -e 2p` 23 | case x${itz_cv_path_site_lisp} in 24 | x*site-lisp*) ;; 25 | x*) itz_cv_path_site_lisp='${datadir}/emacs/site-lisp' ;; 26 | esac]) 27 | ]) 28 | AC_DEFUN([ITZ_CHECK_TYPE], 29 | [AC_CACHE_CHECK([for $1],itz_cv_type_$1, 30 | AC_TRY_COMPILE([ 31 | #include <$2> 32 | ],[ 33 | $1 dummy; 34 | return 0; 35 | ],[itz_cv_type_$1=yes],[itz_cv_type_$1=no])) 36 | ]) 37 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ -d config ] || mkdir config 4 | 5 | version=$(git describe 2>/dev/null) 6 | 7 | # No git? use changelog information 8 | if [ -z "$version" ]; then 9 | version=$(grep '^[[:digit:]]' doc/changelog | head -n1 | cut -d: -f1) 10 | date=$(grep '^[[:digit:]]' doc/changelog | head -n1 | cut -d: -f2) 11 | else 12 | date=$(git log -1 --pretty="format:%ai" "$version") 13 | fi 14 | 15 | cat << eof > configure.ac 16 | AC_INIT([gpm],[$version],[http://www.nico.schottelius.org/software/gpm/]) 17 | 18 | releasedate="$date" 19 | release="$version" 20 | eof 21 | 22 | cat configure.ac.footer >> configure.ac 23 | 24 | ${ACLOCAL-aclocal} -I config 25 | ${LIBTOOLIZE-libtoolize} -n --install 2>/dev/null && LIBTOOL_FLAGS="--install" || LIBTOOL_FLAGS="" 26 | ${LIBTOOLIZE-libtoolize} --force --copy ${LIBTOOL_FLAGS} 27 | ${AUTOHEADER-autoheader} 28 | ${AUTOCONF-autoconf} 29 | -------------------------------------------------------------------------------- /conf/gpm-root.conf: -------------------------------------------------------------------------------- 1 | # sample configuration file for gpm-root 2 | # edit it to please your taste.... 3 | 4 | button 1 { 5 | name "ttys" 6 | 7 | "" f.nop 8 | "login on a new tty" f.mktty 9 | "" f.nop 10 | "tty 1" f.jptty "1" 11 | "tty 2" f.jptty "2" 12 | "tty 3" f.jptty "3" 13 | "tty 4" f.jptty "4" 14 | "" f.nop 15 | "tty 5" f.jptty "5" 16 | "tty 6" f.jptty "6" 17 | "tty 7" f.jptty "7" 18 | "tty 8" f.jptty "8" 19 | "" f.nop 20 | "more of them..." { 21 | 22 | "tty 9" f.jptty "9" 23 | "tty 10" f.jptty "10" 24 | "tty 11" f.jptty "11" 25 | "tty 12" f.jptty "12" 26 | "" f.nop 27 | "tty 13" f.jptty "13" 28 | "tty 14" f.jptty "14" 29 | "tty 15" f.jptty "15" 30 | "tty 16" f.jptty "16" 31 | "" f.nop 32 | "more of them..." { 33 | "tty 17" f.jptty "17" 34 | } 35 | } 36 | 37 | } 38 | 39 | button 2 { 40 | name "system status" 41 | foreground red 42 | background black 43 | border yellow 44 | head bright yellow 45 | 46 | "" f.nop 47 | "%b %d %Y" f.time 48 | "%H:%M" f.time 49 | "" f.nop 50 | "load: " f.load 51 | "free:" f.free 52 | "" f.nop 53 | "report disk usage to ~/du" f.bgcmd "du ~ | sort -rn > ~/du" 54 | "print mail headers to tty" f.bgcmd 55 | "grep '^From ' /var/spool/mail/$USER | tail" 56 | } 57 | 58 | button 3 { 59 | name "far ttys" 60 | 61 | foreground black 62 | background red 63 | border bright yellow 64 | head bright yellow 65 | 66 | "tty 9" f.jptty "9" 67 | "tty 10" f.jptty "10" 68 | "tty 11" f.jptty "11" 69 | "tty 12" f.jptty "12" 70 | "" f.nop 71 | 72 | "tty 13" f.jptty "13" 73 | "tty 14" f.jptty "14" 74 | "tty 15" f.jptty "15" 75 | "tty 16" f.jptty "16" 76 | "" f.nop 77 | 78 | # I use this to halt and reboot the system, but it isn't wise to put it 79 | # in widely accessible boxes. 80 | # 81 | # "----" f.nop 82 | # "" f.nop 83 | # "halt" f.bgcmd "/sbin/shutdown -h now" 84 | # "reboot" f.bgcmd "/sbin/shutdown -r now" 85 | } 86 | -------------------------------------------------------------------------------- /conf/gpm-syn.conf: -------------------------------------------------------------------------------- 1 | /* enabling configuration parameters */ 2 | [edge_motion_enabled] TRUE 3 | [edge_motion_speed_enabled] TRUE 4 | [corner_taps_enabled] TRUE 5 | [tap_gesture_enabled] TRUE 6 | [pressure_speed_enabled] TRUE 7 | [tossing_enabled] TRUE 8 | [does_toss_use_static_speed] TRUE 9 | /* pressure induced speed related configuration parameters */ 10 | [low_pressure] 60 11 | [speed_up_pressure] 60 12 | [pressure_factor] 0.10 13 | [standard_speed_factor] 0.10 14 | /* toss/catch related parameters */ 15 | [min_toss_time] 100 16 | [max_toss_time] 300 17 | [prevent_toss_time] 300 18 | [min_toss_dist] 2 19 | [static_toss_speed] 70 20 | [toss_speed_factor] 0.5 21 | /* edge motion related configuration parameters */ 22 | [edge_speed] 20 23 | /* corner tap actions */ 24 | [upper_left_action] 0 (none) 25 | [upper_right_action] 2 (middle) 26 | [lower_left_action] 0 (none) 27 | [lower_right_action] 3 (right) 28 | /* wmode parameters */ 29 | [wmode_enabled] TRUE 30 | [drag_lock_enabled] FALSE 31 | [finger_threshold] 30 32 | [tap_lower_limit] 5 33 | [tap_upper_limit] 200 34 | [tap_range] 100 35 | [tap_interval] 200 36 | [pads_tap_interval] 8 37 | [multiple_tap_delay] 30 38 | [palm_detect_enabled] TRUE 39 | [palm_detect_level] 12 40 | [multi_finger_tap_enable] TRUE 41 | [multi_finger_stop_enabled] TRUE 42 | [multi_finger_stop_delay] 8 43 | /* Additional options */ 44 | [touch_pad_enabled] TRUE 45 | [stick_enabled] TRUE 46 | [scrolling_enabled] TRUE 47 | [scrolling_edge] 2 48 | [auto_scrolling_enabled] TRUE 49 | 50 | -------------------------------------------------------------------------------- /configure.ac.footer: -------------------------------------------------------------------------------- 1 | AC_REVISION(configure.in,v 1.8 2012-10-26 nico) 2 | 3 | dnl Process this file with autoconf to produce a configure script. 4 | dnl written jan/1997 - T.E.Dickey 5 | 6 | AC_PREREQ(2.61) 7 | 8 | AC_CONFIG_SRCDIR([src/daemon/main.c]) 9 | AC_CONFIG_AUX_DIR([config]) 10 | AC_CONFIG_HEADER([src/headers/config.h]) 11 | 12 | AC_CANONICAL_HOST 13 | 14 | dnl Make srcdir an absolute path. 15 | if test x$srcdir = x ; then 16 | srcdir = `pwd` 17 | else 18 | srcdir=`cd $srcdir && pwd` 19 | fi 20 | 21 | # 22 | # Versioning stuff 23 | # 24 | abi_lev="2" 25 | abi_age="1" 26 | abi_rev="0" 27 | abi_full="${abi_lev}.${abi_age}.${abi_rev}" 28 | 29 | AC_DEFINE_UNQUOTED([GPM_ABI_LEV], [$abi_lev], [Library level]) 30 | AC_DEFINE_UNQUOTED([GPM_ABI_AGE], [$abi_age], [Library age]) 31 | AC_DEFINE_UNQUOTED([GPM_ABI_REV], [$abi_rev], [Library revision]) 32 | AC_DEFINE_UNQUOTED([GPM_ABI_FULL],["$abi_full"],[Full library version]) 33 | 34 | # 35 | # Find programs 36 | # 37 | 38 | AC_PROG_CC 39 | AC_PROG_LIBTOOL 40 | AC_PROG_INSTALL 41 | AC_PROG_YACC 42 | AC_PROG_LN_S 43 | 44 | # check for programs. 45 | AC_PATH_PROG(DVIPS,dvips,no) 46 | AC_PATH_PROG(TEXI2HTML,texi2html,no) 47 | AC_PATH_PROG(TEX,tex,no) 48 | AC_PATH_PROG(TEXINDEX,texindex,no) 49 | AC_PATH_PROG(MAKEINFO,makeinfo,no) 50 | AC_PATH_PROG(DIFF,diff,no) 51 | AC_PATH_PROG(SED,sed,no) 52 | AC_PATH_PROG(emacs,emacs,no) 53 | 54 | if test ${ac_cv_path_emacs} = no ; then 55 | EMACS=: 56 | ELISP= 57 | else 58 | EMACS=${ac_cv_path_emacs} 59 | ELISP="emacs/t-mouse.el emacs/t-mouse.elc" 60 | fi 61 | 62 | if test $EMACS != : ; then 63 | ITZ_PATH_SITE_LISP 64 | lispdir=${itz_cv_path_site_lisp} 65 | else 66 | lispdir='${datadir}/emacs/site-lisp' 67 | fi 68 | 69 | # Header-checks 70 | AC_CHECK_HEADERS(syslog.h linux/input.h linux/joystick.h ncurses.h ncurses/curses.h curses.h) 71 | AC_CHECK_HEADERS(sys/sysmacros.h linux/major.h linux/tty.h) 72 | 73 | # Required headers 74 | AC_CHECK_HEADERS(sys/socket.h,,[AC_MSG_ERROR([Required header file missing])]) 75 | 76 | AC_ARG_ENABLE([static], 77 | [ --enable-static build static libraries @<:@default=no@:>@]) 78 | 79 | LIBGPM_A= 80 | 81 | AS_IF([test "x$enable_static" = "xyes"], [ 82 | LIBGPM_A=lib/libgpm.a 83 | ]) 84 | 85 | 86 | AC_ARG_WITH(curses, 87 | [ --without-curses disable curses support even if curses found]) 88 | 89 | CURSES_OBJS= 90 | 91 | case $with_curses in 92 | No|no|N|n) : ;; 93 | *) if test ${ac_cv_header_ncurses_h} = yes || 94 | test ${ac_cv_header_ncurses_curses_h} = yes || 95 | test ${ac_cv_header_curses_h} = yes ; then 96 | CURSES_OBJS=lib/libcurses.o ; fi ;; 97 | esac 98 | 99 | 100 | ITZ_CHECK_TYPE(__u32,linux/types.h) 101 | if test ${itz_cv_type___u32} = yes || test ${ac_cv_type___u32} = yes ; then 102 | AC_DEFINE(HAVE___U32, 1, [define if the __u32 type exists either in sys/types.h or in linux/types.h]) 103 | fi 104 | 105 | ITZ_SYS_ELF 106 | if test ${itz_cv_sys_elf} = yes && test x${ac_cv_prog_gcc} = xyes ; then 107 | SHLIB=libgpm.so 108 | else 109 | SHLIB= 110 | fi 111 | 112 | AC_CHECK_FUNCS(vsyslog syslog) 113 | AC_FUNC_ALLOCA 114 | 115 | case $with_curses in 116 | No|no|N|n) SHARED_LIBS=-lc ;; 117 | *) 118 | SAVELIBS=$LIBS 119 | LIBS= 120 | for i in tinfo ncurses termcap termlib; do 121 | if test x$LIBS = x; then 122 | AC_CHECK_LIB($i, tputs) 123 | else :; fi 124 | done 125 | TERMLIBS=$LIBS 126 | LIBS= 127 | for i in ncurses curses ncursesw; do 128 | if test x$LIBS = x; then 129 | AC_CHECK_LIB($i, wgetch,,,$TERMLIBS) 130 | else :; fi 131 | done 132 | SHARED_LIBS="$LIBS $TERMLIBS -lc" 133 | LIBS=$SAVELIBS ;; 134 | esac 135 | 136 | GPMXTERM= 137 | AC_SUBST(GPMXTERM) 138 | AC_SUBST(abi_lev) 139 | AC_SUBST(abi_full) 140 | AC_SUBST(EMACS) 141 | AC_SUBST(ELISP) 142 | AC_SUBST(SHLIB) 143 | AC_SUBST(PICFLAGS) 144 | AC_SUBST(SOLDFLAGS) 145 | AC_SUBST(LIBGPM_A) 146 | AC_SUBST(CURSES_OBJS) 147 | AC_SUBST(SHARED_LIBS) 148 | AC_SUBST(lispdir) 149 | AC_SUBST(release) 150 | AC_SUBST(release_date) 151 | 152 | CPPFLAGS="$CPPFLAGS "'-I$(srcdir) $(DEFS) -include headers/config.h -Wall -DSYSCONFDIR="\"$(sysconfdir)\"" -DSBINDIR="\"$(sbindir)\"" -D_GNU_SOURCE' 153 | LDFLAGS="$LDFLAGS "'-L$(srcdir)' 154 | 155 | dnl AC_DEFINE_UNQUOTED(SYSCONFDIR,"$sysconfdir") 156 | dnl AC_DEFINE_UNQUOTED(SBINDIR,"$sbindir") 157 | AC_OUTPUT(Makefile.include Makefile doc/Makefile src/Makefile contrib/Makefile doc/doc.gpm) 158 | -------------------------------------------------------------------------------- /contrib/Makefile.in: -------------------------------------------------------------------------------- 1 | # -*-makefile-*- (gpm/contrib) 2 | # 3 | # Copyright (C) 2001 Nico Schottelius 4 | # 5 | 6 | 7 | srcdir = @srcdir@ 8 | top_builddir = .. 9 | 10 | include $(top_builddir)/Makefile.include 11 | 12 | all: $(srcdir)/$(ELISP) 13 | 14 | install: all 15 | if [ -n "$(ELISP)" ]; then for i in `echo $(ELISP)`; do \ 16 | $(INSTALL_DATA) $(srcdir)/$$i $(lispdir)/`basename $$i` ;\ 17 | done; fi 18 | 19 | %.elc: %.el 20 | $(EMACS) -batch -l $(srcdir)/emacs/exec.el -exec '(byte-compile-file "$<")' 21 | 22 | uninstall: 23 | if [ -n "$(ELISP)" ]; then for i in `echo $(ELISP)`; do \ 24 | rm -f $(lispdir)/$$i ;\ 25 | done; fi 26 | 27 | dist: 28 | $(CP) -r $(srcdir) $(top_builddir)/gpm-$(release)/ 29 | 30 | clean distclean: 31 | $(RM) -f $(srcdir)/emacs/*.elc Makefile 32 | -------------------------------------------------------------------------------- /contrib/emacs/exec.el: -------------------------------------------------------------------------------- 1 | (setq command-switch-alist '( 2 | ("-exec" . cmdline-exec))) 3 | 4 | (defun cmdline-exec (name) 5 | (eval (car (read-from-string (car command-line-args-left)))) 6 | ) 7 | -------------------------------------------------------------------------------- /contrib/init/gpm.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: gpm.init,v 1.2 2002/05/28 19:13:51 nico Exp $ 3 | # 4 | # chkconfig: 2345 85 15 5 | # description: \ 6 | # gpm provides mouse support to text-based Linux applications as \ 7 | # well as console cut-and-paste operations using the mouse. 8 | # 9 | # processname: gpm 10 | # pidfile: /var/run/gpm.pid 11 | # config: /etc/sysconfig/mouse 12 | 13 | # source function library 14 | . /etc/init.d/functions 15 | 16 | OWL_STARTUP_ENABLE=1 17 | 18 | MOUSECFG=/etc/sysconfig/mouse 19 | 20 | case "$1" in 21 | start) 22 | if [ -f "$MOUSECFG" ]; then 23 | . "$MOUSECFG" 24 | else 25 | MOUSETYPE="none" 26 | fi 27 | 28 | if [ "$MOUSETYPE" = "none" ]; then 29 | echo "Not starting gpm (no mouse is configured)" 30 | exit 0 31 | fi 32 | 33 | if [ "$MOUSETYPE" = "Microsoft" ]; then 34 | MOUSETYPE=ms 35 | fi 36 | 37 | if [ -n "$MOUSETYPE" ]; then 38 | GPM_ARG="-t $MOUSETYPE" 39 | else 40 | GPM_ARG="" 41 | fi 42 | 43 | if [ "0$OWL_STARTUP_VERSION" -ge 3 ]; then 44 | daemon --pidfile /var/run/gpm.pid --expect-user root \ 45 | -- gpm "$GPM_ARG" 46 | else 47 | daemon gpm "$GPM_ARG" 48 | fi 49 | ;; 50 | stop) 51 | if [ "0$OWL_STARTUP_VERSION" -ge 3 ]; then 52 | killproc --pidfile /var/run/gpm.pid --expect-user root gpm 53 | else 54 | killproc gpm 55 | fi 56 | ;; 57 | restart|reload) 58 | $0 stop 59 | $0 start 60 | ;; 61 | status) 62 | status --pidfile /var/run/gpm.pid --expect-user root gpm 63 | ;; 64 | *) 65 | echo "Usage: gpm {start|stop|restart|status}" 66 | exit 1 67 | esac 68 | 69 | exit $? 70 | -------------------------------------------------------------------------------- /contrib/other/README: -------------------------------------------------------------------------------- 1 | Have a look into MANIFEST for more informations. 2 | 3 | README - this file 4 | TPdetect.cc - sample TP detection 5 | -------------------------------------------------------------------------------- /contrib/scripts/create_vcs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Script by Jakub Jelinek 4 | # Modified by Ian Zimmerman to reflect names from 5 | # kernel device list 6 | # $Id: create_vcs,v 1.2 2002/05/28 19:13:52 nico Exp $ 7 | 8 | if test -e /dev/vcs0 || test -e /dev/vcs 9 | then 10 | exit 11 | fi 12 | 13 | I=0 14 | while [ $I -lt 25 ] 15 | do 16 | mknod /dev/vcs$I c 7 $I 17 | chmod 622 /dev/vcs$I 18 | chown root.tty /dev/vcs$I 19 | mknod /dev/vcsa$I c 7 `expr $I + 128` 20 | chmod 622 /dev/vcsa$I 21 | chown root.tty /dev/vcsa$I 22 | I=`expr $I + 1` 23 | done 24 | ln -s vcs0 /dev/vcs 25 | ln -s vcsa0 /dev/vcsa 26 | -------------------------------------------------------------------------------- /contrib/scripts/debug_to_report: -------------------------------------------------------------------------------- 1 | 2 | cat $1 | sed 's/gpm_debug_log/gpm_report/g' > $1.tmp 3 | cat $1.tmp | sed 's/LOG_NOTICE/GPM_PR_INFO/g' > $1.tmp2 4 | cat $1.tmp2 | sed 's/LOG_ERR/GPM_PR_ERR/g' > $1.tmp 5 | cat $1.tmp | sed 's/LOG_WARN/GPM_PR_WARN/g' > $1.tmp2 6 | cat $1.tmp2 | sed 's/LOG_DEBUG/GPM_PR_DEBUG/g' > $1.tmp 7 | echo "done:" $1.tmp 8 | -------------------------------------------------------------------------------- /contrib/scripts/gpm_release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Date: 26th of September 2001 4 | # Description: still missing 5 | # Author: Nico Schottelius (nicos@pcsystems.de), 26th of September 2001 6 | # Copying: GPL 2.0 7 | # 8 | 9 | if [ $# -ne 1 ]; then 10 | echo `basename $0`': dir' 11 | echo 'Hey, hey guy, what to release ?' 12 | exit 1 13 | fi 14 | 15 | if [ ! -d $1 ]; then 16 | echo `basename $0`': dir' 17 | echo 'HEY! DIRECTORY! We need a gpm directory!' 18 | exit 1 19 | fi 20 | 21 | version=`echo $1 | sed 's/\/$//' | sed 's/gpm-//'` 22 | echo -n "Releasing gpm-$version ..." 23 | 24 | cd $1 25 | 26 | cat configure.in | sed "s/release=.\*/release=$version/" > configure.on 27 | mv configure.on configure.in 28 | autoconf 29 | 30 | cat src/headers/gpmCfg.h | sed "s/\(#define GPM_DATE\).*/\1 \"`date`\"/" > src/headers/gpmCfg.i; mv src/headers/gpmCfg.i src/headers/gpmCfg.h 31 | 32 | cd .. 33 | 34 | tar cfz gpm-$version.tar.gz $1 35 | tar cfI gpm-$version.tar.bz2 $1 36 | 37 | echo done. 38 | -------------------------------------------------------------------------------- /contrib/scripts/make_diff: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Date: 3rd of October 2001 3 | # Description: still missing 4 | # Author: Nico Schottelius (nicos@pcsystems.de), 3rd of October 2001 5 | # Copying: GPL 2.0 6 | # 7 | 8 | diff -u --recursive --new-file $@ 9 | -------------------------------------------------------------------------------- /contrib/scripts/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | # $Id: mkinstalldirs,v 1.2 2002/05/28 19:13:52 nico Exp $ 8 | 9 | errstatus=0 10 | 11 | for file 12 | do 13 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 | shift 15 | 16 | pathcomp= 17 | for d 18 | do 19 | pathcomp="$pathcomp$d" 20 | case "$pathcomp" in 21 | -* ) pathcomp=./$pathcomp ;; 22 | esac 23 | 24 | if test ! -d "$pathcomp"; then 25 | echo "mkdir $pathcomp" 1>&2 26 | 27 | mkdir "$pathcomp" || lasterr=$? 28 | 29 | if test ! -d "$pathcomp"; then 30 | errstatus=$lasterr 31 | fi 32 | fi 33 | 34 | pathcomp="$pathcomp/" 35 | done 36 | done 37 | 38 | exit $errstatus 39 | 40 | # mkinstalldirs ends here 41 | -------------------------------------------------------------------------------- /contrib/scripts/replace_2_with_3_spaces: -------------------------------------------------------------------------------- 1 | # 8 -> 2*4 --> 4*3 = 12 2 | cat $1 | sed 's/^ \([^ ]\)/ \1/g' > $1.tmp 3 | # 6=3*2 --> 3*3=9 4 | cat $1.tmp | sed 's/^ \([^ ]\)/ \1/g' > $1.tmp2 5 | # 4=2*2 --> 2*3=6 6 | cat $1.tmp2 | sed 's/^ \([^ ]\)/ \1/g' > $1.tmp 7 | # 2=1*2 --> 1*3=3 8 | cat $1.tmp | sed 's/^ \([^ ]\)/ \1/g' > $1.tmp2 9 | echo done: $1.tmp2 10 | -------------------------------------------------------------------------------- /contrib/scripts/replace_tab_with_3_spaces: -------------------------------------------------------------------------------- 1 | # 4 tabs 2 | cat $1 | sed 's/^ \([^ ]\)/ \1/g' > $1.tmp 3 | # 3 tabs 4 | cat $1.tmp | sed 's/^ \([^ ]\)/ \1/g' > $1.tmp2 5 | # 2 tabs 6 | cat $1.tmp2 | sed 's/^ \([^ ]\)/ \1/g' > $1.tmp 7 | # 1 tab 8 | cat $1.tmp | sed 's/^ \([^ ]\)/ \1/g' > $1.tmp2 9 | rm $1.tmp 10 | echo done: $1.tmp2 11 | -------------------------------------------------------------------------------- /contrib/scripts/test_gpm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Date: 18th of September 2001 4 | # Description: Test gpm with this script :) 5 | # Author: Nico Schottelius (nicos@pcsystems.de), 3rd of October 2001 6 | # Copying: GPL 2.0 7 | # Version: 0.2 8 | # 9 | 10 | PREFIX=test- 11 | POSTFIX= 12 | 13 | if [ $# -ne 1 ]; then 14 | echo `basename $0`': dir' 15 | echo 'Hey, hey guy, what to test ?' 16 | exit 1 17 | fi 18 | 19 | if [ ! -d $1 ]; then 20 | echo `basename $0`': dir' 21 | echo 'HEY! I need a DIRECTORY! Not something else!' 22 | exit 1 23 | fi 24 | 25 | echo rm -rf $PREFIX`basename $1`$POSTFIX -r 26 | rm -rf $PREFIX`basename $1`$POSTFIX -r 27 | echo cp $1 $PREFIX`basename $1`$POSTFIX -r 28 | cp $1 $PREFIX`basename $1`$POSTFIX -r 29 | 30 | echo rm -rf mkdir objdir 31 | rm -rf objdir/ && mkdir -p objdir && cd objdir 32 | echo configure 33 | ../$PREFIX`basename $1`$POSTFIX/configure --prefix=/usr/sys 34 | echo make 35 | make 36 | -------------------------------------------------------------------------------- /doc/Announce: -------------------------------------------------------------------------------- 1 | This is to announce gpm-1.0, available by ftp from 2 | 3 | iride.unipv.it:/pub/gpm/gpm-1.0.tar.gz (my site) and 4 | sunsite.unc.edu:/pub/Linux/Incoming/gpm-1.0.tar.gz its final destination 5 | on sunsite and mirrors will be /pub/Linux/system/Daemons 6 | 7 | 8 | What's gpm? 9 | 10 | Gpm ("general purpose mouse") is a user-level daemon in charge of mouse 11 | management. It can deliver mouse events to clients on a per-console basis. 12 | Its client library eases writing mouse-sensitive application which will run 13 | under both the Linux console and xterm. 14 | 15 | Gpm is part of slackware since November 1994 (gpm-0.90). 16 | 17 | From 0.98.x onward it supported two mice running concurrently (like you 18 | do with "MultiMouse") and it can repeat events to an external fifo 19 | (like you do with "mconv"). 20 | 21 | 22 | What's new? 23 | 24 | What made me switch to 1.0 is the availability of the high-level library, 25 | a useful tool for mouse programmers, together with a sample application 26 | using that library ("hltest"). 27 | 28 | "mouse-test" is available as well -- it is a tiny utility meant to 29 | help you in detecting what protocol does your mouse speak. Not too 30 | smart (it has to run attended), but useful when you change mouse. 31 | It works well with serial mice, and is otherwise untested. 32 | 33 | gpm-root is now capable to draw recursive menus. Console locking is still 34 | missing, lazy me. 35 | 36 | The daemon is able to manage two mice running concurrently, 37 | this should be useful for those owning a laptop. 38 | 39 | t-mouse.el is enhanced, in mode-line and vertical-line management (not by 40 | me, actually). 41 | 42 | The alpha architecture is supported. 43 | 44 | 45 | What about the future, after 1.0? 46 | 47 | Most likely I'll release bug-fix updates in the near future (I only 48 | own one mouse :-). 49 | 50 | After that I'll consider making gpm a kernel module, implementing a 51 | mouse-type independent mouse driver. The device driver will be 52 | completely compatible with applications linked with libgpm version 1.0 53 | or later. In this sense 1.0 is incompatible with previous versions: 54 | applications linked with older libraries won't run with the kernel module. 55 | 56 | 57 | I never use text consoles. 58 | 59 | Then, gpm is not important for you (unless you write mouse-sensitive 60 | curses-based application). 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /doc/HACK_GPM: -------------------------------------------------------------------------------- 1 | Hello! 2 | 3 | Nice that you read this document, looks like someone wants to improve gpm again. 4 | I assume you have a good idea or you did some good work you want to see in the 5 | main gpm tree. To make life easy for you and me, please follow the instructions: 6 | 7 | * if you send a patch, explain why it's needed 8 | * if possible, please patch against latest cvs sources (see README) 9 | * if the patch introduces generally new things, explain how it works 10 | * use 3 spaces tabs in the source files (if you use tabs, look into 11 | contrib/scripts/replace_tab_with_3_spaces) 12 | * if the patch is not big, use one file 13 | * if you have to use more files, tar them 14 | * include directory structure (src/mice.c and not mice.c) 15 | * everything fine ? So send the patch. 16 | 17 | Thanks for your help, 18 | 19 | Nico 20 | -------------------------------------------------------------------------------- /doc/README.1.20.2: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dear reader, 4 | 5 | 6 | you are reading this document, because you saw that there is a new 7 | release of gpm available, gpm 1.20.2. 8 | 9 | Unfortunately this release is broken, but that's not a big problem. 10 | 11 | gpm is broken for some time and I did not spent any time to the project 12 | for about two years. 13 | 14 | Some weeks ago, I was contacted by someone asking me to write a very 15 | small feature for gpm (a small client program, included in this 16 | release). I answered the person that I do not have the time to code 17 | that part, but if he really insists that I should write that code, 18 | he should think about sponsoring me [0]. 19 | 20 | Some days later I recieved an email that he wanted to sponsor me. 21 | I was a little bit surprised, because it was the first person really 22 | considering my sponsoring plans. 23 | 24 | So I coded that small program and had some views in the old code of 25 | gpm. There's so much information in it, so many hacks, so many dirty 26 | tricks and there are still many people using it. 27 | 28 | So I considered to try to spent more time to gpm, perhaps even creating 29 | a more clean (and better maintainable) version of it. 30 | 31 | But I _am_ actually a pretty busy person, working almost all time, if not 32 | doing sports (just about 6 hours a week) or sleeping. 33 | 34 | So I thought, perhaps you can help me to get more time for coding FOSS [1] 35 | in general or gpm in specific: 36 | 37 | My idea is, that if you consider sponsoring my work, I can begin to work less 38 | "traditionally" and also finance my second study in computer science, which 39 | I will begin in autumn 2008, if I have the money to do it (living in 40 | Switzerland is not that cheap). 41 | 42 | I am looking forward to get any feedback from you about this idea 43 | at nico-gpm-sponsoring (at) schottelius.org. 44 | 45 | Thanks for reading, 46 | 47 | 48 | Nico Schottelius, 12. May 2007 49 | 50 | 51 | P.S.: GPM is alive! 52 | 53 | [0]: Sponsoring information: http://nico.schottelius.org/about/support 54 | [1]: FOSS: http://nico.schottelius.org/documentations/foss/the-term-foss/ 55 | -------------------------------------------------------------------------------- /doc/README.etouch: -------------------------------------------------------------------------------- 1 | 2 | This file tells how to use gpm and X with a Elotouch screen with 3 | serial interface at 9600 Baud No parity. 4 | 5 | CALIBRATION 6 | ----------- 7 | 8 | Calibration is done in console mode using the program "elocalib" 9 | available from http://www.dobit.com/emblin/pub/elocalib.tgz 10 | See also elocalib --help 11 | To start calibration at console 128x48, for screen 1024x786 12 | > elocalib /dev/ttyS0 -c128 -r48 -w1024 -h768 13 | 14 | Touch the upper-left corner and write down the coordinates Xmin, Ymin 15 | Touch the bottom-right corner and write down the coordinates Xmax, Ymax 16 | Update the file gpm-calibration with this coordinates 17 | 18 | > cat /usr/local/etc/gpm-calibration 19 | # EloTouch calibration coordinates Xmin Ymin Xmax Ymax 20 | 4010 80 80 4010 21 | 22 | 23 | GPM OPERATION 24 | ------------- 25 | 26 | > gpm -m /dev/ttyS0 -t etouch -o clickontouch -Rsumma 27 | 28 | 29 | X OPERATION 30 | ----------- 31 | 32 | In order to use the touchscreen in X, you should install in your 33 | system the "gpmsumma" module 34 | available from http://www.annet.pl/~anowak/mtouch/gpmsumma_drv.o 35 | or from http://www.dobit.com/emblin/pub/gpm_etouch.tgz 36 | 37 | /usr/lib/X11/modules/input/gpmsumma_drv.o 38 | 39 | 40 | Then add the following sections to your XF86config: 41 | 42 | Section "InputDevice" 43 | Identifier "EloTouch" 44 | Driver "gpmsumma" 45 | Option "Device" "/dev/gpmdata" 46 | Option "SendCoreEvents" "On" 47 | EndSection 48 | 49 | Section "ServerLayout" 50 | InputDevice "EloTouch" "SendCoreEvents" 51 | ... 52 | EndSection 53 | -------------------------------------------------------------------------------- /doc/README.microtouch: -------------------------------------------------------------------------------- 1 | 2 | This file tells how to use gpm and X with a touch screen (this is 3 | being written as an addition to gpm 1.17.5 and currently the only 4 | supported touchscreen is the MicroTouch). 5 | 6 | 7 | USER INTERFACE 8 | -------------- 9 | 10 | The decoder currently implemented in gpm is quite simple: it only 11 | supports mouse motion and button-1 events. 12 | 13 | When a user touches the screen, the decoder generates mouse motion 14 | events. Tapping on the screen generates button-press (as well as drag and 15 | release) events. 16 | 17 | A "tap" is a finger-down event generated quickly after a finger-up 18 | (half a secon at most). This means that you'll usually move the 19 | pointer to the desired position and then tap on it. 20 | 21 | Double-and triple clicks are easily generated by repeated tapping. 22 | 23 | Since tapping is usually accompanied by a small movement, the decoder 24 | will use the coordinates of the finger-up event for the button-press. 25 | Further dragging will be relative to the tapping position (i.e., the 26 | finger-up position). Moreover, the last coordinate pair received on 27 | finger-up is discarded, because it usually is slightly offset (due to 28 | the non-negligible area of the fingertip) 29 | 30 | 31 | GPM OPERATION 32 | ------------- 33 | 34 | In order to run the touchscreen with gpm, you need to update the 35 | /dev/mouse symbolic link to point to the right serial port; then 36 | invoke gpm with a command line like 37 | 38 | gpm -t mtouch 39 | 40 | Unfortunately, there is currently no way to paste text. I think some 41 | modifier key should be eligible to this role but this would mean an 42 | in-depth modification to gpm. We have to discuss about it to make the 43 | right choice. 44 | 45 | 46 | Calibration 47 | ----------- 48 | 49 | To calibrate the touchscreen, use the program "microtouch-setup" found 50 | in the source tree of gpm. The gpm daemon must already be running in 51 | order for the program to work flawlessly, as the program stops and 52 | restarts gpm internally (it depends on gpm for correct serial port 53 | initialization). "microtouch-setup" uses /dev/mouse to access the 54 | serial port, so /dev/mouse should point to a "ttyS" device. 55 | 56 | 57 | X OPERATION 58 | ----------- 59 | 60 | In order to use the touchscreen in X, you should install in your 61 | system the "Summa" module, as modified by Frank Holtz (the driver is 62 | available from http://www.hof-berlin.de/tablet/tablet.html). 63 | 64 | Gpm must run in repeater mode, with a command line like: 65 | gpm -t mtouch -Rsumma 66 | , which instructs gpm to repeat packets according to the Summa protocol. 67 | 68 | Then, you need to add the following sections to your XF86config: 69 | 70 | Section "module" 71 | Load "xf86Summa.so" 72 | EndSection 73 | 74 | Section "Xinput" 75 | Subsection "SummaSketch" 76 | Port "/dev/gpmdata" 77 | DeviceName "touchscreen" 78 | Mode Absolute 79 | AlwaysCore 80 | EndSubSection 81 | EndSection 82 | 83 | 84 | Moreover, you should disable the "Pointer" section. I used a trick 85 | like this one: 86 | 87 | Section "Pointer" 88 | Protocol "MouseSystems" 89 | Device "/dev/fifo" 90 | EndSection 91 | 92 | Where /dev/fifo is just a plain unused fifo ("mknod /dev/fifo p") 93 | 94 | Calibration 95 | ----------- 96 | 97 | To calibrate the touchscreen, use the program "microtouch-setup" found 98 | in the source tree of gpm (yes, it is the same program used for the 99 | text mode). The gpm daemon must already be running in order for the 100 | program to work flawlessly, as the program stops and restarts gpm 101 | internally (it depends on gpm for correct serial port 102 | initialization). "microtouch-setup" uses /dev/mouse to access the 103 | serial port, so /dev/mouse should point to a "ttyS" device. 104 | -------------------------------------------------------------------------------- /doc/changelog: -------------------------------------------------------------------------------- 1 | 1.20.8: 2 | * Remove lzma, use xz (Mike Frysinger) 3 | * Install shared lib with +x perms (Mike Frysinger) 4 | 5 | 1.20.7: 2012-10-26 6 | * Fix inclusion of unwanted binary data 7 | * Even more cleanups (Mike Frysinger) 8 | * Fix hyphen-used-as-minus-sign issues in manpages. (ﺄﺤﻣﺩ ﺎﻠﻤﺤﻣﻭﺪﻳ) 9 | * Don't build static libgpm by default (Sean McGovern) 10 | * autogen.sh is now required to create setup version in autoconf (Nico Schottelius) 11 | 12 | 1.20.6: 9th of February 2009 13 | * Some cleanups (Mike Frysinger/Nico Schottelius) 14 | * Pull in fcntl.h rather than unistd.h for open() (Mike Frysinger) 15 | * Fix gcc warning "control reaches end of non-void function" (Mike Frysinger) 16 | * Fix building with libtool-2 (Mike Frysinger) 17 | 18 | 1.20.5: 16th of June 2008 19 | * Fix possible segfault (FD_SET/negative) (Guillem Jover) 20 | * Move more messages to debug (Jonathan Nieder) 21 | * Remove unecessary headers (Jonathan Nieder) 22 | * Allow specifying ELISP variable on commandline (Ulrich Mueller) 23 | * Fix broken code semantics (Mike Frysinger) 24 | * Cleanup documentation (Nico Schottelius) 25 | * Fix socklen_t issue: Require posix header (Mike Frysinger/Nico Schottelius) 26 | * Fix building with glibc 2.8 (Mike Frysinger) 27 | * Updated library to version 2.1.0 (Nico Schottelius) 28 | Gpm_GetLibVersion behaves more consistent (all numbers are one or two digits) 29 | * Including dynamically generated version from git (Nico Schottelius) 30 | 31 | 1.20.4: ? 32 | * Corrected typos 33 | * Added automatic local build test 34 | * Fixed SONAME (praise the Debian guys, Jonathan Nieder) 35 | -------------------------------------------------------------------------------- /doc/infofilter: -------------------------------------------------------------------------------- 1 | #! /usr/bin/sed -f 2 | 3 | 4 | # allow "%" as a comment char 5 | s/^%/@c / 6 | s/[^\\]%.*$// 7 | s/\\%/%/ 8 | 9 | #preserve blanks in @lisp blocks 10 | /@lisp/,/@end lisp/ p 11 | /@lisp/,/@end lisp/ d 12 | 13 | # remove leading blanks 14 | s/^[ ]*// 15 | 16 | #s/\\t/@code/g 17 | -------------------------------------------------------------------------------- /doc/manpager: -------------------------------------------------------------------------------- 1 | #! /usr/bin/awk -f 2 | # Copyright (c) 1998-2001 Alessandro Rubini 3 | 4 | BEGIN {IN=0} 5 | 6 | /^%MANPAGE END/ {IN=0; next} 7 | /^%MANPAGE/ {IN=1; USELP=NEEDLP=INTABLE=0; NAME=$2; next} 8 | IN==0 {next} 9 | 10 | /^%MSKIP/ {SKIP=1;next} 11 | /^%M/ {SKIP=0} 12 | 13 | /^@menu/ {SKIP=1;next} 14 | /^@end menu/ {SKIP=0;next} 15 | 16 | SKIP==1 {next} 17 | /^%M$/ {next} 18 | /^@ignore/ {next} 19 | /^@end ign/ {next} 20 | 21 | #now perform all the substitutions needed 22 | 23 | { gsub("^%M ?",""); } 24 | 25 | # Use gensub for converting tags: itz Sep 30 1998 26 | # 27 | # However, the gensub function is gawk-specific, and we want things 28 | # to work with original-awk too (for portability). 29 | # Therefore, use a normal gsub, even though it's a subobptimal solution 30 | # as it may step in extra braces. The good solution will be piping to sed, 31 | # or match, extract subesxpression, replace, reinsert -- bleah... 32 | # (ARub, Oct 10 2000) 33 | /@b\{/ { 34 | #$0 = gensub(/@b\{([^}]+)\}/, "\\\\fB\\1\\\\fP","g"); 35 | gsub("@b\{","\\fB"); 36 | gsub("\}","\\fP"); 37 | } 38 | 39 | /@var\{/ { 40 | #$0 = gensub(/@var\{([^}]+)\}/, "\\\\fI\\1\\\\fP","g"); 41 | gsub("@var\{","\\fB"); 42 | gsub("\}","\\fP"); 43 | } 44 | 45 | /@(samp|code|file)\{/ { 46 | #$0 = gensub(/@(samp|code|file)\{([^}]+)\}/, "`\\2'","g"); 47 | gsub("@(samp|code|file)\{",""); 48 | gsub("\}",""); 49 | } 50 | 51 | 52 | /@xref\{.*\}\./ { 53 | gsub(/@xref\{.*\}\./,""); 54 | } 55 | 56 | /@ref\{.*\}/ { 57 | gsub("@ref\{",""); 58 | gsub("\}",""); 59 | } 60 | 61 | /@\*/ { 62 | gsub(/@\* */,"\n.br\n"); 63 | } 64 | 65 | /@[a-z]+\{/ { 66 | gsub("@[a-z]+\\{",""); 67 | gsub("}",""); 68 | } 69 | 70 | /^@table/ { TABLE=1; } 71 | /^@itemize/ { TABLE=1; next} 72 | 73 | /^@item/ { 74 | gsub("^@item *",""); 75 | printf ".TP\n%s\n",$0 > NAME; 76 | NEEDLP=0; next; 77 | } 78 | 79 | /^@end table/ {TABLE=0} 80 | /^@end itemize/ {TABLE=0} 81 | 82 | # discard other texinfo commands 83 | 84 | /^@/ {next} 85 | 86 | # manage comments and '%' 87 | 88 | /^%/ {next} 89 | 90 | 91 | { 92 | gsub("[^\\\\]%.*$",""); 93 | gsub("\\%","%"); 94 | } 95 | 96 | 97 | # remove leading blanks 98 | 99 | /^[ \t]/ {gsub("^[ \t]","");} 100 | 101 | # put a .LP at blank lines 102 | 103 | /^.nf/ {USELP=0} 104 | /^.fi/ {USELP=1} 105 | 106 | /^$/ {if (USELP) {NEEDLP++; next;} } 107 | 108 | 109 | /./ { if (NEEDLP) { printf "\n.LP\n" > NAME; NEEDLP=0; } } 110 | 111 | /^.TH/ {USELP=1} 112 | 113 | # Escape single slashes (e.g. in documentation for `-l' command line option) 114 | 115 | {gsub("\\\\ ", "\\\\ ");} 116 | 117 | {gsub("~", "~~");} 118 | 119 | {print > NAME} 120 | 121 | 122 | -------------------------------------------------------------------------------- /doc/mktxt: -------------------------------------------------------------------------------- 1 | #! /usr/bin/awk -f 2 | 3 | # This shouldn't contain any gawk specific features anymore 4 | 5 | # Program to create ascii from info; 6 | # Missing: table of contents 7 | 8 | # skip 9 | 10 | BEGIN {NODELINE=0; NODE=0; KEEP=1; printf "\n\n"} 11 | 12 | 13 | /^\037$/ { NODELINE=1; NODE=NODE+1; KEEP=1; next} 14 | 15 | NODE==1 { next } 16 | 17 | NODELINE==1 { 18 | NODELINE=2; 19 | sub("^.*Node: ","*Node: "); 20 | sub(",.*$",""); 21 | printf "\n\n\n%s",$0; 22 | #print 23 | next; 24 | } 25 | 26 | NODELINE { NODELINE=NODELINE+1 } 27 | 28 | NODELINE==4 { printf "\t\t\t\t"; } 29 | NODELINE==5 { printf "\t\t\t\t"; NODELINE=0} 30 | 31 | 32 | /^\*\ Menu:$/ { KEEP=0 } 33 | 34 | 35 | 36 | KEEP==0 { next } 37 | 38 | { print } 39 | -------------------------------------------------------------------------------- /doc/specs/synaptics/www.synaptics.com/decaf/utilities/511-000024-01a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/telmich/gpm/e82d1a653ca94aa4ed12441424da6ce780b1e530/doc/specs/synaptics/www.synaptics.com/decaf/utilities/511-000024-01a.pdf -------------------------------------------------------------------------------- /doc/specs/synaptics/www.synaptics.com/decaf/utilities/ACF126.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/telmich/gpm/e82d1a653ca94aa4ed12441424da6ce780b1e530/doc/specs/synaptics/www.synaptics.com/decaf/utilities/ACF126.pdf -------------------------------------------------------------------------------- /doc/support/README: -------------------------------------------------------------------------------- 1 | This directory contains emails from/to companies, which were asked, if they 2 | wanted to help support gpm. 3 | This also includes the XFree project, perhaps sometime we can share mouse 4 | support... 5 | -------------------------------------------------------------------------------- /doc/support/logitech_1: -------------------------------------------------------------------------------- 1 | Thank you for using Logitech's Electronic Technical Support. My name is Jesse. The following information addresses your original question. You may wish to print this out and/or save this on your computer. 2 | 3 | The information you are requesting is proprietary and not publicly available. Please visit our web site for all public information on our products. http://www.logitech.com/cf/index.cfm 4 | Logitech does not currently support Linux. 5 | 6 | If you have additional technical questions regarding your product, please visit our web site at www.logitech.com and submit your question. 7 | 8 | Thank you for your interest in Logitech. 9 | 10 | 11 | Regards, 12 | Jesse 13 | Logitech Customer Support 14 | 15 | --- Original Message --- 16 | From: Nico Schottelius 17 | Received: 03/05/2002 11:42am Eastern Standard Time 18 | To: eShare - Logitech Customer Support 19 | Subject: mouse support 20 | 21 | Hello! 22 | 23 | I am the Linux gpm mouse maintainer and I would like to include 24 | some more mouses from logitech into the support. 25 | Gpm is the primary Linux mouse driver. For more information about 26 | gpm visit freshmeat.net and search gpm. 27 | 28 | I only need some protocol specifications and possibly other informations 29 | from you. 30 | 31 | Do you think we can corporate ? 32 | 33 | Thanks for you answer, 34 | 35 | Nico Schottelius 36 | 37 | -- 38 | Nico Schottelius 39 | 40 | Please send your messages pgp-signed or pgp-encrypted. 41 | If you don't know what pgp is visit www.gnupg.org. 42 | (public pgp key: ftp.schottelius.org/pub/familiy/nico/pgp-key) 43 | 44 | ------ Please do not remove your unique tracking number! ------ 45 | <<#140786-104335#>> 46 | 47 | -------------------------------------------------------------------------------- /doc/support/logitech_2: -------------------------------------------------------------------------------- 1 | Thank you for using Logitech's Electronic Technical Support. My name is Peggy. The following information addresses your original question. You may wish to print this out and/or save this on your computer. 2 | 3 | Following is all the information I was able to find on Linux and Logitech mice. I hope it will help you some. 4 | 5 | At this time, LINUX is not a supported operating system for Logitech pointing devices. Do not use the software which comes with the Logitech mouse. 6 | Linux has Logitech drivers built in. Run either Linuxconf (for shell use) or XF86Config and tell it you're using a Logitech mouse. There are specific entries for serial, bus, and PS2 mice. Currently, the kernel does not support USB mice. 7 | As a demand for this operating system increases, Logitech will consider implementing support for it in the future. Please visit our web site periodically for information on product announcements and releases. 8 | Configuring 3 button support in Linux (X-Free): 9 | In LINUX, you normally have only 2 button support, but it is possible to emulate a third button by pressing the left and the right button together (chording). This is a very uncomfortable solution. So, if a customer is asking for a nice solution, tell him following: 10 | Edit the file: /usr/lib/X11/Xconfig 11 | and try the following: 12 | MouseMan "/dev/mouse" 13 | Emulate3buttons 14 | and then you have 3-button-support in LINUX 15 | Configuring 3 button support in Linux ver.1.1.59: 16 | The following information was entered in the configuration file for X11R6 found in the directory: /USR/X11R6/LIB/X11 17 | In this directory the user will find a config file called: XF86CONFIG 18 | They need to change, or make sure the information in the "POINTER" section reads as follows: 19 | Section "Pointer" 20 | Protocol "MouseMan" 21 | Device "/DEV/MOUSE" 22 | EndSection 23 | PROTOCOL specifies the mouse protocol that your mouse uses (not the make or brand of mouse). Valid types for PROTOCOL are: 24 | BusMouse, Logitech, Microsoft, MMSeries, MouseMan, MouseSystems, PS/2 & MMHitTab 25 | DEVICE specifies the device file where the mouse can be accessed. On most Linux systems, this is /DEV/MOUSE. /DEV/MOUSE is usually a link to the appropriate serial port (such as /DEV/CUA0) for serial mice, or the appropriate BusMouse device for BusMice. Just be sure the device file listed in DEVICE exists. 26 | BaudRate and SampleRate are only for some Logitech mice. An example of these, which would be added under DEVICE line are: 27 | BaudRate 9600 28 | SampleRate 150 29 | 30 | 31 | If you have additional technical questions regarding your product, please visit our web site at www.logitech.com and submit your question. 32 | 33 | Thank you for your interest in Logitech. 34 | 35 | 36 | Regards, 37 | Peggy 38 | Logitech Customer Support 39 | 40 | --- Original Message --- 41 | From: Nico Schottelius 42 | Received: 03/11/2002 03:59am Eastern Standard Time 43 | To: eShare - Logitech Customer Support 44 | Subject: Re: mouse support 45 | 46 | Hello Jesse! 47 | 48 | > The information you are requesting is proprietary and not publicly 49 | available. Please visit our web site for all public information on our 50 | products. http://www.logitech.com/cf/index.cfm 51 | > Logitech does not currently support Linux. 52 | 53 | It would be nice for many logitech users to get mouse devices from 54 | logitech to work under Linux. 55 | 56 | When you start sharing information or supporting Linux, please drop me 57 | a line, so I can include the support into gpm and possibly later into X. 58 | 59 | Just one more question, why don't you release those information ? 60 | What's the problem when the information are public available ? 61 | 62 | Thanks in advance, 63 | 64 | Nico Schottelius 65 | 66 | Please send your messages pgp-signed or pgp-encrypted. 67 | If you don't know what pgp is visit www.gnupg.org. 68 | (public pgp key: ftp.schottelius.org/pub/familiy/nico/pgp-key) 69 | 70 | ------ Please do not remove your unique tracking number! ------ 71 | <<#140786-104335#>> 72 | 73 | -------------------------------------------------------------------------------- /doc/support/logitech_3: -------------------------------------------------------------------------------- 1 | Thank you for using Logitech's Electronic Technical Support. My name is Donald. The following information addresses your original question. You may wish to print this out and/or save this on your computer. 2 | 3 | We do not know when or if ever Logitech will support Linux. 4 | 5 | If you have additional technical questions regarding your product, please visit our web site at www.logitech.com and submit your question. 6 | 7 | Thank you for your interest in Logitech. 8 | 9 | 10 | Regards, 11 | Donald 12 | Logitech Customer Support 13 | 14 | --- Original Message --- 15 | From: Nico Schottelius 16 | Received: 03/21/2002 12:11pm Eastern Standard Time 17 | To: eShare - Logitech Customer Support 18 | Subject: Re: mouse support 19 | 20 | 21 | thanks for the information. but I am the gpm maintainer and I know all 22 | that stuff. 23 | 24 | It would just be nice, if you tell me when logitech starts to support 25 | linux, 26 | so we can work together! 27 | 28 | Greetings, 29 | Nico Schottelius 30 | 31 | -- 32 | Nico Schottelius 33 | 34 | Please send your messages pgp-signed or pgp-encrypted. 35 | If you don't know what pgp is visit www.gnupg.org. 36 | (public pgp key: ftp.schottelius.org/pub/familiy/nico/pgp-key) 37 | 38 | ------ Please do not remove your unique tracking number! ------ 39 | <<#140786-104335#>> 40 | 41 | -------------------------------------------------------------------------------- /doc/support/mouse-maintainer-XFree: -------------------------------------------------------------------------------- 1 | On Sun, Feb 17, 2002 at 10:46:48PM +0100, Nico Schottelius wrote: 2 | >Hello David! 3 | > 4 | >As I am the current maintainer of gpm I found out that partly X can handle 5 | >mouse protocols better and partly gpm. Why should we not join our work ? 6 | 7 | That sounds like a good idea. 8 | 9 | >For example the X I use cannot init ps2 correclty, if synps2 was taken before. 10 | >gpm can (1.20.0 and later). 11 | >Who is the mouse maintainer in X, who may I contact ? 12 | 13 | The maintainer was Kazutaka Yokota , 14 | although I haven't heard from him ina while. 15 | 16 | I'm also interested in the mouse driver, so if you can't get in contact 17 | with him, let me know. 18 | 19 | David 20 | -- 21 | David Dawes 22 | Release Engineer/Architect The XFree86 Project 23 | www.XFree86.org/~dawes 24 | 25 | -------------------------------------------------------------------------------- /doc/support/mouse-maintainer-XFree.status: -------------------------------------------------------------------------------- 1 | Didn't get any answer from . 2 | -------------------------------------------------------------------------------- /doc/todo/1.20.6: -------------------------------------------------------------------------------- 1 | - fix Gpm_GetServerVersion 2 | - remove all warnings 3 | - use -Werror -W -Wall 4 | - seperate "drivers" from the rest 5 | - remove the unneeded typedefs 6 | - seperate add daemon and library stuff cleanly 7 | - split off gpm.c and gpn.c 8 | - add report success 9 | -------------------------------------------------------------------------------- /doc/todo/1.99.0: -------------------------------------------------------------------------------- 1 | - splittoff gpm.c 2 | -> finished, 20080220 3 | -------------------------------------------------------------------------------- /doc/todo/1.99.1: -------------------------------------------------------------------------------- 1 | - splittoff gpn.c and startup.c 2 | => Done by 20080222 3 | -------------------------------------------------------------------------------- /doc/todo/1.99.2: -------------------------------------------------------------------------------- 1 | - begin splittoff of mice.c 2 | => no, later 3 | -------------------------------------------------------------------------------- /doc/todo/1.99.3: -------------------------------------------------------------------------------- 1 | - Fixes: 2 | Remove glibc-hacks, where possible and posix conform: 3 | processConn 4 | - begin splittoff of mice.c 5 | - check for rmev (1.19.6 or 1.17.8) 6 | -------------------------------------------------------------------------------- /doc/todo/1.99.4: -------------------------------------------------------------------------------- 1 | - cleanup autoconf stuff 2 | -------------------------------------------------------------------------------- /doc/todo/1.99.5: -------------------------------------------------------------------------------- 1 | - finish gpm2/doc/DESIGN 2 | -------------------------------------------------------------------------------- /doc/todo/1.99.6: -------------------------------------------------------------------------------- 1 | - finish main core for gpm2 2 | -------------------------------------------------------------------------------- /doc/todo/1.99.7: -------------------------------------------------------------------------------- 1 | - first vertical prototype: have on mouse input running 2 | - Add buildtest for gpm1 and gpm2 3 | in ~/temp/gpm, based on the tar 4 | -> fix release errors 5 | -------------------------------------------------------------------------------- /doc/todo/1.99.8: -------------------------------------------------------------------------------- 1 | - freebsd release: check that gpm2 compiles and runs on fbsd 2 | - double check that the os speficih code is in gpm2/os// 3 | -------------------------------------------------------------------------------- /doc/todo/1.99.9: -------------------------------------------------------------------------------- 1 | - cleanly design conf/ 2 | -------------------------------------------------------------------------------- /scripts/git-archiv-tarbz2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # 2008 Nico Schottelius (nico-git-dev at schottelius.org) 4 | # 5 | # 6 | # This file is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This file is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with ccollect. If not, see . 18 | # 19 | # Written on: 20080314 20 | # 21 | 22 | version="$1" 23 | me=${0##*/} 24 | 25 | if [ ! "$version" ]; then 26 | echo "${me}: Version" 27 | exit 1 28 | fi 29 | 30 | if [ ! -d .git ]; then 31 | echo "There is no .git in here." 32 | exit 2 33 | fi 34 | 35 | pwd=$(pwd) 36 | name=${pwd##*/} 37 | 38 | git archive --format=tar --prefix=${name}-${version}/ HEAD | \ 39 | tee ../${name}-${version}.tar | bzip2 -9 > ../${name}-${version}.tar.bz2 40 | -------------------------------------------------------------------------------- /scripts/gpm.release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Nico Schottelius 3 | # Build release tar 4 | # Date: Sat Oct 15 21:38:29 CEST 2005 5 | # Last Changed: ls -l 6 | 7 | # only release if I tell it to release 8 | [ "$1" = "now" ] || exit 23 9 | 10 | #if [ $# -ne 2 ]; then 11 | # echo "This is a maintainer-only script to release cinit" 12 | # echo $(basename $0): source-dir version 13 | # exit 1 14 | #fi 15 | 16 | DDIR="$(cd $(dirname $0)/../../; pwd -P)" 17 | DIR="$(cd $(dirname $0)/../; pwd -P)" 18 | RDIR="$(basename "$DIR")" 19 | 20 | VERSION="$(awk -F= '/^release=/ { print $2 }' configure.in )" 21 | #VERSION="$(cd "$DIR"; pwd -P | sed 's;.*/gpm-;;')" 22 | #VERSION_CONF="$(head -n1 $(dirname $0)/../../conf/version | sed 's/^"\(.*\)"$/\1/')" 23 | #VERSION_CHANGES="$(head -n1 "$(dirname $0)/../../CHANGES" | sed 's/cinit-\(.*\):$/\1/')" 24 | 25 | echo -n "=> Version: $VERSION; ok?" 26 | read ok 27 | #echo "=> Version directory: $VERSION" 28 | #echo "=> Version conf/version: $VERSION_CONF" 29 | #echo "=> Version CHANGES: $VERSION_CHANGES" 30 | 31 | #if [ "$VERSION" = "$VERSION_CONF" -a "$VERSION" = "$VERSION_CHANGES" ]; then 32 | # echo "=> Version confirmed." 33 | #fi 34 | 35 | #DIR=$1 36 | #VERSION=$2 37 | TAR_NAME="gpm-${VERSION}.tar.bz2" 38 | OUT_NAME="$DDIR/$TAR_NAME" 39 | D_HOST=home.schottelius.org 40 | D_BASE=www/org/schottelius/unix/www/gpm 41 | D_DIR=${D_BASE}/archives/ 42 | D_SOURCE=${D_BASE}/browse_source/ 43 | LINK=current 44 | 45 | echo "$VERSION in $DIR to $DDIR with $RDIR?" 46 | echo "Copying to ${D_HOST}:${D_DIR}" 47 | echo -n "=> Continue? " 48 | read yes 49 | 50 | if [ ! -d "$DIR" ]; then 51 | echo "$DIR is not a directory" 52 | exit 1 53 | fi 54 | 55 | #( cd "$DIR" && make dist ) || exit 1 56 | 57 | echo "Creating bzip2 compressed tar" 58 | tar cj -X "$DIR/.exclude" -C "$DDIR" -f "$OUT_NAME" "$RDIR" 59 | chmod 0644 "$OUT_NAME" 60 | echo "Transfering to $D_HOST" 61 | scp "$OUT_NAME" "$D_HOST:$D_DIR" 62 | echo "Extracting to $D_SOURCE" 63 | ssh "$D_HOST" "tar xfj $D_DIR/$OUT_NAME -C $D_SOURCE" 64 | echo "Correcting paranoid permissions" 65 | ssh "$D_HOST" "find \"$D_SOURCE/$RDIR\" -type f -exec chmod 0644 {} \\;" 66 | ssh "$D_HOST" "find \"$D_SOURCE/$RDIR\" -type d -exec chmod 0755 {} \\;" 67 | ssh "$D_HOST" "cd \"$D_SOURCE\" && rm -f \"$LINK\" && ln -s \"$RDIR\" \"$LINK\"" 68 | echo "Please do not forget to update the website..." 69 | -------------------------------------------------------------------------------- /scripts/report_success.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # 2008 Nico Schottelius (nico-ccollect at schottelius.org) 4 | # 5 | # This file is part of ccollect. 6 | # 7 | # ccollect is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # ccollect is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with ccollect. If not, see . 19 | # 20 | # Sends feedback 21 | # 22 | # Adapted for gpm 23 | # 24 | 25 | software="gpm" 26 | author="Nico Schottelius" 27 | subject="==> success: $software" 28 | to="nico-gpm-success" 29 | host="schottelius.org" 30 | fullto="${to}@${host}" 31 | 32 | info="$(awk -F= '/^release=/ { print $2 }' configure.in; uname -s -v -r -m)" 33 | 34 | 35 | echo "Reporting success for $software to ${author}" 36 | echo "-----------------" 37 | echo -n "Your name (leave free for anonymous): " 38 | read name 39 | echo -n "Your email (leave free for anonymous): " 40 | read email 41 | echo -n "Your normal gpm parameters (-m -t -o ...): " 42 | read params 43 | echo -n "Comment (leave free for no comment): " 44 | read comment 45 | 46 | echo "" 47 | echo "The following information will be send to ${author}:" 48 | echo "" 49 | 50 | cat << eof 51 | Name: $name (will be used to contact you and kept secret) 52 | E-Mail: $email (will be used to contact you and kept secret) 53 | Comment: $comment 54 | Info: $info 55 | Parameters: $params 56 | 57 | eof 58 | 59 | echo -n "Is it ok to send out that mail (press enter to send or ctrl-c to abort)? " 60 | read yes 61 | 62 | cat << eof | mail -s "$subject" "$fullto" 63 | Name: $name 64 | E-Mail: $email 65 | Comment: $comment 66 | Info: $info 67 | Parameters: $params 68 | eof 69 | 70 | echo "Send. Thank you for your feedback." 71 | -------------------------------------------------------------------------------- /src/daemon/add_mouse.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse support for Linux 3 | * 4 | * *several tools only needed by the server* 5 | * 6 | * Copyright (c) 2002-2008 Nico Schottelius 7 | * 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 22 | ********/ 23 | 24 | #include "headers/gpmInt.h" 25 | #include "headers/message.h" 26 | #include "headers/daemon.h" 27 | 28 | #include /* malloc() */ 29 | 30 | /* DESCR: add this to the list of mice. initialization follows later */ 31 | /* RETURN: - */ 32 | /* COMMENT: does error handling and exiting itself */ 33 | void add_mouse(int type, char *value) 34 | { 35 | struct micetab *tmp = option.micelist; 36 | 37 | /* PREAMBLE for all work: */ 38 | /* -m /dev/misc/psaux -t ps2 [ -o options ] */ 39 | 40 | switch(type) { 41 | 42 | /*---------------------------------------------------------------------*/ 43 | /********************** -m mousedevice *********************************/ 44 | /*---------------------------------------------------------------------*/ 45 | 46 | case GPM_ADD_DEVICE: 47 | 48 | /* first invocation */ 49 | if(option.micelist == NULL) { 50 | gpm_report(GPM_PR_DEBUG,"adding mouse device: %s",value); 51 | option.micelist = (struct micetab *) malloc(sizeof(struct micetab)); 52 | if(!option.micelist) gpm_report(GPM_PR_OOPS,GPM_MESS_NO_MEM); 53 | option.micelist->next = NULL; 54 | option.micelist->device = value; 55 | option.micelist->protocol = NULL; 56 | option.micelist->options = NULL; 57 | return; 58 | } 59 | 60 | /* find actual mouse */ 61 | while(tmp->device != NULL && tmp->protocol != NULL && tmp->next !=NULL) 62 | tmp = tmp->next; 63 | 64 | gpm_report(GPM_PR_DEBUG,"finished searching"); 65 | 66 | /* found end of micelist, add new mouse */ 67 | if(tmp->next == NULL && tmp->protocol != NULL) { 68 | gpm_report(GPM_PR_DEBUG,"next mouse making"); 69 | tmp->next = (struct micetab *) malloc(sizeof(struct micetab)); 70 | if(!tmp) gpm_report(GPM_PR_OOPS,GPM_MESS_NO_MEM); 71 | tmp->next = NULL; 72 | tmp->device = value; 73 | tmp->protocol = NULL; 74 | tmp->options = NULL; 75 | return; 76 | } else gpm_report(GPM_PR_OOPS,GPM_MESS_FIRST_DEV); 77 | 78 | //} else if(tmp->device != NULL && tmp->protocol == NULL) 79 | // gpm_report(GPM_PR_OOPS,GPM_MESS_FIRST_DEV); /* -m -m */ 80 | 81 | 82 | break; 83 | 84 | /*---------------------------------------------------------------------*/ 85 | /************************* -t type / protocol **************************/ 86 | /*---------------------------------------------------------------------*/ 87 | 88 | case GPM_ADD_TYPE: 89 | if(option.micelist == NULL) gpm_report(GPM_PR_OOPS,GPM_MESS_FIRST_DEV); 90 | 91 | /* skip to next mouse, where either device or protocol is missing */ 92 | while(tmp->device != NULL && tmp->protocol != NULL && tmp->next !=NULL) 93 | tmp = tmp->next; 94 | 95 | /* check whether device (-m) is there, if so, write protocol */ 96 | if(tmp->device == NULL) gpm_report(GPM_PR_OOPS,GPM_MESS_FIRST_DEV); 97 | else { 98 | gpm_report(GPM_PR_DEBUG,"adding mouse type: %s",value); 99 | tmp->protocol = value; 100 | option.no_mice++; /* finally we got our mouse */ 101 | } 102 | 103 | break; 104 | 105 | /*---------------------------------------------------------------------*/ 106 | /*************************** -o options ********************************/ 107 | /*---------------------------------------------------------------------*/ 108 | 109 | case GPM_ADD_OPTIONS: 110 | if(option.micelist == NULL) gpm_report(GPM_PR_OOPS,GPM_MESS_FIRST_DEV); 111 | 112 | /* look for the last mouse */ 113 | tmp = option.micelist; 114 | while(tmp->next != NULL) tmp = tmp->next; 115 | 116 | /* if -m or -t are missing exit */ 117 | if(tmp->device == NULL || tmp->protocol == NULL) 118 | gpm_report(GPM_PR_OOPS,GPM_MESS_FIRST_DEV); 119 | else { 120 | gpm_report(GPM_PR_DEBUG,"adding mouse options: %s",value); 121 | tmp->options = value; 122 | } 123 | break; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/daemon/build_argv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* str* */ 23 | #include /* calloc */ 24 | 25 | #include "headers/message.h" /* messaging in gpm */ 26 | 27 | /* build_argv is used for mouse initialization routines */ 28 | char **build_argv(char *argv0, char *str, int *argcptr, char sep) 29 | { 30 | int argc = 1; 31 | char **argv; 32 | char *s; 33 | 34 | /* argv0 is never NULL, but the extra string may well be */ 35 | if (str) 36 | for (s=str; sep && (s = strchr(s, sep)); argc++) s++; 37 | 38 | argv = calloc(argc+2, sizeof(char **)); 39 | if (!argv) gpm_report(GPM_PR_OOPS,GPM_MESS_ALLOC_FAILED); 40 | argv[0] = argv0; 41 | 42 | if (!str) { 43 | *argcptr = argc; /* 1 */ 44 | return argv; 45 | } 46 | /* else, add arguments */ 47 | s = argv[1] = strdup(str); 48 | argc = 2; /* first to fill */ 49 | 50 | /* ok, now split: the first one is in place, and s is the whole string */ 51 | for ( ; sep && (s = strchr(s, sep)) ; argc++) { 52 | *s = '\0'; 53 | s++; 54 | argv[argc] = s; 55 | } 56 | *argcptr = argc; 57 | return argv; 58 | } 59 | -------------------------------------------------------------------------------- /src/daemon/check_kill.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* kill */ 23 | #include /* unlink */ 24 | #include /* exit */ 25 | 26 | #include "headers/message.h" /* messaging in gpm */ 27 | #include "headers/daemon.h" /* daemon internals */ 28 | 29 | /* itz Sat Sep 12 10:55:51 PDT 1998 Added this as replacement for the 30 | unwanted functionality in check_uniqueness. */ 31 | 32 | void check_kill(void) 33 | { 34 | int old_pid; 35 | FILE* fp = fopen(GPM_NODE_PID, "r"); 36 | 37 | /* if we cannot find the old pid file, leave */ 38 | if (fp == NULL) gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN, GPM_NODE_PID); 39 | 40 | /* else read the pid */ 41 | if (fscanf(fp,"%d",&old_pid) != 1) 42 | gpm_report(GPM_PR_OOPS,GPM_MESS_READ_PROB,GPM_NODE_PID); 43 | fclose(fp); 44 | 45 | gpm_report(GPM_PR_DEBUG,GPM_MESS_KILLING,old_pid); 46 | 47 | /* first check if we run */ 48 | if (kill(old_pid,0) == -1) { 49 | gpm_report(GPM_PR_INFO,GPM_MESS_STALE_PID, GPM_NODE_PID); 50 | unlink(GPM_NODE_PID); 51 | } 52 | /* then kill us (not directly, but the other instance ... ) */ 53 | if (kill(old_pid,SIGTERM) == -1) 54 | gpm_report(GPM_PR_OOPS,GPM_MESS_CANT_KILL, old_pid); 55 | 56 | gpm_report(GPM_PR_DEBUG,GPM_MESS_KILLED,old_pid); 57 | exit(0); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/daemon/check_uniqueness.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* kill */ 23 | #include /* kill, getpid */ 24 | 25 | #include "headers/message.h" /* messaging in gpm */ 26 | #include "headers/daemon.h" /* daemon internals */ 27 | 28 | /* itz Sat Sep 12 10:30:05 PDT 1998 this function used to mix two 29 | completely different things; opening a socket to a running daemon 30 | and checking that a running daemon existed. Ugly. */ 31 | /* rewritten mostly on 20th of February 2002 - nico */ 32 | void check_uniqueness(void) 33 | { 34 | FILE *fp = 0; 35 | int old_pid = -1; 36 | 37 | if((fp = fopen(GPM_NODE_PID, "r")) != NULL) { 38 | fscanf(fp, "%d", &old_pid); 39 | if (kill(old_pid,0) == -1) { 40 | gpm_report(GPM_PR_INFO,GPM_MESS_STALE_PID, GPM_NODE_PID); 41 | unlink(GPM_NODE_PID); 42 | } else /* we are really running, exit asap! */ 43 | gpm_report(GPM_PR_OOPS,GPM_MESS_ALREADY_RUN, old_pid); 44 | } 45 | /* now try to sign ourself */ 46 | if ((fp = fopen(GPM_NODE_PID,"w")) != NULL) { 47 | fprintf(fp,"%d\n",getpid()); 48 | fclose(fp); 49 | } else { 50 | gpm_report(GPM_PR_OOPS,GPM_MESS_NOTWRITE,GPM_NODE_PID); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/daemon/cmdline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* atoi */ 23 | #include /* getopt */ 24 | 25 | #include "headers/message.h" /* messaging in gpm */ 26 | #include "headers/daemon.h" /* daemon internals */ 27 | 28 | /***************************************************************************** 29 | * Check the command line and / or set the appropriate variables 30 | * Can't believe it, today cmdline() really does what the name tries to say 31 | *****************************************************************************/ 32 | void cmdline(int argc, char **argv) 33 | { 34 | extern struct options option; 35 | char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:Tuv23"; 36 | int opt; 37 | 38 | /* initialize for the dual mouse */ 39 | mouse_table[2]=mouse_table[1]=mouse_table[0]; /* copy defaults */ 40 | which_mouse = mouse_table+1; /* use the first */ 41 | 42 | while ((opt = getopt(argc, argv, options)) != -1) { 43 | switch (opt) { 44 | case 'a': (which_mouse->opt_accel) = atoi(optarg); break; 45 | case 'A': opt_aged++; 46 | if (optarg) 47 | opt_age_limit = atoi(optarg); break; 48 | case 'b': (which_mouse->opt_baud) = atoi(optarg); break; 49 | case 'B': (which_mouse->opt_sequence) = optarg; break; 50 | case 'd': (which_mouse->opt_delta) = atoi(optarg); break; 51 | case 'D': option.run_status = GPM_RUN_DEBUG; break; 52 | case 'g': (which_mouse->opt_glidepoint_tap)=atoi(optarg); break; 53 | case 'h': exit(usage(NULL)); 54 | case 'i': (which_mouse->opt_time)=atoi(optarg); break; 55 | case 'k': check_kill(); break; 56 | case 'l': opt_lut = optarg; break; 57 | case 'm': add_mouse(GPM_ADD_DEVICE,optarg); 58 | (which_mouse->opt_dev) = optarg; break; /* GO AWAY!*/ 59 | case 'M': opt_double++; option.repeater++; 60 | if (option.repeater_type == 0) 61 | option.repeater_type = "msc"; 62 | which_mouse=mouse_table+2; break; 63 | case 'o': add_mouse(GPM_ADD_OPTIONS,optarg); 64 | gpm_report(GPM_PR_DEBUG,"options: %s",optarg); 65 | (which_mouse->opt_options) = optarg; break; /* GO AWAY */ 66 | case 'p': opt_ptrdrag = 0; break; 67 | case 'r': 68 | /* being called responsiveness, I must take the inverse */ 69 | (which_mouse->opt_scale)=atoi(optarg); 70 | if(!(which_mouse->opt_scale) || (which_mouse->opt_scale) > 100) (which_mouse->opt_scale)=100; /* the maximum */ 71 | else (which_mouse->opt_scale)=100/(which_mouse->opt_scale); break; 72 | case 'R': 73 | option.repeater++; 74 | if (optarg) option.repeater_type = optarg; 75 | else option.repeater_type = "msc"; break; 76 | case 's': (which_mouse->opt_sample) = atoi(optarg); break; 77 | case 'S': if (optarg) opt_special = optarg; 78 | else opt_special=""; break; 79 | case 't': add_mouse(GPM_ADD_TYPE,optarg); 80 | (which_mouse->opt_type) = optarg; break; /* GO AWAY */ 81 | case 'u': option.autodetect = 1; break; 82 | case 'T': opt_test++; break; 83 | case 'v': printf(GPM_MESS_VERSION "\n"); exit(0); 84 | case '2': (which_mouse->opt_three) = -1; break; 85 | case '3': (which_mouse->opt_three) = 1; break; 86 | default: exit(usage("commandline")); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/daemon/disable_paste.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include "headers/message.h" /* messaging in gpm */ 23 | #include "headers/daemon.h" /* daemon internals */ 24 | 25 | void disable_paste(int vc) 26 | { 27 | opt_aged++; 28 | gpm_report(GPM_PR_INFO,GPM_MESS_DISABLE_PASTE,vc); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/daemon/do_client.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* write */ 23 | 24 | #include "headers/message.h" /* messaging in gpm */ 25 | #include "headers/daemon.h" /* daemon internals */ 26 | #include "headers/gpmInt.h" /* daemon internals */ 27 | 28 | /*-------------------------------------------------------------------*/ 29 | /* returns 0 if the event has not been processed, and 1 if it has */ 30 | int do_client(Gpm_Cinfo *cinfo, Gpm_Event *event) 31 | { 32 | Gpm_Connect info=cinfo->data; 33 | int fd=cinfo->fd; 34 | /* value to return if event is not used */ 35 | int res = !(info.defaultMask & event->type); 36 | 37 | /* instead of returning 0, scan the stack of clients */ 38 | if ((info.minMod & event->modifiers) < info.minMod) 39 | goto scan; 40 | if ((info.maxMod & event->modifiers) < event->modifiers) 41 | goto scan; 42 | 43 | /* if not managed, use default mask */ 44 | if (!(info.eventMask & GPM_BARE_EVENTS(event->type))) { 45 | if (res) return res; 46 | else goto scan; 47 | } 48 | 49 | /* WARNING */ /* This can generate a SIGPIPE... I'd better catch it */ 50 | MAGIC_P((write(fd,&magic, sizeof(int)))); 51 | write(fd,event, sizeof(Gpm_Event)); 52 | 53 | return info.defaultMask & GPM_HARD ? res : 1; /* HARD forces pass-on */ 54 | 55 | scan: 56 | if (cinfo->next != 0) 57 | return do_client (cinfo->next, event); /* try the next */ 58 | return 0; /* no next, not used */ 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/daemon/do_selection.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include "headers/message.h" /* messaging in gpm */ 23 | #include "headers/daemon.h" /* daemon internals */ 24 | #include "headers/gpmInt.h" /* daemon internals */ 25 | 26 | /*-------------------------------------------------------------------*/ 27 | int do_selection(Gpm_Event *event) /* returns 0, always */ 28 | { 29 | static int x1=1, y1=1, x2, y2; 30 | #define UNPOINTER() 0 31 | 32 | x2=event->x; y2=event->y; 33 | switch(GPM_BARE_EVENTS(event->type)) { 34 | case GPM_MOVE: 35 | if (x2<1) x2++; else if (x2>maxx) x2--; 36 | if (y2<1) y2++; else if (y2>maxy) y2--; 37 | selection_copy(x2,y2,x2,y2,3); /* just highlight pointer */ 38 | return 0; 39 | 40 | case GPM_DRAG: 41 | if (event->buttons==GPM_B_LEFT) { 42 | if (event->margin) /* fix margins */ 43 | switch(event->margin) { 44 | case GPM_TOP: x2=1; y2++; break; 45 | case GPM_BOT: x2=maxx; y2--; break; 46 | case GPM_RGT: x2--; break; 47 | case GPM_LFT: y2<=y1 ? x2++ : (x2=maxx, y2--); break; 48 | } 49 | selection_copy(x1,y1,x2,y2,event->clicks); 50 | if (event->clicks>=opt_ptrdrag && !event->margin) /* pointer */ 51 | selection_copy(x2,y2,x2,y2,3); 52 | } /* if */ 53 | return 0; 54 | 55 | case GPM_DOWN: 56 | switch (event->buttons) { 57 | case GPM_B_LEFT: 58 | x1=x2; y1=y2; 59 | selection_copy(x1,y1,x2,y2,event->clicks); /* start selection */ 60 | return 0; 61 | 62 | case GPM_B_MIDDLE: 63 | selection_paste(); 64 | return 0; 65 | 66 | case GPM_B_RIGHT: 67 | if ((which_mouse->opt_three)==1) 68 | selection_copy(x1,y1,x2,y2,event->clicks); 69 | else 70 | selection_paste(); 71 | return 0; 72 | } 73 | } /* switch above */ 74 | return 0; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/daemon/find_mouse_by_name.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* str* */ 23 | #include /* isspace */ 24 | 25 | #include "headers/message.h" /* messaging in gpm */ 26 | #include "headers/daemon.h" /* daemon internals */ 27 | 28 | /***************************************************************************** 29 | * the function returns a valid type pointer or NULL if not found 30 | *****************************************************************************/ 31 | struct Gpm_Type *find_mouse_by_name(char *name) 32 | { 33 | Gpm_Type *type; 34 | char *s; 35 | int len = strlen(name); 36 | 37 | for (type=mice; type->fun; type++) { 38 | if (!strcasecmp(name, type->name)) break; 39 | /* otherwise, look in the synonym list */ 40 | for (s = type->synonyms; s; s = strchr(s, ' ')) { 41 | while (*s && isspace(*s)) s++; /* skip spaces */ 42 | if(!strncasecmp(name, s, len) && !isprint(*(s + len))) break;/*found*/ 43 | } 44 | if(s) break; /* found a synonym */ 45 | } 46 | if (!type->fun) return NULL; 47 | return type; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/daemon/get_console_size.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* close */ 23 | #include /* open */ 24 | 25 | #include "headers/message.h" /* messaging in gpm */ 26 | #include "headers/daemon.h" /* daemon internals */ 27 | #include "headers/gpmInt.h" /* daemon internals */ 28 | 29 | void get_console_size(Gpm_Event *ePtr) 30 | { 31 | int i, prevmaxx, prevmaxy; 32 | struct mouse_features *which_mouse; /* local */ 33 | 34 | /* before asking the new console size, save the previous values */ 35 | prevmaxx = maxx; prevmaxy = maxy; 36 | 37 | i=open_console(O_RDONLY); 38 | ioctl(i, TIOCGWINSZ, &win); 39 | close(i); 40 | if (!win.ws_col || !win.ws_row) { 41 | gpm_report(GPM_PR_DEBUG,GPM_MESS_ZERO_SCREEN_DIM); 42 | win.ws_col=80; win.ws_row=25; 43 | } 44 | maxx=win.ws_col; maxy=win.ws_row; 45 | gpm_report(GPM_PR_DEBUG,GPM_MESS_SCREEN_SIZE,maxx,maxy); 46 | 47 | if (!prevmaxx) { /* first invocation, place the pointer in the middle */ 48 | statusX = ePtr->x = maxx/2; 49 | statusY = ePtr->y = maxy/2; 50 | } else { /* keep the pointer in the same position where it was */ 51 | statusX = ePtr->x = ePtr->x * maxx / prevmaxx; 52 | statusY = ePtr->y = ePtr->y * maxy / prevmaxy; 53 | } 54 | 55 | for (i=1; i <= 1+opt_double; i++) { 56 | which_mouse=mouse_table+i; /* used to access options */ 57 | /* 58 | * the following operation is based on the observation that 80x50 59 | * has square cells. (An author-centric observation ;-) 60 | */ 61 | (which_mouse->opt_scaley)=(which_mouse->opt_scale)*50*maxx/80/maxy; 62 | gpm_report(GPM_PR_DEBUG,GPM_MESS_X_Y_VAL,(which_mouse->opt_scale),(which_mouse->opt_scaley)); 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/daemon/get_data.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* read */ 23 | 24 | #include "headers/message.h" /* messaging in gpm */ 25 | #include "headers/daemon.h" /* daemon internals */ 26 | #include "headers/gpmInt.h" /* daemon internals */ 27 | 28 | /*-------------------------------------------------------------------* 29 | * This was inline, and incurred in a compiler bug (2.7.0) 30 | *-------------------------------------------------------------------*/ 31 | int get_data(Gpm_Connect *where, int whence) 32 | { 33 | static int i; 34 | 35 | #ifdef GPM_USE_MAGIC 36 | while ((i=read(whence,&check,sizeof(int)))==4 && check!=GPM_MAGIC) 37 | gpm_report(GPM_PR_INFO,GPM_MESS_NO_MAGIC); 38 | 39 | if (!i) return 0; 40 | if (check!=GPM_MAGIC) { 41 | gpm_report(GPM_PR_INFO,GPM_MESS_NOTHING_MORE); 42 | return -1; 43 | } 44 | #endif 45 | 46 | if ((i=read(whence, where, sizeof(Gpm_Connect)))!=sizeof(Gpm_Connect)) { 47 | return i ? -1 : 0; 48 | } 49 | 50 | return 1; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/daemon/getmousedata.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* guess what */ 23 | #include /* read */ 24 | #include /* exit */ 25 | #include /* strerror */ 26 | #include /* KD* */ 27 | 28 | #include "headers/message.h" /* messaging in gpm */ 29 | #include "headers/daemon.h" /* daemon internals */ 30 | #include "headers/gpmInt.h" /* daemon internals */ 31 | 32 | /*------------------------------------------------------------------- 33 | * fetch the actual device data from the mouse device, dependent on 34 | * what Gpm_Type is being passed. 35 | *-------------------------------------------------------------------*/ 36 | char *getMouseData(int fd, Gpm_Type *type, int kd_mode) 37 | { 38 | static unsigned char data[32]; /* quite a big margin :) */ 39 | char *edata=data+type->packetlen; 40 | int howmany=type->howmany; 41 | int i,j; 42 | 43 | /*....................................... read and identify one byte */ 44 | 45 | if (read(fd, data, howmany)!=howmany) { 46 | if (opt_test) exit(0); 47 | gpm_report(GPM_PR_ERR,GPM_MESS_READ_FIRST, strerror(errno)); 48 | return NULL; 49 | } 50 | 51 | if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep) 52 | write(fifofd, data, howmany); 53 | 54 | if ((data[0]&((which_mouse->m_type)->proto)[0]) != ((which_mouse->m_type)->proto)[1]) { 55 | if ((which_mouse->m_type)->getextra == 1) { 56 | data[1]=GPM_EXTRA_MAGIC_1; data[2]=GPM_EXTRA_MAGIC_2; 57 | gpm_report(GPM_PR_DEBUG,GPM_EXTRA_DATA,data[0]); 58 | return data; 59 | } 60 | gpm_report(GPM_PR_DEBUG,GPM_MESS_PROT_ERR); 61 | return NULL; 62 | } 63 | 64 | /*....................................... read the rest */ 65 | 66 | /* 67 | * well, this seems to work almost right with ps2 mice. However, I've never 68 | * tried ps2 with the original selection package, which called usleep() 69 | */ 70 | 71 | if((i=(which_mouse->m_type)->packetlen-howmany)) /* still to get */ 72 | do { 73 | j = read(fd,edata-i,i); /* edata is pointer just after data */ 74 | if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep && j > 0) 75 | write(fifofd, edata-i, j); 76 | i -= j; 77 | } while (i && j); 78 | 79 | if (i) { 80 | gpm_report(GPM_PR_ERR,GPM_MESS_READ_REST, strerror(errno)); 81 | return NULL; 82 | } 83 | 84 | if ((data[1]&((which_mouse->m_type)->proto)[2]) != ((which_mouse->m_type)->proto)[3]) { 85 | gpm_report(GPM_PR_INFO,GPM_MESS_SKIP_DATA); 86 | return NULL; 87 | } 88 | gpm_report(GPM_PR_DEBUG,GPM_MESS_DATA_4,data[0],data[1],data[2],data[3]); 89 | return data; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /src/daemon/gpm-killed.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse support 3 | * 4 | * Copyright (C) 1993 Andreq Haylett 5 | * Copyright (C) 1994-1999 Alessandro Rubini 6 | * Copyright (C) 1998 Ian Zimmerman 7 | * Copyright (c) 2001-2008 Nico Schottelius 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 22 | ********/ 23 | 24 | #include /* SIG* */ 25 | #include /* exit() */ 26 | #include /* getpid() */ 27 | 28 | #include "headers/message.h" /* messaging in gpm */ 29 | #include "headers/daemon.h" /* daemon internals */ 30 | 31 | void gpm_killed(int signo) 32 | { 33 | if(signo == SIGWINCH) { 34 | gpm_report(GPM_PR_WARN, GPM_MESS_RESIZING, option.progname, getpid()); 35 | opt_resize++; 36 | return; 37 | } 38 | if(signo==SIGUSR1) { 39 | gpm_report(GPM_PR_WARN,GPM_MESS_KILLED_BY, option.progname, getpid(), option.progname); 40 | } 41 | 42 | exit(0); 43 | } 44 | -------------------------------------------------------------------------------- /src/daemon/gpm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse support 3 | * 4 | * Copyright (C) 1993 Andreq Haylett 5 | * Copyright (C) 1994-1999 Alessandro Rubini 6 | * Copyright (C) 1998 Ian Zimmerman 7 | * Copyright (c) 2001-2008 Nico Schottelius 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 22 | ********/ 23 | 24 | #include 25 | #include 26 | #include /* strerror(); ?!? */ 27 | #include 28 | #include /* select(); */ 29 | #include /* SIGPIPE */ 30 | #include /* time() */ 31 | #include 32 | #include /* O_RDONLY */ 33 | #include /* wait() */ 34 | #include /* mkdir() */ 35 | #include /* timeval */ 36 | #include /* socket() */ 37 | #include /* socket() */ 38 | #include /* struct sockaddr_un */ 39 | 40 | #include /* VT_GETSTATE */ 41 | #include /* for serial console check */ 42 | #include /* KDGETMODE */ 43 | #include /* winsize */ 44 | 45 | #include "headers/gpmInt.h" /* old daemon header */ 46 | #include "headers/message.h" 47 | 48 | #include "headers/daemon.h" /* clean daemon header */ 49 | 50 | /* global variables that are in daemon.h */ 51 | struct options option; /* one should be enough for us */ 52 | Gpm_Type *repeated_type = 0; 53 | 54 | /* FIXME: BRAINDEAD..ok not really, but got to leave anyway... */ 55 | /* argc and argv for mice initialization */ 56 | int mouse_argc[3]; /* 0 for default (unused) and two mice */ 57 | char **mouse_argv[3]; /* 0 for default (unused) and two mice */ 58 | 59 | int opt_aged = 0; 60 | int statusX,statusY,statusB; /* to return info */ 61 | 62 | /* 63 | * all the values duplicated for dual-mouse operation are 64 | * now in this structure (see gpmInt.h) 65 | * mouse_table[0] is single mouse, mouse_table[1] and mouse_table[2] 66 | * are copied data from mouse_table[0] for dual mouse operation. 67 | */ 68 | 69 | struct mouse_features mouse_table[3] = { 70 | { 71 | DEF_TYPE, DEF_DEV, DEF_SEQUENCE, 72 | DEF_BAUD, DEF_SAMPLE, DEF_DELTA, DEF_ACCEL, DEF_SCALE, 0 /* scaley */, 73 | DEF_TIME, DEF_CLUSTER, DEF_THREE, DEF_GLIDEPOINT_TAP, 74 | (char *)NULL /* extra */, 75 | (Gpm_Type *)NULL, 76 | -1 77 | } 78 | }; 79 | struct mouse_features *which_mouse; 80 | 81 | /* These are only the 'global' options */ 82 | 83 | char *opt_lut=DEF_LUT; 84 | int opt_test=DEF_TEST; 85 | int opt_ptrdrag=DEF_PTRDRAG; 86 | int opt_double=0; 87 | 88 | char *opt_special=NULL; /* special commands, like reboot or such */ 89 | int opt_rawrep=0; 90 | 91 | struct winsize win; 92 | int maxx, maxy; 93 | int fifofd=-1; 94 | 95 | int eventFlag=0; 96 | Gpm_Cinfo *cinfo[MAX_VC+1]; 97 | 98 | time_t last_selection_time; 99 | time_t opt_age_limit = 0; 100 | 101 | 102 | int opt_resize=0; /* not really an option */ 103 | 104 | 105 | int statusC = 0; /* clicks */ 106 | void get_console_size(Gpm_Event *ePtr); 107 | 108 | /* in daemon.h */ 109 | fd_set selSet, readySet, connSet; 110 | -------------------------------------------------------------------------------- /src/daemon/gpm_exited.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* unlink,geteuid */ 23 | 24 | #include "headers/message.h" /* messaging in gpm */ 25 | #include "headers/daemon.h" /* daemon internals */ 26 | 27 | /* what todo atexit */ 28 | void gpm_exited(void) 29 | { 30 | gpm_report(GPM_PR_DEBUG,GPM_MESS_REMOVE_FILES, GPM_NODE_PID, GPM_NODE_CTL); 31 | unlink(GPM_NODE_PID); 32 | unlink(GPM_NODE_CTL); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/daemon/header.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include "headers/message.h" /* messaging in gpm */ 23 | #include "headers/daemon.h" /* daemon internals */ 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/daemon/init_mice.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse support for Linux 3 | * 4 | * *several tools only needed by the server* 5 | * 6 | * Copyright (c) 2002-2008 Nico Schottelius 7 | * 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 22 | ********/ 23 | 24 | #include "headers/gpmInt.h" 25 | #include "headers/message.h" 26 | #include "headers/daemon.h" 27 | 28 | #include /* malloc() */ 29 | 30 | /* DESCR: mice initialization. currently print mice. */ 31 | /* RETURN: 0 - failed to init one or more devices 32 | 1 - init was fine */ 33 | /* COMMENT: does error handling and exiting itself */ 34 | int init_mice(struct micetab *micelist) 35 | { 36 | struct micetab *tmp = micelist; 37 | 38 | while(tmp != NULL) { /* there are still mice to init */ 39 | gpm_report(GPM_PR_DEBUG,"initialize %s with proto %s",tmp->device,tmp->protocol); 40 | if(tmp->options != NULL) { 41 | gpm_report(GPM_PR_DEBUG,"and options %s",tmp->options); 42 | } 43 | tmp = tmp->next; 44 | } 45 | 46 | gpm_report(GPM_PR_DEBUG,"finished initialization"); 47 | return 1; 48 | } 49 | -------------------------------------------------------------------------------- /src/daemon/loadlut.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* datatypes */ 23 | #include /* open */ 24 | #include /* malloc */ 25 | #include /* str* */ 26 | #include /* errno.h */ 27 | #include /* getuid */ 28 | 29 | #include "headers/message.h" /* messaging in gpm */ 30 | #include "headers/daemon.h" /* daemon internals */ 31 | #include "headers/gpmInt.h" /* GPM_SYS_CONSOLE */ 32 | 33 | int loadlut(char *charset) 34 | { 35 | int i, c, fd; 36 | unsigned char this, next; 37 | static uint32_t long_array[9]={ 38 | 0x05050505, /* ugly, but preserves alignment */ 39 | 0x00000000, /* control chars */ 40 | 0x00000000, /* digits */ 41 | 0x00000000, /* uppercase and '_' */ 42 | 0x00000000, /* lowercase */ 43 | 0x00000000, /* Latin-1 control */ 44 | 0x00000000, /* Latin-1 misc */ 45 | 0x00000000, /* Latin-1 uppercase */ 46 | 0x00000000 /* Latin-1 lowercase */ 47 | }; 48 | 49 | 50 | #define inwordLut (long_array+1) 51 | 52 | for (i=0; charset[i]; ) { 53 | i += getsym(charset+i, &this); 54 | if (charset[i] == '-' && charset[i + 1] != '\0') 55 | i += getsym(charset+i+1, &next) + 1; 56 | else 57 | next = this; 58 | for (c = this; c <= next; c++) 59 | inwordLut[c>>5] |= 1 << (c&0x1F); 60 | } 61 | 62 | if ((fd=open(option.consolename, O_WRONLY)) < 0) { 63 | /* try /dev/console, if /dev/tty0 failed -- is that really senseful ??? */ 64 | free(option.consolename); /* allocated by main */ 65 | if((option.consolename=malloc(strlen(GPM_SYS_CONSOLE)+1)) == NULL) 66 | gpm_report(GPM_PR_OOPS,GPM_MESS_NO_MEM); 67 | 68 | /* FIXME: remove hardcoded device names */ 69 | strcpy(option.consolename,GPM_SYS_CONSOLE); 70 | 71 | if ((fd=open(option.consolename, O_WRONLY)) < 0) gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN_CON); 72 | } 73 | if (ioctl(fd, TIOCLINUX, &long_array) < 0) { /* fd <0 is checked */ 74 | if (errno==EPERM && getuid()) 75 | gpm_report(GPM_PR_WARN,GPM_MESS_ROOT); /* why do we still continue?*/ 76 | else if (errno==EINVAL) 77 | gpm_report(GPM_PR_OOPS,GPM_MESS_CSELECT); 78 | } 79 | close(fd); 80 | 81 | return 0; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /src/daemon/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse support for Linux 3 | * 4 | * *main.c* 5 | * 6 | * Copyright (c) 2002 Nico Schottelius 7 | * 8 | * small main routine 9 | * 10 | * isn't that a nice clean function ? 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 25 | ********/ 26 | 27 | #include "headers/daemon.h" 28 | #include "headers/gpmInt.h" 29 | 30 | int main(int argc, char **argv) 31 | { 32 | startup(argc,argv); /* setup configurations */ 33 | old_main(); /* LATER: exit(daemon()); */ 34 | return 0; /* if we didn't exit before, just give back success */ 35 | } 36 | -------------------------------------------------------------------------------- /src/daemon/open_console.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* open and co. */ 23 | #include /* stat() */ 24 | #include /* major() */ 25 | #include /* ioctl */ 26 | 27 | #ifdef HAVE_SYS_SYSMACROS_H 28 | #include /* major() w/newer glibc */ 29 | #endif 30 | 31 | /* Linux specific (to be outsourced in gpm2 */ 32 | #include /* for serial console check */ 33 | #include /* for serial console check */ 34 | 35 | 36 | #include "headers/message.h" /* messaging in gpm */ 37 | #include "headers/daemon.h" /* daemon internals */ 38 | 39 | int open_console(const int mode) 40 | { 41 | int fd; 42 | int maj; 43 | int twelve = 12; 44 | struct serial_struct si; 45 | struct stat sb; 46 | 47 | fd = open(option.consolename, mode); 48 | if (fd != -1) { 49 | fstat(fd, &sb); 50 | maj = major(sb.st_rdev); 51 | if (maj != 4 && (maj < 136 || maj > 143)) { 52 | if (ioctl(fd, TIOCLINUX, &twelve) < 0) { 53 | if (si.line > 0) { 54 | gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN_SERIALCON); 55 | } 56 | } 57 | } 58 | } else 59 | gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN_CON); 60 | return fd; 61 | } 62 | -------------------------------------------------------------------------------- /src/daemon/processconn.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * general purpose mouse (gpm) 4 | * 5 | * Copyright (c) 2008 Nico Schottelius 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | * 21 | ********/ 22 | 23 | #include /* accept */ 24 | #include /* malloc */ 25 | #include /* close */ 26 | #include /* unix socket */ 27 | #include /* stat */ 28 | #include /* str* */ 29 | #include /* errno.h */ 30 | 31 | #include "headers/message.h" /* messaging in gpm */ 32 | #include "headers/daemon.h" /* daemon internals */ 33 | 34 | int processConn(int fd) 35 | { /* returns newfd or -1 */ 36 | Gpm_Cinfo *info; 37 | Gpm_Connect *request; 38 | Gpm_Cinfo *next; 39 | int vc, newfd; 40 | socklen_t len; 41 | struct sockaddr_un addr; /* reuse this each time */ 42 | struct stat statbuf; 43 | uid_t uid; 44 | char *tty = NULL; 45 | 46 | /*....................................... Accept */ 47 | 48 | bzero((char *) &addr, sizeof(addr)); 49 | addr.sun_family = AF_UNIX; 50 | 51 | len = sizeof(addr); 52 | if((newfd = accept(fd, (struct sockaddr *) &addr, &len)) == -1) { 53 | gpm_report(GPM_PR_ERR, GPM_MESS_ACCEPT_FAILED, strerror(errno)); 54 | return -1; 55 | } 56 | 57 | gpm_report(GPM_PR_DEBUG, GPM_MESS_CONECT_AT, newfd); 58 | 59 | info = malloc(sizeof(Gpm_Cinfo)); 60 | if(!info) 61 | gpm_report(GPM_PR_OOPS, GPM_MESS_NO_MEM); 62 | request = &(info->data); 63 | 64 | if(get_data(request, newfd) == -1) { 65 | free(info); 66 | close(newfd); 67 | return -1; 68 | } 69 | 70 | vc = request->vc; 71 | if(vc > MAX_VC || vc < 0) { 72 | gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_VC); 73 | free(info); 74 | close(newfd); 75 | return -1; 76 | } 77 | #ifndef SO_PEERCRED 78 | if(stat(addr.sun_path, &statbuf) == -1 || !S_ISSOCK(statbuf.st_mode)) { 79 | gpm_report(GPM_PR_ERR, GPM_MESS_ADDRES_NSOCKET, addr.sun_path); 80 | free(info); /* itz 10-12-95 verify client's right */ 81 | close(newfd); 82 | return -1; /* to read requested tty */ 83 | } 84 | 85 | unlink(addr.sun_path); /* delete socket */ 86 | 87 | staletime = time(0) - 30; 88 | if(statbuf.st_atime < staletime 89 | || statbuf.st_ctime < staletime || statbuf.st_mtime < staletime) { 90 | gpm_report(GPM_PR_ERR, GPM_MESS_SOCKET_OLD); 91 | free(info); 92 | close(newfd); 93 | return -1; /* socket is ancient */ 94 | } 95 | 96 | uid = statbuf.st_uid; /* owner of socket */ 97 | #else 98 | { 99 | struct ucred sucred; 100 | socklen_t credlen = sizeof(struct ucred); 101 | 102 | if(getsockopt(newfd, SOL_SOCKET, SO_PEERCRED, &sucred, &credlen) == -1) { 103 | gpm_report(GPM_PR_ERR, GPM_MESS_GETSOCKOPT, strerror(errno)); 104 | free(info); 105 | close(newfd); 106 | return -1; 107 | } 108 | uid = sucred.uid; 109 | gpm_report(GPM_PR_DEBUG, GPM_MESS_PEER_SCK_UID, uid); 110 | } 111 | #endif 112 | if(uid != 0) { 113 | if((tty = 114 | malloc(strlen(option.consolename) + Gpm_cnt_digits(vc) + 115 | sizeof(char))) == NULL) 116 | gpm_report(GPM_PR_OOPS, GPM_MESS_NO_MEM); 117 | 118 | strncpy(tty, option.consolename, strlen(option.consolename) - 1); 119 | sprintf(&tty[strlen(option.consolename) - 1], "%d", vc); 120 | 121 | if(stat(tty, &statbuf) == -1) { 122 | gpm_report(GPM_PR_ERR, GPM_MESS_STAT_FAILS, tty); 123 | free(info); 124 | free(tty); 125 | close(newfd); 126 | return -1; 127 | } 128 | if(uid != statbuf.st_uid) { 129 | gpm_report(GPM_PR_WARN, GPM_MESS_FAILED_CONNECT, uid, tty); /* SUSPECT! */ 130 | free(info); 131 | free(tty); 132 | close(newfd); 133 | return -1; 134 | } 135 | free(tty); /* at least here it's not needed anymore */ 136 | } 137 | 138 | /* 139 | * register the connection information in the right place 140 | */ 141 | info->next = next = cinfo[vc]; 142 | info->fd = newfd; 143 | cinfo[vc] = info; 144 | gpm_report(GPM_PR_DEBUG, GPM_MESS_LONG_STATUS, 145 | request->pid, request->vc, request->eventMask, 146 | request->defaultMask, request->minMod, request->maxMod); 147 | 148 | /* 149 | * if the client gets motions, give it the current position 150 | */ 151 | if(request->eventMask & GPM_MOVE) { 152 | Gpm_Event event = { 0, 0, vc, 0, 0, statusX, statusY, GPM_MOVE, 0, 0 }; 153 | do_client(info, &event); 154 | } 155 | 156 | return newfd; 157 | } 158 | -------------------------------------------------------------------------------- /src/daemon/processrequest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* close */ 23 | #include /* open */ 24 | #include /* free */ 25 | #include /* vt */ 26 | 27 | 28 | 29 | #include "headers/message.h" /* messaging in gpm */ 30 | #include "headers/daemon.h" /* daemon internals */ 31 | 32 | 33 | int processRequest(Gpm_Cinfo *ci, int vc) 34 | { 35 | int i; 36 | Gpm_Cinfo *cinfoPtr; 37 | Gpm_Cinfo *next; 38 | Gpm_Connect conn; 39 | static Gpm_Event event; 40 | static struct vt_stat stat; 41 | 42 | gpm_report(GPM_PR_INFO, GPM_MESS_CON_REQUEST, ci->fd, vc); 43 | 44 | if (vc>MAX_VC) return -1; 45 | 46 | /* itz 10-22-96 this shouldn't happen now */ 47 | if (vc==-1) gpm_report(GPM_PR_OOPS, GPM_MESS_UNKNOWN_FD); 48 | 49 | i=get_data(&conn,ci->fd); 50 | 51 | if (!i) { /* no data */ 52 | gpm_report(GPM_PR_DEBUG, GPM_MESS_CLOSE); 53 | close(ci->fd); 54 | FD_CLR(ci->fd,&connSet); 55 | FD_CLR(ci->fd,&readySet); 56 | if (cinfo[vc]->fd == ci->fd) { /* it was on top of the stack */ 57 | cinfoPtr = cinfo[vc]; 58 | cinfo[vc]=cinfo[vc]->next; /* pop the stack */ 59 | free(cinfoPtr); 60 | return -1; 61 | } 62 | /* somewhere inside the stack, have to walk it */ 63 | cinfoPtr = cinfo[vc]; 64 | while (cinfoPtr && cinfoPtr->next) { 65 | if (cinfoPtr->next->fd == ci->fd) { 66 | next = cinfoPtr->next; 67 | cinfoPtr->next = next->next; 68 | free (next); 69 | break; 70 | } 71 | cinfoPtr = cinfoPtr->next; 72 | } 73 | return -1; 74 | } /* not data */ 75 | 76 | if (i == -1) return -1; /* too few bytes */ 77 | 78 | if (conn.pid!=0) { 79 | ci->data = conn; 80 | return 0; 81 | } 82 | 83 | /* Aha, request for information (so-called snapshot) */ 84 | switch(conn.vc) { 85 | case GPM_REQ_SNAPSHOT: 86 | i = open_console(O_RDONLY); 87 | ioctl(i,VT_GETSTATE,&stat); 88 | event.modifiers=6; /* code for the ioctl */ 89 | if (ioctl(i,TIOCLINUX,&(event.modifiers))<0) 90 | gpm_report(GPM_PR_OOPS,GPM_MESS_GET_SHIFT_STATE); 91 | close(i); 92 | event.vc = stat.v_active; 93 | event.x=statusX; event.y=statusY; 94 | event.dx=maxx; event.dy=maxy; 95 | event.buttons= statusB; 96 | event.clicks=statusC; 97 | /* fall through */ 98 | /* missing break or do you want this ??? */ 99 | 100 | case GPM_REQ_BUTTONS: 101 | event.type= ((which_mouse->opt_three)==1 ? 3 : 2); /* buttons */ 102 | write(ci->fd,&event,sizeof(Gpm_Event)); 103 | break; 104 | 105 | case GPM_REQ_NOPASTE: 106 | disable_paste(vc); 107 | break; 108 | } 109 | 110 | return 0; 111 | } 112 | 113 | /*-------------------------------------------------------------------*/ 114 | -------------------------------------------------------------------------------- /src/daemon/reset_mice.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse support for Linux 3 | * 4 | * *several tools only needed by the server* 5 | * 6 | * Copyright (c) 2002-2008 Nico Schottelius 7 | * 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 22 | ********/ 23 | 24 | #include "headers/gpmInt.h" 25 | #include "headers/message.h" 26 | #include "headers/daemon.h" 27 | 28 | #include /* malloc() */ 29 | 30 | /* DESCR: when leaving, we should reset mice to their normal state */ 31 | /* RETURN: 0 - failed to reset one or more devices 32 | 1 - reset was fine */ 33 | /* COMMENT: does error handling and exiting itself */ 34 | int reset_mice(struct micetab *micelist) 35 | { 36 | struct micetab *tmp = micelist; 37 | struct micetab *end = tmp; 38 | 39 | while(tmp != NULL) { /* FIXME! I never get NULL, as free()d before */ 40 | end = tmp; 41 | while(tmp->next != NULL) { /* set end to the last mouse */ 42 | end = tmp; 43 | tmp = tmp->next; 44 | } 45 | 46 | gpm_report(GPM_PR_DEBUG,"reset: %s with proto %s",end->device,end->protocol); 47 | if(tmp->options != NULL) { 48 | gpm_report(GPM_PR_DEBUG,"and options %s",end->options); 49 | } 50 | free(end); /* be clean() */ 51 | tmp = micelist; /* reset to the first mice again */ 52 | } 53 | 54 | return 1; 55 | } 56 | -------------------------------------------------------------------------------- /src/daemon/selection_copy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* open */ 23 | #include /* close */ 24 | #include /* time */ 25 | 26 | 27 | #include "headers/message.h" /* messaging in gpm */ 28 | #include "headers/daemon.h" /* daemon internals */ 29 | 30 | void selection_copy(int x1, int y1, int x2, int y2, int mode) 31 | { 32 | /* 33 | * The approach in "selection" causes a bus error when run under SunOS 4.1 34 | * due to alignment problems... 35 | */ 36 | unsigned char buf[6*sizeof(short)]; 37 | unsigned short *arg = (unsigned short *)buf + 1; 38 | int fd; 39 | 40 | buf[sizeof(short)-1] = 2; /* set selection */ 41 | 42 | arg[0]=(unsigned short)x1; 43 | arg[1]=(unsigned short)y1; 44 | arg[2]=(unsigned short)x2; 45 | arg[3]=(unsigned short)y2; 46 | arg[4]=(unsigned short)mode; 47 | 48 | if ((fd=open_console(O_WRONLY))<0) 49 | gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN_CON); 50 | /* FIXME: should be replaced with string constant (headers/message.h) */ 51 | gpm_report(GPM_PR_DEBUG,"ctl %i, mode %i",(int)*buf, arg[4]); 52 | if (ioctl(fd, TIOCLINUX, buf+sizeof(short)-1) < 0) 53 | gpm_report(GPM_PR_OOPS,GPM_MESS_IOCTL_TIOCLINUX); 54 | close(fd); 55 | 56 | if (mode < 3) { 57 | opt_aged = 0; 58 | last_selection_time = time(0); 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /src/daemon/selection_paste.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* time */ 23 | #include /* open */ 24 | #include /* close */ 25 | 26 | #include "headers/message.h" /* messaging in gpm */ 27 | #include "headers/daemon.h" /* daemon internals */ 28 | 29 | void selection_paste(void) 30 | { 31 | char c=3; 32 | int fd; 33 | 34 | if (!opt_aged && (0 != opt_age_limit) && 35 | (last_selection_time + opt_age_limit < time(0))) { 36 | opt_aged = 1; 37 | } 38 | 39 | if (opt_aged) { 40 | gpm_report(GPM_PR_DEBUG,GPM_MESS_SKIP_PASTE); 41 | return; 42 | } 43 | 44 | fd=open_console(O_WRONLY); 45 | if(ioctl(fd, TIOCLINUX, &c) < 0) 46 | gpm_report(GPM_PR_OOPS,GPM_MESS_IOCTL_TIOCLINUX); 47 | close(fd); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/daemon/usage.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include "headers/message.h" /* messaging in gpm */ 23 | #include "headers/daemon.h" /* daemon internals */ 24 | 25 | int usage(char *whofailed) 26 | { 27 | if (whofailed) { 28 | gpm_report(GPM_PR_ERR,GPM_MESS_SPEC_ERR,whofailed,option.progname); 29 | return 1; 30 | } 31 | printf(GPM_MESS_USAGE,option.progname, DEF_ACCEL, DEF_BAUD, DEF_SEQUENCE, 32 | DEF_DELTA, DEF_TIME, DEF_LUT,DEF_SCALE, DEF_SAMPLE, DEF_TYPE); 33 | return 1; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/daemon/wait_text.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include /* sleep() */ 23 | #include /* open */ 24 | #include /* KDGETMODE */ 25 | 26 | #include "headers/message.h" /* messaging in gpm */ 27 | #include "headers/daemon.h" /* daemon internals */ 28 | #include "headers/gpmInt.h" /* evil old headers */ 29 | 30 | int wait_text(int *fdptr) 31 | { 32 | int fd; 33 | int kd_mode; 34 | 35 | close(*fdptr); 36 | do 37 | { 38 | sleep(2); 39 | fd = open_console(O_RDONLY); 40 | if (ioctl(fd, KDGETMODE, &kd_mode)<0) 41 | gpm_report(GPM_PR_OOPS,GPM_MESS_IOCTL_KDGETMODE); 42 | close(fd); 43 | } while (kd_mode != KD_TEXT); 44 | 45 | /* reopen, reinit (the function is only used if we have one mouse device) */ 46 | if ((*fdptr=open((which_mouse->opt_dev),O_RDWR))<0) 47 | gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN,(which_mouse->opt_dev)); 48 | if ((which_mouse->m_type)->init) 49 | (which_mouse->m_type)=((which_mouse->m_type)->init)(*fdptr, (which_mouse->m_type)->flags, (which_mouse->m_type), mouse_argc[1], 50 | mouse_argv[1]); 51 | return (1); 52 | } 53 | -------------------------------------------------------------------------------- /src/drivers/README: -------------------------------------------------------------------------------- 1 | This could be the home of the new driver structure in gpm2. 2 | 3 | Some ideas: 4 | 5 | - clean seperation: one directory per driver 6 | - shared objects: make each driver being a shared object 7 | - and put those objects into libexec? 8 | - and make etc/gpm2/enabled_drivers a list of drivers to be enabled 9 | - each driver has the following functions: 10 | * int gpm2_dr__detect(struct gpm2_dr_info *): detect whether a supported mouse is connected 11 | returns: 12 | -1: cannot detect mice 13 | 0: no mouse detected 14 | 1: mouse detected 15 | * int gpm2_dr__init(struct gpm2_dr_info *): init mouse 16 | returns: 17 | 0: mouse init failed 18 | 1: mouse init success 19 | * gpm2_dr__handle(struct gpm2_dr_info *): the main function that handles the mouse 20 | --> perhaps need to pass info from gpm2_dr__init to gpm2_dr__handle 21 | 22 | - gpm2 passes a structure to all functions: 23 | struct gpm2_dr_info { 24 | char *dev; 25 | char *opts; 26 | } 27 | 28 | - gpm2 creates a fork for each mouse connected 29 | - gpm2 forks die on sigterm (normally issued by gpm2) 30 | -------------------------------------------------------------------------------- /src/generic/getsym.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | extern int isodigit(const unsigned char c); 23 | 24 | /* routine to convert digits from octal notation (Andries Brouwer) */ 25 | int getsym(const unsigned char *p0, unsigned char *res) 26 | { 27 | const unsigned char *p = p0; 28 | char c; 29 | 30 | c = *p++; 31 | if (c == '\\' && *p) { 32 | c = *p++; 33 | if (isodigit(c)) { 34 | c -= '0'; 35 | if (isodigit(*p)) c = 8*c + (*p++ - '0'); 36 | if (isodigit(*p)) c = 8*c + (*p++ - '0'); 37 | } 38 | } 39 | *res = c; 40 | return (p - p0); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/generic/isodigit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | int isodigit(const unsigned char c) 23 | { 24 | return ((c & ~7) == '0'); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/gpm2/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # cinit 3 | # 4 | # Nico Schottelius 5 | # 6 | # Don't edit Makefiles, use conf/* for configuration. 7 | # 8 | 9 | #include Makefile.tests 10 | 11 | # Build tools / locations 12 | CC=./tmp/cc 13 | CFLAGS= 14 | LD=./tmp/ld 15 | LDFLAGS= 16 | STRIP=./tmp/strip 17 | SBIN=../sbin 18 | 19 | # directories and files 20 | CONFIG_H=include/config.h 21 | 22 | BIN=cinit 23 | 24 | # 25 | # End user targets 26 | # 27 | all: out/gpm2-daemon 28 | 29 | 30 | # 31 | # All objects depend on headers. 32 | # 33 | GPM2_DAEMON_HEADERS=$(shell cat deps/gpm2-daemon-headers) 34 | 35 | 36 | # 37 | # Objects 38 | # 39 | 40 | GPM2_DAEMON_OBJECTS=$(shell cat deps/gpm2-daemon) 41 | $(GPM2_DAEMON_OBJECTS): $(GPM2_DAEMON_HEADERS) 42 | 43 | GPM2_DAEMON_PROTOCOLS=$(shell cat tmp/protocol-deps) 44 | 45 | CLIENT= 46 | 47 | COMMUNICATION= 48 | 49 | OBJ= 50 | 51 | # 52 | # Programs 53 | # 54 | 55 | out/gpm2-daemon: $(GPM2_DAEMON_OBJECTS) $(GPM2_DAEMON_PROTOCOLS) 56 | $(LD) -o $@ $^ 57 | 58 | 59 | # 60 | # Generic 61 | # 62 | 63 | %.o: %.c .configured 64 | $(CC) -c -o $@ $< 65 | 66 | 67 | 68 | # 69 | # First do configuration, so we include the right variables 70 | # 71 | Makefile: .configured 72 | 73 | .configured: conf/* 74 | @./scripts/generate_cbuiltconfig.sh conf 75 | 76 | $(CINIT_OBJ): $(CONFIG_H) 77 | 78 | 79 | $(CONFIG_H): ../conf/* 80 | ../scripts/cinit.mkheader > $(CONFIG_H) 81 | 82 | cservice: $(SBIN)/cservice 83 | 84 | $(SBIN)/cservice util/cservice: $(SBIN) $(CSVC_OBJ) 85 | $(LD) $(LDFLAGS) $(CSVC_OBJ) -o $@ 86 | $(STRIP) $@ 87 | 88 | ccontrol: $(SBIN)/ccontrol 89 | 90 | $(SBIN)/ccontrol util/ccontrol: config.h $(SBIN) $(CCO_OBJ) 91 | $(LD) $(LDFLAGS) $(CCO_OBJ) -o $@ 92 | $(STRIP) $@ 93 | 94 | install: install-dir cinit cservice ccontrol 95 | @echo '*** Installing cinit ***' 96 | ./bin/cinit.install.binary 97 | 98 | install-miniconf: 99 | ./bin/cinit.install.miniconf 100 | 101 | install-dir: 102 | ./bin/cinit.install.dir 103 | 104 | 105 | ################################################################################ 106 | # 107 | # Build targets 108 | # 109 | cinit: $(CINIT_OBJ) 110 | $(LD) $^ -o $@ 111 | 112 | uml: cinit 113 | ../../vm/uml/uml-mount.sh 114 | cp cinit ../../vm/uml/root/sbin/cinit 115 | ../../vm/uml/uml-umount.sh 116 | 117 | umlstart: uml 118 | ../../vm/uml/uml-start.sh 119 | 120 | ################################################################################ 121 | # 122 | # Generic targets 123 | # 124 | 125 | .PHONY: dist 126 | dist: distclean 127 | 128 | .PHONY: distclean 129 | distclean: clean 130 | rm -f os/current ipc/current .configured 131 | 132 | .PHONY: clean 133 | clean: 134 | rm -f ../tmpbin/*.configured 135 | rm -f $(BIN) $(CINIT_OBJ) 136 | rm -f test/*.o 137 | -------------------------------------------------------------------------------- /src/gpm2/TODO: -------------------------------------------------------------------------------- 1 | - read cconfig-directory 2 | - create mouse structures 3 | - use cconfig-protocol-options as base for each protocol 4 | char *fullpath? 5 | -------------------------------------------------------------------------------- /src/gpm2/client/README: -------------------------------------------------------------------------------- 1 | The files in this directory should built up the client interface. 2 | 3 | Some ideas: 4 | 5 | struct gpm2_conn *gpm2_connect(): 6 | client connects to gpm2-daemon 7 | 8 | gpm2_get_mice(struct gpm2_conn *g2c): 9 | get list of devices, including protocols and ids 10 | 11 | struct *mouseinfo gpm2_open_mouse(int mouse_id, int type); 12 | returns set of descriptors: 13 | - to read mousedata 14 | 15 | int gpm2_close_mouse(struct *mouseinfo mi); 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/gpm2/conf/README: -------------------------------------------------------------------------------- 1 | This is the conf/ directory Nico Schottelius uses to configure his 2 | software projects. They evolve with every project and the aim is 3 | to replace autoconf once. 4 | 5 | In general, the idea is to create extremly simply configuration files, 6 | that are editable by non-interactive programs (distributor friendly). 7 | 8 | In most cases only the first line is important and the other lines are 9 | simply the description. 10 | 11 | programs/ - contains definitions of programs we need in our built process 12 | -------------------------------------------------------------------------------- /src/gpm2/conf/built-options/protocols: -------------------------------------------------------------------------------- 1 | ps2 2 | 3 | List of protocols to enable (at built time: not expandable later). 4 | -------------------------------------------------------------------------------- /src/gpm2/conf/built/ld: -------------------------------------------------------------------------------- 1 | gcc 2 | 3 | The program used to link 4 | -------------------------------------------------------------------------------- /src/gpm2/conf/programs/cc: -------------------------------------------------------------------------------- 1 | gcc 2 | 3 | The c-compiler to use. 4 | -------------------------------------------------------------------------------- /src/gpm2/conf/programs/cc.params: -------------------------------------------------------------------------------- 1 | -pipe -W -Wall -Werror -I. -Iinclude -g 2 | 3 | flags to pass to the c-compiler. 4 | -------------------------------------------------------------------------------- /src/gpm2/conf/programs/ld: -------------------------------------------------------------------------------- 1 | gcc 2 | 3 | The linker to use. 4 | -------------------------------------------------------------------------------- /src/gpm2/core/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * main: Where life of gpm2 begins. 22 | ********/ 23 | 24 | 25 | #include "gpm2-daemon.h" 26 | 27 | int main(int argc, char **argv) 28 | { 29 | set_defaults(); 30 | 31 | if(!commandline(argc,argv)) return 1; 32 | 33 | if(!read_config(opts.cconfig)) return 1; 34 | 35 | /* creates a fork() */ 36 | if(!mice_handler()) return 1; 37 | 38 | /* listen to messages: exits only on failure or shutdown */ 39 | // listen_ipc(); 40 | 41 | // shutdown_gpm2(); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /src/gpm2/core/read_config.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * read cconfig 22 | ********/ 23 | 24 | #include "gpm2-daemon.h" 25 | 26 | int read_config(char *cconfig) 27 | { 28 | /* open cconfig-dir (FIXME: write small framework for reuse) */ 29 | 30 | if(!cconfig) return 0; /* remove, just to make gcc happy */ 31 | /* set options */ 32 | 33 | return 1; 34 | } 35 | -------------------------------------------------------------------------------- /src/gpm2/core/set_defaults.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * set the default options 22 | ********/ 23 | 24 | 25 | #include "gpm2-daemon.h" 26 | 27 | void set_defaults() 28 | { 29 | /* options */ 30 | opts.cconfig = GPM2_CCONFIG; 31 | } 32 | -------------------------------------------------------------------------------- /src/gpm2/deps/gpm2-daemon: -------------------------------------------------------------------------------- 1 | core/main.o 2 | core/read_config.o 3 | core/set_defaults.o 4 | generic/commandline.o 5 | generic/daemon-usage.o 6 | generic/mini_printf.o 7 | mice/mice_handler.o 8 | -------------------------------------------------------------------------------- /src/gpm2/deps/gpm2-daemon-headers: -------------------------------------------------------------------------------- 1 | include/gpm2-daemon.h 2 | -------------------------------------------------------------------------------- /src/gpm2/doc/CONFIGURATION: -------------------------------------------------------------------------------- 1 | Configuration: 2 | /etc/gpm2/ 3 | mice/ 4 | default/ 5 | mice-userid: userid of person reading/writing mice devices 6 | mice-groupid: groupid of person reading/writing mice devices 7 | 8 | / 9 | device: link or device to use 10 | protocol: one line, containing protocol 11 | userid: overwrites default/mice-userid 12 | groupid: overwrites default/mice-groupid 13 | options/: options for that protocol 14 | 15 | 16 | 17 | clients/ 18 | -------------------------------------------------------------------------------- /src/gpm2/doc/DESIGN: -------------------------------------------------------------------------------- 1 | Possible design of gpm2: 2 | 3 | gpm2-starter: 4 | - reads configuration 5 | - starts daemons 6 | * first gpm2-daemon 7 | - connects daemons 8 | * connects them through stdin and stdout? 9 | - perhaps a job of gpm2-daemon? 10 | * stderr is relayed to the log console 11 | - which can log to syslog 12 | 13 | gpm2-daemon: 14 | - main daemon 15 | - starts mice handlers 16 | - listens for ipc 17 | - relays input data abstracted to clients 18 | - does *NOT* draw a cursor or something like that 19 | - can be used by x.org (see below) 20 | - opens mice devices? 21 | - should be portable 22 | 23 | gpm2-io: 24 | - gets list of opened fds or of devices 25 | - uses poll() / select() on mice devices 26 | - retrieves data packets 27 | - forwards raw data packets to gpm2-daemon from devices 28 | - either 29 | - forwards raw data packets from gpm2-daemon to devices?? 30 | - decodes mice packets: does protocol handling and 31 | forwards decoded packages to gpm2_daemon 32 | - has a mouse - fd_in - fd_out list 33 | - has *NO* root priviliges 34 | 35 | gpm2-decode: 36 | - forwards raw data packets from gpm2-daemon 37 | - forwards decoded packages to clients (like gpm2-cdisplay) 38 | 39 | gpm2-raw-relay: 40 | - reads data from gpm2-daemon 41 | - writes raw data to clients 42 | - a client needs to connect n times for n mice 43 | 44 | gpm2-cdisplay: 45 | - Console DISPLAYS: displays mouse cursor on console 46 | - reads input from gpm2-daemon 47 | - reads mouse information 48 | - perhaps os-specific versions 49 | 50 | gpm2-ccandp: 51 | - Console Copy AND Paste daemon 52 | - reads input from gpm2-daemon 53 | - copies selected text into own buffer 54 | - pastes buffer to console 55 | - perhaps os-specific versions 56 | 57 | gpm2-xorg: 58 | - interface between gpm2 and x.org 59 | - could make mouse support unecessary in x.org 60 | - should be portable 61 | 62 | gpm2-syslog: 63 | - connects to the gpm2-daemon logging port 64 | - reads messages 65 | - relays them to syslog 66 | -------------------------------------------------------------------------------- /src/gpm2/generic/commandline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * handle command line arguments 22 | ********/ 23 | 24 | #include /* getopt() */ 25 | 26 | #include "gpm2-daemon.h" 27 | 28 | int commandline(int argc, char **argv) 29 | { 30 | int opt; 31 | 32 | while((opt = getopt(argc,argv,GPM2_ARGS)) != -1) { 33 | switch(opt) { 34 | default: 35 | usage(); 36 | break; 37 | } 38 | 39 | } 40 | 41 | return 1; 42 | } 43 | -------------------------------------------------------------------------------- /src/gpm2/generic/daemon-usage.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * Print out, how to use gpm2-daemon 22 | ********/ 23 | 24 | #include "gpm2-generic.h" 25 | 26 | void usage() 27 | { 28 | mini_printf("gpm2-daemon: written by Nico Schottelius\n",1); 29 | mini_printf("\n",1); 30 | mini_printf(" -c : specify configuration directory\n",1); 31 | mini_printf(" -f: fork into background after startup \n",1); 32 | } 33 | -------------------------------------------------------------------------------- /src/gpm2/generic/mini_printf.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * 2005-2007 Nico Schottelius (nico-cinit at schottelius.org) 4 | * 5 | * part of cLinux/cinit 6 | * 7 | * Print the world! 8 | * 9 | */ 10 | 11 | #include 12 | 13 | void mini_printf(char *str,int fd) 14 | { 15 | char *p; 16 | 17 | /* don't get fooled by bad pointers */ 18 | if(str == NULL) return; 19 | 20 | p = str; 21 | while(*p) p++; 22 | 23 | write(fd,str,(size_t) (p - str)); 24 | } 25 | -------------------------------------------------------------------------------- /src/gpm2/generic/read_packet.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * read one mouse packet and return it 22 | ********/ 23 | 24 | #include /* read() */ 25 | #include /* NULL */ 26 | #include /* malloc() */ 27 | #include /* errno */ 28 | 29 | char *read_packet(int fd, int len) 30 | { 31 | char *packet; 32 | 33 | errno = 0; /* no library function ever sets errno to 0, so we do */ 34 | 35 | packet = malloc(len); 36 | if(packet == NULL) return NULL; 37 | 38 | if(read(fd,&packet,len) == -1) { 39 | free(packet); 40 | return NULL; 41 | } 42 | 43 | return packet; 44 | } 45 | -------------------------------------------------------------------------------- /src/gpm2/include/gpm2-client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * client information 22 | ********/ 23 | 24 | /* functions */ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/gpm2/include/gpm2-config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * values shared by daemon and clients 22 | ********/ 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/gpm2/include/gpm2-daemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * daemon specific include file 22 | ********/ 23 | 24 | #ifndef GPM2_DAEMON 25 | #define GPM2_DAEMON 26 | 27 | /* parameters and options */ 28 | #define GPM2_ARGS "c:f" 29 | #define GPM2_CCONFIG "/etc/gpm2" 30 | 31 | struct gpm2_options { 32 | char *cconfig; /* configuration directory */ 33 | } opts; 34 | 35 | /* functions */ 36 | int commandline(int argc, char **argv); 37 | int mice_handler(); 38 | int read_config(char *cconfig); 39 | void set_defaults(); 40 | void usage(); 41 | 42 | 43 | /* structs */ 44 | 45 | struct mouse { 46 | /* pointer to init and decode functions */ 47 | int (*open)(int fd); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/gpm2/include/gpm2-data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * data definitions used by clients and daemon 22 | ********/ 23 | 24 | /* structs */ 25 | struct gpm2_mouse { 26 | char *name; 27 | char *dev; 28 | int fd; 29 | }; 30 | 31 | struct gpm2_me { /* mouse element */ 32 | struct gpm2_mouse mouse; 33 | struct gpm2_me *next; 34 | struct gpm2_me *prev; 35 | }; 36 | 37 | struct gpm2_packet_raw() { /* raw mouse packets */ 38 | char *data; 39 | int len; 40 | }; 41 | 42 | /* must contain everything a mouse can do */ 43 | struct gpm2_packet() { /* decoded mouse packets */ 44 | 45 | int nr_buttons; 46 | int *buttons; 47 | 48 | int pos_type; /* absolute or relativ */ 49 | }; 50 | 51 | /* structure */ 52 | struct gpm2_mic 53 | 54 | /* gpm2-daemon needs a list of mice, containing: 55 | * - name of mouse 56 | * - device used 57 | * - filedescriptor 58 | * - mouse configuration as found in cconfig 59 | */ 60 | -------------------------------------------------------------------------------- /src/gpm2/include/gpm2-generic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * generic functions: used by daemon and clients 22 | ********/ 23 | 24 | /* generic functions */ 25 | void mini_printf(char *str,int fd); 26 | -------------------------------------------------------------------------------- /src/gpm2/include/gpm2-io.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * data definitions used by clients and daemon 22 | ********/ 23 | 24 | #ifndef GPM2_IO_H 25 | #define GPM2_IO_H 26 | 27 | char *read_packet(int fd, int len); /* needed? */ 28 | 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/gpm2/mice/README: -------------------------------------------------------------------------------- 1 | This directory should contain the mice-protocol implementations. 2 | 3 | Each file (or if bigger: directory) implements one protocol. 4 | 5 | You have to create three functions: 6 | 7 | gpm2_open_(); 8 | gpm2_handle_(); 9 | gpm2_close_(); 10 | 11 | It's not yet clear, how to register protocols to gpm2. 12 | 13 | First idea of inclusion: 14 | 15 | - create deps/mouse- containging all dependencies 16 | - conf/built-options/mice specifies which mice protocols to include 17 | - a script generates include/gpm2-daemon-mice.h containg a struct-array 18 | that looks like: 19 | 20 | struct mice_protos { 21 | char *name; 22 | int (*open)(); 23 | int (*handle)(); 24 | int (*open)(); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- 28 | More design ideas for using mice: 29 | 30 | - The gpm2_handle function gets a pointer to a char array containing the 31 | data packet. 32 | - The gpm2_handle function returns what the packet means 33 | - gpm2_daemon may then decide what todo with this information 34 | 35 | -------------------------------------------------------------------------------- 36 | It would be nice to have a read_config_ that reads and verifies 37 | the protocol specific options. 38 | 39 | For this, it would be nice to have a libcconfig() like this: 40 | 41 | struct cconfig_fd *cconfig_open(char *dir); 42 | struct cconfig_tree *cconfig_read_tree(struct cconfig_fd *which); 43 | 44 | struct cconfig_element *cconfig_select_below(char *basepath, struct cconfig_fd *which, ...); 45 | 46 | The tree, cconfig_read_tree creates could consist of elements 47 | of the following definition: 48 | 49 | struct cconfig_element { 50 | char *path; 51 | struct stat sbuf; 52 | }; 53 | 54 | -------------------------------------------------------------------------------- 55 | gpm2_open_*: 56 | - needs fd 57 | - needs options 58 | 59 | -------------------------------------------------------------------------------- 60 | struct datapacket *gpm2_read_*(int fd) 61 | - reads one packet 62 | - returns it 63 | -------------------------------------------------------------------------------- 64 | -------------------------------------------------------------------------------- /src/gpm2/mice/deps/ps2: -------------------------------------------------------------------------------- 1 | mice/ps2.o 2 | -------------------------------------------------------------------------------- /src/gpm2/mice/init_mice_handler.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * handle mice 22 | ********/ 23 | 24 | /* unclean headers */ 25 | #include 26 | #include 27 | #include 28 | #include /* close */ 29 | 30 | 31 | #include "gpm2-daemon.h" 32 | #include "tmp/protocols.h" 33 | 34 | int init_mice_handler() 35 | { 36 | /* open connections: pipes */ 37 | 38 | return 1; 39 | } 40 | -------------------------------------------------------------------------------- /src/gpm2/mice/mice_handler.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * handle mice 22 | ********/ 23 | 24 | /* unclean headers */ 25 | #include 26 | #include 27 | #include 28 | #include /* close */ 29 | 30 | 31 | #include "gpm2-daemon.h" 32 | #include "tmp/protocols.h" 33 | 34 | int mice_handler() 35 | { 36 | 37 | /* init_mice_handler(); 38 | * open connections to gpm2_daemon: 39 | * - one for each mouse: 40 | * * raw channel (unidirectional) 41 | * * decoded channel (unidirectional) 42 | * * control channel (bidirectional) 43 | */ 44 | init_mice_handler(); 45 | 46 | /* init_mice: 47 | * 48 | * - open mousedev 49 | * - drop priviliges after that 50 | */ 51 | //init_mice(); 52 | 53 | 54 | //handle_mice(); /* forks and maintains mice */ 55 | 56 | /* dirty hack */ 57 | int ps2test = open("/dev/psaux",O_RDWR); 58 | 59 | gpm2_open_ps2(ps2test); 60 | gpm2_decode_ps2(ps2test); 61 | 62 | close(ps2test); 63 | 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /src/gpm2/mice/ps2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm2 - mouse driver for the console 3 | * 4 | * Copyright (c) 2007 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * 21 | * handle standard ps2 22 | ********/ 23 | 24 | #include /* usleep() */ 25 | #include /* tcflush() */ 26 | #include 27 | 28 | #include "gpm2-daemon.h" 29 | #include "gpm2-generic.h" 30 | 31 | /* protocol handler stolen from gpm1/mice.c */ 32 | 33 | /* ps2 protocol description 34 | * 35 | * 3 Bytes per packet 36 | * 37 | * first bit of data[0]: Left Button 38 | * second bit of data[0]: Right Button 39 | * third bit of data[0]: Middle Button 40 | * fourth bit of data[0]: Always 1 41 | * fifth bit of data[0]: X Sign 42 | * sixth bit of data[0]: Y Sign 43 | * seventh bit of data[0]: X Overflow 44 | * eighth bit of data[0]: Y Overflow 45 | * 46 | * data[1]: X Movement 47 | * data[2]: Y Movement 48 | */ 49 | 50 | /* standard ps2 */ 51 | /* FIXME: implement error handling and options as described on 52 | * http://www.computer-engineering.org/ps2mouse/ 53 | */ 54 | int gpm2_open_ps2(int fd) 55 | { 56 | //static unsigned char s[] = { 246, 230, 244, 243, 100, 232, 3, }; 57 | // write(fd, s, sizeof (s)); 58 | 59 | // static unsigned char s[] = { 246, 230, 244, 243, 100, 232, 3, }; 60 | 61 | char obuf, ibuf; 62 | /* FIXME: check return */ 63 | 64 | obuf = 0xff; /* reset mouse */ 65 | write(fd, &obuf, 1); 66 | read(fd,&ibuf,1); 67 | printf("RX: %#hhx\n",ibuf); 68 | // if(ibuf != 0xfa) return 0; 69 | 70 | // obuf = 0xf6; /* set mouse to default */ 71 | // write(fd, &obuf, 1); 72 | // read(fd,&ibuf,1); 73 | // printf("DF: %#hhx\n",ibuf); 74 | 75 | obuf = 0xf2; /* device id */ 76 | write(fd, &obuf, 1); 77 | read(fd,&ibuf,1); 78 | printf("ST: %#hhx\n",ibuf); 79 | read(fd,&ibuf,1); 80 | printf("DI: %#hhx\n",ibuf); 81 | 82 | /* set resolution: 0xe8 */ 83 | 84 | //if(scaling = 2) { e7h 85 | // 86 | // 0xe6 scaling =1 87 | 88 | /* do 0xf2, get device id and print it out */ 89 | /* do 0xe9 and print out values as status */ 90 | 91 | /* FIXME: time correct? */ 92 | usleep (30000); 93 | tcflush (fd, TCIFLUSH); 94 | return 0; 95 | 96 | } 97 | 98 | /* returs gpm2-readable data */ 99 | //int *gpm2_decode_ps2(char *data, struct mousedata *decoded) 100 | int gpm2_decode_ps2(int fd) 101 | { 102 | char data[3]; 103 | 104 | data[0] = 0; 105 | data[1] = 0; 106 | data[2] = 0; 107 | 108 | read(fd,data,3); 109 | 110 | if(data[0] & 0x01) mini_printf("left!\n",1); 111 | if(data[0] & 0x02) mini_printf("right!\n",1); 112 | if(data[0] & 0x04) mini_printf("middle!\n",1); 113 | 114 | /* decoded->button_left = data[0] & 0x01; 115 | decoded->button_right = data[0] & 0x02; 116 | decoded->button_middle = data[0] & 0x04; 117 | 118 | decoded-> */ 119 | 120 | return 1; 121 | } 122 | -------------------------------------------------------------------------------- /src/gpm2/scripts/generate_cbuiltconfig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Nico Schottelius 3 | # 2007-05-11 4 | # First script to generate built environment from 5 | # a standard cconfig directory for building. 6 | 7 | [ "$#" -eq 1 ] || exit 23 8 | 9 | set -e 10 | 11 | # args 12 | confdir="$1" 13 | 14 | # paths below the configuration directory 15 | programs="programs" 16 | progdir="$confdir/$programs" 17 | 18 | # paths directly in the srcdir 19 | tmpdir="tmp" 20 | 21 | # 22 | # generate built programs 23 | # 24 | 25 | for tmp in "${progdir}"/*; do 26 | prog="" 27 | params="" 28 | baseprog="$(basename "$tmp")" 29 | destprog="$tmpdir/$baseprog" 30 | 31 | # ignore *.params, those are parameters, not programs 32 | if [ "${tmp%.params}" != "${tmp}" ]; then 33 | continue 34 | fi 35 | 36 | # check for params 37 | pfile="${tmp}.params" 38 | if [ -f "$pfile" ]; then 39 | params="$(head -n1 "$pfile")" 40 | fi 41 | 42 | prog=$(head -n1 "$tmp") 43 | 44 | echo "Creating $destprog: $prog $params" 45 | echo '#!/bin/sh' > "${destprog}" 46 | echo "\"${prog}\" $params \"\$@\"" >> "${destprog}" 47 | chmod 0700 "${destprog}" 48 | done 49 | -------------------------------------------------------------------------------- /src/gpm2/scripts/include_protocols.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Nico Schottelius 3 | # 2007-05-13 4 | # Create protocol related files 5 | 6 | [ "$#" -eq 1 ] || exit 23 7 | 8 | set -e 9 | 10 | # args 11 | confdir="$1" 12 | 13 | # paths below the configuration directory 14 | builtopts="built-options" 15 | builtoptsdir="$confdir/$builtopts" 16 | 17 | # paths directly in the srcdir 18 | tmpdir="tmp" 19 | 20 | # 21 | # generate built programs 22 | # 23 | 24 | : > "${tmpdir}/protocols.h" 25 | 26 | for proto in $(head -n1 ${builtoptsdir}/protocols); do 27 | echo "int gpm2_open_${proto}(int fd);" > "${tmpdir}/protocols.h" 28 | echo "int gpm2_decode_${proto}(int fd);" >> "${tmpdir}/protocols.h" 29 | done 30 | -------------------------------------------------------------------------------- /src/gpm2/tmp/README: -------------------------------------------------------------------------------- 1 | Directory for temporarily created files. 2 | -------------------------------------------------------------------------------- /src/headers/gpm-proto.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __GPMPROTO_H__ 3 | #define __GPMPROTO_H__ 4 | 5 | /* 6 | * This is a draft for a protocol to use for a "generic input device" 7 | * that can feed packets to gpm. In general, this "generic input 8 | * device" will be a program that collects data from whatever source 9 | * fits its scope and pushes packet to gpm for handling. The same 10 | * protocol may be used to get events into X. My main motivation for 11 | * this is exploiting my screenless touchscreen to do handwriting 12 | * recognition and other silly stuff. 13 | * 14 | * While it may look complex, I think it's in fact easy; also, it 15 | * fits the fixed-size contraint that simplifies data transfer, features 16 | * aligned data items and does not pose any limit on the number of 17 | * axis/buttons/keys delivered with each packet. It can be 18 | * implemented slowly and each functionality can be verified in real 19 | * usage. It should be extensible enough to be pretty long-lived. 20 | * 21 | * Please note that I don't know of any similar effort, so I may just 22 | * be reinventing the wheel or doing some other stupid errors. 23 | * 24 | * Please note that timestamping is still missing, although it should 25 | * fit the design (just forgot about it, and the joystick api reminded 26 | * me about that). 27 | */ 28 | 29 | /* 30 | * This is the fixed-size packet, multi-byte fields use the network 31 | * byte order, so ntohl() and ntohs() are needed, but portability is 32 | * ensured. Note that it is 16 bytes, 4 of them are "control" info and 33 | * the rest is three 4-bytes data items. 34 | */ 35 | 36 | struct gpm_procotol_packet { 37 | __u8 flags; /* 10xxxxFF flags defined later */ 38 | __u8 buttons; /* 01BBBBBB button-1 to button-6 */ 39 | __u16 key; /* how to read the following data */ 40 | union { 41 | __u32 l; /* "long" */ 42 | __s32 sl; /* "signed long" */ 43 | __u16 w[2]; /* "word" */ 44 | __s16 sw[2]; /* "signed word" */ 45 | __u8 b[4]; /* "byte" */ 46 | __s8 sb[4]; /* "signed byte" */ 47 | } data[3]; 48 | }; 49 | 50 | /* 51 | * these flags can be used to build up longer packets (thus placing no limit 52 | * on the number of dimensions, buttons, keypresses per packet). A complete 53 | * packet has both flags set, otherwise other packets must be retrieved to 54 | * have all the information available. Most "simple" input devices will 55 | * just need one chunk of data (it offers three dimensions and 6 buttons) 56 | */ 57 | #define GPM_PROTOCOL_FLAG_FIRST 0x01 58 | #define GPM_PROTOCOL_FLAG_LAST 0x02 59 | 60 | /* 61 | * The "key" field is made up of three bitfields, each defines what the 62 | * corresponfing "data" item means. There are 15 meanings for each datum, 63 | * and the top four bits are currently unused and must be cleared. 64 | */ 65 | enum gpm_protocol_item { 66 | GPM_ITEM_UNUSED = 0, /* the data field is unused */ 67 | GPM_ITEM_RAXIS, /* relative X, Y, Z or further (signed long) */ 68 | GPM_ITEM_AAXIS, /* absolute axis (unsigned long, full-range) */ 69 | GPM_ITEM_BUTTONS, /* 32 buttons (7-38, 39-70, ...) as u32 mask */ 70 | GPM_ITEM_8BITKEYS, /* ascii or so, as u8. 0xff == unused */ 71 | GPM_ITEM_KEYCODES, /* keycodes as s16: pos/neg, 0x8000 == unused */ 72 | GPM_ITEM_KEYSYM, /* X keysym. positive/negative (?) as s32 */ 73 | GPM_ITEM_RESERVED, 74 | GPM_ITEM_RESERVED, 75 | GPM_ITEM_RESERVED, 76 | GPM_ITEM_RESERVED, 77 | GPM_ITEM_RESERVED, 78 | GPM_ITEM_RESERVED, 79 | GPM_ITEM_RESERVED, 80 | GPM_ITEM_RESERVED, 81 | GPM_ITEM_RESERVED 82 | }; 83 | 84 | /* 85 | RAXIS: relative position. First axis is X, then Y, then Z and so 86 | on. Use of third-and-further axis is application 87 | specific. As for scaling, I think every motion must be 88 | rescaled, and a mouse tick may be 1/1024 of the whole 89 | screen or so, but I'm not sure about that. If it is not 90 | rescaled to match absolute movements, then you can't mix 91 | relative and absolute movements, something that I want 92 | to be able to do. 93 | 94 | AAXIS: absolute position on an axis, scaled to the whole 32bit 95 | range. 96 | 97 | BUTTONS: if more than 6 buttons are there, a data field can host 98 | 32 extra buttons. If 38 are not enough other data fields 99 | can follow. If the complete packet is made up by more 100 | than one protocol item, the "buttons" field of trailing 101 | items is unused. Use of the buttons is application 102 | specific. 103 | 104 | 8BITKEYS: One to four ascii-or-so keys to push in the keyboard buffer. 105 | This is needed by the twiddler, for example. I have to study 106 | how the X protocol works before I can use this in X. 107 | 108 | KEYCODES: Raw keyboard keycodes. I feel these must be discouraged, as 109 | users remap their keyboards (although smart use of dumpkeys 110 | can unmap the keycodes properly). Positive for press and 111 | negative for release; up to two keycodes can fit in one 112 | data item 113 | 114 | KEYSYM: X keysym. (range 0 to 0xFFFFFF). Once again, I have to study X, 115 | but I think there is no need for press/release events. Each 116 | data item can host a single keysym as they span 24 bits 117 | 118 | */ 119 | 120 | 121 | #endif /* __GPM_PROTO_H__ */ 122 | -------------------------------------------------------------------------------- /src/headers/gpmCfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpm-Linux configuration file (server only) 3 | * 4 | * Copyright 1994-1996 rubini@linux.it 5 | * Copyright (C) 1998 Ian Zimmerman 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | ********/ 21 | 22 | #ifndef _GPMCFG_INCLUDED 23 | #define _GPMCFG_INCLUDED 24 | 25 | #define GPM_NAME "gpm" 26 | #define GPM_DATE "May 2002" 27 | 28 | /* timeout for the select() syscall */ 29 | #define SELECT_TIME 86400 /* one day */ 30 | 31 | #ifdef HAVE_LINUX_TTY_H 32 | #include 33 | #endif 34 | 35 | /* FIXME: still needed ?? */ 36 | /* How many virtual consoles are managed? */ 37 | #ifndef MAX_NR_CONSOLES 38 | # define MAX_NR_CONSOLES 64 /* this is always sure */ 39 | #endif 40 | 41 | #define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */ 42 | 43 | /* How many buttons may the mouse have? */ 44 | /* #define MAX_BUTTONS 3 ===> not used, it is hardwired :-( */ 45 | 46 | /* all the default values */ 47 | #define DEF_TYPE "ms" 48 | #define DEF_DEV NULL /* use the type-related one */ 49 | #define DEF_LUT "-a-zA-Z0-9_./\300-\326\330-\366\370-\377" 50 | #define DEF_SEQUENCE "123" /* how buttons are reordered */ 51 | #define DEF_BAUD 1200 52 | #define DEF_SAMPLE 100 53 | #define DEF_DELTA 25 54 | #define DEF_ACCEL 2 55 | #define DEF_SCALE 10 56 | #define DEF_TIME 250 /* time interval (ms) for multiple clicks */ 57 | #define DEF_THREE 0 /* have three buttons? */ 58 | #define DEF_KERNEL 0 /* no kernel module, by default */ 59 | 60 | /* 10 on old computers (<=386), 0 on current machines */ 61 | #define DEF_CLUSTER 0 /* maximum number of clustered events */ 62 | 63 | #define DEF_TEST 0 64 | #define DEF_PTRDRAG 1 /* double or triple click */ 65 | #define DEF_GLIDEPOINT_TAP 0 /* tapping emulates no buttons by default */ 66 | 67 | #endif /* _GPMCFG_INCLUDED */ 68 | -------------------------------------------------------------------------------- /src/headers/gpmInt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gpmInt.h - server-only stuff for gpm 3 | * 4 | * Copyright (C) 1994-1999 Alessandro Rubini 5 | * Copyright (C) 1998 Ian Zimmerman 6 | * Copyright (C) 2001-2008 Nico Schottelius 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 | ********/ 22 | 23 | #ifndef _GPMINT_INCLUDED 24 | #define _GPMINT_INCLUDED 25 | 26 | #include /* time_t */ /* for whom ???? FIXME */ 27 | 28 | #include "gpm.h" 29 | 30 | #if !defined(__GNUC__) 31 | # define inline 32 | #endif 33 | 34 | /*....................................... old gpmCfg.h */ 35 | /* timeout for the select() syscall */ 36 | #define SELECT_TIME 86400 /* one day */ 37 | 38 | #ifdef HAVE_LINUX_TTY_H 39 | #include 40 | #endif 41 | 42 | /* How many buttons may the mouse have? */ 43 | /* #define MAX_BUTTONS 3 ===> not used, it is hardwired :-( */ 44 | 45 | /* misc :) */ 46 | #define GPM_NULL_DEV "/dev/null" 47 | #define GPM_SYS_CONSOLE "/dev/console" 48 | #define GPM_DEVFS_CONSOLE "/dev/vc/0" 49 | #define GPM_OLD_CONSOLE "/dev/tty0" 50 | 51 | /*** mouse commands ***/ 52 | 53 | #define GPM_AUX_SEND_ID 0xF2 54 | #define GPM_AUX_ID_ERROR -1 55 | #define GPM_AUX_ID_PS2 0 56 | #define GPM_AUX_ID_IMPS2 3 57 | 58 | /* these are shameless stolen from /usr/src/linux/include/linux/pc_keyb.h */ 59 | 60 | #define GPM_AUX_SET_RES 0xE8 /* Set resolution */ 61 | #define GPM_AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */ 62 | #define GPM_AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */ 63 | #define GPM_AUX_GET_SCALE 0xE9 /* Get scaling factor */ 64 | #define GPM_AUX_SET_STREAM 0xEA /* Set stream mode */ 65 | #define GPM_AUX_SET_SAMPLE 0xF3 /* Set sample rate */ 66 | #define GPM_AUX_ENABLE_DEV 0xF4 /* Enable aux device */ 67 | #define GPM_AUX_DISABLE_DEV 0xF5 /* Disable aux device */ 68 | #define GPM_AUX_RESET 0xFF /* Reset aux device */ 69 | #define GPM_AUX_ACK 0xFA /* Command byte ACK. */ 70 | 71 | #define GPM_AUX_BUF_SIZE 2048 /* This might be better divisible by 72 | three to make overruns stay in sync 73 | but then the read function would need 74 | a lock etc - ick */ 75 | 76 | 77 | /*....................................... Structures */ 78 | 79 | #define GPM_EXTRA_MAGIC_1 0xAA 80 | #define GPM_EXTRA_MAGIC_2 0x55 81 | 82 | // looks unused; delete 83 | //typedef struct Opt_struct_type {int a,B,d,i,p,r,V,A;} Opt_struct_type; 84 | 85 | /* the other variables */ 86 | 87 | extern int opt_kill; 88 | extern int opt_kernel, opt_explicittype; 89 | extern int opt_aged; 90 | extern time_t opt_age_limit; 91 | 92 | /*....................................... Prototypes */ 93 | 94 | /* mice.c */ 95 | extern int M_listTypes(void); 96 | /* special.c */ 97 | int processSpecial(Gpm_Event *event); 98 | int twiddler_key(unsigned long message); 99 | int twiddler_key_init(void); 100 | 101 | /*....................................... Dirty hacks */ 102 | 103 | #undef GPM_USE_MAGIC /* magic token foreach message? */ 104 | #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0)) /* startup_daemon */ 105 | 106 | 107 | #ifdef GPM_USE_MAGIC 108 | #define MAGIC_P(code) code 109 | #else 110 | #define MAGIC_P(code) 111 | #endif 112 | 113 | #endif /* _GPMINT_INCLUDED */ 114 | -------------------------------------------------------------------------------- /src/headers/synaptics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * synaptics.h - support for the synaptics serial and ps2 touchpads 3 | * 4 | * Copyright 1999 hdavies@ameritech.net (Henry Davies 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | ********/ 20 | 21 | /* 22 | ** Design/Goals 23 | ** I want to use the Synaptics Serial touchpad as a cursor device under 24 | ** Linux (gpm). With this device I want to support operations similar 25 | ** to those supported by the Synaptics WinDOS driver, and some others 26 | ** of my own devising. 27 | ** 28 | ** Features: 29 | ** Corner Clicks 30 | ** This recognizes taps on the touchpad in the corner(s) and 31 | ** translates them into specific actions. Initially I am looking 32 | ** at actions on the order of alternate button clicks. Other 33 | ** alternatives include drags and whatnot. 34 | ** Edge Extensions 35 | ** This recognizes that the finger has moved from the center region 36 | ** of the touchpad and dragged to the edge area. At which point 37 | ** I want to be able to extend the motion by automatically moving 38 | ** in the direction of the edge. 39 | ** Toss n Catch 40 | ** This recognizes a quick motion of the finger on the touchpad and 41 | ** uses that to define a velocity vector for the cursor. A tap 42 | ** on the touchpad at a later time catches (stops) the cursor. 43 | ** Tap n Drag 44 | ** A quick tap of the touchpad followed by finger motion on the 45 | ** touchpad initiates what would be a drag with a normal mouse 46 | ** type device. 47 | ** Pressure Sensitive Velocity 48 | ** The Synaptics touchpad indicates the touch pressure of the finger 49 | ** (really an interface area) this is used to accelerate the cursor 50 | ** motion. This can be used in the normal motion, Tap n Drag, or 51 | ** Edge Extension modes. In normal motion and Tap n Drag this may 52 | ** be awkward due to increased friction caused by the pressure. 53 | */ 54 | 55 | 56 | #ifndef _SYNAPTICS_H_ 57 | #define _SYNAPTICS_H_ 58 | 59 | 60 | /* 61 | ** syn_process_serial_data 62 | ** 63 | ** Process the touchpad 6/7/8 byte data. 64 | */ 65 | void syn_process_serial_data (Gpm_Event *state, 66 | unsigned char *data); 67 | 68 | 69 | 70 | /* 71 | ** syn_process_ps2_data 72 | ** 73 | ** Process the touchpad 6 byte data. 74 | */ 75 | void syn_process_ps2_data (Gpm_Event *state, 76 | unsigned char *data); 77 | 78 | 79 | 80 | /* 81 | ** syn_serial_init 82 | ** 83 | ** Initialize the synaptics touchpad. Read model and identification. 84 | ** Determine the size of the touchpad in "pixels". Select 6/7/8 byte packets, 85 | ** select 9600 baud, and select high packet rate. 86 | ** Return how many bytes in a packet. 87 | */ 88 | int syn_serial_init (int fd); 89 | 90 | 91 | 92 | /* 93 | ** syn_ps2_init 94 | ** 95 | ** Initialize the synaptics touchpad. Read model and identification. 96 | ** Determine the size of the touchpad in "pixels". Select 6 byte packets, 97 | ** and select high packet rate. 98 | */ 99 | void syn_ps2_init (int fd); 100 | 101 | 102 | /* 103 | ** syn_ps2_reset 104 | ** 105 | ** Reset the synaptics touchpad. Touchpad ends in relative mode. 106 | */ 107 | void syn_ps2_reset (int fd); 108 | 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /src/headers/twiddler.h: -------------------------------------------------------------------------------- 1 | /* definition of the twiddler protocol */ 2 | 3 | /* 4 | * 2400,8,n,1 5-bytes 5 | * 6 | * bit 7 6 5 4 3 2 1 0 7 | * 0 4L 3M 3L 2M 2L 1M 1L 8 | * 1 Mo Al Co Fn Nm Sh 4M 9 | * 1 V6 V5 V4 V3 V2 V1 V0 10 | * 1 H4 H3 H2 H1 H0 V8 V7 11 | * 1 0 0 0 H8 H7 H6 H5 12 | * H and V are two complement: up and left is positive 13 | */ 14 | 15 | #define TW_L1 0x0001 16 | #define TW_M1 0x0002 17 | #define TW_R1 0x0003 18 | #define TW_ANY1 0x0003 19 | #define TW_L2 0x0004 20 | #define TW_M2 0x0008 21 | #define TW_R2 0x000C 22 | #define TW_ANY2 0x000C 23 | #define TW_L3 0x0010 24 | #define TW_M3 0x0020 25 | #define TW_R3 0x0030 26 | #define TW_ANY3 0x0030 27 | #define TW_L4 0x0040 28 | #define TW_M4 0x0080 29 | #define TW_R4 0x00C0 30 | #define TW_ANY4 0x00C0 31 | 32 | #define TW_MOD_0 0x0000 33 | #define TW_MOD_S 0x0100 34 | #define TW_MOD_N 0x0200 35 | #define TW_MOD_F 0x0400 36 | #define TW_MOD_C 0x0800 37 | #define TW_MOD_A 0x1000 38 | #define TW_MOD_M 0x2000 39 | 40 | #define TW_ANY_KEY 0x3fff /* any button or modifier */ 41 | #define TW_ANY_MOD 0x3f00 /* any modifier */ 42 | 43 | 44 | #define TW_V_SHIFT 14 45 | #define TW_H_SHIFT 23 46 | #define TW_M_MASK 0x1FF /* mask of movement bits, after shifting */ 47 | #define TW_M_BIT 0x100 48 | 49 | #define TW_SYSTEM_FILE SYSCONFDIR "/gpm-twiddler.conf" 50 | #define TW_CUSTOM_FILE SYSCONFDIR "/gpm-twiddler.user" 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/lib/libcurses.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libcurses.c - client library - curses level (gpm-Linux) 3 | * 4 | * Copyright 1994,1995 rubini@linux.it (Alessandro Rubini) 5 | * Copyright 2002 nico@schottelius.org (Nico Schottelius) 6 | * 7 | * xterm management is mostly by Miguel de Icaza 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 22 | ********/ 23 | 24 | #include 25 | #include 26 | #include /* select(); */ 27 | #include /* timeval */ 28 | #include /* socket() */ 29 | 30 | #include "headers/gpmInt.h" 31 | 32 | #ifdef HAVE_NCURSES_H 33 | #include 34 | #else 35 | #ifdef HAVE_NCURSES_CURSES_H 36 | #include 37 | #else 38 | #ifdef HAVE_CURSES_H 39 | #include 40 | #endif /* HAVE_CURSES_H */ 41 | #endif /* HAVE_NCURSES_CURSES_H */ 42 | #endif /* HAVE_NCURSES_H */ 43 | 44 | #define GET(win) ((win) ? wgetch(win) : getch()) 45 | 46 | int Gpm_Wgetch(WINDOW *win) 47 | { 48 | fd_set selSet; 49 | int max, flag, result; 50 | int fd=STDIN_FILENO; 51 | static Gpm_Event ev; 52 | 53 | if (!gpm_flag || gpm_fd==-1) return GET(win); 54 | if (gpm_morekeys) return (*gpm_handler)(&ev,gpm_data); 55 | gpm_hflag=0; 56 | 57 | max = (gpm_fd>fd) ? gpm_fd : fd; 58 | 59 | /*...................................................................*/ 60 | if (gpm_fd>=0) /* linux */ 61 | while(1) 62 | { 63 | if (gpm_visiblepointer) GPM_DRAWPOINTER(&ev); 64 | do 65 | { 66 | FD_ZERO(&selSet); 67 | FD_SET(fd,&selSet); 68 | if (gpm_fd>-1) 69 | FD_SET(gpm_fd,&selSet); 70 | gpm_timeout.tv_sec=SELECT_TIME; 71 | flag=select(max+1,&selSet,(fd_set *)NULL,(fd_set *)NULL,&gpm_timeout); 72 | } 73 | while (!flag); 74 | 75 | if (FD_ISSET(fd,&selSet)) 76 | return GET(win); 77 | 78 | if (flag==-1) 79 | continue; 80 | 81 | if (Gpm_GetEvent(&ev) && gpm_handler 82 | && (result=(*gpm_handler)(&ev,gpm_data))) 83 | { 84 | gpm_hflag=1; 85 | return result; 86 | } 87 | } 88 | else 89 | /*...................................................................*/ 90 | if (gpm_fd==-2) /* xterm */ 91 | { 92 | #define DELAY_MS 100 93 | static struct timeval to={0,DELAY_MS*1000}; 94 | static fd_set selSet; 95 | /* JD patch 11/08/1998 */ 96 | #define MAXNBPREVCHAR 4 /* I don't think more is usefull, JD */ 97 | static int nbprevchar=0, prevchar[MAXNBPREVCHAR]; 98 | extern int gpm_convert_event(char *data, Gpm_Event *event); 99 | int c; unsigned char mdata[4]; 100 | 101 | /* JD patch 11/08/1998 */ 102 | if (nbprevchar) /* if there are some consumed char ... */ 103 | return prevchar[--nbprevchar]; 104 | /* if ungetc() didn't suffice... */ 105 | /* if ((c=prevchar)!=EOF) 106 | { 107 | prevchar=EOF; 108 | return c; 109 | } 110 | */ 111 | 112 | while(1) 113 | { 114 | do 115 | { 116 | FD_ZERO(&selSet); FD_SET(fd,&selSet); 117 | gpm_timeout.tv_sec=SELECT_TIME; 118 | flag=select(fd+1,&selSet,(fd_set *)NULL,(fd_set *)NULL,&gpm_timeout); 119 | } 120 | while (!flag); 121 | 122 | if ((c=GET(win))!=0x1b) return c; 123 | 124 | /* escape: go on */ 125 | FD_ZERO(&selSet); FD_SET(fd,&selSet); to.tv_usec=DELAY_MS*1000; 126 | if ((flag=select(fd+1,&selSet,(fd_set *)NULL,(fd_set *)NULL,&to))==0) 127 | return c; 128 | if ((c=GET(win))!='[') 129 | {prevchar[nbprevchar++]=c; return 0x1B;} /* patche par JD 11/08/1998 */ 130 | /* {ungetc(c,stdin); return 0x1B;} */ 131 | 132 | /* '[': go on */ 133 | FD_ZERO(&selSet); FD_SET(fd,&selSet); to.tv_usec=DELAY_MS*1000; 134 | 135 | if ((flag=select(fd+1,&selSet,(fd_set *)NULL,(fd_set *)NULL,&to))==0) 136 | {prevchar[nbprevchar++]=c; return 0x1B;} /* patche par JD 11/08/1998 */ 137 | /* {ungetc(c,stdin); return 0x1B;} */ 138 | 139 | if ((c=GET(win))!='M') 140 | /* patche par JD 11/08/1998 NOTICE: prevchar is a lifo !*/ 141 | {prevchar[nbprevchar++]=c; prevchar[nbprevchar++]='['; return 0x1B;} 142 | /* {ungetc(c,stdin);prevchar='['; return 0x1B;} */ 143 | 144 | 145 | /* now, it surely is a mouse event */ 146 | 147 | for (c=0;c<3;c++) mdata[c]=GET(win); 148 | gpm_convert_event(mdata,&ev); 149 | 150 | if (gpm_handler && (result=(*gpm_handler)(&ev,gpm_data))) 151 | { 152 | gpm_hflag=1; 153 | return result; 154 | } 155 | } /* while(1) */ 156 | } 157 | return 0; 158 | } 159 | -------------------------------------------------------------------------------- /src/lib/libxtra.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * libxtra.c - client library - extra functions (gpm-Linux) 4 | * 5 | * Copyright 1994,1995 rubini@linux.it (Alessandro Rubini) 6 | * Copyright (C) 1998 Ian Zimmerman 7 | * 8 | * xterm management is mostly by Miguel de Icaza 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 23 | ********/ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "headers/gpmInt.h" 33 | #include "headers/message.h" 34 | 35 | /*-------------------------------------------------------------------*/ 36 | 37 | /* 38 | * these two functions return version information 39 | */ 40 | 41 | //static char *gpml_ver_s = GPM_ABI_FULL; 42 | //static int gpml_ver_i = 0; 43 | 44 | char *Gpm_GetLibVersion(int *where) 45 | { 46 | if(where) 47 | *where = GPM_ABI_LEV * 10000 + GPM_ABI_AGE * 100 + GPM_ABI_REV; 48 | return GPM_ABI_FULL; 49 | } 50 | 51 | static char gpm_ver_s[16]; 52 | static int gpm_ver_i = 0; 53 | 54 | char *Gpm_GetServerVersion(int *where) 55 | { 56 | char line[128]; 57 | FILE *f; 58 | int i, j, k = 0; 59 | 60 | if(!gpm_ver_s[0]) { 61 | f = popen(SBINDIR "/gpm -v", "r"); 62 | if(!f) 63 | return NULL; 64 | fgets(line, 128, f); 65 | if(pclose(f)) 66 | return 0; 67 | sscanf(line, "%*s %s", gpm_ver_s); /* "gpm-Linux 0.98, March 1995" 68 | */ 69 | gpm_ver_s[strlen(gpm_ver_s) - 1] = '\0'; /* cut the ',' */ 70 | 71 | sscanf(gpm_ver_s, "%d.%d.%d", &i, &j, &k); 72 | gpm_ver_i = i * 10000 + j * 100 + k; 73 | } 74 | 75 | if(where) 76 | *where = gpm_ver_i; 77 | return gpm_ver_s; 78 | } 79 | 80 | /*-------------------------------------------------------------------*/ 81 | 82 | /* 83 | * This returns all the available information about the current situation: 84 | * The return value is the number of buttons, as known to the server, 85 | * the ePtr, if any, is filled with information on the current state. 86 | */ 87 | int Gpm_GetSnapshot(Gpm_Event * ePtr) 88 | { 89 | Gpm_Connect conn; 90 | Gpm_Event event; 91 | fd_set sillySet; 92 | struct timeval to = { 0, 0 }; 93 | int i; 94 | 95 | if(!gpm_ver_i) { 96 | if(0 == Gpm_GetServerVersion(NULL)) { 97 | gpm_report(GPM_PR_WARN, "can't get gpm server version"); 98 | } /* if */ 99 | gpm_report(GPM_PR_INFO, "libgpm: got server version as %i", gpm_ver_i); 100 | } 101 | if(gpm_ver_i < 9802) { 102 | gpm_report(GPM_PR_INFO, 103 | "gpm server version too old to obtain status info"); 104 | return -1; /* error */ 105 | } 106 | if(gpm_fd <= 0) { 107 | gpm_report(GPM_PR_INFO, 108 | "gpm connection must be open to obtain status info"); 109 | return -1; /* error */ 110 | } 111 | 112 | conn.pid = 0; /* this signals a request */ 113 | if(ePtr) 114 | conn.vc = GPM_REQ_SNAPSHOT; 115 | else { 116 | conn.vc = GPM_REQ_BUTTONS; 117 | ePtr = &event; 118 | } 119 | 120 | if(gpm_fd == -1) 121 | return -1; 122 | FD_ZERO(&sillySet); 123 | FD_SET(gpm_fd, &sillySet); 124 | if(select(gpm_fd + 1, &sillySet, NULL, NULL, &to) == 1) 125 | return 0; 126 | write(gpm_fd, &conn, sizeof(Gpm_Connect)); 127 | 128 | if((i = Gpm_GetEvent(ePtr)) != 1) 129 | return -1; 130 | 131 | i = ePtr->type; 132 | ePtr->type = 0; 133 | return i; /* number of buttons */ 134 | } 135 | 136 | /* Local Variables: */ 137 | 138 | /* c-indent-level: 2 */ 139 | 140 | /* End: */ 141 | -------------------------------------------------------------------------------- /src/lib/report-lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * report-lib.c: the exported version of gpm_report. used in Gpm_Open and co. 3 | * 4 | * Copyright (c) 2001 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | */ 20 | 21 | #include /* NULL */ 22 | #include /* va_arg/start/... */ 23 | #include /* exit() */ 24 | 25 | #include "headers/message.h" 26 | 27 | void gpm_report(int line, const char *file, int stat, const char *text, ... ) 28 | { 29 | const char *string = NULL; 30 | int log_level; 31 | va_list ap; 32 | 33 | if (stat == GPM_STAT_DEBUG) return; 34 | 35 | va_start(ap,text); 36 | 37 | switch(stat) { 38 | case GPM_STAT_INFO : string = GPM_TEXT_INFO ; 39 | log_level = LOG_INFO; break; 40 | case GPM_STAT_WARN : string = GPM_TEXT_WARN ; 41 | log_level = LOG_WARNING; break; 42 | case GPM_STAT_ERR : string = GPM_TEXT_ERR ; 43 | log_level = LOG_ERR; break; 44 | case GPM_STAT_DEBUG: string = GPM_TEXT_DEBUG; 45 | log_level = LOG_DEBUG; break; 46 | case GPM_STAT_OOPS : string = GPM_TEXT_OOPS; 47 | log_level = LOG_CRIT; break; 48 | } 49 | #ifdef HAVE_VSYSLOG 50 | syslog(log_level, "%s", string); 51 | vsyslog(log_level, text, ap); 52 | #else 53 | fprintf(stderr,"%s[%s(%d)]:\n",string,file,line); 54 | vfprintf(stderr,text,ap); 55 | fprintf(stderr,"\n"); 56 | #endif 57 | 58 | if(stat == GPM_STAT_OOPS) exit(1); /* may a lib function call exit ???? */ 59 | } 60 | -------------------------------------------------------------------------------- /src/prog/disable-paste.c: -------------------------------------------------------------------------------- 1 | /* 2 | * disable-paste.c - trivial program to stop gpm from pasting the 3 | * current selection until the next user action 4 | * 5 | * Copyright (C) 1998 Ian Zimmerman 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 | ********/ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include "headers/gpm.h" 35 | #include "headers/gpmInt.h" 36 | 37 | int 38 | main(int argc, char** argv) 39 | { 40 | Gpm_Connect conn; 41 | const int len = sizeof(Gpm_Connect); 42 | int exit_status = 0; 43 | conn.eventMask = (unsigned short)(-1); conn.defaultMask = 0; 44 | conn.minMod = 0; conn.maxMod = (unsigned short)(-1); 45 | 46 | if (0 > Gpm_Open(&conn,0)) { 47 | fprintf(stderr,"disable-paste: cannot open mouse connection\n"); 48 | exit(1); 49 | } 50 | conn.vc = GPM_REQ_NOPASTE; 51 | conn.pid = 0; 52 | if (len > write(gpm_fd, &conn, len)) { 53 | fprintf(stderr,"disable-paste: cannot write request\n"); 54 | exit_status = 2; 55 | } 56 | Gpm_Close(); 57 | exit(exit_status); 58 | } 59 | -------------------------------------------------------------------------------- /src/prog/display-buttons.c: -------------------------------------------------------------------------------- 1 | /* 2 | * display-coords.c - a very simple gpm client 3 | * 4 | * Copyright 2007-2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * Compile and link with: gcc -o display-buttons -lgpm display-buttons.c 21 | * 22 | ********/ 23 | 24 | /* 25 | * This client is connects to gpm and displays the following values until 26 | * it is killed by control+c: 27 | * 28 | * left/middle/right button 29 | * time: when packet was recievesd 30 | * dtime: delta to the last packet 31 | * 32 | */ 33 | 34 | #include /* write, read, open */ 35 | #include /* strtol() */ 36 | #include /* printf() */ 37 | #include /* time() */ 38 | #include /* errno */ 39 | #include /* fd_set and FD_* */ 40 | #include /* gpm information */ 41 | 42 | /* display resulting data */ 43 | int display_data(Gpm_Event *event, void *data) 44 | { 45 | static time_t last = 0; 46 | time_t now = time(NULL); 47 | int delta; 48 | 49 | delta = now - last; 50 | last = now; 51 | 52 | /* display time, delta time */ 53 | printf("[%d] delta: %ds",now,delta); 54 | 55 | /* display mouse information */ 56 | printf(": p=%d, l=%1d, m=%1d, r=%1d, clicks=%d\n", 57 | event->type & GPM_DOWN, 58 | event->buttons & GPM_B_LEFT, 59 | event->buttons & GPM_B_MIDDLE, 60 | event->buttons & GPM_B_RIGHT, 61 | event->clicks); 62 | 63 | return 0; 64 | } 65 | 66 | int main(int argc, char **argv) 67 | { 68 | int vc; /* argv: console number */ 69 | Gpm_Connect conn; /* connection to gpm */ 70 | fd_set fds; 71 | 72 | /* select virtual console, 0 if not set */ 73 | vc = (argc == 2) ? strtol(argv[1],NULL,10) : 0; 74 | 75 | conn.eventMask = GPM_DRAG | GPM_DOWN | GPM_UP; 76 | conn.defaultMask = ~GPM_HARD; /* inverted GPM_HARD mask */ 77 | conn.minMod = 0; 78 | conn.maxMod = ~0; 79 | 80 | if(Gpm_Open(&conn,vc) == -1) { 81 | printf("Cannot connect to gpm!\n"); 82 | return 1; 83 | } 84 | if(gpm_fd == -2) { 85 | printf("I must be run on the console\n"); 86 | return 1; 87 | } 88 | 89 | printf("\tp=pressed (0=release)\n\tl=left\n\tm=middle\n\tr=right\n"); 90 | 91 | 92 | while(1) { /* read data */ 93 | FD_ZERO(&fds); 94 | FD_SET(gpm_fd, &fds); 95 | 96 | if (select(gpm_fd+1, &fds, 0, 0, 0) < 0 && errno == EINTR) 97 | continue; 98 | if (FD_ISSET(gpm_fd, &fds)) { 99 | Gpm_Event evt; 100 | if (Gpm_GetEvent(&evt) > 0) { 101 | display_data(&evt, NULL); 102 | } else { 103 | printf("Gpm_GetEvent failed\n"); 104 | } 105 | } 106 | } 107 | 108 | Gpm_Close(); /* close connection */ 109 | 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /src/prog/display-coords.c: -------------------------------------------------------------------------------- 1 | /* 2 | * display-coords.c - a very simple gpm client 3 | * 4 | * Copyright 2007-2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * Compile and link with: gcc -o display-coords -lgpm display-coords.c 21 | * 22 | ********/ 23 | 24 | /* 25 | * This client is connects to gpm and displays the following values until 26 | * it is killed by control+c: 27 | * 28 | * x/y coords on the screen 29 | * dx, dy: deltas 30 | * time: when packet was recievesd 31 | * dtime: delta to the last packet 32 | * 33 | */ 34 | 35 | #include /* write, read, open */ 36 | #include 37 | #include /* strtol() */ 38 | #include /* printf() */ 39 | #include /* time() */ 40 | #include /* errno */ 41 | #include /* fd_set and FD_* */ 42 | #include /* gpm information */ 43 | 44 | /* display resulting data */ 45 | int display_data(Gpm_Event *event, void *data) 46 | { 47 | static time_t last = 0; 48 | time_t now = time(NULL); 49 | int delta; 50 | 51 | delta = now - last; 52 | last = now; 53 | 54 | /* display time, delta time */ 55 | printf("[%jd] delta: %ds",(intmax_t)now,delta); 56 | 57 | /* display mouse information */ 58 | printf(": x=%2i, y=%2i, dx=%2i, dy=%2i\n", event->x, event->y, event->dx, event->dy); 59 | 60 | return 0; 61 | } 62 | 63 | int main(int argc, char **argv) 64 | { 65 | int vc; /* argv: console number */ 66 | Gpm_Connect conn; /* connection to gpm */ 67 | fd_set fds; 68 | 69 | /* select virtual console, 0 if not set */ 70 | vc = (argc == 2) ? strtol(argv[1],NULL,10) : 0; 71 | 72 | conn.eventMask = GPM_MOVE; /* read only moves */ 73 | conn.defaultMask = ~GPM_HARD; /* inverted GPM_HARD mask */ 74 | conn.minMod = 0; 75 | conn.maxMod = ~0; 76 | 77 | if(Gpm_Open(&conn,vc) == -1) { 78 | printf("Cannot connect to gpm!\n"); 79 | return 1; 80 | } 81 | if(gpm_fd == -2) { 82 | printf("I must be run on the console\n"); 83 | return 1; 84 | } 85 | 86 | 87 | while(1) { /* read data */ 88 | FD_ZERO(&fds); 89 | FD_SET(gpm_fd, &fds); 90 | 91 | if (select(gpm_fd+1, &fds, 0, 0, 0) < 0 && errno == EINTR) 92 | continue; 93 | if (FD_ISSET(gpm_fd, &fds)) { 94 | Gpm_Event evt; 95 | if (Gpm_GetEvent(&evt) > 0) { 96 | display_data(&evt, NULL); 97 | } else { 98 | printf("Gpm_GetEvent failed\n"); 99 | } 100 | } 101 | } 102 | 103 | Gpm_Close(); /* close connection */ 104 | 105 | return 0; 106 | } 107 | -------------------------------------------------------------------------------- /src/prog/get-versions.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Get gpm library and server version 3 | * 4 | * Copyright 2007-2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | * Compile and link with: gcc -lgpm 21 | * 22 | ********/ 23 | 24 | #include /* printf() */ 25 | #include /* gpm information */ 26 | 27 | int main() 28 | { 29 | char *ver; 30 | int intver; 31 | 32 | ver = Gpm_GetLibVersion(&intver); 33 | printf("lib: %s, %d\n",ver,intver); 34 | 35 | ver = Gpm_GetServerVersion(&intver); 36 | printf("srv: %s, %d\n",ver,intver); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /src/prog/open_console.c: -------------------------------------------------------------------------------- 1 | /* 2 | * general purpose mouse (gpm) 3 | * 4 | * Copyright (c) 2008 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | * 20 | ********/ 21 | 22 | #include "headers/message.h" /* messaging in gpm */ 23 | #include "headers/daemon.h" /* daemon internals */ 24 | #include 25 | 26 | int open_console(const int mode) 27 | { 28 | int fd; 29 | if ((fd = open(option.consolename, mode)) < 0) 30 | gpm_report(GPM_PR_OOPS, GPM_MESS_OPEN, option.consolename); 31 | return fd; 32 | } 33 | -------------------------------------------------------------------------------- /src/tools.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tools.c - tools which are needed by client and server 3 | * 4 | * Copyright (c) 2001 Nico Schottelius 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 19 | ********/ 20 | 21 | #include /* NULL */ 22 | #include 23 | #include 24 | #include /* these three are */ 25 | #include /* needed for */ 26 | #include /* stat() */ 27 | 28 | #include "headers/gpmInt.h" /* only used for some defines */ 29 | #include "headers/message.h" 30 | 31 | /***************************************************************************** 32 | * check, whether devfs is used or not. 33 | * See /usr/src/linux/Documentation/filesystems/devfs/ for details. 34 | * Returns: the name of the console (/dev/tty0 or /dev/vc/0) 35 | *****************************************************************************/ 36 | char *Gpm_get_console( void ) 37 | { 38 | 39 | char *back = NULL, *tmp = NULL; 40 | struct stat buf; 41 | 42 | /* first try the devfs device, because in the next time this will be 43 | * the preferred one. If that fails, take the old console */ 44 | 45 | /* Check for open new console */ 46 | if (stat(GPM_DEVFS_CONSOLE,&buf) == 0) 47 | tmp = GPM_DEVFS_CONSOLE; 48 | 49 | /* Failed, try OLD console */ 50 | else if(stat(GPM_OLD_CONSOLE,&buf) == 0) 51 | tmp = GPM_OLD_CONSOLE; 52 | 53 | if(tmp != NULL) 54 | if((back = malloc(strlen(tmp) + sizeof(char)) ) != NULL) 55 | strcpy(back,tmp); 56 | 57 | return(back); 58 | } 59 | 60 | /* what's the english name for potenz ? */ 61 | int Gpm_x_high_y(int base, int pot_y) 62 | { 63 | int val = 1; 64 | 65 | if(pot_y == 0) val = 1; 66 | else if(pot_y < 0) val = 0; /* ugly hack ;) */ 67 | else while(pot_y > 0) { 68 | val = val * base; 69 | pot_y--; 70 | } 71 | return val; 72 | } 73 | 74 | /* return characters needed to display int */ 75 | int Gpm_cnt_digits(int number) 76 | { 77 | /* 0-9 = 1 10^0 <-> (10^1)-1 78 | * 10 - 99 = 2 10^1 <-> (10^2)-1 79 | * 100 - 999 = 3 10^2 <-> (10^3)-1 80 | * 1000 - 9999 = 4 ... */ 81 | 82 | int ret = 0, num = 0; 83 | 84 | /* non negative, please */ 85 | if(number < 0) number *= -1; 86 | else if(number == 0) ret = 1; 87 | else while(number > num) { 88 | ret++; 89 | num = (Gpm_x_high_y(10,ret) - 1); 90 | } 91 | 92 | return(ret); 93 | } 94 | --------------------------------------------------------------------------------