- added X server auto detection

- added forgotten GPL notices to the new files



git-svn-id: svn+ssh://svn.code.sf.net/p/spacenav/code/trunk/spacenavd@87 ef983eb1-d774-4af8-acfd-baaf7b16a646
pull/1/head
John Tsiombikas 2009-07-24 01:04:12 +00:00
rodzic 1ffb617673
commit d5ec2140e5
18 zmienionych plików z 276 dodań i 34 usunięć

Wyświetl plik

@ -5,7 +5,7 @@ ctl = spnavd_ctl
CC = gcc
INSTALL = install
CFLAGS = -pedantic -Wall $(dbg) $(opt) $(x11)
CFLAGS = -pedantic -Wall $(dbg) $(opt)
LDFLAGS = $(xlib)
$(bin): $(obj)
@ -23,13 +23,15 @@ install: $(bin)
$(INSTALL) -d $(PREFIX)/bin
$(INSTALL) -m 755 $(bin) $(PREFIX)/bin/$(bin)
$(INSTALL) -m 755 $(srcdir)/$(ctl) $(PREFIX)/bin/$(ctl)
[ -d /etc/hal/fdi/policy ] && \
$(INSTALL) -m 644 spacenav.fdi /etc/hal/fdi/policy/spacenav.fdi
cd $(srcdir) && ./setup_init --no-install
# [ -d /etc/hal/fdi/policy ] && \
# $(INSTALL) -m 644 spacenav.fdi /etc/hal/fdi/policy/spacenav.fdi
.PHONY: uninstall
uninstall:
rm -f $(PREFIX)/bin/$(bin)
rm -f $(PREFIX)/bin/$(ctl)
rm -f /etc/hal/fdi/policy/spacenav.fdi
# cd $(srcdir) && ./setup_init remove

12
README
Wyświetl plik

