moved everything into subdirectories (src, include)

proto1
John Tsiombikas 2018-08-24 05:22:35 +03:00
rodzic da5d466a1b
commit c66e740e67
8 zmienionych plików z 87 dodań i 16 usunięć

3
.gitignore vendored
Wyświetl plik

@ -6,3 +6,6 @@
*.so.* *.so.*
spnav_config.h spnav_config.h
Makefile Makefile
examples/cube/cube
examples/simple/simple_af_unix
examples/simple/simple_x11

Wyświetl plik

@ -1,11 +1,11 @@
src = $(sort $(wildcard src/*.c))
obj = spnav.o $(magellan_obj) obj = $(src:.c=.o)
hdr = spnav.h spnav_magellan.h spnav_config.h pubhdr = $(wildcard include/*.h)
name = spnav name = spnav
lib_a = lib$(name).a lib_a = lib$(name).a
incpaths = -I. -I/usr/local/include -I/usr/X11R6/include incpaths = -Iinclude -Isrc -I/usr/local/include -I/usr/X11R6/include
libpaths = -L/usr/local/lib -L/usr/X11R6/lib libpaths = -L/usr/local/lib -L/usr/X11R6/lib
CC = gcc CC = gcc
@ -48,7 +48,7 @@ distclean:
rm -f $(obj) $(lib_a) $(lib_so) Makefile rm -f $(obj) $(lib_a) $(lib_so) Makefile
.PHONY: install .PHONY: install
install: $(lib_a) $(lib_so) $(hdr) install: $(lib_a) $(lib_so) $(pubhdr)
mkdir -p $(DESTDIR)$(PREFIX)/$(libdir) $(DESTDIR)$(PREFIX)/include mkdir -p $(DESTDIR)$(PREFIX)/$(libdir) $(DESTDIR)$(PREFIX)/include
cp $(lib_a) $(DESTDIR)$(PREFIX)/$(libdir)/$(lib_a) cp $(lib_a) $(DESTDIR)$(PREFIX)/$(libdir)/$(lib_a)
cp $(lib_so) $(DESTDIR)$(PREFIX)/$(libdir)/$(lib_so) cp $(lib_so) $(DESTDIR)$(PREFIX)/$(libdir)/$(lib_so)
@ -57,7 +57,7 @@ install: $(lib_a) $(lib_so) $(hdr)
ln -s $(DESTDIR)$(PREFIX)/$(libdir)/$(lib_so) $(DESTDIR)$(PREFIX)/$(libdir)/$(soname) && \ ln -s $(DESTDIR)$(PREFIX)/$(libdir)/$(lib_so) $(DESTDIR)$(PREFIX)/$(libdir)/$(soname) && \
ln -s $(DESTDIR)$(PREFIX)/$(libdir)/$(soname) $(DESTDIR)$(PREFIX)/$(libdir)/$(devlink) || \ ln -s $(DESTDIR)$(PREFIX)/$(libdir)/$(soname) $(DESTDIR)$(PREFIX)/$(libdir)/$(devlink) || \
true true
for h in $(hdr); do cp -p $(srcdir)/$$h $(DESTDIR)$(PREFIX)/include/; done for h in $(pubhdr); do cp -p $(srcdir)/$$h $(DESTDIR)$(PREFIX)/include/; done
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstall:
@ -66,5 +66,5 @@ uninstall:
[ -n "$(soname)" ] && \ [ -n "$(soname)" ] && \
rm -f $(DESTDIR)$(PREFIX)/$(libdir)/$(soname) $(DESTDIR)$(PREFIX)/$(libdir)/$(devlink) || \ rm -f $(DESTDIR)$(PREFIX)/$(libdir)/$(soname) $(DESTDIR)$(PREFIX)/$(libdir)/$(devlink) || \
true true
for i in $(hdr); do rm -f $(DESTDIR)$(PREFIX)/include/$$i; done for i in $(pubhdr); do rm -f $(DESTDIR)$(PREFIX)/include/$$i; done

14
configure vendored
Wyświetl plik

@ -91,22 +91,22 @@ if [ "$OPT" = 'yes' ]; then
fi fi
if [ "$X11" = 'yes' ]; then if [ "$X11" = 'yes' ]; then
echo 'magellan_obj = spnav_magellan.o' >>Makefile
echo 'xlib = -lX11' >>Makefile echo 'xlib = -lX11' >>Makefile
fi fi
cat "$srcdir/Makefile.in" >>Makefile cat "$srcdir/Makefile.in" >>Makefile
# create spnav_config.h # create spnav_config.h
cfghdr=include/spnav_config.h
echo 'creating spnav_config.h ...' echo 'creating spnav_config.h ...'
echo '#ifndef SPNAV_CONFIG_H_' >spnav_config.h echo '#ifndef SPNAV_CONFIG_H_' >$cfghdr
echo '#define SPNAV_CONFIG_H_' >>spnav_config.h echo '#define SPNAV_CONFIG_H_' >>$cfghdr
echo '' >>spnav_config.h echo '' >>$cfghdr
if [ "$X11" = 'yes' ]; then if [ "$X11" = 'yes' ]; then
echo '#define USE_X11' >>spnav_config.h echo '#define USE_X11' >>$cfghdr
echo '' >>spnav_config.h echo '' >>$cfghdr
fi fi
echo '#endif /* SPNAV_CONFIG_H_ */' >>spnav_config.h echo '#endif /* SPNAV_CONFIG_H_ */' >>$cfghdr
#done #done
echo '' echo ''

Wyświetl plik

@ -148,7 +148,7 @@ enum {
SPNAV_GET_HAVE_DISP, /* int: non-zero if the device has a display */ SPNAV_GET_HAVE_DISP, /* int: non-zero if the device has a display */
SPNAV_GET_DISP_XRES, /* int: display horizontal resolution */ SPNAV_GET_DISP_XRES, /* int: display horizontal resolution */
SPNAV_GET_DISP_YRES, /* int: display vertical resolution */ SPNAV_GET_DISP_YRES, /* int: display vertical resolution */
SPNAV_GET_DISP_COLORS, /* int: display number of colors */ SPNAV_GET_DISP_COLORS /* int: display number of colors */
}; };
int spnav_get_int(int query, int *res); int spnav_get_int(int query, int *res);
int spnav_get_str(int query, char *buf, int bufsz); int spnav_get_str(int query, char *buf, int bufsz);

68
src/inpsrc.h 100644
Wyświetl plik

@ -0,0 +1,68 @@
/*
This file is part of libspnav, part of the spacenav project (spacenav.sf.net)
Copyright (C) 2007-2018 John Tsiombikas <nuclear@member.fsf.org>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
/* input source abstraction */
#ifndef INPSRC_H_
#define INPSRC_H_
struct display;
struct input_src {
const char *name; /* module name */
int fd; /* file descriptor for select */
void *data; /* extra data */
struct display *disp; /* display callbacks */
int (*open)(struct input_src*);
int (*close)(struct input_src*);
int (*pending)(struct input_src*);
int (*process)(struct input_src*);
int (*get_int)(struct input_src*, int*);
int (*get_str)(struct input_src*, char*, int);
};
struct display {
struct input_src *inp;
int width, height;
int num_colors;
void *(*map)(struct display*);
int (*unmap)(struct display*);
int (*color)(struct display*, unsigned int, unsigned int);
int (*cursor)(struct display*, int, int);
int (*print)(struct display*, const char*);
int (*clear)(struct display*);
int (*rect)(struct display*, int, int, int, int);
int (*fill)(struct display*, int, int, int, int);
int (*line)(struct display*, int, int, int, int);
};
#endif /* INPSRC_H_ */

Wyświetl plik

@ -105,7 +105,7 @@ int spnav_open(void)
} }
proto = 0; proto = 0;
if(conn_unix(s, SPNAVEXT_SOCK_PATH) == -1) { if(conn_unix(s, SPNAV1_SOCK_PATH) == -1) {
proto = 1; proto = 1;
if(conn_unix(s, SPNAV_SOCK_PATH) == -1) { if(conn_unix(s, SPNAV_SOCK_PATH) == -1) {
perror("failed to connect"); perror("failed to connect");