Commit 63a65e81 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

package stuff

parent e87390ac
......@@ -62,8 +62,10 @@ cleandeps::
-rm -f src/*.dep src/*/*.dep
install:: ${TARGET}
install jellyfish @prefix@/bin/
install assets/* @prefix@/lib/jellyfish/
install -d $(DESTDIR)@prefix@/bin/
install jellyfish $(DESTDIR)@prefix@/bin/
install -d $(DESTDIR)@prefix@/lib/jellyfish/
install assets/* $(DESTDIR)@prefix@/lib/jellyfish/
distclean:: clean
-rm -rf config.status autom4te.cache config.log Makefile
......@@ -3081,13 +3081,13 @@ _ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgl" >&5
$as_echo_n "checking for main in -lgl... " >&6; }
if ${ac_cv_lib_gl_main+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lGL" >&5
$as_echo_n "checking for main in -lGL... " >&6; }
if ${ac_cv_lib_GL_main+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lgl $LIBS"
LIBS="-lGL $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
......@@ -3101,22 +3101,22 @@ return main ();
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_gl_main=yes
ac_cv_lib_GL_main=yes
else
ac_cv_lib_gl_main=no
ac_cv_lib_GL_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gl_main" >&5
$as_echo "$ac_cv_lib_gl_main" >&6; }
if test "x$ac_cv_lib_gl_main" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_GL_main" >&5
$as_echo "$ac_cv_lib_GL_main" >&6; }
if test "x$ac_cv_lib_GL_main" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBGL 1
_ACEOF
LIBS="-lgl $LIBS"
LIBS="-lGL $LIBS"
fi
......
......@@ -15,7 +15,7 @@ AC_CHECK_LIB(EGL, eglCopyBuffers)
AC_CHECK_LIB(m, cos)
AC_CHECK_LIB(glut, main)
AC_CHECK_LIB(gl, main)
AC_CHECK_LIB(GL, main)
AC_CHECK_LIB(png, main)
AC_CHECK_LIB(pthread, main)
AC_CHECK_LIB(dl, main)
......
#include "alsa.h"
alsa_device::alsa_device() {
int i;
int err;
short buf[128];
snd_pcm_hw_params_t *hw_params;
if ((err = snd_pcm_open (&playback_handle, "hw:0,0", SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
fprintf (stderr, "cannot open audio device %s (%s)\n",
"hw:0,0",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params_any (playback_handle, hw_params)) < 0) {
fprintf (stderr, "cannot initialize hardware parameter structure (%s)\n",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params_set_access (playback_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
fprintf (stderr, "cannot set access type (%s)\n",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params_set_format (playback_handle, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
fprintf (stderr, "cannot set sample format (%s)\n",
snd_strerror (err));
exit (1);
}
/*
if ((err = snd_pcm_hw_params_set_rate_near (playback_handle, hw_params, 48000, 0)) < 0) {
fprintf (stderr, "cannot set sample rate (%s)\n",
snd_strerror (err));
exit (1);
}
*/
if ((err = snd_pcm_hw_params_set_channels (playback_handle, hw_params, 2)) < 0) {
fprintf (stderr, "cannot set channel count (%s)\n",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params (playback_handle, hw_params)) < 0) {
fprintf (stderr, "cannot set parameters (%s)\n",
snd_strerror (err));
exit (1);
}
snd_pcm_hw_params_free (hw_params);
if ((err = snd_pcm_prepare (playback_handle)) < 0) {
fprintf (stderr, "cannot prepare audio interface for use (%s)\n",
snd_strerror (err));
exit (1);
}
}
alsa_device::~alsa_device() {
snd_pcm_close (playback_handle);
}
void alsa_device::play(short* buf, size_t length) {
if ((err = snd_pcm_writei (playback_handle, buf, length)) != length) {
fprintf (stderr, "write to audio interface failed (%s)\n",
snd_strerror (err));
exit (1);
}
}
#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>
#include <limits.h>
main (int argc, char *argv[])
{
int i;
int err;
short buf[128];
snd_pcm_t *playback_handle;
snd_pcm_hw_params_t *hw_params;
if ((err = snd_pcm_open (&playback_handle, argv[1], SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
fprintf (stderr, "cannot open audio device %s (%s)\n",
argv[1],
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params_any (playback_handle, hw_params)) < 0) {
fprintf (stderr, "cannot initialize hardware parameter structure (%s)\n",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params_set_access (playback_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
fprintf (stderr, "cannot set access type (%s)\n",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params_set_format (playback_handle, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
fprintf (stderr, "cannot set sample format (%s)\n",
snd_strerror (err));
exit (1);
}
fprintf (stderr, "here\n");
/*
if ((err = snd_pcm_hw_params_set_rate_near (playback_handle, hw_params, 48000, 0)) < 0) {
fprintf (stderr, "cannot set sample rate (%s)\n",
snd_strerror (err));
exit (1);
}
*/
fprintf (stderr, "there\n");
if ((err = snd_pcm_hw_params_set_channels (playback_handle, hw_params, 2)) < 0) {
fprintf (stderr, "cannot set channel count (%s)\n",
snd_strerror (err));
exit (1);
}
if ((err = snd_pcm_hw_params (playback_handle, hw_params)) < 0) {
fprintf (stderr, "cannot set parameters (%s)\n",
snd_strerror (err));
exit (1);
}
snd_pcm_hw_params_free (hw_params);
if ((err = snd_pcm_prepare (playback_handle)) < 0) {
fprintf (stderr, "cannot prepare audio interface for use (%s)\n",
snd_strerror (err));
exit (1);
}
for (i = 0; i<128; i++) {
buf[i]=rand()%SHRT_MAX;
}
for (i = 0; i < 100; ++i) {
if ((err = snd_pcm_writei (playback_handle, buf, 128)) != 128) {
fprintf (stderr, "write to audio interface failed (%s)\n",
snd_strerror (err));
exit (1);
}
}
snd_pcm_close (playback_handle);
exit (0);
}
#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>
#include <limits.h>
class alsa_device {
alsa_device();
~alsa_device();
void alsa_device::play(short* buf, size_t length);
private:
snd_pcm_t *playback_handle;
};
......@@ -15,7 +15,7 @@
/* Define to 1 if you have the `EGL' library (-lEGL). */
#undef HAVE_LIBEGL
/* Define to 1 if you have the `gl' library (-lgl). */
/* Define to 1 if you have the `GL' library (-lGL). */
#undef HAVE_LIBGL
/* Define to 1 if you have the `GLESv1_CM' library (-lGLESv1_CM). */
......
// code adapted from https://github.com/chriscamacho/gles2framework
#include <stdbool.h>
#include <stdio.h> // sprintf
#include <stdlib.h> // malloc
#include <math.h>
#include <fcntl.h> // open fcntl
#include <unistd.h> // read close
#include <string.h>
#include <dirent.h>
#include "linux/kd.h" // keyboard stuff...
#include "termios.h"
#include "sys/ioctl.h"
#include "linux/input.h"
#include "keys.h"
static struct termios tty_attr_old;
static int old_keyboard_mode;
int __mouse_fd=-1;
int __mouse[3];
bool __rel_mouse;
int __key_fd=0; // defaults to 0 ie console
void restoreKbd() {
if (__key_fd==0) {
tcsetattr(0, TCSAFLUSH, &tty_attr_old);
// ioctl(0, KDSKBMODE, old_keyboard_mode);
ioctl(0, KDSKBMODE, K_XLATE);
}
}
void doEvents(int __display_width, int __display_height,
void (*KeyDownCallback)(unsigned char,int,int),
void (*KeyUpCallback)(unsigned char,int,int)) {
if (__key_fd==0) {
char buf[1];
int res;
res = read(__key_fd, &buf[0], 1);
while (res >= 0) {
//printf("keyboard %i\n",buf[0]);
if (buf[0] & 0x80) {
printf("key %i released\n",(buf[0]&~0x80));
KeyUpCallback(buf[0]&~0x80,0,0);
} else {
printf("key %i pressed\n",(buf[0]&~0x80));
KeyDownCallback(buf[0]&~0x80,0,0);
}
res = read(__key_fd, &buf[0], 1);
}
} else {
struct input_event ev;
int res;
res = read(__key_fd, &ev,sizeof(struct input_event));
while (res>=0) {
//printf(" %i %i %i\n",ev.type,ev.code,ev.value);
// should probably handle MSC and SYN as well - meh
if (ev.type==EV_KEY) {
if (ev.value==1) {
printf("%d\n",lc_map[ev.code]);
KeyDownCallback(lc_map[ev.code&0xff],0,0);
} else if (ev.value==0) {
KeyUpCallback(lc_map[ev.code&0xff],0,0);
}
}
res = read(__key_fd, &ev,sizeof(struct input_event));
}
}
if (__rel_mouse) {
__mouse[0]=0;
__mouse[1]=0;
}
if(__mouse_fd>0) {
signed char mbuf[3];
int mres;
mres=read(__mouse_fd,&mbuf[0],3);
while(mres>=0) {
//printf("%i %i %i\n",mbuf[0]&7,mbuf[1],mbuf[2]);
__mouse[2]=mbuf[0]&7;
if (__rel_mouse) {
__mouse[0]=mbuf[1];
__mouse[1]=-mbuf[2];
} else {
__mouse[0]=__mouse[0]+mbuf[1];
__mouse[1]=__mouse[1]-mbuf[2];
if (__mouse[0]<0) __mouse[0]=0;
if (__mouse[1]<0) __mouse[1]=0;
if (__mouse[0]>__display_width) __mouse[0]=__display_width;
if (__mouse[1]>__display_height) __mouse[1]=__display_height;
}
mres=read(__mouse_fd,&mbuf[0],3);
}
}
}
void setMouseRelative(bool mode) {
__rel_mouse=mode;
}
int *getMouse()
{
__rel_mouse=false;
__mouse_fd = open("/dev/input/mouse0", O_RDONLY);
if (__mouse_fd < 0) {
printf("open failed\n");
} else {
// make none blocking
int flags = fcntl(__mouse_fd, F_GETFL);
flags |= O_NONBLOCK;
fcntl(__mouse_fd, F_SETFL, flags);
}
return &__mouse[0];
}
static int __dsort (const struct dirent **a,const struct dirent **b) {
return 1; // dummy sort
}
static int __dfilter(const struct dirent *d) {
if (d->d_type==DT_DIR) return 0;
int i=0;
i=strlen(d->d_name)-1;
//printf ("%i %c %c %c \n",d->d_type,d->d_name[i-2],d->d_name[i-1],d->d_name[i]);
// allegedly usb keyboard symlink *always* ends kbd
if (d->d_name[i-2]=='k' & d->d_name[i-1]=='b' & d->d_name[i]=='d' ) return 1;
return 0;
}
void getKeys()
{
struct dirent **eps;
int n;
n = scandir ("/dev/input/by-path/", &eps, __dfilter, __dsort);
if(n >= 0 && eps != 0 && eps[0] != 0) {
// only check 1st usb keyboard....
char fn[256];
sprintf(fn,"/dev/input/by-path/%s\0",eps[0]->d_name);
__key_fd=open(fn, O_RDONLY);
printf("%i %s\n",__key_fd,fn);
}
if (__key_fd==-1) __key_fd=0; // on usb evdev failure default to console
int flags;
flags = fcntl(__key_fd, F_GETFL);
flags |= O_NONBLOCK;
fcntl(__key_fd, F_SETFL, flags);
if (__key_fd==0) {
struct termios tty_attr;
/* save old keyboard mode */
if (ioctl(__key_fd, KDGKBMODE, &old_keyboard_mode) < 0) {
//return 0;
printf("couldn't get the keyboard, are you running via ssh\n");
printf("or without setting evdev permissions? \n");
}
tcgetattr(__key_fd, &tty_attr_old);
/* turn off buffering, echo and key processing */
tty_attr = tty_attr_old;
tty_attr.c_lflag &= ~(ICANON | ECHO | ISIG);
tty_attr.c_iflag &= ~(ISTRIP | INLCR | ICRNL | IGNCR | IXON | IXOFF);
tcsetattr(__key_fd, TCSANOW, &tty_attr);
ioctl(__key_fd, KDSKBMODE, K_RAW);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment