Added raw fbdev/evdev/ALSA render backend

This commit is contained in:
Michael Pavone committed 2019-03-10 21:30:09 -07:00
1 parent 05486c5829
commit a87a964939
5 files changed
+2087 -3

No files matched your search

+19 -2
View File
@@ -38,12 +38,21 @@ ifeq ($(OS),Darwin)
LIBS=sdl2 glew
FONT:=nuklear_ui/font_mac.o
else
ifdef USE_FBDEV
LIBS=alsa
ifndef NOGL
LIBS+=glesv2 egl
endif
CFLAGS+= -DUSE_GLES -DUSE_FBDEV -pthread
else
ifdef USE_GLES
LIBS=sdl2 glesv2
CFLAGS+= -DUSE_GLES
else
LIBS=sdl2 glew gl
endif #USE_GLES
endif #USE_FBDEV
FONT:=nuklear_ui/font.o
endif #Darwin
@@ -88,6 +97,9 @@ LDFLAGS:=-lm
else
CFLAGS:=$(shell pkg-config --cflags-only-I $(LIBS)) $(CFLAGS)
LDFLAGS:=-lm $(shell pkg-config --libs $(LIBS))
ifdef USE_FBDEV
LDFLAGS+= -pthread
endif
endif #libblastem.so
ifeq ($(OS),Darwin)
@@ -168,8 +180,13 @@ Z80OBJS=z80inst.o z80_to_x86.o
endif
AUDIOOBJS=ym2612.o psg.o wave.o
CONFIGOBJS=config.o tern.o util.o paths.o
NUKLEAROBJS=$(FONT) nuklear_ui/blastem_nuklear.o nuklear_ui/sfnt.o controller_info.o
RENDEROBJS=render_sdl.o ppm.o
NUKLEAROBJS=$(FONT) nuklear_ui/blastem_nuklear.o nuklear_ui/sfnt.o
RENDEROBJS=ppm.o controller_info.o
ifdef USE_FBDEV
RENDEROBJS+= render_fbdev.o
else
RENDEROBJS+= render_sdl.o
endif
ifdef NOZLIB
CFLAGS+= -DDISABLE_ZLIB
+23 -1
View File
@@ -1,5 +1,8 @@
#include <string.h>
#include <stdlib.h>
#ifndef USE_FBDEV
#include "render_sdl.h"
#endif
#include "controller_info.h"
#include "config.h"
#include "util.h"
@@ -70,6 +73,7 @@ static void load_ctype_config(void)
controller_info get_controller_info(int joystick)
{
#ifndef USE_FBDEV
load_ctype_config();
char guid_string[33];
SDL_Joystick *stick = render_get_joystick(joystick);
@@ -148,6 +152,9 @@ controller_info get_controller_info(int joystick)
return res;
}
}
#else
const char *name = "Unknown";
#endif
//default to a 360
return (controller_info){
.type = TYPE_GENERIC_MAPPING,
@@ -159,6 +166,7 @@ controller_info get_controller_info(int joystick)
static void mappings_iter(char *key, tern_val val, uint8_t valtype, void *data)
{
#ifndef USE_FBDEV
if (valtype != TVAL_NODE) {
return;
}
@@ -169,6 +177,7 @@ static void mappings_iter(char *key, tern_val val, uint8_t valtype, void *data)
SDL_GameControllerAddMapping(full);
free(full);
}
#endif
}
void controller_add_mappings(void)
@@ -181,6 +190,7 @@ void controller_add_mappings(void)
void save_controller_info(int joystick, controller_info *info)
{
#ifndef USE_FBDEV
char guid_string[33];
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(render_get_joystick(joystick)), guid_string, sizeof(guid_string));
tern_node *existing = tern_find_node(info_config, guid_string);
@@ -188,17 +198,19 @@ void save_controller_info(int joystick, controller_info *info)
existing = tern_insert_ptr(existing, "variant", (void *)variant_names[info->variant]);
info_config = tern_insert_node(info_config, guid_string, existing);
persist_config_at(info_config, "controller_types.cfg");
#endif
}
void save_controller_mapping(int joystick, char *mapping_string)
{
#ifndef USE_FBDEV
char guid_string[33];
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(render_get_joystick(joystick)), guid_string, sizeof(guid_string));
tern_node *existing = tern_find_node(info_config, guid_string);
existing = tern_insert_ptr(existing, "mapping", mapping_string);
info_config = tern_insert_node(info_config, guid_string, existing);
persist_config_at(info_config, "controller_types.cfg");
#endif
}
char const *labels_xbox[] = {
@@ -255,10 +267,12 @@ static const char** label_source(controller_info *info)
const char *get_button_label(controller_info *info, int button)
{
#ifndef USE_FBDEV
if (button >= SDL_CONTROLLER_BUTTON_DPAD_UP) {
static char const * dirs[] = {"Up", "Down", "Left", "Right"};
return dirs[button - SDL_CONTROLLER_BUTTON_DPAD_UP];
}
#endif
return label_source(info)[button];
}
@@ -267,11 +281,15 @@ static char const *axis_labels[] = {
};
const char *get_axis_label(controller_info *info, int axis)
{
#ifndef USE_FBDEV
if (axis < SDL_CONTROLLER_AXIS_TRIGGERLEFT) {
return axis_labels[axis];
} else {
return label_source(info)[axis - SDL_CONTROLLER_AXIS_TRIGGERLEFT + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER + 1];
}
#else
return NULL;
#endif
}
char *make_controller_type_key(controller_info *info)
@@ -316,6 +334,9 @@ char *make_human_readable_type_name(controller_info *info)
prefix = "Normal ";
} else {
static const char *parts[] = {"6 button (", NULL, "/", NULL, ") "};
#ifdef USE_FBDEV
parts[1] = parts[3] = "??";
#else
if (info->variant == VARIANT_6B_BUMPERS) {
parts[1] = get_button_label(info, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
parts[3] = get_button_label(info, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
@@ -323,6 +344,7 @@ char *make_human_readable_type_name(controller_info *info)
parts[1] = get_button_label(info, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
parts[3] = get_axis_label(info, SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
}
#endif
prefix = alloc_concat_m(5, parts);
}
char *ret = alloc_concat(prefix, base);
+5
View File
@@ -7,6 +7,10 @@
#define RENDER_H_
#ifndef IS_LIB
#ifdef USE_FBDEV
#include "special_keys_evdev.h"
#define render_relative_mouse(V)
#else
#include <SDL.h>
#define RENDERKEY_UP SDLK_UP
#define RENDERKEY_DOWN SDLK_DOWN
@@ -62,6 +66,7 @@
#define RENDER_DPAD_RIGHT SDL_HAT_RIGHT
#define render_relative_mouse SDL_SetRelativeMouseMode
#endif
#endif
#define MAX_JOYSTICKS 8
#define MAX_MICE 8
Executable
+1981
View File
File diff suppressed because it is too large. Load diff
+59
View File
@@ -0,0 +1,59 @@
#ifndef SPECIAL_KEYS_EVDEV_H_
#define SPECIAL_KEYS_EVDEV_H_
enum {
RENDERKEY_DOWN = 128,
RENDERKEY_UP,
RENDERKEY_LEFT,
RENDERKEY_RIGHT,
RENDERKEY_ESC,
RENDERKEY_DEL,
RENDERKEY_LSHIFT,
RENDERKEY_RSHIFT,
RENDERKEY_LCTRL,
RENDERKEY_RCTRL,
RENDERKEY_LALT,
RENDERKEY_RALT,
RENDERKEY_HOME,
RENDERKEY_END,
RENDERKEY_PAGEUP,
RENDERKEY_PAGEDOWN,
RENDERKEY_F1,
RENDERKEY_F2,
RENDERKEY_F3,
RENDERKEY_F4,
RENDERKEY_F5,
RENDERKEY_F6,
RENDERKEY_F7,
RENDERKEY_F8,
RENDERKEY_F9,
RENDERKEY_F10,
RENDERKEY_F11,
RENDERKEY_F12,
RENDERKEY_SELECT,
RENDERKEY_PLAY,
RENDERKEY_SEARCH,
RENDERKEY_BACK,
RENDERKEY_NP0,
RENDERKEY_NP1,
RENDERKEY_NP2,
RENDERKEY_NP3,
RENDERKEY_NP4,
RENDERKEY_NP5,
RENDERKEY_NP6,
RENDERKEY_NP7,
RENDERKEY_NP8,
RENDERKEY_NP9,
RENDERKEY_NP_DIV,
RENDERKEY_NP_MUL,
RENDERKEY_NP_MIN,
RENDERKEY_NP_PLUS,
RENDERKEY_NP_ENTER,
RENDERKEY_NP_STOP,
RENDER_DPAD_UP,
RENDER_DPAD_DOWN,
RENDER_DPAD_LEFT,
RENDER_DPAD_RIGHT
};
#endif //SPECIAL_KEYS_EVDEV_H_