Import Upstream version 1.9.0

This commit is contained in:
Giacomo Catenazzi committed 2019-04-29 15:42:59 +02:00
commit a60b7c6315
79 files changed
+51673

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
METASOURCES = AUTO
libdir = /usr/share/g15daemon/plugins
AM_CFLAGS = -Wall
lib_LTLIBRARIES =g15plugin_uinput.la g15plugin_tcpserver.la g15plugin_clock.la
INCLUDES = -I$(top_builddir)/libg15daemon_client/ -I$(top_builddir)/g15daemon
g15plugin_uinput_la_SOURCES = g15_plugin_uinput.c
g15plugin_uinput_la_LDFLAGS = -avoid-version -module
g15plugin_tcpserver_la_SOURCES = g15_plugin_net.c
g15plugin_tcpserver_la_LDFLAGS = -avoid-version -module
g15plugin_clock_la_SOURCES = g15_plugin_clock.c
g15plugin_clock_la_LDFLAGS = -avoid-version -module
+477
View File
@@ -0,0 +1,477 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = plugins
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
g15plugin_clock_la_LIBADD =
am_g15plugin_clock_la_OBJECTS = g15_plugin_clock.lo
g15plugin_clock_la_OBJECTS = $(am_g15plugin_clock_la_OBJECTS)
g15plugin_tcpserver_la_LIBADD =
am_g15plugin_tcpserver_la_OBJECTS = g15_plugin_net.lo
g15plugin_tcpserver_la_OBJECTS = $(am_g15plugin_tcpserver_la_OBJECTS)
g15plugin_uinput_la_LIBADD =
am_g15plugin_uinput_la_OBJECTS = g15_plugin_uinput.lo
g15plugin_uinput_la_OBJECTS = $(am_g15plugin_uinput_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(g15plugin_clock_la_SOURCES) \
$(g15plugin_tcpserver_la_SOURCES) \
$(g15plugin_uinput_la_SOURCES)
DIST_SOURCES = $(g15plugin_clock_la_SOURCES) \
$(g15plugin_tcpserver_la_SOURCES) \
$(g15plugin_uinput_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = /usr/share/g15daemon/plugins
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
METASOURCES = AUTO
AM_CFLAGS = -Wall
lib_LTLIBRARIES = g15plugin_uinput.la g15plugin_tcpserver.la g15plugin_clock.la
INCLUDES = -I$(top_builddir)/libg15daemon_client/ -I$(top_builddir)/g15daemon
g15plugin_uinput_la_SOURCES = g15_plugin_uinput.c
g15plugin_uinput_la_LDFLAGS = -avoid-version -module
g15plugin_tcpserver_la_SOURCES = g15_plugin_net.c
g15plugin_tcpserver_la_LDFLAGS = -avoid-version -module
g15plugin_clock_la_SOURCES = g15_plugin_clock.c
g15plugin_clock_la_LDFLAGS = -avoid-version -module
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu plugins/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
g15plugin_clock.la: $(g15plugin_clock_la_OBJECTS) $(g15plugin_clock_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(g15plugin_clock_la_LDFLAGS) $(g15plugin_clock_la_OBJECTS) $(g15plugin_clock_la_LIBADD) $(LIBS)
g15plugin_tcpserver.la: $(g15plugin_tcpserver_la_OBJECTS) $(g15plugin_tcpserver_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(g15plugin_tcpserver_la_LDFLAGS) $(g15plugin_tcpserver_la_OBJECTS) $(g15plugin_tcpserver_la_LIBADD) $(LIBS)
g15plugin_uinput.la: $(g15plugin_uinput_la_OBJECTS) $(g15plugin_uinput_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(g15plugin_uinput_la_LDFLAGS) $(g15plugin_uinput_la_OBJECTS) $(g15plugin_uinput_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/g15_plugin_clock.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/g15_plugin_net.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/g15_plugin_uinput.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(libdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am: install-libLTLIBRARIES
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am \
install-libLTLIBRARIES install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+349
View File
@@ -0,0 +1,349 @@
/*
This file is part of g15daemon.
g15daemon is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
g15daemon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 197 $ - $Date: 2006-12-11 12:26:17 +1030 (Mon, 11 Dec 2006) $ $Author: aneurysm9 $
simple Clock plugin, replace the various functions with your own, and change the g15plugin_info struct below to suit,
edit Makefile.am and compile. Add salt and pepper to taste. For a more advanced plugin that creates it's own lcd screens on-the-fly,
see the tcpserver plugin in this directory.
*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include <libg15.h>
#include <config.h>
#include <g15daemon.h>
#include <libg15render.h>
extern double round(double);
// clock specs:
#define CLOCK_CENTERX 25
#define CLOCK_CENTERY 21
#define CLOCK_RADIUS 20
// useful shortcuts (g15r_drawCircle() is a bit egg-shaped, or my math is :)
#define CLOCK_STARTX (CLOCK_CENTERX-CLOCK_RADIUS-1)
#define CLOCK_STARTY (CLOCK_CENTERY-CLOCK_RADIUS)
#define CLOCK_ENDX (CLOCK_CENTERX+CLOCK_RADIUS+1)
#define CLOCK_ENDY (CLOCK_CENTERY+CLOCK_RADIUS)
static int mode=1;
static int showdate=0;
static int digital=1;
g15canvas *static_canvas = NULL;
//----------------------------------------------------------------------------
// calc x,y for given minute/hour/sec (pos), cut_off is for radius variations
// ( ie. shorter/longer clock-hands, line parts....)
void get_clock_pos(int pos, int *x, int *y, int cut_off)
{
// pos = [0-60]
// make sure it's in range:
pos %= 60;
// angles go contra-clockwise, but clock goes clockwise :), so invert clock orientation
pos = 60 - pos;
// this math is patent-copy-trademark-protected by <Rasta Freak> :)
double ang = 270.0 - 6.0*(double)pos;
ang = (ang * 2.0 * M_PI) / 360.0;
// simple pre-school math for naturaly dumb:
double _x = (double)CLOCK_CENTERX + (cos(ang)*(double)(CLOCK_RADIUS+1-cut_off));
double _y = (double)CLOCK_CENTERY + (sin(ang)*(double)(CLOCK_RADIUS-cut_off));
*x = (int)(round(_x));
*y = (int)(round(_y));
}
//----------------------------------------------------------------------------
// draw clock frame (only once, as it is stored in static_canvas)
// NOTE - coords here are hardcoded !
void draw_static_canvas(void)
{
g15canvas *c = static_canvas;
int i;
g15r_clearScreen (c, G15_COLOR_WHITE);
g15r_drawCircle(c, CLOCK_CENTERX, CLOCK_CENTERY, CLOCK_RADIUS, 0, G15_COLOR_BLACK);
g15r_drawCircle(c, CLOCK_CENTERX, CLOCK_CENTERY, 2, 1, G15_COLOR_BLACK);
for (i=0; i<60; i+=5)
{
if ((i%15)==0)
{
// draw number (12/3/6/9):
switch (i)
{
case 0:
g15r_renderString(c, (unsigned char*)"12", 0, G15_TEXT_SMALL, 22, 3);
break;
case 15:
g15r_renderString(c, (unsigned char*)"3", 3, G15_TEXT_SMALL, 42, 1);
break;
case 30:
g15r_renderString(c, (unsigned char*)"6", 6, G15_TEXT_SMALL, 24, -1);
break;
case 45:
g15r_renderString(c, (unsigned char*)"9", 3, G15_TEXT_SMALL, 6, 1);
break;
}
}
else
{
// draw 4-pixel square dot for other hours:
int x1,y1,dir;
if (i>15 && i<45) dir=-1; else dir=1;
get_clock_pos(i, &x1, &y1, 3);
g15r_setPixel(c, x1, y1, G15_COLOR_BLACK);
g15r_setPixel(c, x1+dir, y1, G15_COLOR_BLACK);
g15r_setPixel(c, x1, y1+dir, G15_COLOR_BLACK);
g15r_setPixel(c, x1+dir, y1+dir, G15_COLOR_BLACK);
}
}
}
static int draw_digital(g15canvas *canvas)
{
unsigned int col = 0;
unsigned int len=0;
int narrows=0;
int totalwidth=0;
char buf[10];
char ampm[3];
int height = G15_LCD_HEIGHT - 1;
time_t currtime = time(NULL);
memset(buf,0,10);
memset(ampm,0,3);
if(showdate) {
char buf2[40];
strftime(buf2,40,"%A %e %B %Y",localtime(&currtime));
g15r_renderString (canvas,(unsigned char *)buf2 , 0, G15_TEXT_MED, 80-((strlen(buf2)*5)/2), height-6);
height-=10;
}
if(mode) {
strftime(buf,6,"%H:%M",localtime(&currtime));
} else {
strftime(buf,6,"%l:%M",localtime(&currtime));
strftime(ampm,3,"%p",localtime(&currtime));
}
if(buf[0]==49)
narrows=1;
len = strlen(buf);
if(buf[0]==' ')
len++;
if(narrows)
totalwidth=(len*20)+(15);
else
totalwidth=len*20;
for (col=0;col<len;col++)
{
int num = -1;
if ((buf[col] > 47) && (buf[col] < 59))
num = buf[col] - 48;
else if (buf[col] == 45)
num = 11;
else if (buf[col] == 46)
num = 12;
if (num >= 0)
g15r_drawBigNum (canvas, (80-(totalwidth)/2)+col*20, 1,(80-(totalwidth)/2)+(col+1)*20, height, G15_COLOR_BLACK, num);
}
if(ampm[0]!=0)
g15r_renderString (canvas,(unsigned char *)ampm,0,G15_TEXT_LARGE,totalwidth+15,height-6);
return G15_PLUGIN_OK;
}
static int draw_analog(g15canvas *c)
{
int xh, yh;
int xm, ym;
int xs, ys;
time_t now = time(NULL);
struct tm *t = localtime(&now);
int h;
h = t->tm_hour;
h %= 12;
h *= 5;
h += t->tm_min * 5 / 60;
get_clock_pos(h, &xh, &yh, 9);
get_clock_pos(t->tm_min, &xm, &ym, 6);
get_clock_pos(t->tm_sec, &xs, &ys, 3);
// put background:
memcpy(c, static_canvas, sizeof(g15canvas));
// hour
g15r_drawLine(c, CLOCK_CENTERX-2, CLOCK_CENTERY, xh, yh, G15_COLOR_BLACK);
g15r_drawLine(c, CLOCK_CENTERX-1, CLOCK_CENTERY, xh, yh, G15_COLOR_BLACK);
g15r_drawLine(c, CLOCK_CENTERX, CLOCK_CENTERY, xh, yh+1, G15_COLOR_BLACK);
g15r_drawLine(c, CLOCK_CENTERX+1, CLOCK_CENTERY, xh, yh, G15_COLOR_BLACK);
g15r_drawLine(c, CLOCK_CENTERX+2, CLOCK_CENTERY, xh, yh, G15_COLOR_BLACK);
// minute
g15r_drawLine(c, CLOCK_CENTERX-1, CLOCK_CENTERY, xm, ym, G15_COLOR_BLACK);
g15r_drawLine(c, CLOCK_CENTERX, CLOCK_CENTERY, xm, ym+1, G15_COLOR_BLACK);
g15r_drawLine(c, CLOCK_CENTERX+1, CLOCK_CENTERY, xm, ym, G15_COLOR_BLACK);
// second:
g15r_drawLine(c, CLOCK_CENTERX, CLOCK_CENTERY, xs, ys, G15_COLOR_BLACK);
//
// draw texts:
//
char day[32]; // Tuesday
char mon[32]; // March
char year[32]; // 1234 AD
char time[32]; // 22:33:44
char date[32]; // 21.April
strftime(day, sizeof(day), "%A", t);
strftime(mon, sizeof(mon), "%B", t);
sprintf(date, "%d.%s", t->tm_mday, mon);
sprintf(year, "%4d AD", t->tm_year+1900);
if(mode)
strftime(time,sizeof(time),"%H:%M:%S",t);
else
strftime(time,sizeof(time),"%r",t);
if(showdate) {
g15r_renderString(c, (unsigned char*)time, 0, G15_TEXT_LARGE, 60, 5);
g15r_renderString(c, (unsigned char*)day, 1, G15_TEXT_LARGE, 60, 5);
g15r_renderString(c, (unsigned char*)date, 2, G15_TEXT_LARGE, 60, 5);
g15r_renderString(c, (unsigned char*)year, 3, G15_TEXT_LARGE, 60, 5);
} else
g15r_renderString(c, (unsigned char*)time, 0, G15_TEXT_LARGE, 60, 18);
return G15_PLUGIN_OK;
}
static int *lcdclock(lcd_t *lcd)
{
int ret = 0;
g15canvas *canvas = (g15canvas *) malloc (sizeof (g15canvas));
if (canvas != NULL)
{
memset(canvas->buffer, 0, G15_BUFFER_LEN);
canvas->mode_cache = 0;
canvas->mode_reverse = 0;
canvas->mode_xor = 0;
}
memset(lcd->buf,0,G15_BUFFER_LEN);
if(digital)
ret = draw_digital(canvas);
else
ret = draw_analog(canvas);
memcpy (lcd->buf, canvas->buffer, G15_BUFFER_LEN);
lcd->ident = random();
free(canvas);
return G15_PLUGIN_OK;
}
static int myeventhandler(plugin_event_t *myevent) {
lcd_t *lcd = (lcd_t*) myevent->lcd;
config_section_t *clockcfg =NULL;
switch (myevent->event)
{
case G15_EVENT_KEYPRESS:
clockcfg = g15daemon_cfg_load_section(lcd->masterlist,"Clock");
if(myevent->value & G15_KEY_L2){
mode = 1^mode;
g15daemon_cfg_write_bool(clockcfg, "24hrFormat", mode);
}
if(myevent->value & G15_KEY_L3) {
showdate = 1^showdate;
g15daemon_cfg_write_bool(clockcfg, "ShowDate", showdate);
}
if(myevent->value & G15_KEY_L4) {
digital = 1^digital;
g15daemon_cfg_write_bool(clockcfg, "Digital", digital);
}
// printf("Clock plugin received keypress event : %i\n",myevent->value);
break;
case G15_EVENT_VISIBILITY_CHANGED:
// printf("Clock received new visibility status (%i)\n",myevent->value);
break;
default:
break;
}
return G15_PLUGIN_OK;
}
/* completely uncessary function called when plugin is exiting */
static void *callmewhenimdone(lcd_t *lcd){
return NULL;
}
/* completely unnecessary initialisation function which could just as easily have been set to NULL in the g15plugin_info struct */
static void *myinithandler(lcd_t *lcd){
config_section_t *clockcfg = g15daemon_cfg_load_section(lcd->masterlist,"Clock");
mode=g15daemon_cfg_read_bool(clockcfg, "24hrFormat",1);
showdate=g15daemon_cfg_read_bool(clockcfg, "ShowDate",0);
digital=g15daemon_cfg_read_bool(clockcfg, "Digital",1);
static_canvas = (g15canvas*)malloc(sizeof(g15canvas));
if (static_canvas != NULL)
{
memset(static_canvas->buffer, 0, G15_BUFFER_LEN);
static_canvas->mode_cache = 0;
static_canvas->mode_reverse = 0;
static_canvas->mode_xor = 0;
draw_static_canvas();
}
return NULL;
}
/* if no exitfunc or eventhandler, member should be NULL */
plugin_info_t g15plugin_info[] = {
/* TYPE, name, initfunc, updatefreq, exitfunc, eventhandler, initfunc */
{G15_PLUGIN_LCD_CLIENT, "Clock", (void*)lcdclock, 500, (void*)callmewhenimdone, (void*)myeventhandler, (void*)myinithandler},
{G15_PLUGIN_NONE, "" , NULL, 0, NULL, NULL, NULL}
};
+434
View File
@@ -0,0 +1,434 @@
/*
This file is part of g15daemon.
g15daemon is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
g15daemon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 244 $ - $Date: 2007-01-05 08:04:05 +1030 (Fri, 05 Jan 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
*/
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <poll.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <libg15.h>
#include <g15daemon.h>
static int leaving;
int server_events(plugin_event_t *myevent);
/* tcp server defines */
#define LISTEN_PORT 15550
#define LISTEN_ADDR "127.0.0.1"
/* any more than this number of simultaneous clients will be rejected. */
#define MAX_CLIENTS 10
/* custom plugininfo for clients... */
plugin_info_t lcdclient_info[] = {
/* TYPE, name, initfunc, updatefreq, exitfunc, eventhandler, initfunc */
{G15_PLUGIN_LCD_SERVER, "LCDclient" , NULL, 500, NULL, (void*)server_events, NULL},
{G15_PLUGIN_NONE, "" , NULL, 0, NULL, NULL, NULL}
};
static void process_client_cmds(lcdnode_t *lcdnode, int sock, unsigned int *msgbuf, unsigned int len)
{
switch(msgbuf[0]){
case CLIENT_CMD_SWITCH_PRIORITIES: {
g15daemon_send_event(lcdnode,G15_EVENT_REQ_PRIORITY,1);
break;
}
case CLIENT_CMD_IS_FOREGROUND: { /* client wants to know if it's currently viewable */
pthread_mutex_lock(&lcdlist_mutex);
memset(msgbuf,0,2);
if(lcdnode->list->current == lcdnode){
msgbuf[0] = '1';
}else{
msgbuf[0] = '0';
}
pthread_mutex_unlock(&lcdlist_mutex);
send(sock,msgbuf,1,MSG_OOB);
break;
}
case CLIENT_CMD_IS_USER_SELECTED: { /* client wants to know if it was set to foreground by the user */
pthread_mutex_lock(&lcdlist_mutex);
if(lcdnode->lcd->usr_foreground) /* user manually selected this lcd */
msgbuf[0] = '1';
else
msgbuf[0] = '0';
pthread_mutex_unlock(&lcdlist_mutex);
send(sock,msgbuf,1,0);
break;
}
case CLIENT_CMD_BACKLIGHT: { /* client wants to change the LCD backlight */
/* return current state to the client then implement the new state */
send(sock,&lcdnode->lcd->backlight_state,1,MSG_OOB);
lcdnode->lcd->backlight_state = msgbuf[0]-0x80;
lcdnode->lcd->state_changed = 1;
break;
}
case CLIENT_CMD_KB_BACKLIGHT: { /* client wants to change the KB backlight */
setKBBrightness((unsigned int)msgbuf[0]-0x80);
break;
}
case CLIENT_CMD_CONTRAST: { /* client wants to change the LCD contrast */
/* send current state to the client */
send(sock,&lcdnode->lcd->contrast_state,1,MSG_OOB);
lcdnode->lcd->contrast_state = msgbuf[0]-0x40;
lcdnode->lcd->state_changed = 1;
break;
}
default:
if(msgbuf[0] & CLIENT_CMD_MKEY_LIGHTS)
{ /* client wants to change the M-key backlights */
lcdnode->lcd->mkey_state = msgbuf[0]-0x20;
lcdnode->lcd->state_changed = 1;
//if the client is the keyhandler, allow full, direct control over the mled status
if(lcdnode->lcd->masterlist->remote_keyhandler_sock==lcdnode->lcd->connection)
setLEDs(msgbuf[0]-0x20);
} else if (msgbuf[0] & CLIENT_CMD_KEY_HANDLER)
{
g15daemon_log(LOG_WARNING, "Client is taking over keystate");
lcdnode->list->remote_keyhandler_sock = sock;
g15daemon_log(LOG_WARNING, "Client has taken over keystate");
}
}
}
/* create and open a socket for listening */
int init_sockserver(){
int listening_socket;
int yes=1;
int tos = 0x18;
struct sockaddr_in servaddr;
if ((listening_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) {
g15daemon_log(LOG_WARNING, "Unable to create socket.\n");
return -1;
}
setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
setsockopt(listening_socket, SOL_SOCKET, SO_PRIORITY, &tos, sizeof(tos));
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
inet_aton (LISTEN_ADDR, &servaddr.sin_addr);
servaddr.sin_port = htons(LISTEN_PORT);
if (bind(listening_socket, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ) {
g15daemon_log(LOG_WARNING, "error calling bind()\n");
return -1;
}
if (listen(listening_socket, MAX_CLIENTS) < 0 ) {
g15daemon_log(LOG_WARNING, "error calling listen()\n");
return -1;
}
return listening_socket;
}
int g15_send(int sock, char *buf, unsigned int len)
{
int total = 0;
int retval = 0;
int bytesleft = len;
struct pollfd pfd[1];
while(total < len && !leaving) {
memset(pfd,0,sizeof(pfd));
pfd[0].fd = sock;
pfd[0].events = POLLOUT | POLLERR | POLLHUP | POLLNVAL;
if(poll(pfd,1,500)>0) {
if(pfd[0].revents & POLLOUT && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) {
retval = send(sock, buf+total, bytesleft, 0);
if (retval == -1) {
break;
}
bytesleft -= retval;
total += retval;
}
if((pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)){
retval=-1;
break;
}
}
}
return retval==-1?-1:0;
}
int g15_recv(lcdnode_t *lcdnode, int sock, char *buf, unsigned int len)
{
int total = 0;
int retval = 0;
int msgret = 0;
int bytesleft = len;
struct pollfd pfd[1];
unsigned int msgbuf[20];
while(total < len && !leaving) {
memset(pfd,0,sizeof(pfd));
pfd[0].fd = sock;
pfd[0].events = POLLIN | POLLPRI | POLLERR | POLLHUP | POLLNVAL;
if(poll(pfd,1,500)>0){
if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) { /* receive out-of-band request from client and deal with it */
memset(msgbuf,0,20);
msgret = recv(sock, msgbuf, 10 , MSG_OOB);
if (msgret < 1) {
break;
}
process_client_cmds(lcdnode, sock, msgbuf,len);
}
else if(pfd[0].revents & POLLIN && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) {
retval = recv(sock, buf+total, bytesleft, 0);
if (retval < 1) {
break;
}
total += retval;
bytesleft -= retval;
}
if((pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)){
retval=-1;
break;
}
}
}
return total;
}
/* the client must send 6880 bytes for each lcd screen. This thread will continue to copy data
* into the clients LCD buffer for as long as the connection remains open.
* so, the client should open a socket, check to ensure that the server is a g15daemon,
* and send multiple 6880 byte packets (1 for each screen update)
* once the client disconnects by closing the socket, the LCD buffer is
* removed and will no longer be displayed.
*/
void *lcd_client_thread(void *display) {
lcdnode_t *g15node = display;
lcd_t *client_lcd = g15node->lcd;
int retval;
unsigned int width, height, buflen,header=4;
int client_sock = client_lcd->connection;
char helo[]=SERV_HELO;
unsigned char *tmpbuf=g15daemon_xmalloc(6880);
if(g15_send(client_sock, (char*)helo, strlen(SERV_HELO))<0){
goto exitthread;
}
/* check for requested buffer type.. we only handle pixel buffers atm */
if(g15_recv(g15node, client_sock,(char*)tmpbuf,4)<4)
goto exitthread;
/* we will in the future handle txt buffers gracefully but for now we just hangup */
if(tmpbuf[0]=='G') {
while(!leaving) {
retval = g15_recv(g15node, client_sock,(char *)tmpbuf,6880);
if(retval!=6880){
break;
}
pthread_mutex_lock(&lcdlist_mutex);
memset(client_lcd->buf,0,1024);
g15daemon_convert_buf(client_lcd,tmpbuf);
client_lcd->ident = random();
pthread_mutex_unlock(&lcdlist_mutex);
}
}
else if (tmpbuf[0]=='R') { /* libg15render buffer */
while(!leaving) {
retval = g15_recv(g15node, client_sock, (char *)tmpbuf, 1048);
if(retval != 1048) {
break;
}
pthread_mutex_lock(&lcdlist_mutex);
memcpy(client_lcd->buf,tmpbuf,sizeof(client_lcd->buf));
client_lcd->ident = random();
pthread_mutex_unlock(&lcdlist_mutex);
}
}
else if (tmpbuf[0]=='W'){ /* wbmp buffer - we assume (stupidly) that it's 160 pixels wide */
while(!leaving) {
retval = g15_recv(g15node, client_sock,(char*)tmpbuf, 865);
if(!retval)
break;
if (tmpbuf[2] & 1) {
width = ((unsigned char)tmpbuf[2] ^ 1) | (unsigned char)tmpbuf[3];
height = tmpbuf[4];
header = 5;
} else {
width = tmpbuf[2];
height = tmpbuf[3];
header = 4;
}
buflen = (width/8)*height;
if(buflen>860){ /* grab the remainder of the image and discard excess bytes */
/* retval=g15_recv(client_sock,(char*)tmpbuf+865,buflen-860); */
retval=g15_recv(g15node, client_sock,NULL,buflen-860);
buflen = 860;
}
if(width!=160) /* FIXME - we ought to scale images I suppose */
goto exitthread;
pthread_mutex_lock(&lcdlist_mutex);
memcpy(client_lcd->buf,tmpbuf+header,buflen+header);
client_lcd->ident = random();
pthread_mutex_unlock(&lcdlist_mutex);
}
}
exitthread:
if(client_lcd->masterlist->remote_keyhandler_sock==client_sock)
client_lcd->masterlist->remote_keyhandler_sock=0;
close(client_sock);
free(tmpbuf);
g15daemon_lcdnode_remove(display);
pthread_exit(NULL);
}
/* poll the listening socket for connections, spawning new threads as needed to handle clients */
int g15_clientconnect (g15daemon_t **g15daemon, int listening_socket) {
int conn_s;
struct pollfd pfd[1];
pthread_t client_connection;
pthread_attr_t attr;
lcdnode_t *clientnode;
memset(pfd,0,sizeof(pfd));
pfd[0].fd = listening_socket;
pfd[0].events = POLLIN;
if (poll(pfd,1,500)>0){
if (!(pfd[0].revents & POLLIN)){
return 0;
}
if ( (conn_s = accept(listening_socket, NULL, NULL) ) < 0 ) {
if(errno==EWOULDBLOCK || errno==EAGAIN){
}else{
g15daemon_log(LOG_WARNING, "error calling accept()\n");
return -1;
}
}
clientnode = g15daemon_lcdnode_add(g15daemon);
clientnode->lcd->connection = conn_s;
/* override the default (generic handler and use our own for our clients */
clientnode->lcd->g15plugin->info=(void*)(&lcdclient_info);
memset(&attr,0,sizeof(pthread_attr_t));
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&attr,256*1024); /* set stack to 768k - dont need 8Mb - this is probably rather excessive also */
if (pthread_create(&client_connection, &attr, lcd_client_thread, clientnode) != 0) {
g15daemon_log(LOG_WARNING,"Unable to create client thread.");
if (close(conn_s) < 0 ) {
g15daemon_log(LOG_WARNING, "error calling close()\n");
return -1;
}
}
pthread_detach(client_connection);
}
return 0;
}
/* this thread only listens for new connections.
* sockserver_accept will spawn a new thread for each connected client
*/
static void lcdserver_thread(void *lcdlist){
g15daemon_t *masterlist = (g15daemon_t*) lcdlist ;
int g15_socket=-1;
if((g15_socket = init_sockserver())<0){
g15daemon_log(LOG_ERR,"Unable to initialise the server at port %i",LISTEN_PORT);
return;
}
if (fcntl(g15_socket, F_SETFL, O_NONBLOCK) <0 ) {
g15daemon_log(LOG_ERR,"Unable to set socket to nonblocking");
}
while ( !leaving ) {
g15_clientconnect(&masterlist,g15_socket);
}
close(g15_socket);
return;
}
/* incoming events */
int server_events(plugin_event_t *event) {
lcd_t *lcd = (lcd_t*) event->lcd;
switch (event->event)
{
case G15_EVENT_KEYPRESS:{
if(lcd->connection && lcd->masterlist->remote_keyhandler_sock!=lcd->connection) { /* server client */
if((send(lcd->connection,(void *)&event->value,sizeof(event->value),0))<0)
g15daemon_log(LOG_WARNING,"Error in send: %s\n",strerror(errno));
}
break;
}
case G15_EVENT_VISIBILITY_CHANGED:
break;
case G15_EVENT_USER_FOREGROUND:
lcd->usr_foreground = event->value;
break;
case G15_EVENT_MLED:
case G15_EVENT_BACKLIGHT:
case G15_EVENT_CONTRAST:
/* should never receive these */
default:
break;
}
return G15_PLUGIN_OK;
}
/* if no exitfunc or eventhandler, member should be NULL */
plugin_info_t g15plugin_info[] = {
/* TYPE, name, initfunc, updatefreq, exitfunc, eventhandler, initfunc */
{G15_PLUGIN_LCD_SERVER, "LCDServer" , (void*)lcdserver_thread, 500, NULL, (void*)server_events, NULL},
{G15_PLUGIN_NONE, "" , NULL, 0, NULL, NULL, NULL}
};
+324
View File
@@ -0,0 +1,324 @@
/*
This file is part of g15daemon.
g15daemon is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
g15daemon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 177 $ - $Date: 2006-11-19 00:16:03 +1030 (Sun, 19 Nov 2006) $ $Author: mlampard $
UINPUT key processing plugin. receives events and sends keycodes to the linux kernel.
*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <config.h>
#include <g15daemon.h>
#include <pwd.h>
#ifdef HAVE_CONFIG_H
#ifdef HAVE_LINUX_UINPUT_H
#include <linux/input.h>
#include <linux/uinput.h>
#include <libg15.h>
static int uinp_fd = -1;
static config_section_t *uinput_cfg=NULL;
static int map_Lkeys = 0;
#define GKEY_OFFSET 167
#define MKEY_OFFSET 185
#define LKEY_OFFSET 189
#define G15KEY_DOWN 1
#define G15KEY_UP 0
int g15_init_uinput(void *plugin_args) {
int i=0;
char *custom_filename;
g15daemon_t *masterlist = (g15daemon_t*) plugin_args;
struct uinput_user_dev uinp;
static const char *uinput_device_fn[] = { "/dev/uinput", "/dev/input/uinput","/dev/misc/uinput",0};
uinput_cfg = g15daemon_cfg_load_section(masterlist,"Keyboard OS Mapping (uinput)");
custom_filename = g15daemon_cfg_read_string(uinput_cfg, "device",(char*)uinput_device_fn[1]);
map_Lkeys=g15daemon_cfg_read_int(uinput_cfg, "Lkeys.mapped",0);
seteuid(0);
setegid(0);
while (uinput_device_fn[i] && (uinp_fd = open(uinput_device_fn[i],O_RDWR))<0){
++i;
}
if(uinp_fd<0) { /* try reading the users preference in the config */
uinp_fd = open(custom_filename,O_RDWR);
}
if(uinp_fd<0){
g15daemon_log(LOG_ERR,"Unable to open UINPUT device. Please ensure the uinput driver is loaded into the kernel and that you have permission to open the device.");
return -1;
}
/* all other processes/threads should be seteuid nobody */
seteuid(masterlist->nobody->pw_uid);
setegid(masterlist->nobody->pw_gid);
memset(&uinp,0,sizeof(uinp));
strncpy(uinp.name, "G15 Extra Keys", UINPUT_MAX_NAME_SIZE);
#ifdef HAVE_UINPUT_USER_DEV_ID
uinp.id.version = 4;
uinp.id.bustype = BUS_USB;
#else
uinp.idversion = 4;
uinp.idbus = BUS_USB;
#endif
ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
for (i=0; i<256; ++i)
ioctl(uinp_fd, UI_SET_KEYBIT, i);
write(uinp_fd, &uinp, sizeof(uinp));
if (ioctl(uinp_fd, UI_DEV_CREATE))
{
g15daemon_log(LOG_ERR,"Unable to create UINPUT device.");
return -1;
}
return 0;
}
void g15_exit_uinput(void *plugin_args){
ioctl(uinp_fd, UI_DEV_DESTROY);
close(uinp_fd);
}
void g15_uinput_keydown(unsigned char code)
{
struct input_event event;
memset(&event, 0, sizeof(event));
event.type = EV_KEY;
event.code = code;
event.value = G15KEY_DOWN;
write (uinp_fd, &event, sizeof(event));
}
void g15_uinput_keyup(unsigned char code)
{
struct input_event event;
memset(&event, 0, sizeof(event));
event.type = EV_KEY;
event.code = code;
event.value = G15KEY_UP;
write (uinp_fd, &event, sizeof(event));
}
void (*keyup)(unsigned char code) = &g15_uinput_keyup;
void (*keydown)(unsigned char code) = &g15_uinput_keydown;
#else
void keyup(unsigned char code) { printf("Extra Keys not supported due to missing Uinput.h\n"); }
void keydown(unsigned char code) { printf("Extra Keys not supported due to missing Uinput.h\n"); }
#endif
#endif
void g15_process_keys(g15daemon_t *masterlist, unsigned int currentkeys, unsigned int lastkeys)
{
/* 'G' keys */
if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
keydown(GKEY_OFFSET);
else if(!(currentkeys & G15_KEY_G1) && (lastkeys & G15_KEY_G1))
keyup(GKEY_OFFSET);
if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
keydown(GKEY_OFFSET+1);
else if(!(currentkeys & G15_KEY_G2) && (lastkeys & G15_KEY_G2))
keyup(GKEY_OFFSET+1);
if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
keydown(GKEY_OFFSET+2);
else if(!(currentkeys & G15_KEY_G3) && (lastkeys & G15_KEY_G3))
keyup(GKEY_OFFSET+2);
if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
keydown(GKEY_OFFSET+3);
else if(!(currentkeys & G15_KEY_G4) && (lastkeys & G15_KEY_G4))
keyup(GKEY_OFFSET+3);
if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
keydown(GKEY_OFFSET+4);
else if(!(currentkeys & G15_KEY_G5) && (lastkeys & G15_KEY_G5))
keyup(GKEY_OFFSET+4);
if((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6))
keydown(GKEY_OFFSET+5);
else if(!(currentkeys & G15_KEY_G6) && (lastkeys & G15_KEY_G6))
keyup(GKEY_OFFSET+5);
if((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7))
keydown(GKEY_OFFSET+6);
else if(!(currentkeys & G15_KEY_G7) && (lastkeys & G15_KEY_G7))
keyup(GKEY_OFFSET+6);
if((currentkeys & G15_KEY_G8) && !(lastkeys & G15_KEY_G8))
keydown(GKEY_OFFSET+7);
else if(!(currentkeys & G15_KEY_G8) && (lastkeys & G15_KEY_G8))
keyup(GKEY_OFFSET+7);
if((currentkeys & G15_KEY_G9) && !(lastkeys & G15_KEY_G9))
keydown(GKEY_OFFSET+8);
else if(!(currentkeys & G15_KEY_G9) && (lastkeys & G15_KEY_G9))
keyup(GKEY_OFFSET+8);
if((currentkeys & G15_KEY_G10) && !(lastkeys & G15_KEY_G10))
keydown(GKEY_OFFSET+9);
else if(!(currentkeys & G15_KEY_G10) && (lastkeys & G15_KEY_G10))
keyup(GKEY_OFFSET+9);
if((currentkeys & G15_KEY_G11) && !(lastkeys & G15_KEY_G11))
keydown(GKEY_OFFSET+10);
else if(!(currentkeys & G15_KEY_G11) && (lastkeys & G15_KEY_G11))
keyup(GKEY_OFFSET+10);
if((currentkeys & G15_KEY_G12) && !(lastkeys & G15_KEY_G12))
keydown(GKEY_OFFSET+11);
else if(!(currentkeys & G15_KEY_G12) && (lastkeys & G15_KEY_G12))
keyup(GKEY_OFFSET+11);
if((currentkeys & G15_KEY_G13) && !(lastkeys & G15_KEY_G13))
keydown(GKEY_OFFSET+12);
else if(!(currentkeys & G15_KEY_G13) && (lastkeys & G15_KEY_G13))
keyup(GKEY_OFFSET+12);
if((currentkeys & G15_KEY_G14) && !(lastkeys & G15_KEY_G14))
keydown(GKEY_OFFSET+13);
else if(!(currentkeys & G15_KEY_G14) && (lastkeys & G15_KEY_G14))
keyup(GKEY_OFFSET+13);
if((currentkeys & G15_KEY_G15) && !(lastkeys & G15_KEY_G15))
keydown(GKEY_OFFSET+14);
else if(!(currentkeys & G15_KEY_G15) && (lastkeys & G15_KEY_G15))
keyup(GKEY_OFFSET+14);
if((currentkeys & G15_KEY_G16) && !(lastkeys & G15_KEY_G16))
keydown(GKEY_OFFSET+15);
else if(!(currentkeys & G15_KEY_G16) && (lastkeys & G15_KEY_G16))
keyup(GKEY_OFFSET+15);
if((currentkeys & G15_KEY_G17) && !(lastkeys & G15_KEY_G17))
keydown(GKEY_OFFSET+16);
else if(!(currentkeys & G15_KEY_G17) && (lastkeys & G15_KEY_G17))
keyup(GKEY_OFFSET+16);
if((currentkeys & G15_KEY_G18) && !(lastkeys & G15_KEY_G18))
keydown(GKEY_OFFSET+17);
else if(!(currentkeys & G15_KEY_G18) && (lastkeys & G15_KEY_G18))
keyup(GKEY_OFFSET+17);
/* 'M' keys */
if((currentkeys & G15_KEY_M1) && !(lastkeys & G15_KEY_M1))
keydown(MKEY_OFFSET);
else if(!(currentkeys & G15_KEY_M1) && (lastkeys & G15_KEY_M1))
keyup(MKEY_OFFSET);
if((currentkeys & G15_KEY_M2) && !(lastkeys & G15_KEY_M2))
keydown(MKEY_OFFSET+1);
else if(!(currentkeys & G15_KEY_M2) && (lastkeys & G15_KEY_M2))
keyup(MKEY_OFFSET+1);
if((currentkeys & G15_KEY_M3) && !(lastkeys & G15_KEY_M3))
keydown(MKEY_OFFSET+2);
else if(!(currentkeys & G15_KEY_M3) && (lastkeys & G15_KEY_M3))
keyup(MKEY_OFFSET+2);
if((currentkeys & G15_KEY_MR) && !(lastkeys & G15_KEY_MR))
keydown(MKEY_OFFSET+3);
else if(!(currentkeys & G15_KEY_MR) && (lastkeys & G15_KEY_MR))
keyup(MKEY_OFFSET+3);
if(map_Lkeys){
/* 'L' keys... */
if((currentkeys & G15_KEY_L1) && !(lastkeys & G15_KEY_L1))
keydown(LKEY_OFFSET);
else if(!(currentkeys & G15_KEY_L1) && (lastkeys & G15_KEY_L1))
keyup(LKEY_OFFSET);
if((currentkeys & G15_KEY_L2) && !(lastkeys & G15_KEY_L2))
keydown(LKEY_OFFSET+1);
else if(!(currentkeys & G15_KEY_L2) && (lastkeys & G15_KEY_L2))
keyup(LKEY_OFFSET+1);
if((currentkeys & G15_KEY_L3) && !(lastkeys & G15_KEY_L3))
keydown(LKEY_OFFSET+2);
else if(!(currentkeys & G15_KEY_L3) && (lastkeys & G15_KEY_L3))
keyup(LKEY_OFFSET+2);
if((currentkeys & G15_KEY_L4) && !(lastkeys & G15_KEY_L4))
keydown(LKEY_OFFSET+3);
else if(!(currentkeys & G15_KEY_L4) && (lastkeys & G15_KEY_L4))
keyup(LKEY_OFFSET+3);
if((currentkeys & G15_KEY_L5) && !(lastkeys & G15_KEY_L5))
keydown(LKEY_OFFSET+4);
else if(!(currentkeys & G15_KEY_L5) && (lastkeys & G15_KEY_L5))
keyup(LKEY_OFFSET+4);
}
}
int keyevents(plugin_event_t *myevent) {
lcd_t *lcd = (lcd_t*) myevent->lcd;
static int lastkeys;
switch (myevent->event)
{
case G15_EVENT_KEYPRESS:{
g15_process_keys(lcd->masterlist, myevent->value,lastkeys);
lastkeys = myevent->value;
break;
}
case G15_EVENT_VISIBILITY_CHANGED:
case G15_EVENT_USER_FOREGROUND:
case G15_EVENT_MLED:
case G15_EVENT_BACKLIGHT:
case G15_EVENT_CONTRAST:
case G15_EVENT_REQ_PRIORITY:
case G15_EVENT_CYCLE_PRIORITY:
default:
break;
}
return G15_PLUGIN_OK;
}
/* if no exitfunc or eventhandler, member should be NULL */
plugin_info_t g15plugin_info[] = {
/* TYPE, name, initfunc, updatefreq, exitfunc, eventhandler, initfunc */
{G15_PLUGIN_CORE_OS_KB, "Linux UINPUT Keyboard Output" , NULL, 500, (void*)g15_exit_uinput, (void*)keyevents, (void*)g15_init_uinput},
{G15_PLUGIN_NONE, "" , NULL, 0, NULL, NULL, NULL}
};