Commit 96023974 authored by Giacomo Catenazzi's avatar Giacomo Catenazzi

Import Upstream version 1.9.1.0.svn346

parent 9404a616
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 295 $ - $Date: 2007-09-09 06:37:50 +0200 (Sun, 09 Sep 2007) $ $Author: mlampard $
$Revision: 343 $ - $Date: 2007-12-18 06:26:28 +0100 (Tue, 18 Dec 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -84,7 +84,7 @@ allow clients use of all 'L' keys.
1.2.5svn -> current
- Add compiletime check for uinput version, should resolve compilation problems on some distro's
- Security improved - the daemon now sets its effective uid to nobody as soon as possible.
1.9.0SVN
1.9.0
- Add plugin API
- partially rewritten event core
- updated g15daemon_xmms_spectrum plugin with new features, available in trunk/g15daemon_audio_plugins (SVN)
......@@ -93,5 +93,26 @@ allow clients use of all 'L' keys.
- g15daemon is now dependant on libg15render.
- Clock now includes analog clock thanks to Rasta Freak <igor.jusic@zg.t-com.hr>
- Moved g15daemon_xmms_spectrum plugin to separate package
- Plugins are now installed in ${PREFIX}/lib/g15daemon/${VERSION}/plugins
1.9.1
- Plugins are now installed in ${PREFIX}/{${LIBDIR}/g15daemon/${VERSION}/plugins
- OS-X support thanks to Fabrizio Sestito.
- Bugfix: libg15daemon_client: keypresses were being corrupted.
- Bugfix: libg15daemon_client: use g15_recv rather than recv.
- Bugfix: use default scheduling for all threads.
- Optimisation: minor optimisation of lcd_cycle() code.
- Security: repair some potential security holes.
- Bugfix: Backlight status was being mis-applied when cycling screens.
- Bugfix: Language bindings were not being distributed.
1.9.1->SVN
- Add exitfunc to net plugin for exit notification.
- Use pause() instead of sleeping
- create leaving var as volatile.
- Add NAME section to g15daemon_client manpages
- Tweak delay between successive keyboard reads. This reduces cpu load by
50% on my system.
- Bugfix: Ensure that all plugin exit functions are called on leaving.
- Bugfix: if keypress event is received (very early in the startup process,
the daemon would crash. Check that expected pointers are valid.
- Bugfix: Dont attempt compilation of uinput plugin if headers are
unavailable.
- Bugfix: Write a blank buffer to the LCD before exiting.
.TH "G15daemon Client Development" "" "1.0" "G15Daemon" ""
.SH "NAME" g15daemon_client \- G15Daemon Server / Client communication for g15daemon.
.SH "SYNOPSIS"
#include <libg15.h>
.br
......
......@@ -23,7 +23,7 @@ dist-hook:
rm -rf `find $(distdir)/debian -name .svn`
rm -rf `find $(distdir)/contrib -name .svn`
rm -rf `find $(distdir)/Documentation -name .svn`
rm -rf `find $(distdir)/lang_bindings -name .svn`
rm -rf `find $(distdir)/lang-bindings -name .svn`
rm -rf `find $(distdir)/patches -name .svn`
rm -rf `find $(distdir)/rpm -name .svn`
rm -rf `find $(distdir)/plugins -name .svn`
......
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# $Revision: 295 $ - $Date: 2007-09-09 06:37:50 +0200 (Sun, 09 Sep 2007) $ $Author: mlampard $
# $Revision: 334 $ - $Date: 2007-12-07 15:08:03 +0100 (Fri, 07 Dec 2007) $ $Author: mlampard $
AC_PREREQ(2.59)
AC_INIT(g15daemon, [1.9pre], [mlampard@users.sf.net])
AC_INIT(g15daemon, [1.9.1], [mlampard@users.sf.net])
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AC_CANONICAL_TARGET()
......@@ -32,6 +32,7 @@ AC_CHECK_HEADERS([ linux/uinput.h arpa/inet.h fcntl.h stdlib.h string.h sys/sock
#include <linux/input.h>
#endif
])
#if HAVE_LINUX_UINPUT_H
dnl check for uinput.h version 2.4 or 2.6 ?
AC_CHECK_MEMBER([struct uinput_user_dev.id],
......@@ -42,9 +43,12 @@ AC_CHECK_HEADERS([ linux/uinput.h arpa/inet.h fcntl.h stdlib.h string.h sys/sock
#include <linux/uinput.h>
]
)
uinput=true
dnl end of uinput version checks
#endif
AM_CONDITIONAL(UINPUT_INTERFACE_PLUGIN, [test x$uinput = xtrue])
case $host_os in
*linux*)
AC_DEFINE([OSTYPE_LINUX], [1],[Target OS is Linux])
......
g15daemon for Debian
--------------------
<possible notes regarding this package - if none, delete this file>
-- Anthony J. Mirabella <mirabeaj@gmail.com>, Thu, 28 Sep 2006 04:46:06 -0400
g15daemon (1.2.1-1) breezy; urgency=low
* Initial release
-- Anthony J. Mirabella <mirabeaj@gmail.com> Thu, 28 Sep 2006 04:46:06 -0400
Source: g15daemon
Section: utils
Priority: optional
Maintainer: Anthony J. Mirabella <mirabeaj@gmail.com>
Build-Depends: debhelper (>= 4.0.0), autotools-dev, libg15-dev, libg15render-dev
Standards-Version: 3.6.2
Package: g15daemon
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libg15daemon-client (= ${Source-Version})
Description: Screen multiplexer for Logitech G15 Keyboard
G15daemon provides multiple virtual screens for the LCD on the Logitech
G15 Keyboard
Package: libg15daemon-client
Section: libs
Architecture: any
Depends: ${shlibs:Depends}
Description: Client library for communicating with g15daemon
Provides interface functions for clients that wish to communicate with
a running instance of g15daemon
Package: libg15daemon-client-dev
Section: libdevel
Architecture: any
Depends: libg15daemon-client (= ${Source-Version})
Description: Development packages for libg15daemon-client
Includes the files needed for developing g15daemon clients
This package was debianized by Anthony J. Mirabella <mirabeaj@gmail.com> on
Thu, 28 Sep 2006 04:46:06 -0400.
It was downloaded from <fill in ftp site>
Copyright Holder: <put author(s) name and email here>
License:
<Put the license of the package here>
NEWS
README
TODO
usr/include/*
usr/lib/lib*.a
usr/lib/lib*.so
usr/lib/pkgconfig/*
usr/lib/*.la
usr/share/pkgconfig/*
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
config.status: configure
dh_testdir
# Add here commands to configure the package.
CFLAGS="$(CFLAGS) -Wl,-z,defs" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
build: build-stamp
build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
$(MAKE)
#docbook-to-man debian/g15daemon.sgml > g15daemon.1
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
-$(MAKE) distclean
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
cp -f /usr/share/misc/config.guess config.guess
endif
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/g15daemon.
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
dh_installdocs
dh_installexamples
dh_install -a --sourcedir=debian/tmp
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman Documentation/g15daemon.1 Documentation/g15daemon_client_devel.3
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_python
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 179 $ - $Date: 2006-11-19 09:33:12 +0100 (Sun, 19 Nov 2006) $ $Author: mlampard $
$Revision: 333 $ - $Date: 2007-12-02 04:50:57 +0100 (Sun, 02 Dec 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -46,7 +46,7 @@
#include <libg15render.h>
extern int leaving;
extern volatile int leaving;
void * g15daemon_dlopen_plugin(char *name,unsigned int library) {
......@@ -129,7 +129,7 @@ void run_advanced_client(plugin_t *plugin_args)
g15daemon_msleep(info->update_msecs);
}
}else{
while(1){
while(!leaving){
g15daemon_msleep(500);
}
}
......
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 300 $ - $Date: 2007-09-10 09:52:01 +0200 (Mon, 10 Sep 2007) $ $Author: mlampard $
$Revision: 324 $ - $Date: 2007-11-29 02:45:27 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
// keystate = g15_send_cmd (g15screen_fd, G15DAEMON_GET_KEYSTATE, foo);
//while(1){
//recv(g15screen_fd, &keystate, 4, 0);
recv(g15screen_fd, &keystate, 4, 0);
if(keystate)
printf("keystate = %i\n",keystate);
//}
......@@ -79,19 +79,19 @@ int main(int argc, char *argv[])
// break;
/* G2,G3 & G4 change LCD backlight */
// if(keystate & G15_KEY_G2){
// retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_DARK);
// }
// if(keystate & G15_KEY_G3){
// retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_MEDIUM);
if(keystate & G15_KEY_G2){
retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_DARK);
}
if(keystate & G15_KEY_G3){
retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_MEDIUM);
unsigned char packet[2];
packet[0] = G15DAEMON_BACKLIGHT|G15_BRIGHTNESS_MEDIUM;
printf("sent %i bytes\n",send(g15screen_fd, packet, 1, MSG_OOB ));
// }
// if(keystate & G15_KEY_G4){
// retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_BRIGHT);
// }
}
if(keystate & G15_KEY_G4){
retval = g15_send_cmd (g15screen_fd, G15DAEMON_BACKLIGHT, G15_BRIGHTNESS_BRIGHT);
}
/*
retval = g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, foo);
......@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
// }
*/
sleep(2);
// sleep(2);
#ifdef TEST_KEYHANDLER
/* ok.. request that all G&M keys are passed to us.. */
retval = g15_send_cmd (g15screen_fd, G15DAEMON_KEY_HANDLER, foo);
......
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 177 $ - $Date: 2006-11-18 14:46:03 +0100 (Sat, 18 Nov 2006) $ $Author: mlampard $
$Revision: 321 $ - $Date: 2007-11-29 01:00:29 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -119,6 +119,7 @@ void g15daemon_lcdnode_cycle(g15daemon_t *masterlist)
lcdnode_t *current_screen = masterlist->current;
g15daemon_send_event(current_screen->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_HIDDEN);
do
{
pthread_mutex_lock(&lcdlist_mutex);
......@@ -132,19 +133,18 @@ void g15daemon_lcdnode_cycle(g15daemon_t *masterlist)
pthread_mutex_unlock(&lcdlist_mutex);
}
while (current_screen != masterlist->current);
pthread_mutex_lock(&lcdlist_mutex);
if(masterlist->tail == masterlist->current) {
masterlist->current = masterlist->head;
} else {
masterlist->current = masterlist->current->prev;
}
pthread_mutex_unlock(&lcdlist_mutex);
g15daemon_send_event(masterlist->current->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_VISIBLE);
g15daemon_send_event(current_screen->lcd, G15_EVENT_USER_FOREGROUND, 1);
pthread_mutex_lock(&lcdlist_mutex);
masterlist->current->lcd->state_changed = 1;
masterlist->current->last_priority = masterlist->current;
pthread_mutex_unlock(&lcdlist_mutex);
g15daemon_send_event(current_screen->lcd, G15_EVENT_USER_FOREGROUND, 1);
g15daemon_send_event(masterlist->current->lcd, G15_EVENT_VISIBILITY_CHANGED, SCR_VISIBLE);
}
void g15daemon_lcdnode_remove (lcdnode_t *oldnode) {
......
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 302 $ - $Date: 2007-09-10 09:57:53 +0200 (Mon, 10 Sep 2007) $ $Author: mlampard $
$Revision: 346 $ - $Date: 2007-12-18 06:44:36 +0100 (Tue, 18 Dec 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -49,7 +49,7 @@
#endif
/* all threads will exit if leaving >0 */
int leaving = 0;
volatile int leaving = 0;
int keyboard_backlight_off_onexit = 0;
unsigned int g15daemon_debug = 0;
unsigned int cycle_key;
......@@ -64,6 +64,10 @@ int g15daemon_send_event(void *caller, unsigned int event, unsigned long value)
static unsigned long lastkeys;
if(!(value & cycle_key) && !(lastkeys & cycle_key)){
lcd_t *lcd = (lcd_t*)caller;
if(!lcd->g15plugin->info)
break;
int *(*plugin_listener)(plugin_event_t *newevent) = (void*)lcd->g15plugin->info->event_handler;
plugin_event_t *newevent=g15daemon_xmalloc(sizeof(plugin_event_t));
newevent->event = event;
......@@ -82,9 +86,12 @@ int g15daemon_send_event(void *caller, unsigned int event, unsigned long value)
g15daemon_log(LOG_WARNING,"Error in send: %s\n",strerror(errno));
}
if(value & G15_KEY_LIGHT){ // the backlight key was pressed - maintain user-selected state
lcd_t *displaying = lcd->masterlist->tail->lcd;
lcd->masterlist->kb_backlight_state++;
if(lcd->masterlist->kb_backlight_state>2)
lcd->masterlist->kb_backlight_state=0;
displaying->backlight_state++;
displaying->backlight_state %= 3; // limit to 0-2 inclusive
}
free(newevent);
}else{
......@@ -168,33 +175,38 @@ static void *keyboard_watch_thread(void *lcdlist){
unsigned int keypresses = 0;
int retval = 0;
static int lastkeys = 0;
while (!leaving) {
pthread_mutex_lock(&g15lib_mutex);
retval = getPressedKeys(&keypresses, 40);
retval = getPressedKeys(&keypresses, 2);
pthread_mutex_unlock(&g15lib_mutex);
/* every 2nd packet contains the codes we want.. immediately try again */
while (retval == G15_ERROR_TRY_AGAIN){
pthread_mutex_lock(&g15lib_mutex);
retval = getPressedKeys(&keypresses, 40);
retval = getPressedKeys(&keypresses, 2);
pthread_mutex_unlock(&g15lib_mutex);
}
if(retval == G15_NO_ERROR){
if(retval == G15_NO_ERROR && lastkeys != keypresses) {
g15daemon_send_event(masterlist->current->lcd,
G15_EVENT_KEYPRESS, keypresses);
}
if(retval == -ENODEV && LIBG15_VERSION>=1200) {
lastkeys = keypresses;
}else if(retval == -ENODEV && LIBG15_VERSION>=1200) {
pthread_mutex_lock(&g15lib_mutex);
while((retval=re_initLibG15() != G15_NO_ERROR) && !leaving){
sleep(1);
}
if(!leaving) { masterlist->current->lcd->state_changed=1; masterlist->current->lcd->ident=random();}
if(!leaving) {
masterlist->current->lcd->state_changed=1;
masterlist->current->lcd->ident=random();
}
pthread_mutex_unlock(&g15lib_mutex);
}
g15daemon_msleep(10);
g15daemon_msleep(40);
}
return NULL;
......@@ -257,6 +269,7 @@ void g15daemon_sighandler(int sig) {
case SIGUSR1:
keyboard_backlight_off_onexit = 1;
case SIGINT:
case SIGTERM:
case SIGQUIT:
leaving = 1;
break;
......@@ -275,7 +288,8 @@ int main (int argc, char *argv[])
struct sigaction new_action;
cycle_key = G15_KEY_L1;
unsigned char user[256];
unsigned int lcdlevel = 1;
pthread_t keyboard_thread;
pthread_t lcd_thread;
memset(user,0,256);
......@@ -309,13 +323,13 @@ int main (int argc, char *argv[])
if (!strncmp(daemonargs, "-h",2) || !strncmp(daemonargs, "--help",6)) {
printf("G15Daemon version %s - %s\n",VERSION,uf_return_running() >= 0 ?"Loaded & Running":"Not Running");
printf("%s -h (--help) or -k (--kill) or -s (--switch) or -d (--debug) or -v (--version)\n\n -k will kill a previous incarnation",argv[0]);
printf("%s -h (--help) or -k (--kill) or -s (--switch) or -d (--debug) [level] or -v (--version) or -l (--lcdlevel) [0-2] \n\n -k will kill a previous incarnation",argv[0]);
#ifdef LIBG15_VERSION
#if LIBG15_VERSION >= 1200
printf(", if uppercase -K or -KILL turn off the keyboard backlight on the way out.");
#endif
#endif
printf("\n -h shows this help\n -s changes the screen-switch key from MR to L1\n -d debug mode - stay in foreground and output all debug messages to STDERR\n -v show version\n");
printf("\n -h shows this help\n -s changes the screen-switch key from MR to L1\n -d debug mode - stay in foreground and output all debug messages to STDERR\n -v show version\n -l set default LCD backlight level\n");
exit(0);
}
......@@ -340,6 +354,13 @@ int main (int argc, char *argv[])
}
}
if (!strncmp(daemonargs, "-l",2) || !strncmp(daemonargs, "--lcdlevel",7)) {
if((argv[i+1])!=NULL)
if(isdigit(argv[i+1][0])){
lcdlevel = atoi(argv[i+1]);
}
}
}
if(uf_return_running()>=0) {
g15daemon_log(LOG_ERR,"G15Daemon already running.. Exiting");
......@@ -401,7 +422,8 @@ int main (int argc, char *argv[])
setLCDContrast(1);
setLEDs(0);
lcdlist->kb_backlight_state=1;
setLCDBrightness(lcdlist->kb_backlight_state);
lcdlist->current->lcd->backlight_state=lcdlevel;
setLCDBrightness(lcdlevel);
#ifdef LIBG15_VERSION
#if LIBG15_VERSION >= 1200
......@@ -422,19 +444,12 @@ int main (int argc, char *argv[])
pthread_mutex_init(&g15lib_mutex, NULL);
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr,512*1024); /* set stack to 512k - dont need 8Mb !! */
pthread_attr_setscope(&attr,PTHREAD_SCOPE_SYSTEM);
int thread_policy=SCHED_RR;
pthread_attr_setschedpolicy(&attr,thread_policy);
if (pthread_create(&keyboard_thread, &attr, keyboard_watch_thread, lcdlist) != 0) {
g15daemon_log(LOG_ERR,"Unable to create keyboard listener thread. Exiting");
goto exitnow;
}
pthread_attr_setstacksize(&attr,128*1024);
/* all other threads have a lower priority... maybe */
pthread_attr_setscope(&attr,PTHREAD_SCOPE_PROCESS);
thread_policy=SCHED_OTHER;
pthread_attr_setschedpolicy(&attr,thread_policy);
if (pthread_create(&lcd_thread, &attr, lcd_draw_thread, lcdlist) != 0) {
g15daemon_log(LOG_ERR,"Unable to create display thread. Exiting");
......@@ -461,11 +476,11 @@ int main (int argc, char *argv[])
new_action.sa_flags = 0;
sigaction(SIGINT, &new_action, NULL);
sigaction(SIGQUIT, &new_action, NULL);
sigaction(SIGTERM, &new_action, NULL);
sigaction(SIGUSR1, &new_action, NULL);
do {
sleep(1);
pause();
} while( leaving == 0);
g15daemon_log(LOG_INFO,"Leaving by request");
......@@ -473,6 +488,10 @@ int main (int argc, char *argv[])
pthread_join(lcd_thread,NULL);
pthread_join(keyboard_thread,NULL);
/* switch off the lcd backlight */
char *blank=malloc(G15_BUFFER_LEN);
memset(blank,0,G15_BUFFER_LEN);
writePixmapToLCD((unsigned char*)blank);
free(blank);
setLCDBrightness(0);
#ifdef LIBG15_VERSION
#if LIBG15_VERSION >= 1200
......
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 190 $ - $Date: 2006-11-21 17:31:03 +0100 (Tue, 21 Nov 2006) $ $Author: mlampard $
$Revision: 339 $ - $Date: 2007-12-15 07:10:26 +0100 (Sat, 15 Dec 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -195,18 +195,24 @@ void g15daemon_sleep(int seconds) {
pthread_mutex_destroy(&dummy_mutex);
}
/* microsecond sleep routine. */
int g15daemon_usleep(int useconds) {
struct timeval timeout;
if(useconds < 10000)
useconds = 10000;
timeout.tv_sec = useconds / 1000000;
timeout.tv_usec = useconds % 1000000;
return select (0,0,0,0,&timeout);
}
/* millisecond sleep routine. */
int g15daemon_msleep(int milliseconds) {
struct timespec timeout;
if(milliseconds>999)
milliseconds=999;
timeout.tv_sec = 0;
timeout.tv_nsec = milliseconds*1000000;
return nanosleep (&timeout, NULL);
return g15daemon_usleep(milliseconds*1000);
}
unsigned int g15daemon_gettime_ms(){
struct timeval tv;
gettimeofday(&tv,NULL);
......@@ -367,7 +373,6 @@ char * uf_remove_whitespace(char *str){
int g15daemon_cfg_write_string(config_section_t *section, char *key, char *val){
config_items_t *new = NULL;
const char empty[]=" ";
if(section==NULL)
return -1;
......@@ -519,7 +524,7 @@ int uf_conf_open(g15daemon_t *list, char *filename) {
int config_fd=-1;
char *sect;
char *start;
char *bar;
char *bar = NULL;
int i;
struct stat stats;
......
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 301 $ - $Date: 2007-09-10 09:55:15 +0200 (Mon, 10 Sep 2007) $ $Author: mlampard $
$Revision: 322 $ - $Date: 2007-11-29 01:04:29 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -67,7 +67,7 @@ int g15_send(int sock, char *buf, unsigned int len);
int g15_recv(int sock, char *buf, unsigned int len);
/* send a command (defined above) to the daemon. any replies from the daemon are returned */
int g15_send_cmd (int sock, unsigned char command, unsigned char value);
unsigned long g15_send_cmd (int sock, unsigned char command, unsigned char value);
/* receive an oob byte from the daemon, used internally by g15_send_cmd, but useful elsewhere */
#define G15_FOREGROUND_SENT_OOB 1
int g15_recv_oob_answer(int sock);
......
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 301 $ - $Date: 2007-09-10 09:55:15 +0200 (Mon, 10 Sep 2007) $ $Author: mlampard $
$Revision: 322 $ - $Date: 2007-11-29 01:04:29 +0100 (Thu, 29 Nov 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -177,7 +177,7 @@ int g15_recv_oob_answer(int sock) {
return packet[0];
}
int g15_send_cmd (int sock, unsigned char command, unsigned char value)
unsigned long g15_send_cmd (int sock, unsigned char command, unsigned char value)
{
int retval;
unsigned char packet[2];
......@@ -219,9 +219,9 @@ int g15_send_cmd (int sock, unsigned char command, unsigned char value)
break;
case G15DAEMON_GET_KEYSTATE:{
retval = 0;
packet[0] = (unsigned char)command;
send( sock, packet, 1, MSG_OOB );
g15_recv(sock, (char*)&retval, sizeof(retval));
unsigned long keystate = 0;
g15_recv(sock, (char*)&keystate, sizeof(keystate));
return keystate;
break;
}
case G15DAEMON_IS_FOREGROUND:{
......
......@@ -3,11 +3,14 @@ METASOURCES = AUTO
libdir = @G15DAEMON_PLUGIN_DIR@
AM_CFLAGS = -Wall
lib_LTLIBRARIES =g15plugin_uinput.la g15plugin_tcpserver.la g15plugin_clock.la
INCLUDES = -I$(top_builddir)/libg15daemon_client/ -I$(top_builddir)/g15daemon
if UINPUT_INTERFACE_PLUGIN
g15plugin_uinput_la_SOURCES = g15_plugin_uinput.c
g15plugin_uinput_la_LDFLAGS = -avoid-version -module
input_la = g15plugin_uinput.la
endif
lib_LTLIBRARIES = ${input_la} g15plugin_tcpserver.la g15plugin_clock.la
INCLUDES = -I$(top_builddir)/libg15daemon_client/ -I$(top_builddir)/g15daemon
g15plugin_tcpserver_la_SOURCES = g15_plugin_net.c
g15plugin_tcpserver_la_LDFLAGS = -avoid-version -module
......
......@@ -17,7 +17,7 @@
(c) 2006 Mike Lampard, Philip Lawatsch, and others
$Revision: 299 $ - $Date: 2007-09-09 19:19:52 +0200 (Sun, 09 Sep 2007) $ $Author: mlampard $
$Revision: 329 $ - $Date: 2007-11-30 06:15:06 +0100 (Fri, 30 Nov 2007) $ $Author: mlampard $
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
......@@ -40,7 +40,7 @@
#include <libg15.h>
#include <g15daemon.h>
static int leaving;
static int leaving = 0;
int server_events(plugin_event_t *myevent);
#ifndef SO_PRIORITY
......@@ -108,7 +108,8 @@ static void process_client_cmds(lcdnode_t *lcdnode, int sock, unsigned int *msgb
}
else if (msgbuf[0] & CLIENT_CMD_BACKLIGHT)
{
send(sock,&lcdnode->lcd->backlight_state,1,MSG_OOB);
unsigned char retval = lcdnode->lcd->backlight_state;
send(sock,&retval,1,MSG_OOB);
lcdnode->lcd->backlight_state = msgbuf[0]-0x80;
lcdnode->lcd->state_changed = 1;
}
......@@ -426,10 +427,14 @@ int server_events(plugin_event_t *event) {
return G15_PLUGIN_OK;
}
static void g15plugin_net_exit() {
leaving = 1;
}
/* 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_LCD_SERVER, "LCDServer" , (void*)lcdserver_thread, 500, g15plugin_net_exit, (void*)server_events, NULL},
{G15_PLUGIN_NONE, "" , NULL, 0, NULL, NULL, NULL}
};