@ -1,4 +1,4 @@
spacenavd - 0.4
spacenavd - $Rev$
---------------
1. About
@ -38,16 +38,6 @@ spacenavd - 0.4
follow your init documentation and set this up yourself. You may be able to
use the provided init_script file as a starting point.
Depending on how your system startup process is set up, it might be the case
that the spacenavd daemon starts before the X server (for instance if you
don't use a graphical login). In that case the daemon will start properly, but
won't connect to the X server until explicitly told to do so. You can do that
by running ``spnavd_ctl x11 start'' as root, or by using the graphical
spnavcfg program. You don't really want to have to do that all the time
though, so it's a better idea to add the aforementioned spnavd_ctl command to
either your ~/.xsession or ~/.xinitrd file, or the system-wide
/etc/X11/Xsession file.
5. Configuration
The spacenavd daemon reads a number of options from the /etc/spnavrc file. If
that file doesn't exist, then it uses default values for everything. You may

21
configure vendored
Wyświetl plik

@ -1,11 +1,12 @@
#!/bin/sh
echo 'configuring spacenavd...'
PREFIX=/usr/local
OPT=yes
DBG=yes
X11=yes
VER=`head -1 README | sed 's/^.*- //'`
echo "configuring spacenavd - $VER"
srcdir="`dirname "$0"`"
@ -64,6 +65,7 @@ fi
echo 'creating Makefile ...'
echo "PREFIX = $PREFIX" >Makefile
echo "srcdir = $srcdir" >>Makefile
echo "ver = $VER" >>Makefile
if [ "$DBG" = 'yes' ]; then
echo 'dbg = -g' >>Makefile
@ -74,12 +76,25 @@ if [ "$OPT" = 'yes' ]; then
fi
if [ "$X11" = 'yes' ]; then
echo 'x11 = -DUSE_X11' >>Makefile
echo 'xlib = -lX11' >>Makefile
fi
cat "$srcdir/Makefile.in" >>Makefile
# create config.h
echo 'creating config.h'
echo '#ifndef CONFIG_H_' >src/config.h
echo '#define CONFIG_H_' >>src/config.h
echo >>src/config.h
if [ "$X11" = yes ]; then
echo '#define USE_X11' >>src/config.h
echo >>src/config.h
fi
echo '#define VERSION "'$VER'"' >>src/config.h
echo >>src/config.h
echo '#endif /* CONFIG_H_ */' >>src/config.h
echo ''
echo 'Done. You can now type make (or gmake) to compile spacenavd.'
echo ''

Wyświetl plik

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.product" contains="3Dconnexion">
<remove key="input.x11_driver"/>
</match>
</device>
</deviceinfo>

Wyświetl plik

@ -1,6 +1,6 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@siggraph.org>
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,6 +15,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Wyświetl plik

@ -1,6 +1,6 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@siggraph.org>
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,9 +15,12 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CFGFILE_H_
#define CFGFILE_H_
#include "config.h"
#define MAX_BUTTONS 64
struct cfg {

Wyświetl plik

@ -1,3 +1,22 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include "client.h"

Wyświetl plik

@ -1,6 +1,26 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CLIENT_H_
#define CLIENT_H_
#include "config.h"
#ifdef USE_X11
#include <X11/Xlib.h>
#endif

Wyświetl plik

@ -1,6 +1,25 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEV_H_
#define DEV_H_
#include "config.h"
#include "event.h"
/* device hotplug detection */

Wyświetl plik

@ -1,3 +1,22 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Wyświetl plik

@ -1,3 +1,22 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include "event.h"
#include "client.h"

Wyświetl plik

@ -1,6 +1,25 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EVENT_H_
#define EVENT_H_
#include "config.h"
#include <sys/time.h>
enum {

Wyświetl plik

@ -1,3 +1,22 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -54,6 +73,16 @@ int init_unix(void)
return 0;
}
void close_unix(void)
{
if(lsock != -1) {
close(lsock);
lsock = -1;
unlink(SOCK_NAME);
}
}
int get_unix_socket(void)
{
return lsock;

Wyświetl plik

@ -1,10 +1,30 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROTO_UNIX_H_
#define PROTO_UNIX_H_
#include "config.h"
#include "event.h"
#include "client.h"
int init_unix(void);
void close_unix(void);
int get_unix_socket(void);
void send_uevent(spnav_event *ev, struct client *c);

Wyświetl plik

@ -1,8 +1,28 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include "proto_x11.h"
#include "client.h"
#include "spnavd.h"
#include "xdetect.h"
enum cmd_msg {
@ -51,6 +71,8 @@ int init_x11(void)
if(!(dpy = XOpenDisplay(0))) {
fprintf(stderr, "failed to open X11 display \"%s\"\n", getenv("DISPLAY"));
xdet_start();
return -1;
}
scr_count = ScreenCount(dpy);
@ -94,6 +116,7 @@ int init_x11(void)
}
XFlush(dpy);
xdet_stop(); /* stop X server detection if it was running */
return 0;
}
@ -133,7 +156,7 @@ void close_x11(void)
int get_x11_socket(void)
{
return dpy ? ConnectionNumber(dpy) : -1;
return dpy ? ConnectionNumber(dpy) : xdet_get_fd();
}
void send_xevent(spnav_event *ev, struct client *c)
@ -192,6 +215,9 @@ void send_xevent(spnav_event *ev, struct client *c)
int handle_xevents(fd_set *rset)
{
if(!dpy) {
if(xdet_get_fd() != -1) {
handle_xdet_events(rset);
}
return -1;
}

Wyświetl plik

@ -1,6 +1,25 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROTO_X11_H_
#define PROTO_X11_H_
#include "config.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>

Wyświetl plik

@ -15,7 +15,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "proto_unix.h"
#include "proto_x11.h"
static void cleanup(void);
static void daemonize(void);
static int write_pid_file(void);
static void handle_events(fd_set *rset);
@ -74,6 +75,8 @@ int main(int argc, char **argv)
}
write_pid_file();
puts("Spacenav daemon " VERSION);
read_cfg("/etc/spnavrc", &cfg);
if(init_clients() == -1) {
@ -95,6 +98,8 @@ int main(int argc, char **argv)
init_x11();
#endif
atexit(cleanup);
for(;;) {
fd_set rset;
int fd, max_fd = 0;
@ -148,6 +153,16 @@ int main(int argc, char **argv)
return 0; /* unreachable */
}
static void cleanup(void)
{
#ifdef USE_X11
close_x11(); /* call to avoid leaving garbage in the X server's root windows */
#endif
close_unix();
shutdown_dev();
remove(PIDFILE);
}
static void daemonize(void)
{
int i, pid;
@ -241,11 +256,6 @@ static void sig_handler(int s)
fprintf(stderr, "Segmentation fault caught, trying to exit gracefully\n");
case SIGINT:
case SIGTERM:
#ifdef USE_X11
close_x11(); /* call to avoid leaving garbage in the X server's root windows */
#endif
shutdown_dev();
remove(PIDFILE);
exit(0);
#ifdef USE_X11

Wyświetl plik

@ -1,6 +1,25 @@
/*
spacenavd - a free software replacement driver for 6dof space-mice.
Copyright (C) 2007-2009 John Tsiombikas <nuclear@member.fsf.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SPNAVD_H_
#define SPNAVD_H_
#include "config.h"
#include "cfgfile.h"
#define SOCK_NAME "/var/run/spnav.sock"