X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Flinux%2Fio.c;h=1b912c98d9163fddce6ecd5eaa80944c6b99e3b0;hb=d4d626658a7a999f48009f408b4a22d280ab80ea;hp=b16cf08d9e286a32a653223ec240c3ba8273ec23;hpb=697746df021a83dcb556afdb36abc6977780985c;p=picodrive.git diff --git a/platform/linux/io.c b/platform/linux/io.c index b16cf08..1b912c9 100644 --- a/platform/linux/io.c +++ b/platform/linux/io.c @@ -1,31 +1,39 @@ +/* + * PicoDrive + * (C) notaz, 2007-2010 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include #include #include -#include -#include -#include - -#include -#include -#include -#include +#include "../libpicofe/menu.h" +#include "../libpicofe/input.h" #include "../common/emu.h" -#include "../common/menu.h" -#include "sndout_oss.h" +#include "../common/input_pico.h" #include "version.h" #include "log_io.h" -unsigned long current_keys = 0; +int current_keys; +unsigned char *PicoDraw2FB; + +#ifdef FBDEV + +#include "fbdev.h" + +#else + +#include +#include + static int current_bpp = 16; static int current_pal[256]; static const char *verstring = "PicoDrive " VERSION; static int scr_changed = 0, scr_w = SCREEN_WIDTH, scr_h = SCREEN_HEIGHT; -/* ifndef is for qemu build without video out */ -#ifndef ARM - /* faking GP2X pad */ enum { GP2X_UP=0x1, GP2X_LEFT=0x4, GP2X_DOWN=0x10, GP2X_RIGHT=0x40, GP2X_START=1<<8, GP2X_SELECT=1<<9, GP2X_L=1<<10, GP2X_R=1<<11, @@ -245,23 +253,24 @@ static void xlib_init(void) sem_wait(&xlib_sem); sem_destroy(&xlib_sem); } -#endif // !ARM /* --- */ static void realloc_screen(void) { - void *old = g_screen_ptr; - g_screen_width = scr_w; - g_screen_height = scr_h; - g_screen_ptr = calloc(g_screen_width * g_screen_height * 2, 1); - free(old); + int size = scr_w * scr_h * 2; + g_screen_width = g_menuscreen_w = scr_w; + g_screen_height = g_menuscreen_h = scr_h; + g_screen_ptr = realloc(g_screen_ptr, size); + g_menubg_ptr = realloc(g_menubg_ptr, size); + memset(g_screen_ptr, 0, size); + memset(g_menubg_ptr, 0, size); + PicoDraw2FB = g_menubg_ptr; scr_changed = 0; } -void update_screen(void) +void plat_video_flip(void) { -#ifndef ARM unsigned int *image; int pixel_count, i; @@ -300,40 +309,56 @@ void update_screen(void) if (scr_changed) { realloc_screen(); ximage_realloc(xlib_display, DefaultVisual(xlib_display, 0)); + + // propagate new ponters to renderers + plat_video_toggle_renderer(0, 0); } -#endif } +void plat_video_wait_vsync(void) +{ +} + +#endif // !FBDEV + void plat_early_init(void) { } void plat_init(void) { +#ifdef FBDEV + int ret, w, h; + ret = vout_fbdev_init(&w, &h); + if (ret != 0) + exit(1); + g_screen_width = g_menuscreen_w = w; + g_screen_height = g_menuscreen_h = h; + g_menubg_ptr = realloc(g_menubg_ptr, w * g_screen_height * 2); + PicoDraw2FB = g_menubg_ptr; +#else realloc_screen(); memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); - - // snd - sndout_oss_init(); - -#ifndef ARM xlib_init(); #endif } void plat_finish(void) { +#ifdef FBDEV + vout_fbdev_finish(); +#else free(g_screen_ptr); - sndout_oss_exit(); +#endif } /* misc */ -int mp3_get_bitrate(FILE *f, int size) +int mp3_get_bitrate(void *f, int size) { return 128; } -void mp3_start_play(FILE *f, int pos) +void mp3_start_play(void *f, int pos) { } @@ -341,13 +366,20 @@ void mp3_update(int *buffer, int length, int stereo) { } -/* lprintf */ -void lprintf(const char *fmt, ...) -{ - va_list vl; +#include - va_start(vl, fmt); - vprintf(fmt, vl); - va_end(vl); -} +struct in_default_bind in_evdev_defbinds[] = +{ + /* MXYZ SACB RLDU */ + { KEY_UP, IN_BINDTYPE_PLAYER12, 0 }, + { KEY_DOWN, IN_BINDTYPE_PLAYER12, 1 }, + { KEY_LEFT, IN_BINDTYPE_PLAYER12, 2 }, + { KEY_RIGHT, IN_BINDTYPE_PLAYER12, 3 }, + { KEY_S, IN_BINDTYPE_PLAYER12, 4 }, /* B */ + { KEY_D, IN_BINDTYPE_PLAYER12, 5 }, /* C */ + { KEY_A, IN_BINDTYPE_PLAYER12, 6 }, /* A */ + { KEY_ENTER, IN_BINDTYPE_PLAYER12, 7 }, + { KEY_BACKSLASH, IN_BINDTYPE_EMU, PEVB_MENU }, + { 0, 0, 0 } +};