Merge pull request #675 from lakkatv/lakka-integration

Lakka integration
This commit is contained in:
Twinaphex 2014-05-09 16:31:54 +02:00
commit b136ce5004
43 changed files with 5400 additions and 519 deletions

View File

@ -69,7 +69,6 @@ endif
DEFINES = -DHAVE_CONFIG_H -DHAVE_SCREENSHOTS -DRARCH_INTERNAL -DHAVE_CC_RESAMPLER
#HAVE_LAKKA = 1
ifeq ($(GLOBAL_CONFIG_DIR),)
GLOBAL_CONFIG_DIR = /etc
@ -103,8 +102,9 @@ ifeq ($(HAVE_RGUI), 1)
DEFINES += -DHAVE_MENU
HAVE_MENU_COMMON = 1
ifeq ($(HAVE_LAKKA), 1)
OBJ += frontend/menu/disp/lakka.o
OBJ += frontend/menu/disp/png_texture_load.o frontend/menu/disp/tween.o frontend/menu/backend/menu_lakka_backend.o frontend/menu/disp/lakka.o
DEFINES += -DHAVE_LAKKA
LIBS += -lpng
endif
endif

View File

@ -1669,12 +1669,13 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = {
#if defined(HAVE_RMENU_XUI)
&menu_ctx_rmenu_xui,
#endif
#if defined(HAVE_RGUI)
&menu_ctx_rgui,
#endif
#if defined(HAVE_LAKKA)
&menu_ctx_lakka,
#endif
#if defined(HAVE_RGUI)
&menu_ctx_rgui,
#endif
NULL // zero length array is not valid
};

View File

@ -685,6 +685,7 @@ extern const menu_ctx_driver_t menu_ctx_rgui;
extern const menu_ctx_driver_t menu_ctx_lakka;
extern const menu_ctx_driver_backend_t menu_ctx_backend_common;
extern const menu_ctx_driver_backend_t menu_ctx_backend_lakka;
#ifdef HAVE_FILTERS_BUILTIN
extern const struct softfilter_implementation *blargg_ntsc_snes_rf_get_implementation(softfilter_simd_mask_t simd);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
void lakka_render(void *data);
typedef struct
{
char* name;
GLuint icon;
float alpha;
float zoom;
float y;
struct font_output_list out;
} menu_subitem;
typedef struct
{
char* name;
char* rom;
GLuint icon;
float alpha;
float zoom;
float y;
int active_subitem;
int num_subitems;
menu_subitem *subitems;
struct font_output_list out;
} menu_item;
typedef struct
{
char* name;
char* libretro;
GLuint icon;
float alpha;
float zoom;
int active_item;
int num_items;
menu_item *items;
struct font_output_list out;
} menu_category;

View File

@ -0,0 +1,172 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
* Copyright (C) 2011-2013 - Daniel De Matteis
*
* RetroArch 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 Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "png_texture_load.h"
// thanks to https://github.com/DavidEGrayson/ahrs-visualizer/blob/master/png_texture.cpp
GLuint png_texture_load(const char * file_name, int * width, int * height)
{
png_byte header[8];
FILE *fp = fopen(file_name, "rb");
if (fp == 0)
{
perror(file_name);
return 0;
}
// read the header
fread(header, 1, 8, fp);
if (png_sig_cmp(header, 0, 8))
{
fprintf(stderr, "error: %s is not a PNG.\n", file_name);
fclose(fp);
return 0;
}
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
{
fprintf(stderr, "error: png_create_read_struct returned 0.\n");
fclose(fp);
return 0;
}
// create png info struct
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
fprintf(stderr, "error: png_create_info_struct returned 0.\n");
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
fclose(fp);
return 0;
}
// create png info struct
png_infop end_info = png_create_info_struct(png_ptr);
if (!end_info)
{
fprintf(stderr, "error: png_create_info_struct returned 0.\n");
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
fclose(fp);
return 0;
}
// the code in this if statement gets called if libpng encounters an error
if (setjmp(png_jmpbuf(png_ptr))) {
fprintf(stderr, "error from libpng\n");
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
fclose(fp);
return 0;
}
// init png reading
png_init_io(png_ptr, fp);
// let libpng know you already read the first 8 bytes
png_set_sig_bytes(png_ptr, 8);
// read all the info up to the image data
png_read_info(png_ptr, info_ptr);
// variables to pass to get info
int bit_depth, color_type;
png_uint_32 temp_width, temp_height;
// get info about png
png_get_IHDR(png_ptr, info_ptr, &temp_width, &temp_height, &bit_depth, &color_type,
NULL, NULL, NULL);
if (width){ *width = temp_width; }
if (height){ *height = temp_height; }
//printf("%s: %lux%lu %d\n", file_name, temp_width, temp_height, color_type);
if (bit_depth != 8)
{
fprintf(stderr, "%s: Unsupported bit depth %d. Must be 8.\n", file_name, bit_depth);
return 0;
}
GLint format;
switch(color_type)
{
case PNG_COLOR_TYPE_RGB:
format = GL_RGB;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
format = GL_RGBA;
break;
default:
fprintf(stderr, "%s: Unknown libpng color type %d.\n", file_name, color_type);
return 0;
}
// Update the png info struct.
png_read_update_info(png_ptr, info_ptr);
// Row size in bytes.
int rowbytes = png_get_rowbytes(png_ptr, info_ptr);
// glTexImage2d requires rows to be 4-byte aligned
rowbytes += 3 - ((rowbytes-1) % 4);
// Allocate the image_data as a big block, to be given to opengl
png_byte * image_data = (png_byte *)malloc(rowbytes * temp_height * sizeof(png_byte)+15);
if (image_data == NULL)
{
fprintf(stderr, "error: could not allocate memory for PNG image data\n");
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
fclose(fp);
return 0;
}
// row_pointers is for pointing to image_data for reading the png with libpng
png_byte ** row_pointers = (png_byte **)malloc(temp_height * sizeof(png_byte *));
if (row_pointers == NULL)
{
fprintf(stderr, "error: could not allocate memory for PNG row pointers\n");
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
free(image_data);
fclose(fp);
return 0;
}
// set the individual row_pointers to point at the correct offsets of image_data
for (unsigned int i = 0; i < temp_height; i++)
{
row_pointers[temp_height - 1 - i] = image_data + i * rowbytes;
}
// read the png into image_data through row_pointers
png_read_image(png_ptr, row_pointers);
// Generate the OpenGL texture object
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, format, temp_width, temp_height, 0, format, GL_UNSIGNED_BYTE, image_data);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// clean up
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
free(image_data);
free(row_pointers);
fclose(fp);
return texture;
}

