@@ -27,7 +27,8 @@ libcaca_la_SOURCES = \ | |||
driver_slang.c \ | |||
driver_vga.c \ | |||
driver_win32.c \ | |||
$(extra_drivers) \ | |||
$(cocoa_source) \ | |||
$(extra_source) \ | |||
$(NULL) | |||
libcaca_la_LDFLAGS = -no-undefined -version-info @LT_VERSION@ | |||
libcaca_la_LIBADD = ../cucul/libcucul.la @CACA_LIBS@ | |||
@@ -44,6 +45,10 @@ libgl_plugin_la_SOURCES = driver_gl.c | |||
libgl_plugin_la_LDFLAGS = -no-undefined -module -no-version | |||
libgl_plugin_la_LIBADD = libcaca.la ../cucul/libcucul.la @GL_LIBS@ | |||
else | |||
extra_drivers = driver_x11.c driver_gl.c | |||
extra_source = driver_x11.c driver_gl.c | |||
endif | |||
if USE_COCOA | |||
cocoa_source = driver_cocoa.m | |||
endif | |||
@@ -162,10 +162,13 @@ static int caca_select_driver(caca_display_t *dp) | |||
{ | |||
#if defined(HAVE_GETENV) && defined(HAVE_STRCASECMP) | |||
char *var = getenv("CACA_DRIVER"); | |||
/* If the environment variable was set, use it */ | |||
if(var && *var) | |||
{ | |||
#if defined(USE_COCOA) | |||
if(!strcasecmp(var, "cocoa")) return cocoa_install(dp); | |||
#endif | |||
#if defined(USE_WIN32) | |||
if(!strcasecmp(var, "win32")) return win32_install(dp); | |||
#endif | |||
@@ -194,6 +197,9 @@ static int caca_select_driver(caca_display_t *dp) | |||
} | |||
#endif | |||
#if defined(USE_COCOA) | |||
if(cocoa_install(dp) == 0) return 0; | |||
#endif | |||
#if defined(USE_WIN32) | |||
if(win32_install(dp) == 0) return 0; | |||
#endif | |||
@@ -29,30 +29,36 @@ enum caca_driver | |||
{ | |||
CACA_DRIVER_NONE = 0, | |||
CACA_DRIVER_RAW = 1, | |||
#if defined(USE_COCOA) | |||
CACA_DRIVER_COCOA = 2, | |||
#endif | |||
#if defined(USE_CONIO) | |||
CACA_DRIVER_CONIO = 2, | |||
CACA_DRIVER_CONIO = 3, | |||
#endif | |||
#if defined(USE_GL) | |||
CACA_DRIVER_GL = 3, | |||
CACA_DRIVER_GL = 4, | |||
#endif | |||
#if defined(USE_NCURSES) | |||
CACA_DRIVER_NCURSES = 4, | |||
CACA_DRIVER_NCURSES = 5, | |||
#endif | |||
#if defined(USE_SLANG) | |||
CACA_DRIVER_SLANG = 5, | |||
CACA_DRIVER_SLANG = 6, | |||
#endif | |||
#if defined(USE_VGA) | |||
CACA_DRIVER_VGA = 6, | |||
CACA_DRIVER_VGA = 7, | |||
#endif | |||
#if defined(USE_WIN32) | |||
CACA_DRIVER_WIN32 = 7, | |||
CACA_DRIVER_WIN32 = 8, | |||
#endif | |||
#if defined(USE_X11) | |||
CACA_DRIVER_X11 = 8, | |||
CACA_DRIVER_X11 = 9, | |||
#endif | |||
}; | |||
/* Available external drivers */ | |||
#if defined(USE_COCOA) | |||
int cocoa_install(caca_display_t *); | |||
#endif | |||
#if defined(USE_CONIO) | |||
int conio_install(caca_display_t *); | |||
#endif | |||
@@ -0,0 +1,109 @@ | |||
/* | |||
* libcaca Colour ASCII-Art library | |||
* Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> | |||
* All Rights Reserved | |||
* | |||
* $Id$ | |||
* | |||
* This library is free software; you can redistribute it and/or | |||
* modify it under the terms of the Do What The Fuck You Want To | |||
* Public License, Version 2, as published by Sam Hocevar. See | |||
* http://sam.zoy.org/wtfpl/COPYING for more details. | |||
*/ | |||
/* | |||
* This file contains the libcaca Cocoa input and output driver | |||
*/ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined USE_COCOA | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include <Cocoa/Cocoa.h> | |||
#include "caca.h" | |||
#include "caca_internals.h" | |||
#include "cucul.h" | |||
#include "cucul_internals.h" | |||
struct driver_private | |||
{ | |||
/* Just testing stuff */ | |||
NSAutoreleasePool *pool; | |||
}; | |||
static int cocoa_init_graphics(caca_display_t *dp) | |||
{ | |||
dp->drv.p = malloc(sizeof(struct driver_private)); | |||
dp->drv.p->pool = [NSAutoreleasePool new]; | |||
return 0; | |||
} | |||
static int cocoa_end_graphics(caca_display_t *dp) | |||
{ | |||
[dp->drv.p->pool release]; | |||
free(dp->drv.p); | |||
return 0; | |||
} | |||
static int cocoa_set_display_title(caca_display_t *dp, char const *title) | |||
{ | |||
return -1; | |||
} | |||
static unsigned int cocoa_get_display_width(caca_display_t *dp) | |||
{ | |||
return 0; | |||
} | |||
static unsigned int cocoa_get_display_height(caca_display_t *dp) | |||
{ | |||
return 0; | |||
} | |||
static void cocoa_display(caca_display_t *dp) | |||
{ | |||
; | |||
} | |||
static void cocoa_handle_resize(caca_display_t *dp) | |||
{ | |||
; | |||
} | |||
static int cocoa_get_event(caca_display_t *dp, caca_event_t *ev) | |||
{ | |||
ev->type = CACA_EVENT_NONE; | |||
return 0; | |||
} | |||
/* | |||
* Driver initialisation | |||
*/ | |||
int cocoa_install(caca_display_t *dp) | |||
{ | |||
dp->drv.driver = CACA_DRIVER_RAW; | |||
dp->drv.init_graphics = cocoa_init_graphics; | |||
dp->drv.end_graphics = cocoa_end_graphics; | |||
dp->drv.set_display_title = cocoa_set_display_title; | |||
dp->drv.get_display_width = cocoa_get_display_width; | |||
dp->drv.get_display_height = cocoa_get_display_height; | |||
dp->drv.display = cocoa_display; | |||
dp->drv.handle_resize = cocoa_handle_resize; | |||
dp->drv.get_event = cocoa_get_event; | |||
dp->drv.set_mouse = NULL; | |||
return 0; | |||
} | |||
#endif /* USE_COCOA */ |
@@ -15,6 +15,10 @@ AM_PROG_CC_C_O | |||
AC_PROG_CPP | |||
AC_PROG_CXX | |||
AC_PROG_CXXCPP | |||
_AM_DEPENDENCIES([OBJC]) | |||
OBJC="${CXX}" | |||
AC_SUBST(OBJC) | |||
AC_SUBST(OBJCFLAGS) | |||
AM_PROG_AS | |||
AC_LIBTOOL_WIN32_DLL | |||
@@ -48,6 +52,8 @@ AC_ARG_ENABLE(x11, | |||
[ --enable-x11 X11 support (autodetected)]) | |||
AC_ARG_ENABLE(gl, | |||
[ --enable-gl OpenGL support (autodetected)]) | |||
AC_ARG_ENABLE(cocoa, | |||
[ --enable-cocoa Cocoa support (autodetected)]) | |||
AC_ARG_ENABLE(network, | |||
[ --enable-network Network support (autodetected)]) | |||
AC_ARG_ENABLE(vga, | |||
@@ -191,6 +197,25 @@ if test "${enable_gl}" != "no"; then | |||
fi | |||
fi | |||
if test "${enable_cocoa}" != "no"; then | |||
ac_cv_my_have_cocoa="no" | |||
AC_LANG_PUSH(C++) | |||
savedCPPFLAGS="${CPPFLAGS}" | |||
CPPFLAGS="${CPPFLAGS} -ObjC" | |||
AC_CHECK_HEADERS(Cocoa/Cocoa.h, | |||
[ac_cv_my_have_cocoa="yes"]) | |||
if test "${ac_cv_my_have_cocoa}" = "yes"; then | |||
AC_DEFINE(USE_COCOA, 1, Define to 1 to activate the Cocoa backend driver) | |||
CACA_LIBS="${CACA_LIBS} -Wl,-framework,Cocoa" | |||
CACA_DRIVERS="${CACA_DRIVERS} cocoa" | |||
elif test "${enable_cocoa}" = "yes"; then | |||
AC_MSG_ERROR([cannot find Cocoa development files]) | |||
fi | |||
CPPFLAGS="${savedCPPFLAGS}" | |||
AC_LANG_POP(C++) | |||
fi | |||
AM_CONDITIONAL(USE_COCOA, test "${ac_cv_my_have_cocoa}" = "yes") | |||
if test "${enable_ncurses}" != "no"; then | |||
ac_cv_my_have_ncurses="no" | |||
AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h, | |||