View File

@ -0,0 +1,21 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
* Copyright (C) 2011-2013 - Daniel De Matteis
*
* RetroArch 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 Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../../gfx/gl_common.h"
#include "../../../gfx/gfx_common.h"
#include <png.h>
GLuint png_texture_load(const char *, int *, int *);

View File

@ -0,0 +1,75 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
* Copyright (C) 2011-2013 - Daniel De Matteis
*
* RetroArch 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 Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdio.h>
#include "tween.h"
tween* tweens = NULL;
int numtweens = 0;
float inOutQuad(float t, float b, float c, float d)
{
t = t / d * 2;
if (t < 1)
return c / 2 * pow(t, 2) + b;
return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
}
void add_tween(float duration, float target_value, float* subject, easingFunc easing) {
numtweens++;
tweens = realloc(tweens, numtweens * sizeof(tween));
tweens[numtweens-1].alive = 1;
tweens[numtweens-1].duration = duration;
tweens[numtweens-1].running_since = 0;
tweens[numtweens-1].initial_value = *subject;
tweens[numtweens-1].target_value = target_value;
tweens[numtweens-1].subject = subject;
tweens[numtweens-1].easing = easing;
}
void update_tweens(float dt)
{
int active_tweens = 0;
for(int i = 0; i < numtweens; i++)
{
tweens[i] = update_tween(tweens[i], dt);
active_tweens += tweens[i].running_since < tweens[i].duration ? 1 : 0;
}
if (numtweens && !active_tweens) {
numtweens = 0;
}
}
tween update_tween(tween tw, float dt)
{
if (tw.running_since < tw.duration) {
tw.running_since += dt;
*(tw.subject) = tw.easing(
tw.running_since,
tw.initial_value,
tw.target_value - tw.initial_value,
tw.duration);
if (tw.running_since >= tw.duration)
*(tw.subject) = tw.target_value;
}
return tw;
}
void free_tweens()
{
free(tweens);
}

View File

@ -0,0 +1,37 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
* Copyright (C) 2011-2013 - Daniel De Matteis
*
* RetroArch 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 Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch 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 RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "math.h"
typedef float (*easingFunc)(float, float, float, float);
float inOutQuad(float, float, float, float);
typedef struct
{
int alive;
float duration;
float running_since;
float initial_value;
float target_value;
float* subject;
easingFunc easing;
} tween;
tween update_tween(tween, float);
void update_tweens(float);
void add_tween(float, float, float*, easingFunc);
void free_tweens();

View File

@ -49,6 +49,10 @@
#include "shader_glsl.h"
#endif
#ifdef HAVE_LAKKA
#include "../frontend/menu/disp/lakka.h"
#endif
#include "shader_common.h"
// Used for the last pass when rendering to the back buffer.
@ -1515,7 +1519,11 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
#if defined(HAVE_MENU)
if (gl->rgui_texture_enable)
gl_draw_texture(gl);
#if defined(HAVE_LAKKA)
lakka_render(gl);
#else
gl_draw_texture(gl);
#endif
#endif
if (msg && gl->font_ctx)

BIN
media/lakka/fceu-game.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
media/lakka/fceu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
media/lakka/fceumm-game.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
media/lakka/fceumm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
media/lakka/gambatte.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
media/lakka/genplus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
media/lakka/imame4all.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
media/lakka/loadstate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
media/lakka/mame078.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
media/lakka/nx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
media/lakka/nxengine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
media/lakka/picodrive.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
media/lakka/pocketsnes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

BIN
media/lakka/reload.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
media/lakka/resume.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

BIN
media/lakka/run.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

BIN
media/lakka/savestate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
media/lakka/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
media/lakka/setting.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
media/lakka/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
media/lakka/snes9x-next.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -274,6 +274,6 @@ add_define_make OS "$OS"
# Creates config.mk and config.h.
add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR"
VARS="RGUI ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 SDL_IMAGE ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT"
VARS="RGUI LAKKA ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 SDL_IMAGE ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT"
create_config_make config.mk $VARS
create_config_header config.h $VARS

View File

@ -1,4 +1,5 @@
HAVE_RGUI=yes # Disable RGUI
HAVE_LAKKA=no # Enable Lakka menu
HAVE_DYNAMIC=yes # Disable dynamic loading of libretro library
HAVE_SDL=auto # SDL support
HAVE_UDEV=auto # Udev/Evdev gamepad support