mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
start new makefile, migrate to libpicofe
This commit is contained in:
parent
4685e5a10e
commit
e743be2070
47 changed files with 246 additions and 6342 deletions
|
@ -1,26 +0,0 @@
|
|||
@ vim:filetype=armasm
|
||||
#include <sys/syscall.h>
|
||||
|
||||
|
||||
.global cache_flush_d_inval_i @ const void *start_addr, const void *end_addr
|
||||
|
||||
cache_flush_d_inval_i:
|
||||
mov r2, #0
|
||||
#ifdef __ARM_EABI__
|
||||
/* EABI version */
|
||||
str r7, [sp, #-4]!
|
||||
mov r7, #(__ARM_NR_cacheflush & 0xff)
|
||||
#if (__ARM_NR_cacheflush & 0x00ff00)
|
||||
orr r7, r7, #(__ARM_NR_cacheflush & 0x00ff00)
|
||||
#endif
|
||||
#if (__ARM_NR_cacheflush & 0xff0000)
|
||||
orr r7, r7, #(__ARM_NR_cacheflush & 0xff0000)
|
||||
#endif
|
||||
swi 0
|
||||
ldr r7, [sp], #4
|
||||
#else
|
||||
/* OABI */
|
||||
swi __ARM_NR_cacheflush
|
||||
#endif
|
||||
bx lr
|
||||
|
|
@ -1 +0,0 @@
|
|||
extern void cache_flush_d_inval_i(const void *start_addr, const void *end_addr);
|
|
@ -1,6 +1,3 @@
|
|||
ifneq ($(DEBUG),)
|
||||
CFLAGS += -ggdb
|
||||
endif
|
||||
ifeq "$(profile)" "1"
|
||||
CFLAGS += -fprofile-generate
|
||||
endif
|
||||
|
@ -120,35 +117,28 @@ DIRS += platform platform/common pico pico/cd pico/pico pico/32x pico/sound pico
|
|||
@echo ">>>" $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean_prof:
|
||||
find ../.. -name '*.gcno' -delete
|
||||
find ../.. -name '*.gcda' -delete
|
||||
|
||||
mkdirs:
|
||||
mkdir -p $(DIRS)
|
||||
|
||||
../../tools/textfilter: ../../tools/textfilter.c
|
||||
make -C ../../tools/ textfilter
|
||||
tools/textfilter: tools/textfilter.c
|
||||
make -C tools/ textfilter
|
||||
|
||||
|
||||
# random deps
|
||||
pico/carthw/svp/compiler.o : ../../cpu/drc/emit_$(ARCH).c
|
||||
cpu/sh2/compiler.o : ../../cpu/drc/emit_$(ARCH).c
|
||||
cpu/sh2/mame/sh2pico.o : ../../cpu/sh2/mame/sh2.c
|
||||
pico/pico.o pico/cd/pico.o : ../../pico/pico_cmn.c ../../pico/pico_int.h
|
||||
pico/memory.o pico/cd/memory.o : ../../pico/pico_int.h ../../pico/memory.h
|
||||
pico/carthw/svp/compiler.o : cpu/drc/emit_$(ARCH).c
|
||||
cpu/sh2/compiler.o : cpu/drc/emit_$(ARCH).c
|
||||
cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c
|
||||
pico/pico.o pico/cd/pico.o : pico/pico_cmn.c pico/pico_int.h
|
||||
pico/memory.o pico/cd/memory.o : pico/pico_int.h pico/memory.h
|
||||
|
||||
../../cpu/musashi/m68kops.c :
|
||||
@make -C ../../cpu/musashi
|
||||
cpu/musashi/m68kops.c :
|
||||
@make -C cpu/musashi
|
||||
|
||||
../../cpu/mz80/mz80.asm :
|
||||
@make -C ../../cpu/mz80/
|
||||
|
||||
cpu/fame/famec.o : ../../cpu/fame/famec.c ../../cpu/fame/famec_opcodes.h
|
||||
cpu/fame/famec.o : cpu/fame/famec.c cpu/fame/famec_opcodes.h
|
||||
@echo ">>>" $<
|
||||
$(CC) $(CFLAGS) -Wno-unused -c $< -o $@
|
||||
|
||||
../../cpu/Cyclone/proj/Cyclone.s:
|
||||
cpu/Cyclone/proj/Cyclone.s:
|
||||
@echo building Cyclone...
|
||||
@make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h
|
||||
@make -C cpu/Cyclone/proj CONFIG_FILE=config_pico.h
|
||||
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
#ifdef __EPOC32__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../libpicofe/input.h"
|
||||
#include "../libpicofe/plat.h"
|
||||
#include "../libpicofe/lprintf.h"
|
||||
#include "config.h"
|
||||
#include "plat.h"
|
||||
#include "input.h"
|
||||
#include "lprintf.h"
|
||||
|
||||
static char *mystrip(char *str);
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_pico.h"
|
||||
#include "emu.h"
|
||||
#include <pico/pico.h>
|
||||
|
|
|
@ -10,14 +10,15 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "../libpicofe/posix.h"
|
||||
#include "../libpicofe/input.h"
|
||||
#include "../libpicofe/fonts.h"
|
||||
#include "../libpicofe/lprintf.h"
|
||||
#include "../libpicofe/plat.h"
|
||||
#include "emu.h"
|
||||
#include "menu.h"
|
||||
#include "fonts.h"
|
||||
#include "lprintf.h"
|
||||
#include "input_pico.h"
|
||||
#include "menu_pico.h"
|
||||
#include "config.h"
|
||||
#include "plat.h"
|
||||
#include "input.h"
|
||||
#include "posix.h"
|
||||
|
||||
#include <pico/pico_int.h>
|
||||
#include <pico/patch.h>
|
||||
|
@ -184,7 +185,7 @@ static int find_bios(int region, char **bios_file)
|
|||
} else {
|
||||
sprintf(static_buff, "no %s BIOS files found, read docs",
|
||||
region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");
|
||||
me_update_msg(static_buff);
|
||||
menu_update_msg(static_buff);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -510,32 +511,32 @@ int emu_reload_rom(char *rom_fname)
|
|||
int dummy;
|
||||
FILE *movie_file = fopen(rom_fname, "rb");
|
||||
if (!movie_file) {
|
||||
me_update_msg("Failed to open movie.");
|
||||
menu_update_msg("Failed to open movie.");
|
||||
return 0;
|
||||
}
|
||||
fseek(movie_file, 0, SEEK_END);
|
||||
movie_size = ftell(movie_file);
|
||||
fseek(movie_file, 0, SEEK_SET);
|
||||
if (movie_size < 64+3) {
|
||||
me_update_msg("Invalid GMV file.");
|
||||
menu_update_msg("Invalid GMV file.");
|
||||
fclose(movie_file);
|
||||
return 0;
|
||||
}
|
||||
movie_data = malloc(movie_size);
|
||||
if (movie_data == NULL) {
|
||||
me_update_msg("low memory.");
|
||||
menu_update_msg("low memory.");
|
||||
fclose(movie_file);
|
||||
return 0;
|
||||
}
|
||||
dummy = fread(movie_data, 1, movie_size, movie_file);
|
||||
fclose(movie_file);
|
||||
if (strncmp((char *)movie_data, "Gens Movie TEST", 15) != 0) {
|
||||
me_update_msg("Invalid GMV file.");
|
||||
menu_update_msg("Invalid GMV file.");
|
||||
return 0;
|
||||
}
|
||||
dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);
|
||||
if (!dummy) {
|
||||
me_update_msg("Could't find a ROM for movie.");
|
||||
menu_update_msg("Could't find a ROM for movie.");
|
||||
return 0;
|
||||
}
|
||||
get_ext(rom_fname, ext);
|
||||
|
@ -547,7 +548,7 @@ int emu_reload_rom(char *rom_fname)
|
|||
PicoPatchLoad(rom_fname);
|
||||
dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);
|
||||
if (!dummy) {
|
||||
me_update_msg("Could't find a ROM to patch.");
|
||||
menu_update_msg("Could't find a ROM to patch.");
|
||||
return 0;
|
||||
}
|
||||
get_ext(rom_fname, ext);
|
||||
|
@ -555,7 +556,7 @@ int emu_reload_rom(char *rom_fname)
|
|||
|
||||
media_type = detect_media(rom_fname);
|
||||
if (media_type == PM_BAD) {
|
||||
me_update_msg("Not a ROM/CD img selected.");
|
||||
menu_update_msg("Not a ROM/CD img selected.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -590,7 +591,7 @@ int emu_reload_rom(char *rom_fname)
|
|||
PicoAHW |= PAHW_MCD;
|
||||
}
|
||||
else {
|
||||
me_update_msg("Invalid CD image");
|
||||
menu_update_msg("Invalid CD image");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -601,7 +602,7 @@ int emu_reload_rom(char *rom_fname)
|
|||
|
||||
rom = pm_open(used_rom_name);
|
||||
if (rom == NULL) {
|
||||
me_update_msg("Failed to open ROM");
|
||||
menu_update_msg("Failed to open ROM");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -611,9 +612,9 @@ int emu_reload_rom(char *rom_fname)
|
|||
ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoAHW & PAHW_SMS) ? 1 : 0);
|
||||
pm_close(rom);
|
||||
if (ret != 0) {
|
||||
if (ret == 2) me_update_msg("Out of memory");
|
||||
else if (ret == 3) me_update_msg("Read failed");
|
||||
else me_update_msg("PicoCartLoad() failed.");
|
||||
if (ret == 2) menu_update_msg("Out of memory");
|
||||
else if (ret == 3) menu_update_msg("Read failed");
|
||||
else menu_update_msg("PicoCartLoad() failed.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -629,7 +630,7 @@ int emu_reload_rom(char *rom_fname)
|
|||
}
|
||||
|
||||
if (bad_rom) {
|
||||
me_update_msg("Bad ROM detected.");
|
||||
menu_update_msg("Bad ROM detected.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -643,7 +644,7 @@ int emu_reload_rom(char *rom_fname)
|
|||
|
||||
emu_make_path(static_buff, "carthw.cfg", sizeof(static_buff));
|
||||
if (PicoCartInsert(rom_data, rom_size, static_buff)) {
|
||||
me_update_msg("Failed to load ROM.");
|
||||
menu_update_msg("Failed to load ROM.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -653,7 +654,7 @@ int emu_reload_rom(char *rom_fname)
|
|||
if (ret != 0) {
|
||||
PicoCartUnload();
|
||||
rom_data = NULL; // freed by unload
|
||||
me_update_msg("Insert_CD() failed, invalid CD image?");
|
||||
menu_update_msg("Insert_CD() failed, invalid CD image?");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -716,7 +717,7 @@ int emu_swap_cd(const char *fname)
|
|||
if (cd_type != CIT_NOT_CD)
|
||||
ret = Insert_CD(fname, cd_type);
|
||||
if (ret != 0) {
|
||||
me_update_msg("Load failed, invalid CD image?");
|
||||
menu_update_msg("Load failed, invalid CD image?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,6 +149,34 @@ void emu_status_msg(const char *format, ...);
|
|||
/* used by some (but not all) platforms */
|
||||
void emu_cmn_forced_frame(int no_scale, int do_emu);
|
||||
|
||||
/* stuff to be implemented by platform code */
|
||||
extern const char *renderer_names[];
|
||||
extern const char *renderer_names32x[];
|
||||
|
||||
void pemu_prep_defconfig(void);
|
||||
void pemu_validate_config(void);
|
||||
void pemu_loop_prep(void);
|
||||
void pemu_loop_end(void);
|
||||
void pemu_forced_frame(int no_scale, int do_emu); // ..to g_menubg_src_ptr
|
||||
void pemu_finalize_frame(const char *fps, const char *notice_msg);
|
||||
|
||||
void pemu_sound_start(void);
|
||||
void pemu_sound_stop(void);
|
||||
void pemu_sound_wait(void);
|
||||
|
||||
void plat_early_init(void);
|
||||
void plat_init(void);
|
||||
void plat_finish(void);
|
||||
|
||||
/* used before things blocking for a while (these funcs redraw on return) */
|
||||
void plat_status_msg_busy_first(const char *msg);
|
||||
void plat_status_msg_busy_next(const char *msg);
|
||||
void plat_status_msg_clear(void);
|
||||
|
||||
void plat_video_toggle_renderer(int change, int menu_call);
|
||||
|
||||
void plat_update_volume(int has_changed, int is_up);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
|
|
@ -1,218 +0,0 @@
|
|||
unsigned char fontdata8x8[64*16] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x3C,0x42,0x99,0xBD,0xBD,0x99,0x42,0x3C,0x3C,0x42,0x81,0x81,0x81,0x81,0x42,0x3C,
|
||||
0xFE,0x82,0x8A,0xD2,0xA2,0x82,0xFE,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x64,0x74,0x7C,0x38,0x00,0x00,
|
||||
0x80,0xC0,0xF0,0xFC,0xF0,0xC0,0x80,0x00,0x01,0x03,0x0F,0x3F,0x0F,0x03,0x01,0x00,
|
||||
0x18,0x3C,0x7E,0x18,0x7E,0x3C,0x18,0x00,0xEE,0xEE,0xEE,0xCC,0x00,0xCC,0xCC,0x00,
|
||||
0x00,0x00,0x30,0x68,0x78,0x30,0x00,0x00,0x00,0x38,0x64,0x74,0x7C,0x38,0x00,0x00,
|
||||
0x3C,0x66,0x7A,0x7A,0x7E,0x7E,0x3C,0x00,0x0E,0x3E,0x3A,0x22,0x26,0x6E,0xE4,0x40,
|
||||
0x18,0x3C,0x7E,0x3C,0x3C,0x3C,0x3C,0x00,0x3C,0x3C,0x3C,0x3C,0x7E,0x3C,0x18,0x00,
|
||||
0x08,0x7C,0x7E,0x7E,0x7C,0x08,0x00,0x00,0x10,0x3E,0x7E,0x7E,0x3E,0x10,0x00,0x00,
|
||||
0x58,0x2A,0xDC,0xC8,0xDC,0x2A,0x58,0x00,0x24,0x66,0xFF,0xFF,0x66,0x24,0x00,0x00,
|
||||
0x00,0x10,0x10,0x38,0x38,0x7C,0xFE,0x00,0xFE,0x7C,0x38,0x38,0x10,0x10,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x18,0x00,0x18,0x18,0x00,
|
||||
0x6C,0x6C,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x7C,0x28,0x7C,0x28,0x00,0x00,
|
||||
0x10,0x38,0x60,0x38,0x0C,0x78,0x10,0x00,0x40,0xA4,0x48,0x10,0x24,0x4A,0x04,0x00,
|
||||
0x18,0x34,0x18,0x3A,0x6C,0x66,0x3A,0x00,0x18,0x18,0x20,0x00,0x00,0x00,0x00,0x00,
|
||||
0x30,0x60,0x60,0x60,0x60,0x60,0x30,0x00,0x0C,0x06,0x06,0x06,0x06,0x06,0x0C,0x00,
|
||||
0x10,0x54,0x38,0x7C,0x38,0x54,0x10,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x04,0x08,0x10,0x20,0x40,0x00,0x00,
|
||||
0x38,0x4C,0xC6,0xC6,0xC6,0x64,0x38,0x00,0x18,0x38,0x18,0x18,0x18,0x18,0x7E,0x00,
|
||||
0x7C,0xC6,0x0E,0x3C,0x78,0xE0,0xFE,0x00,0x7E,0x0C,0x18,0x3C,0x06,0xC6,0x7C,0x00,
|
||||
0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x0C,0x00,0xFC,0xC0,0xFC,0x06,0x06,0xC6,0x7C,0x00,
|
||||
0x3C,0x60,0xC0,0xFC,0xC6,0xC6,0x7C,0x00,0xFE,0xC6,0x0C,0x18,0x30,0x30,0x30,0x00,
|
||||
0x78,0xC4,0xE4,0x78,0x86,0x86,0x7C,0x00,0x7C,0xC6,0xC6,0x7E,0x06,0x0C,0x78,0x00,
|
||||
0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x18,0x30,
|
||||
0x1C,0x38,0x70,0xE0,0x70,0x38,0x1C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00,
|
||||
0x70,0x38,0x1C,0x0E,0x1C,0x38,0x70,0x00,0x7C,0xC6,0xC6,0x1C,0x18,0x00,0x18,0x00,
|
||||
0x3C,0x42,0x99,0xA1,0xA5,0x99,0x42,0x3C,0x38,0x6C,0xC6,0xC6,0xFE,0xC6,0xC6,0x00,
|
||||
0xFC,0xC6,0xC6,0xFC,0xC6,0xC6,0xFC,0x00,0x3C,0x66,0xC0,0xC0,0xC0,0x66,0x3C,0x00,
|
||||
0xF8,0xCC,0xC6,0xC6,0xC6,0xCC,0xF8,0x00,0xFE,0xC0,0xC0,0xFC,0xC0,0xC0,0xFE,0x00,
|
||||
0xFE,0xC0,0xC0,0xFC,0xC0,0xC0,0xC0,0x00,0x3E,0x60,0xC0,0xCE,0xC6,0x66,0x3E,0x00,
|
||||
0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0x00,0x7E,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,
|
||||
0x06,0x06,0x06,0x06,0xC6,0xC6,0x7C,0x00,0xC6,0xCC,0xD8,0xF0,0xF8,0xDC,0xCE,0x00,
|
||||
0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0x00,
|
||||
0xC6,0xE6,0xF6,0xFE,0xDE,0xCE,0xC6,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,
|
||||
0xFC,0xC6,0xC6,0xC6,0xFC,0xC0,0xC0,0x00,0x7C,0xC6,0xC6,0xC6,0xDE,0xCC,0x7A,0x00,
|
||||
0xFC,0xC6,0xC6,0xCE,0xF8,0xDC,0xCE,0x00,0x78,0xCC,0xC0,0x7C,0x06,0xC6,0x7C,0x00,
|
||||
0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,
|
||||
0xC6,0xC6,0xC6,0xEE,0x7C,0x38,0x10,0x00,0xC6,0xC6,0xD6,0xFE,0xFE,0xEE,0xC6,0x00,
|
||||
0xC6,0xEE,0x3C,0x38,0x7C,0xEE,0xC6,0x00,0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x00,
|
||||
0xFE,0x0E,0x1C,0x38,0x70,0xE0,0xFE,0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,
|
||||
0x60,0x60,0x30,0x18,0x0C,0x06,0x06,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,
|
||||
0x18,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
|
||||
0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x06,0x3E,0x66,0x66,0x3C,0x00,
|
||||
0x60,0x7C,0x66,0x66,0x66,0x66,0x7C,0x00,0x00,0x3C,0x66,0x60,0x60,0x66,0x3C,0x00,
|
||||
0x06,0x3E,0x66,0x66,0x66,0x66,0x3E,0x00,0x00,0x3C,0x66,0x66,0x7E,0x60,0x3C,0x00,
|
||||
0x1C,0x30,0x78,0x30,0x30,0x30,0x30,0x00,0x00,0x3E,0x66,0x66,0x66,0x3E,0x06,0x3C,
|
||||
0x60,0x7C,0x76,0x66,0x66,0x66,0x66,0x00,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x00,
|
||||
0x0C,0x00,0x1C,0x0C,0x0C,0x0C,0x0C,0x38,0x60,0x60,0x66,0x6C,0x78,0x6C,0x66,0x00,
|
||||
0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0xEC,0xFE,0xFE,0xFE,0xD6,0xC6,0x00,
|
||||
0x00,0x7C,0x76,0x66,0x66,0x66,0x66,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x3C,0x00,
|
||||
0x00,0x7C,0x66,0x66,0x66,0x7C,0x60,0x60,0x00,0x3E,0x66,0x66,0x66,0x3E,0x06,0x06,
|
||||
0x00,0x7E,0x70,0x60,0x60,0x60,0x60,0x00,0x00,0x3C,0x60,0x3C,0x06,0x66,0x3C,0x00,
|
||||
0x30,0x78,0x30,0x30,0x30,0x30,0x1C,0x00,0x00,0x66,0x66,0x66,0x66,0x6E,0x3E,0x00,
|
||||
0x00,0x66,0x66,0x66,0x66,0x3C,0x18,0x00,0x00,0xC6,0xD6,0xFE,0xFE,0x7C,0x6C,0x00,
|
||||
0x00,0x66,0x3C,0x18,0x3C,0x66,0x66,0x00,0x00,0x66,0x66,0x66,0x66,0x3E,0x06,0x3C,
|
||||
0x00,0x7E,0x0C,0x18,0x30,0x60,0x7E,0x00,0x0E,0x18,0x0C,0x38,0x0C,0x18,0x0E,0x00,
|
||||
0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x70,0x18,0x30,0x1C,0x30,0x18,0x70,0x00,
|
||||
0x00,0x00,0x76,0xDC,0x00,0x00,0x00,0x00,0x10,0x28,0x10,0x54,0xAA,0x44,0x00,0x00,
|
||||
};
|
||||
|
||||
|
||||
/* The font is generated from Xorg clR5x8.bdf */
|
||||
/*
|
||||
COMMENT Copyright 1989 Dale Schumacher, dal@syntel.mn.org
|
||||
COMMENT 399 Beacon Ave.
|
||||
COMMENT St. Paul, MN 55104-3527
|
||||
COMMENT
|
||||
COMMENT Permission to use, copy, modify, and distribute this software and
|
||||
COMMENT its documentation for any purpose and without fee is hereby
|
||||
COMMENT granted, provided that the above copyright notice appear in all
|
||||
COMMENT copies and that both that copyright notice and this permission
|
||||
COMMENT notice appear in supporting documentation, and that the name of
|
||||
COMMENT Dale Schumacher not be used in advertising or publicity pertaining to
|
||||
COMMENT distribution of the software without specific, written prior
|
||||
COMMENT permission. Dale Schumacher makes no representations about the
|
||||
COMMENT suitability of this software for any purpose. It is provided "as
|
||||
COMMENT is" without express or implied warranty.
|
||||
COMMENT
|
||||
*/
|
||||
unsigned char fontdata6x8[256][8] = {
|
||||
{ 0x7c>>2, 0x44>>2, 0x7c>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0xff>>2, 0x7c>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x10>>2, 0x28>>2, 0x44>>2, 0x7c>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x78>>2, 0x44>>2, 0x78>>2, 0x44>>2, 0x78>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x38>>2, 0x44>>2, 0x40>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x78>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x78>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x7c>>2, 0x40>>2, 0x78>>2, 0x40>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x7c>>2, 0x40>>2, 0x78>>2, 0x40>>2, 0x40>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x3c>>2, 0x40>>2, 0x4c>>2, 0x44>>2, 0x3c>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x44>>2, 0x7c>>2, 0x44>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x38>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x1c>>2, 0x04>>2, 0x04>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x48>>2, 0x50>>2, 0x60>>2, 0x50>>2, 0x48>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x6c>>2, 0x54>>2, 0x54>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x64>>2, 0x54>>2, 0x4c>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x38>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x78>>2, 0x44>>2, 0x78>>2, 0x40>>2, 0x40>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x38>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x0c>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x78>>2, 0x44>>2, 0x78>>2, 0x50>>2, 0x4c>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x3c>>2, 0x40>>2, 0x38>>2, 0x04>>2, 0x78>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x7c>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x44>>2, 0x28>>2, 0x28>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x54>>2, 0x54>>2, 0x6c>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x28>>2, 0x10>>2, 0x28>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x28>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x7c>>2, 0x08>>2, 0x10>>2, 0x20>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0xe0>>2, 0x80>>2, 0xe0>>2, 0x8c>>2, 0xf0>>2, 0x10>>2, 0x10>>2, 0x0c>>2, },
|
||||
{ 0x00>>2, 0x10>>2, 0x38>>2, 0x7c>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x7c>>2, 0x38>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x10>>2, 0x18>>2, 0xfc>>2, 0x18>>2, 0x10>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x20>>2, 0x60>>2, 0xfc>>2, 0x60>>2, 0x20>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x00>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x28>>2, 0x28>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x28>>2, 0x7c>>2, 0x28>>2, 0x7c>>2, 0x28>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x3c>>2, 0x50>>2, 0x38>>2, 0x14>>2, 0x78>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x60>>2, 0x64>>2, 0x08>>2, 0x10>>2, 0x20>>2, 0x4c>>2, 0x0c>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x40>>2, 0x40>>2, 0x20>>2, 0x54>>2, 0x48>>2, 0x34>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x20>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x04>>2, 0x08>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x08>>2, 0x04>>2, 0x00>>2, },
|
||||
{ 0x40>>2, 0x20>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x20>>2, 0x40>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x10>>2, 0x54>>2, 0x38>>2, 0x54>>2, 0x10>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x10>>2, 0x10>>2, 0x7c>>2, 0x10>>2, 0x10>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x10>>2, 0x10>>2, 0x20>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x00>>2, 0x7c>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x04>>2, 0x04>>2, 0x08>>2, 0x08>>2, 0x10>>2, 0x10>>2, 0x20>>2, 0x20>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x4c>>2, 0x54>>2, 0x64>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x30>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x04>>2, 0x08>>2, 0x10>>2, 0x20>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x04>>2, 0x18>>2, 0x04>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x18>>2, 0x18>>2, 0x28>>2, 0x28>>2, 0x7c>>2, 0x08>>2, 0x1c>>2, 0x00>>2, },
|
||||
{ 0x7c>>2, 0x40>>2, 0x78>>2, 0x04>>2, 0x04>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x18>>2, 0x20>>2, 0x40>>2, 0x78>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x7c>>2, 0x44>>2, 0x04>>2, 0x08>>2, 0x08>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x44>>2, 0x3c>>2, 0x04>>2, 0x08>>2, 0x30>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x10>>2, 0x10>>2, 0x00>>2, 0x00>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x10>>2, 0x10>>2, 0x00>>2, 0x00>>2, 0x10>>2, 0x10>>2, 0x20>>2, },
|
||||
{ 0x00>>2, 0x0c>>2, 0x30>>2, 0xc0>>2, 0x30>>2, 0x0c>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x7c>>2, 0x00>>2, 0x7c>>2, 0x00>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0xc0>>2, 0x30>>2, 0x0c>>2, 0x30>>2, 0xc0>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x04>>2, 0x08>>2, 0x10>>2, 0x00>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x5c>>2, 0x5c>>2, 0x58>>2, 0x40>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x28>>2, 0x44>>2, 0x44>>2, 0x7c>>2, 0x44>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x78>>2, 0x44>>2, 0x44>>2, 0x78>>2, 0x44>>2, 0x44>>2, 0x78>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x70>>2, 0x48>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x48>>2, 0x70>>2, 0x00>>2, },
|
||||
{ 0x7c>>2, 0x40>>2, 0x40>>2, 0x78>>2, 0x40>>2, 0x40>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0x7c>>2, 0x40>>2, 0x40>>2, 0x78>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x40>>2, 0x4c>>2, 0x44>>2, 0x44>>2, 0x3c>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x44>>2, 0x44>>2, 0x7c>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x7c>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0x1c>>2, 0x04>>2, 0x04>>2, 0x04>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x48>>2, 0x50>>2, 0x60>>2, 0x50>>2, 0x48>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x40>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x6c>>2, 0x54>>2, 0x54>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x64>>2, 0x64>>2, 0x54>>2, 0x4c>>2, 0x4c>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x78>>2, 0x44>>2, 0x44>>2, 0x78>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x0c>>2, },
|
||||
{ 0x78>>2, 0x44>>2, 0x44>>2, 0x78>>2, 0x50>>2, 0x48>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x38>>2, 0x44>>2, 0x40>>2, 0x38>>2, 0x04>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x7c>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x44>>2, 0x44>>2, 0x28>>2, 0x28>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x44>>2, 0x44>>2, 0x54>>2, 0x54>>2, 0x6c>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x44>>2, 0x28>>2, 0x10>>2, 0x28>>2, 0x44>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x44>>2, 0x44>>2, 0x28>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x7c>>2, 0x04>>2, 0x08>>2, 0x10>>2, 0x20>>2, 0x40>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0x1c>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x1c>>2, 0x00>>2, },
|
||||
{ 0x20>>2, 0x20>>2, 0x10>>2, 0x10>>2, 0x08>>2, 0x08>>2, 0x04>>2, 0x04>>2, },
|
||||
{ 0x70>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x70>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x28>>2, 0x44>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0xfc>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x08>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x3c>>2, 0x44>>2, 0x44>>2, 0x4c>>2, 0x34>>2, 0x00>>2, },
|
||||
{ 0x40>>2, 0x40>>2, 0x78>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x78>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x3c>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x3c>>2, 0x00>>2, },
|
||||
{ 0x04>>2, 0x04>>2, 0x3c>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x3c>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x38>>2, 0x44>>2, 0x7c>>2, 0x40>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x1c>>2, 0x20>>2, 0x78>>2, 0x20>>2, 0x20>>2, 0x20>>2, 0x20>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x3c>>2, 0x44>>2, 0x44>>2, 0x3c>>2, 0x04>>2, 0x38>>2, },
|
||||
{ 0x40>>2, 0x40>>2, 0x78>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x00>>2, 0x30>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x08>>2, 0x00>>2, 0x38>>2, 0x08>>2, 0x08>>2, 0x08>>2, 0x08>>2, 0x70>>2, },
|
||||
{ 0x40>>2, 0x40>>2, 0x48>>2, 0x50>>2, 0x60>>2, 0x50>>2, 0x48>>2, 0x00>>2, },
|
||||
{ 0x30>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x68>>2, 0x54>>2, 0x54>>2, 0x54>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x58>>2, 0x64>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x38>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x38>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x78>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x78>>2, 0x40>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x3c>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x3c>>2, 0x04>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x58>>2, 0x60>>2, 0x40>>2, 0x40>>2, 0x40>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x3c>>2, 0x40>>2, 0x38>>2, 0x04>>2, 0x78>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x10>>2, 0x7c>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x0c>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x4c>>2, 0x34>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x6c>>2, 0x28>>2, 0x28>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x54>>2, 0x54>>2, 0x54>>2, 0x28>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x28>>2, 0x10>>2, 0x28>>2, 0x44>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x44>>2, 0x44>>2, 0x44>>2, 0x3c>>2, 0x04>>2, 0x38>>2, },
|
||||
{ 0x00>>2, 0x00>>2, 0x7c>>2, 0x08>>2, 0x10>>2, 0x20>>2, 0x7c>>2, 0x00>>2, },
|
||||
{ 0x04>>2, 0x08>>2, 0x08>>2, 0x10>>2, 0x08>>2, 0x08>>2, 0x04>>2, 0x00>>2, },
|
||||
{ 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x10>>2, 0x00>>2, },
|
||||
{ 0x40>>2, 0x20>>2, 0x20>>2, 0x10>>2, 0x20>>2, 0x20>>2, 0x40>>2, 0x00>>2, },
|
||||
{ 0x20>>2, 0x54>>2, 0x08>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, 0x00>>2, },
|
||||
{ 0x00>>2, 0x10>>2, 0x10>>2, 0x28>>2, 0x28>>2, 0x44>>2, 0x7c>>2, 0x00>>2, },
|
||||
};
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
extern unsigned char fontdata8x8[64*16];
|
||||
extern unsigned char fontdata6x8[256-32][8];
|
||||
|
|
@ -1,467 +0,0 @@
|
|||
/*
|
||||
* (C) Gražvydas "notaz" Ignotas, 2012
|
||||
*
|
||||
* This work is licensed under the terms of any of these licenses
|
||||
* (at your option):
|
||||
* - GNU GPL, version 2 or later.
|
||||
* - GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <SDL.h>
|
||||
#include "input.h"
|
||||
#include "in_sdl.h"
|
||||
|
||||
#define IN_SDL_PREFIX "sdl:"
|
||||
/* should be machine word for best performace */
|
||||
typedef unsigned long keybits_t;
|
||||
#define KEYBITS_WORD_BITS (sizeof(keybits_t) * 8)
|
||||
|
||||
struct in_sdl_state {
|
||||
SDL_Joystick *joy;
|
||||
int joy_id;
|
||||
int axis_keydown[2];
|
||||
keybits_t keystate[SDLK_LAST / KEYBITS_WORD_BITS + 1];
|
||||
};
|
||||
|
||||
static const char * const in_sdl_keys[SDLK_LAST] = {
|
||||
[SDLK_BACKSPACE] = "backspace",
|
||||
[SDLK_TAB] = "tab",
|
||||
[SDLK_CLEAR] = "clear",
|
||||
[SDLK_RETURN] = "return",
|
||||
[SDLK_PAUSE] = "pause",
|
||||
[SDLK_ESCAPE] = "escape",
|
||||
[SDLK_SPACE] = "space",
|
||||
[SDLK_EXCLAIM] = "!",
|
||||
[SDLK_QUOTEDBL] = "\"",
|
||||
[SDLK_HASH] = "#",
|
||||
[SDLK_DOLLAR] = "$",
|
||||
[SDLK_AMPERSAND] = "&",
|
||||
[SDLK_QUOTE] = "'",
|
||||
[SDLK_LEFTPAREN] = "(",
|
||||
[SDLK_RIGHTPAREN] = ")",
|
||||
[SDLK_ASTERISK] = "*",
|
||||
[SDLK_PLUS] = "+",
|
||||
[SDLK_COMMA] = ",",
|
||||
[SDLK_MINUS] = "-",
|
||||
[SDLK_PERIOD] = ".",
|
||||
[SDLK_SLASH] = "/",
|
||||
[SDLK_0] = "0",
|
||||
[SDLK_1] = "1",
|
||||
[SDLK_2] = "2",
|
||||
[SDLK_3] = "3",
|
||||
[SDLK_4] = "4",
|
||||
[SDLK_5] = "5",
|
||||
[SDLK_6] = "6",
|
||||
[SDLK_7] = "7",
|
||||
[SDLK_8] = "8",
|
||||
[SDLK_9] = "9",
|
||||
[SDLK_COLON] = ":",
|
||||
[SDLK_SEMICOLON] = ",",
|
||||
[SDLK_LESS] = "<",
|
||||
[SDLK_EQUALS] = "=",
|
||||
[SDLK_GREATER] = ">",
|
||||
[SDLK_QUESTION] = "?",
|
||||
[SDLK_AT] = "@",
|
||||
[SDLK_LEFTBRACKET] = "[",
|
||||
[SDLK_BACKSLASH] = "\\",
|
||||
[SDLK_RIGHTBRACKET] = "]",
|
||||
[SDLK_CARET] = "^",
|
||||
[SDLK_UNDERSCORE] = "_",
|
||||
[SDLK_BACKQUOTE] = "`",
|
||||
[SDLK_a] = "a",
|
||||
[SDLK_b] = "b",
|
||||
[SDLK_c] = "c",
|
||||
[SDLK_d] = "d",
|
||||
[SDLK_e] = "e",
|
||||
[SDLK_f] = "f",
|
||||
[SDLK_g] = "g",
|
||||
[SDLK_h] = "h",
|
||||
[SDLK_i] = "i",
|
||||
[SDLK_j] = "j",
|
||||
[SDLK_k] = "k",
|
||||
[SDLK_l] = "l",
|
||||
[SDLK_m] = "m",
|
||||
[SDLK_n] = "n",
|
||||
[SDLK_o] = "o",
|
||||
[SDLK_p] = "p",
|
||||
[SDLK_q] = "q",
|
||||
[SDLK_r] = "r",
|
||||
[SDLK_s] = "s",
|
||||
[SDLK_t] = "t",
|
||||
[SDLK_u] = "u",
|
||||
[SDLK_v] = "v",
|
||||
[SDLK_w] = "w",
|
||||
[SDLK_x] = "x",
|
||||
[SDLK_y] = "y",
|
||||
[SDLK_z] = "z",
|
||||
[SDLK_DELETE] = "delete",
|
||||
|
||||
[SDLK_KP0] = "[0]",
|
||||
[SDLK_KP1] = "[1]",
|
||||
[SDLK_KP2] = "[2]",
|
||||
[SDLK_KP3] = "[3]",
|
||||
[SDLK_KP4] = "[4]",
|
||||
[SDLK_KP5] = "[5]",
|
||||
[SDLK_KP6] = "[6]",
|
||||
[SDLK_KP7] = "[7]",
|
||||
[SDLK_KP8] = "[8]",
|
||||
[SDLK_KP9] = "[9]",
|
||||
[SDLK_KP_PERIOD] = "[.]",
|
||||
[SDLK_KP_DIVIDE] = "[/]",
|
||||
[SDLK_KP_MULTIPLY] = "[*]",
|
||||
[SDLK_KP_MINUS] = "[-]",
|
||||
[SDLK_KP_PLUS] = "[+]",
|
||||
[SDLK_KP_ENTER] = "enter",
|
||||
[SDLK_KP_EQUALS] = "equals",
|
||||
|
||||
[SDLK_UP] = "up",
|
||||
[SDLK_DOWN] = "down",
|
||||
[SDLK_RIGHT] = "right",
|
||||
[SDLK_LEFT] = "left",
|
||||
[SDLK_DOWN] = "down",
|
||||
[SDLK_INSERT] = "insert",
|
||||
[SDLK_HOME] = "home",
|
||||
[SDLK_END] = "end",
|
||||
[SDLK_PAGEUP] = "page up",
|
||||
[SDLK_PAGEDOWN] = "page down",
|
||||
|
||||
[SDLK_F1] = "f1",
|
||||
[SDLK_F2] = "f2",
|
||||
[SDLK_F3] = "f3",
|
||||
[SDLK_F4] = "f4",
|
||||
[SDLK_F5] = "f5",
|
||||
[SDLK_F6] = "f6",
|
||||
[SDLK_F7] = "f7",
|
||||
[SDLK_F8] = "f8",
|
||||
[SDLK_F9] = "f9",
|
||||
[SDLK_F10] = "f10",
|
||||
[SDLK_F11] = "f11",
|
||||
[SDLK_F12] = "f12",
|
||||
[SDLK_F13] = "f13",
|
||||
[SDLK_F14] = "f14",
|
||||
[SDLK_F15] = "f15",
|
||||
|
||||
[SDLK_NUMLOCK] = "numlock",
|
||||
[SDLK_CAPSLOCK] = "caps lock",
|
||||
[SDLK_SCROLLOCK] = "scroll lock",
|
||||
[SDLK_RSHIFT] = "right shift",
|
||||
[SDLK_LSHIFT] = "left shift",
|
||||
[SDLK_RCTRL] = "right ctrl",
|
||||
[SDLK_LCTRL] = "left ctrl",
|
||||
[SDLK_RALT] = "right alt",
|
||||
[SDLK_LALT] = "left alt",
|
||||
[SDLK_RMETA] = "right meta",
|
||||
[SDLK_LMETA] = "left meta",
|
||||
[SDLK_LSUPER] = "left super", /* "Windows" keys */
|
||||
[SDLK_RSUPER] = "right super",
|
||||
[SDLK_MODE] = "alt gr",
|
||||
[SDLK_COMPOSE] = "compose",
|
||||
};
|
||||
|
||||
static void in_sdl_probe(void)
|
||||
{
|
||||
struct in_sdl_state *state;
|
||||
SDL_Joystick *joy;
|
||||
int i, joycount;
|
||||
char name[256];
|
||||
|
||||
state = calloc(1, sizeof(*state));
|
||||
if (state == NULL) {
|
||||
fprintf(stderr, "in_sdl: OOM\n");
|
||||
return;
|
||||
}
|
||||
|
||||
in_register(IN_SDL_PREFIX "keys", -1, state, SDLK_LAST,
|
||||
in_sdl_keys, 0);
|
||||
|
||||
/* joysticks go here too */
|
||||
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
|
||||
|
||||
joycount = SDL_NumJoysticks();
|
||||
for (i = 0; i < joycount; i++) {
|
||||
joy = SDL_JoystickOpen(i);
|
||||
if (joy == NULL)
|
||||
continue;
|
||||
|
||||
state = calloc(1, sizeof(*state));
|
||||
if (state == NULL) {
|
||||
fprintf(stderr, "in_sdl: OOM\n");
|
||||
break;
|
||||
}
|
||||
state->joy = joy;
|
||||
state->joy_id = i;
|
||||
|
||||
snprintf(name, sizeof(name), IN_SDL_PREFIX "%s", SDL_JoystickName(i));
|
||||
in_register(name, -1, state, SDLK_LAST, in_sdl_keys, 0);
|
||||
}
|
||||
|
||||
if (joycount > 0)
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
}
|
||||
|
||||
static void in_sdl_free(void *drv_data)
|
||||
{
|
||||
struct in_sdl_state *state = drv_data;
|
||||
|
||||
if (state != NULL) {
|
||||
if (state->joy != NULL)
|
||||
SDL_JoystickClose(state->joy);
|
||||
free(state);
|
||||
}
|
||||
}
|
||||
|
||||
static const char * const *
|
||||
in_sdl_get_key_names(int *count)
|
||||
{
|
||||
*count = SDLK_LAST;
|
||||
return in_sdl_keys;
|
||||
}
|
||||
|
||||
/* could use SDL_GetKeyState, but this gives better packing */
|
||||
static void update_keystate(keybits_t *keystate, int sym, int is_down)
|
||||
{
|
||||
keybits_t *ks_word, mask;
|
||||
|
||||
mask = 1;
|
||||
mask <<= sym & (KEYBITS_WORD_BITS - 1);
|
||||
ks_word = keystate + sym / KEYBITS_WORD_BITS;
|
||||
if (is_down)
|
||||
*ks_word |= mask;
|
||||
else
|
||||
*ks_word &= ~mask;
|
||||
}
|
||||
|
||||
static int handle_event(struct in_sdl_state *state, SDL_Event *event,
|
||||
int *kc_out, int *down_out)
|
||||
{
|
||||
if (event->type != SDL_KEYDOWN && event->type != SDL_KEYUP)
|
||||
return 0;
|
||||
|
||||
update_keystate(state->keystate, event->key.keysym.sym,
|
||||
event->type == SDL_KEYDOWN);
|
||||
if (kc_out != NULL)
|
||||
*kc_out = event->key.keysym.sym;
|
||||
if (down_out != NULL)
|
||||
*down_out = event->type == SDL_KEYDOWN;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int handle_joy_event(struct in_sdl_state *state, SDL_Event *event,
|
||||
int *kc_out, int *down_out)
|
||||
{
|
||||
int kc = -1, down = 0, ret = 0;
|
||||
|
||||
/* FIXME: should ckeck .which */
|
||||
/* TODO: remaining axis */
|
||||
switch (event->type) {
|
||||
case SDL_JOYAXISMOTION:
|
||||
if (event->jaxis.axis > 1)
|
||||
break;
|
||||
if (-16384 <= event->jaxis.value && event->jaxis.value <= 16384) {
|
||||
kc = state->axis_keydown[event->jaxis.axis];
|
||||
state->axis_keydown[event->jaxis.axis] = 0;
|
||||
ret = 1;
|
||||
}
|
||||
else if (event->jaxis.value < -16384) {
|
||||
kc = state->axis_keydown[event->jaxis.axis];
|
||||
if (kc)
|
||||
update_keystate(state->keystate, kc, 0);
|
||||
kc = event->jaxis.axis ? SDLK_UP : SDLK_LEFT;
|
||||
state->axis_keydown[event->jaxis.axis] = kc;
|
||||
down = 1;
|
||||
ret = 1;
|
||||
}
|
||||
else if (event->jaxis.value > 16384) {
|
||||
kc = state->axis_keydown[event->jaxis.axis];
|
||||
if (kc)
|
||||
update_keystate(state->keystate, kc, 0);
|
||||
kc = event->jaxis.axis ? SDLK_DOWN : SDLK_RIGHT;
|
||||
state->axis_keydown[event->jaxis.axis] = kc;
|
||||
down = 1;
|
||||
ret = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP:
|
||||
kc = (int)event->jbutton.button + SDLK_WORLD_0;
|
||||
down = event->jbutton.state == SDL_PRESSED;
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
update_keystate(state->keystate, kc, down);
|
||||
if (kc_out != NULL)
|
||||
*kc_out = kc;
|
||||
if (down_out != NULL)
|
||||
*down_out = down;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define JOY_EVENTS (SDL_JOYAXISMOTIONMASK | SDL_JOYBALLMOTIONMASK | SDL_JOYHATMOTIONMASK \
|
||||
| SDL_JOYBUTTONDOWNMASK | SDL_JOYBUTTONUPMASK)
|
||||
|
||||
static int collect_events(struct in_sdl_state *state, int *one_kc, int *one_down)
|
||||
{
|
||||
SDL_Event events[4];
|
||||
Uint32 mask = state->joy ? JOY_EVENTS : (SDL_ALLEVENTS & ~JOY_EVENTS);
|
||||
int count, maxcount;
|
||||
int i, ret, retval = 0;
|
||||
|
||||
maxcount = (one_kc != NULL) ? 1 : sizeof(events) / sizeof(events[0]);
|
||||
|
||||
SDL_PumpEvents();
|
||||
while (1) {
|
||||
count = SDL_PeepEvents(events, maxcount, SDL_GETEVENT, mask);
|
||||
if (count <= 0)
|
||||
break;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (state->joy)
|
||||
ret = handle_joy_event(state,
|
||||
&events[i], one_kc, one_down);
|
||||
else
|
||||
ret = handle_event(state,
|
||||
&events[i], one_kc, one_down);
|
||||
retval |= ret;
|
||||
if (one_kc != NULL && ret)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int in_sdl_update(void *drv_data, const int *binds, int *result)
|
||||
{
|
||||
struct in_sdl_state *state = drv_data;
|
||||
keybits_t mask;
|
||||
int i, sym, bit, b;
|
||||
|
||||
collect_events(state, NULL, NULL);
|
||||
|
||||
for (i = 0; i < SDLK_LAST / KEYBITS_WORD_BITS + 1; i++) {
|
||||
mask = state->keystate[i];
|
||||
if (mask == 0)
|
||||
continue;
|
||||
for (bit = 0; mask != 0; bit++, mask >>= 1) {
|
||||
if ((mask & 1) == 0)
|
||||
continue;
|
||||
sym = i * KEYBITS_WORD_BITS + bit;
|
||||
|
||||
for (b = 0; b < IN_BINDTYPE_COUNT; b++)
|
||||
result[b] |= binds[IN_BIND_OFFS(sym, b)];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int in_sdl_update_keycode(void *drv_data, int *is_down)
|
||||
{
|
||||
struct in_sdl_state *state = drv_data;
|
||||
int ret_kc = -1, ret_down = 0;
|
||||
|
||||
collect_events(state, &ret_kc, &ret_down);
|
||||
|
||||
if (is_down != NULL)
|
||||
*is_down = ret_down;
|
||||
|
||||
return ret_kc;
|
||||
}
|
||||
|
||||
struct menu_keymap {
|
||||
short key;
|
||||
short pbtn;
|
||||
};
|
||||
|
||||
static const struct menu_keymap key_pbtn_map[] =
|
||||
{
|
||||
{ SDLK_UP, PBTN_UP },
|
||||
{ SDLK_DOWN, PBTN_DOWN },
|
||||
{ SDLK_LEFT, PBTN_LEFT },
|
||||
{ SDLK_RIGHT, PBTN_RIGHT },
|
||||
/* XXX: maybe better set this from it's plat code somehow */
|
||||
{ SDLK_RETURN, PBTN_MOK },
|
||||
{ SDLK_ESCAPE, PBTN_MBACK },
|
||||
{ SDLK_a, PBTN_MA2 },
|
||||
{ SDLK_s, PBTN_MA3 },
|
||||
{ SDLK_BACKSLASH, PBTN_MENU },
|
||||
{ SDLK_LEFTBRACKET, PBTN_L },
|
||||
{ SDLK_RIGHTBRACKET, PBTN_R },
|
||||
};
|
||||
#define KEY_PBTN_MAP_SIZE (sizeof(key_pbtn_map) / sizeof(key_pbtn_map[0]))
|
||||
|
||||
static const struct menu_keymap joybtn_pbtn_map[] =
|
||||
{
|
||||
{ SDLK_UP, PBTN_UP },
|
||||
{ SDLK_DOWN, PBTN_DOWN },
|
||||
{ SDLK_LEFT, PBTN_LEFT },
|
||||
{ SDLK_RIGHT, PBTN_RIGHT },
|
||||
/* joystick */
|
||||
{ SDLK_WORLD_0, PBTN_MOK },
|
||||
{ SDLK_WORLD_1, PBTN_MBACK },
|
||||
{ SDLK_WORLD_2, PBTN_MA2 },
|
||||
{ SDLK_WORLD_3, PBTN_MA3 },
|
||||
};
|
||||
#define JOYBTN_PBTN_MAP_SIZE (sizeof(joybtn_pbtn_map) / sizeof(joybtn_pbtn_map[0]))
|
||||
|
||||
static int in_sdl_menu_translate(void *drv_data, int keycode, char *charcode)
|
||||
{
|
||||
struct in_sdl_state *state = drv_data;
|
||||
const struct menu_keymap *map;
|
||||
int map_len;
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
map = state->joy ? joybtn_pbtn_map : key_pbtn_map;
|
||||
map_len = state->joy ? JOYBTN_PBTN_MAP_SIZE : KEY_PBTN_MAP_SIZE;
|
||||
|
||||
if (keycode < 0)
|
||||
{
|
||||
/* menu -> kc */
|
||||
keycode = -keycode;
|
||||
for (i = 0; i < map_len; i++)
|
||||
if (map[i].pbtn == keycode)
|
||||
return map[i].key;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < map_len; i++) {
|
||||
if (map[i].key == keycode) {
|
||||
ret = map[i].pbtn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (charcode != NULL && (unsigned int)keycode < SDLK_LAST &&
|
||||
in_sdl_keys[keycode] != NULL && in_sdl_keys[keycode][1] == 0)
|
||||
{
|
||||
ret |= PBTN_CHAR;
|
||||
*charcode = in_sdl_keys[keycode][0];
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const in_drv_t in_sdl_drv = {
|
||||
.prefix = IN_SDL_PREFIX,
|
||||
.probe = in_sdl_probe,
|
||||
.free = in_sdl_free,
|
||||
.get_key_names = in_sdl_get_key_names,
|
||||
.update = in_sdl_update,
|
||||
.update_keycode = in_sdl_update_keycode,
|
||||
.menu_translate = in_sdl_menu_translate,
|
||||
};
|
||||
|
||||
void in_sdl_init(const struct in_default_bind *defbinds)
|
||||
{
|
||||
in_register_driver(&in_sdl_drv, defbinds);
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
struct in_default_bind;
|
||||
|
||||
void in_sdl_init(const struct in_default_bind *defbinds);
|
|
@ -1,991 +0,0 @@
|
|||
/*
|
||||
* (C) Gražvydas "notaz" Ignotas, 2008-2011
|
||||
*
|
||||
* This work is licensed under the terms of any of these licenses
|
||||
* (at your option):
|
||||
* - GNU GPL, version 2 or later.
|
||||
* - GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "input.h"
|
||||
#include "plat.h"
|
||||
#include "lprintf.h"
|
||||
|
||||
#ifdef IN_GP2X
|
||||
#error needs update: in_gp2x_init in_gp2x_update
|
||||
#include "../gp2x/in_gp2x.h"
|
||||
#endif
|
||||
#ifdef IN_VK
|
||||
#error needs update: in_vk_init in_vk_update
|
||||
#include "../win32/in_vk.h"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int drv_id;
|
||||
int drv_fd_hnd;
|
||||
void *drv_data;
|
||||
char *name;
|
||||
int key_count;
|
||||
int *binds; /* total = key_count * bindtypes * 2 */
|
||||
const char * const *key_names;
|
||||
unsigned int probed:1;
|
||||
unsigned int does_combos:1;
|
||||
} in_dev_t;
|
||||
|
||||
static in_drv_t *in_drivers;
|
||||
static in_dev_t in_devices[IN_MAX_DEVS];
|
||||
static int in_driver_count = 0;
|
||||
static int in_dev_count = 0; /* probed + bind devices */
|
||||
static int in_have_async_devs = 0;
|
||||
static int in_probe_dev_id;
|
||||
static int menu_key_state = 0;
|
||||
static int menu_last_used_dev = 0;
|
||||
|
||||
#define DRV(id) in_drivers[id]
|
||||
|
||||
|
||||
static int *in_alloc_binds(int drv_id, int key_count)
|
||||
{
|
||||
const struct in_default_bind *defbinds;
|
||||
int *binds;
|
||||
int i;
|
||||
|
||||
binds = calloc(key_count * IN_BINDTYPE_COUNT * 2, sizeof(binds[0]));
|
||||
if (binds == NULL)
|
||||
return NULL;
|
||||
|
||||
defbinds = DRV(drv_id).defbinds;
|
||||
if (defbinds != NULL) {
|
||||
for (i = 0; ; i++) {
|
||||
if (defbinds[i].bit == 0 && defbinds[i].code == 0)
|
||||
break;
|
||||
binds[IN_BIND_OFFS(defbinds[i].code, defbinds[i].btype)] =
|
||||
1 << defbinds[i].bit;
|
||||
}
|
||||
|
||||
/* always have a copy of defbinds */
|
||||
memcpy(binds + key_count * IN_BINDTYPE_COUNT, binds,
|
||||
sizeof(binds[0]) * key_count * IN_BINDTYPE_COUNT);
|
||||
}
|
||||
|
||||
return binds;
|
||||
}
|
||||
|
||||
static void in_unprobe(in_dev_t *dev)
|
||||
{
|
||||
if (dev->probed)
|
||||
DRV(dev->drv_id).free(dev->drv_data);
|
||||
dev->probed = 0;
|
||||
dev->drv_data = NULL;
|
||||
}
|
||||
|
||||
static void in_free(in_dev_t *dev)
|
||||
{
|
||||
in_unprobe(dev);
|
||||
free(dev->name);
|
||||
dev->name = NULL;
|
||||
free(dev->binds);
|
||||
dev->binds = NULL;
|
||||
}
|
||||
|
||||
/* to be called by drivers
|
||||
* async devices must set drv_fd_hnd to -1 */
|
||||
void in_register(const char *nname, int drv_fd_hnd, void *drv_data,
|
||||
int key_count, const char * const *key_names, int combos)
|
||||
{
|
||||
int i, ret, dupe_count = 0, *binds;
|
||||
char name[256], *name_end, *tmp;
|
||||
|
||||
strncpy(name, nname, sizeof(name));
|
||||
name[sizeof(name)-12] = 0;
|
||||
name_end = name + strlen(name);
|
||||
|
||||
for (i = 0; i < in_dev_count; i++)
|
||||
{
|
||||
if (in_devices[i].name == NULL)
|
||||
continue;
|
||||
if (strcmp(in_devices[i].name, name) == 0)
|
||||
{
|
||||
if (in_devices[i].probed) {
|
||||
dupe_count++;
|
||||
sprintf(name_end, " [%d]", dupe_count);
|
||||
continue;
|
||||
}
|
||||
goto update;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= IN_MAX_DEVS)
|
||||
{
|
||||
/* try to find unused device */
|
||||
for (i = 0; i < IN_MAX_DEVS; i++)
|
||||
if (!in_devices[i].probed) break;
|
||||
if (i >= IN_MAX_DEVS) {
|
||||
lprintf("input: too many devices, can't add %s\n", name);
|
||||
return;
|
||||
}
|
||||
in_free(&in_devices[i]);
|
||||
}
|
||||
|
||||
tmp = strdup(name);
|
||||
if (tmp == NULL)
|
||||
return;
|
||||
|
||||
binds = in_alloc_binds(in_probe_dev_id, key_count);
|
||||
if (binds == NULL) {
|
||||
free(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
in_devices[i].name = tmp;
|
||||
in_devices[i].binds = binds;
|
||||
in_devices[i].key_count = key_count;
|
||||
if (i + 1 > in_dev_count)
|
||||
in_dev_count = i + 1;
|
||||
|
||||
lprintf("input: new device #%d \"%s\"\n", i, name);
|
||||
update:
|
||||
in_devices[i].probed = 1;
|
||||
in_devices[i].does_combos = combos;
|
||||
in_devices[i].drv_id = in_probe_dev_id;
|
||||
in_devices[i].drv_fd_hnd = drv_fd_hnd;
|
||||
in_devices[i].key_names = key_names;
|
||||
in_devices[i].drv_data = drv_data;
|
||||
|
||||
if (in_devices[i].binds != NULL) {
|
||||
ret = DRV(in_probe_dev_id).clean_binds(drv_data, in_devices[i].binds,
|
||||
in_devices[i].binds + key_count * IN_BINDTYPE_COUNT);
|
||||
if (ret == 0) {
|
||||
/* no useable binds */
|
||||
free(in_devices[i].binds);
|
||||
in_devices[i].binds = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* key combo handling, to be called by drivers that support it.
|
||||
* Only care about IN_BINDTYPE_EMU */
|
||||
void in_combos_find(const int *binds, int last_key, int *combo_keys, int *combo_acts)
|
||||
{
|
||||
int act, u;
|
||||
|
||||
*combo_keys = *combo_acts = 0;
|
||||
for (act = 0; act < sizeof(binds[0]) * 8; act++)
|
||||
{
|
||||
int keyc = 0;
|
||||
for (u = 0; u <= last_key; u++)
|
||||
if (binds[IN_BIND_OFFS(u, IN_BINDTYPE_EMU)] & (1 << act))
|
||||
keyc++;
|
||||
|
||||
if (keyc > 1)
|
||||
{
|
||||
// loop again and mark those keys and actions as combo
|
||||
for (u = 0; u <= last_key; u++)
|
||||
{
|
||||
if (binds[IN_BIND_OFFS(u, IN_BINDTYPE_EMU)] & (1 << act)) {
|
||||
*combo_keys |= 1 << u;
|
||||
*combo_acts |= 1 << act;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int in_combos_do(int keys, const int *binds, int last_key, int combo_keys, int combo_acts)
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
for (i = 0; i <= last_key; i++)
|
||||
{
|
||||
int acts, acts_c, u;
|
||||
|
||||
if (!(keys & (1 << i)))
|
||||
continue;
|
||||
|
||||
acts = binds[IN_BIND_OFFS(i, IN_BINDTYPE_EMU)];
|
||||
if (!acts)
|
||||
continue;
|
||||
|
||||
if (!(combo_keys & (1 << i))) {
|
||||
ret |= acts;
|
||||
continue;
|
||||
}
|
||||
|
||||
acts_c = acts & combo_acts;
|
||||
u = last_key;
|
||||
if (acts_c) {
|
||||
// let's try to find the other one
|
||||
for (u = i + 1; u <= last_key; u++)
|
||||
if ( (keys & (1 << u)) && (binds[IN_BIND_OFFS(u, IN_BINDTYPE_EMU)] & acts_c) ) {
|
||||
ret |= acts_c & binds[IN_BIND_OFFS(u, IN_BINDTYPE_EMU)];
|
||||
keys &= ~((1 << i) | (1 << u));
|
||||
break;
|
||||
}
|
||||
}
|
||||
// add non-combo actions if combo ones were not found
|
||||
if (u >= last_key)
|
||||
ret |= acts & ~combo_acts;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void in_probe(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
in_have_async_devs = 0;
|
||||
menu_key_state = 0;
|
||||
menu_last_used_dev = 0;
|
||||
|
||||
for (i = 0; i < in_dev_count; i++)
|
||||
in_unprobe(&in_devices[i]);
|
||||
|
||||
for (i = 0; i < in_driver_count; i++) {
|
||||
in_probe_dev_id = i;
|
||||
in_drivers[i].probe();
|
||||
}
|
||||
|
||||
/* get rid of devs without binds and probes */
|
||||
for (i = 0; i < in_dev_count; i++) {
|
||||
if (!in_devices[i].probed && in_devices[i].binds == NULL) {
|
||||
in_dev_count--;
|
||||
if (i < in_dev_count) {
|
||||
free(in_devices[i].name);
|
||||
memmove(&in_devices[i], &in_devices[i+1],
|
||||
(in_dev_count - i) * sizeof(in_devices[0]));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_devices[i].probed && in_devices[i].drv_fd_hnd == -1)
|
||||
in_have_async_devs = 1;
|
||||
}
|
||||
|
||||
if (in_have_async_devs)
|
||||
lprintf("input: async-only devices detected..\n");
|
||||
|
||||
in_debug_dump();
|
||||
}
|
||||
|
||||
/* async update */
|
||||
int in_update(int *result)
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
for (i = 0; i < in_dev_count; i++) {
|
||||
in_dev_t *dev = &in_devices[i];
|
||||
if (dev->probed && dev->binds != NULL)
|
||||
ret |= DRV(dev->drv_id).update(dev->drv_data, dev->binds, result);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static in_dev_t *get_dev(int dev_id)
|
||||
{
|
||||
if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
|
||||
return NULL;
|
||||
|
||||
return &in_devices[dev_id];
|
||||
}
|
||||
|
||||
int in_update_analog(int dev_id, int axis_id, int *result)
|
||||
{
|
||||
in_dev_t *dev = get_dev(dev_id);
|
||||
|
||||
if (dev == NULL || !dev->probed)
|
||||
return -1;
|
||||
|
||||
return DRV(dev->drv_id).update_analog(dev->drv_data, axis_id, result);
|
||||
}
|
||||
|
||||
static int in_update_kc_async(int *dev_id_out, int *is_down_out, int timeout_ms)
|
||||
{
|
||||
int i, is_down, result;
|
||||
unsigned int ticks;
|
||||
|
||||
ticks = plat_get_ticks_ms();
|
||||
|
||||
while (1)
|
||||
{
|
||||
for (i = 0; i < in_dev_count; i++) {
|
||||
in_dev_t *d = &in_devices[i];
|
||||
if (!d->probed)
|
||||
continue;
|
||||
|
||||
result = DRV(d->drv_id).update_keycode(d->drv_data, &is_down);
|
||||
if (result == -1)
|
||||
continue;
|
||||
|
||||
if (dev_id_out)
|
||||
*dev_id_out = i;
|
||||
if (is_down_out)
|
||||
*is_down_out = is_down;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (timeout_ms >= 0 && (int)(plat_get_ticks_ms() - ticks) > timeout_ms)
|
||||
break;
|
||||
|
||||
plat_sleep_ms(10);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* wait for a press, always return some keycode or -1 on timeout or error
|
||||
*/
|
||||
int in_update_keycode(int *dev_id_out, int *is_down_out, char *charcode, int timeout_ms)
|
||||
{
|
||||
int result = -1, dev_id = 0, is_down, result_menu;
|
||||
int fds_hnds[IN_MAX_DEVS];
|
||||
int i, ret, count = 0;
|
||||
in_drv_t *drv = NULL;
|
||||
unsigned int ticks;
|
||||
|
||||
if (in_have_async_devs) {
|
||||
result = in_update_kc_async(&dev_id, &is_down, timeout_ms);
|
||||
if (result == -1)
|
||||
return -1;
|
||||
drv = &DRV(in_devices[dev_id].drv_id);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
ticks = plat_get_ticks_ms();
|
||||
|
||||
for (i = 0; i < in_dev_count; i++) {
|
||||
if (in_devices[i].probed)
|
||||
fds_hnds[count++] = in_devices[i].drv_fd_hnd;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
/* don't deadlock, fail */
|
||||
lprintf("input: failed to find devices to read\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
ret = plat_wait_event(fds_hnds, count, timeout_ms);
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
for (i = 0; i < in_dev_count; i++) {
|
||||
if (in_devices[i].drv_fd_hnd == ret) {
|
||||
dev_id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
drv = &DRV(in_devices[dev_id].drv_id);
|
||||
result = drv->update_keycode(in_devices[dev_id].drv_data, &is_down);
|
||||
if (result >= 0)
|
||||
break;
|
||||
|
||||
if (result == -2) {
|
||||
lprintf("input: \"%s\" errored out, removing.\n", in_devices[dev_id].name);
|
||||
in_unprobe(&in_devices[dev_id]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (timeout_ms >= 0) {
|
||||
unsigned int ticks2 = plat_get_ticks_ms();
|
||||
timeout_ms -= ticks2 - ticks;
|
||||
ticks = ticks2;
|
||||
if (timeout_ms <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
return -1;
|
||||
finish:
|
||||
/* keep track of menu key state, to allow mixing
|
||||
* in_update_keycode() and in_menu_wait_any() calls */
|
||||
result_menu = drv->menu_translate(in_devices[dev_id].drv_data, result, charcode);
|
||||
if (result_menu != 0) {
|
||||
if (is_down)
|
||||
menu_key_state |= result_menu;
|
||||
else
|
||||
menu_key_state &= ~result_menu;
|
||||
}
|
||||
|
||||
if (dev_id_out != NULL)
|
||||
*dev_id_out = dev_id;
|
||||
if (is_down_out != NULL)
|
||||
*is_down_out = is_down;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* same as above, only return bitfield of PBTN_* */
|
||||
int in_menu_wait_any(char *charcode, int timeout_ms)
|
||||
{
|
||||
int keys_old = menu_key_state;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int code, is_down = 0, dev_id = 0;
|
||||
|
||||
code = in_update_keycode(&dev_id, &is_down, charcode, timeout_ms);
|
||||
if (code < 0)
|
||||
break;
|
||||
|
||||
if (keys_old != menu_key_state) {
|
||||
menu_last_used_dev = dev_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return menu_key_state;
|
||||
}
|
||||
|
||||
/* wait for menu input, do autorepeat */
|
||||
int in_menu_wait(int interesting, char *charcode, int autorep_delay_ms)
|
||||
{
|
||||
static int inp_prev = 0;
|
||||
static int repeats = 0;
|
||||
int ret, release = 0, wait = 450;
|
||||
|
||||
if (repeats)
|
||||
wait = autorep_delay_ms;
|
||||
|
||||
ret = in_menu_wait_any(charcode, wait);
|
||||
if (ret == inp_prev)
|
||||
repeats++;
|
||||
|
||||
while (!(ret & interesting)) {
|
||||
ret = in_menu_wait_any(charcode, -1);
|
||||
release = 1;
|
||||
}
|
||||
|
||||
if (release || ret != inp_prev)
|
||||
repeats = 0;
|
||||
|
||||
inp_prev = ret;
|
||||
|
||||
/* we don't need diagonals in menus */
|
||||
if ((ret & PBTN_UP) && (ret & PBTN_LEFT)) ret &= ~PBTN_LEFT;
|
||||
if ((ret & PBTN_UP) && (ret & PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
|
||||
if ((ret & PBTN_DOWN) && (ret & PBTN_LEFT)) ret &= ~PBTN_LEFT;
|
||||
if ((ret & PBTN_DOWN) && (ret & PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const int *in_get_dev_binds(int dev_id)
|
||||
{
|
||||
in_dev_t *dev = get_dev(dev_id);
|
||||
|
||||
return dev ? dev->binds : NULL;
|
||||
}
|
||||
|
||||
const int *in_get_dev_def_binds(int dev_id)
|
||||
{
|
||||
in_dev_t *dev = get_dev(dev_id);
|
||||
if (dev == NULL)
|
||||
return NULL;
|
||||
|
||||
return dev->binds + dev->key_count * IN_BINDTYPE_COUNT;
|
||||
}
|
||||
|
||||
int in_get_config(int dev_id, int what, void *val)
|
||||
{
|
||||
int *ival = val;
|
||||
in_dev_t *dev;
|
||||
|
||||
dev = get_dev(dev_id);
|
||||
if (dev == NULL || val == NULL)
|
||||
return -1;
|
||||
|
||||
switch (what) {
|
||||
case IN_CFG_BIND_COUNT:
|
||||
*ival = dev->key_count;
|
||||
break;
|
||||
case IN_CFG_DOES_COMBOS:
|
||||
*ival = dev->does_combos;
|
||||
break;
|
||||
case IN_CFG_BLOCKING:
|
||||
case IN_CFG_KEY_NAMES:
|
||||
return -1; /* not implemented */
|
||||
default:
|
||||
return DRV(dev->drv_id).get_config(dev->drv_data, what, ival);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int in_set_blocking(int is_blocking)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
/* have_async_devs means we will have to do all reads async anyway.. */
|
||||
if (!in_have_async_devs) {
|
||||
for (i = 0; i < in_dev_count; i++) {
|
||||
if (in_devices[i].probed)
|
||||
DRV(in_devices[i].drv_id).set_config(in_devices[i].drv_data,
|
||||
IN_CFG_BLOCKING, is_blocking);
|
||||
}
|
||||
}
|
||||
|
||||
menu_key_state = 0;
|
||||
|
||||
/* flush events */
|
||||
do {
|
||||
ret = in_update_keycode(NULL, NULL, NULL, 0);
|
||||
} while (ret >= 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int in_set_config(int dev_id, int what, const void *val, int size)
|
||||
{
|
||||
const char * const *names;
|
||||
const int *ival = val;
|
||||
in_dev_t *dev;
|
||||
int count;
|
||||
|
||||
if (what == IN_CFG_BLOCKING)
|
||||
return in_set_blocking(*ival);
|
||||
|
||||
dev = get_dev(dev_id);
|
||||
if (dev == NULL)
|
||||
return -1;
|
||||
|
||||
switch (what) {
|
||||
case IN_CFG_KEY_NAMES:
|
||||
names = val;
|
||||
count = size / sizeof(names[0]);
|
||||
|
||||
if (count < dev->key_count) {
|
||||
lprintf("input: set_key_names: not enough keys\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dev->key_names = names;
|
||||
return 0;
|
||||
case IN_CFG_DEFAULT_DEV:
|
||||
/* just set last used dev, for now */
|
||||
menu_last_used_dev = dev_id;
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (dev->probed)
|
||||
return DRV(dev->drv_id).set_config(dev->drv_data, what, *ival);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix)
|
||||
{
|
||||
const char *name, *tmp;
|
||||
in_dev_t *dev;
|
||||
|
||||
dev = get_dev(dev_id);
|
||||
if (dev == NULL)
|
||||
return NULL;
|
||||
|
||||
if (must_be_active && !dev->probed)
|
||||
return NULL;
|
||||
|
||||
name = dev->name;
|
||||
if (name == NULL || !skip_pfix)
|
||||
return name;
|
||||
|
||||
/* skip prefix */
|
||||
tmp = strchr(name, ':');
|
||||
if (tmp != NULL)
|
||||
name = tmp + 1;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
int in_name_to_id(const char *dev_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < in_dev_count; i++)
|
||||
if (strcmp(dev_name, in_devices[i].name) == 0)
|
||||
break;
|
||||
|
||||
if (i >= in_dev_count) {
|
||||
lprintf("input: in_name_to_id: no such device: %s\n", dev_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* never returns NULL */
|
||||
const char *in_get_key_name(int dev_id, int keycode)
|
||||
{
|
||||
const char *name = NULL;
|
||||
static char xname[16];
|
||||
in_drv_t *drv;
|
||||
in_dev_t *dev;
|
||||
|
||||
if (dev_id < 0) /* want last used dev? */
|
||||
dev_id = menu_last_used_dev;
|
||||
|
||||
dev = get_dev(dev_id);
|
||||
if (dev == NULL)
|
||||
return "Unkn0";
|
||||
|
||||
drv = &DRV(dev->drv_id);
|
||||
if (keycode < 0) /* want name for menu key? */
|
||||
keycode = drv->menu_translate(dev->drv_data, keycode, NULL);
|
||||
|
||||
if (dev->key_names != NULL && 0 <= keycode && keycode < dev->key_count)
|
||||
name = dev->key_names[keycode];
|
||||
if (name != NULL)
|
||||
return name;
|
||||
|
||||
if (drv->get_key_name != NULL)
|
||||
name = drv->get_key_name(keycode);
|
||||
if (name != NULL)
|
||||
return name;
|
||||
|
||||
/* assume scancode */
|
||||
if ((keycode >= '0' && keycode <= '9') || (keycode >= 'a' && keycode <= 'z')
|
||||
|| (keycode >= 'A' && keycode <= 'Z'))
|
||||
sprintf(xname, "%c", keycode);
|
||||
else
|
||||
sprintf(xname, "\\x%02X", keycode);
|
||||
return xname;
|
||||
}
|
||||
|
||||
int in_get_key_code(int dev_id, const char *key_name)
|
||||
{
|
||||
in_dev_t *dev;
|
||||
int i;
|
||||
|
||||
if (dev_id < 0) /* want last used dev? */
|
||||
dev_id = menu_last_used_dev;
|
||||
|
||||
dev = get_dev(dev_id);
|
||||
if (dev == NULL)
|
||||
return -1;
|
||||
|
||||
if (dev->key_names == NULL)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < dev->key_count; i++)
|
||||
if (dev->key_names[i] && strcasecmp(dev->key_names[i], key_name) == 0)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind)
|
||||
{
|
||||
int ret, count;
|
||||
in_dev_t *dev;
|
||||
|
||||
dev = get_dev(dev_id);
|
||||
if (dev == NULL || bind_type >= IN_BINDTYPE_COUNT)
|
||||
return -1;
|
||||
|
||||
count = dev->key_count;
|
||||
|
||||
if (dev->binds == NULL) {
|
||||
if (force_unbind)
|
||||
return 0;
|
||||
dev->binds = in_alloc_binds(dev->drv_id, count);
|
||||
if (dev->binds == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (keycode < 0 || keycode >= count)
|
||||
return -1;
|
||||
|
||||
if (force_unbind)
|
||||
dev->binds[IN_BIND_OFFS(keycode, bind_type)] &= ~mask;
|
||||
else
|
||||
dev->binds[IN_BIND_OFFS(keycode, bind_type)] ^= mask;
|
||||
|
||||
ret = DRV(dev->drv_id).clean_binds(dev->drv_data, dev->binds,
|
||||
dev->binds + count * IN_BINDTYPE_COUNT);
|
||||
if (ret == 0) {
|
||||
free(dev->binds);
|
||||
dev->binds = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unbind act_mask on binds with type bind_type
|
||||
* - if dev_id_ < 0, affects all devices
|
||||
* else only affects dev_id_
|
||||
* - if act_mask == -1, unbind all keys
|
||||
* else only actions in mask
|
||||
*/
|
||||
void in_unbind_all(int dev_id_, int act_mask, int bind_type)
|
||||
{
|
||||
int dev_id = 0, dev_last = IN_MAX_DEVS - 1;
|
||||
int i, count;
|
||||
in_dev_t *dev;
|
||||
|
||||
if (dev_id_ >= 0)
|
||||
dev_id = dev_last = dev_id_;
|
||||
|
||||
if (bind_type >= IN_BINDTYPE_COUNT)
|
||||
return;
|
||||
|
||||
for (; dev_id <= dev_last; dev_id++) {
|
||||
dev = &in_devices[dev_id];
|
||||
count = dev->key_count;
|
||||
|
||||
if (dev->binds == NULL)
|
||||
continue;
|
||||
|
||||
if (act_mask != -1) {
|
||||
for (i = 0; i < count; i++)
|
||||
dev->binds[IN_BIND_OFFS(i, bind_type)] &= ~act_mask;
|
||||
}
|
||||
else
|
||||
memset(dev->binds, 0, sizeof(dev->binds[0]) * count * IN_BINDTYPE_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
/* returns device id, or -1 on error */
|
||||
int in_config_parse_dev(const char *name)
|
||||
{
|
||||
int drv_id = -1, i;
|
||||
|
||||
for (i = 0; i < in_driver_count; i++) {
|
||||
int len = strlen(in_drivers[i].prefix);
|
||||
if (strncmp(name, in_drivers[i].prefix, len) == 0) {
|
||||
drv_id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (drv_id < 0) {
|
||||
lprintf("input: missing driver for %s\n", name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < in_dev_count; i++)
|
||||
{
|
||||
if (in_devices[i].name == NULL)
|
||||
continue;
|
||||
if (strcmp(in_devices[i].name, name) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
if (i >= IN_MAX_DEVS)
|
||||
{
|
||||
/* try to find unused device */
|
||||
for (i = 0; i < IN_MAX_DEVS; i++)
|
||||
if (in_devices[i].name == NULL) break;
|
||||
if (i >= IN_MAX_DEVS) {
|
||||
lprintf("input: too many devices, can't add %s\n", name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&in_devices[i], 0, sizeof(in_devices[i]));
|
||||
|
||||
in_devices[i].name = strdup(name);
|
||||
if (in_devices[i].name == NULL)
|
||||
return -1;
|
||||
|
||||
in_devices[i].key_names = DRV(drv_id).get_key_names(&in_devices[i].key_count);
|
||||
in_devices[i].drv_id = drv_id;
|
||||
|
||||
if (i + 1 > in_dev_count)
|
||||
in_dev_count = i + 1;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int in_config_bind_key(int dev_id, const char *key, int acts, int bind_type)
|
||||
{
|
||||
in_dev_t *dev;
|
||||
int i, offs, kc;
|
||||
|
||||
dev = get_dev(dev_id);
|
||||
if (dev == NULL || bind_type >= IN_BINDTYPE_COUNT)
|
||||
return -1;
|
||||
|
||||
/* maybe a raw code? */
|
||||
if (key[0] == '\\' && key[1] == 'x') {
|
||||
char *p = NULL;
|
||||
kc = (int)strtoul(key + 2, &p, 16);
|
||||
if (p == NULL || *p != 0)
|
||||
kc = -1;
|
||||
}
|
||||
else {
|
||||
/* device specific key name */
|
||||
if (dev->binds == NULL) {
|
||||
dev->binds = in_alloc_binds(dev->drv_id, dev->key_count);
|
||||
if (dev->binds == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
kc = -1;
|
||||
if (dev->key_names != NULL) {
|
||||
for (i = 0; i < dev->key_count; i++) {
|
||||
const char *k = dev->key_names[i];
|
||||
if (k != NULL && strcasecmp(k, key) == 0) {
|
||||
kc = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kc < 0)
|
||||
kc = DRV(dev->drv_id).get_key_code(key);
|
||||
if (kc < 0 && strlen(key) == 1) {
|
||||
/* assume scancode */
|
||||
kc = key[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (kc < 0 || kc >= dev->key_count) {
|
||||
lprintf("input: bad key: %s\n", key);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bind_type == IN_BINDTYPE_NONE) {
|
||||
for (i = 0; i < IN_BINDTYPE_COUNT; i++)
|
||||
dev->binds[IN_BIND_OFFS(kc, i)] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
offs = IN_BIND_OFFS(kc, bind_type);
|
||||
if (dev->binds[offs] == -1)
|
||||
dev->binds[offs] = 0;
|
||||
dev->binds[offs] |= acts;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void in_clean_binds(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < IN_MAX_DEVS; i++) {
|
||||
int ret, count, *binds, *def_binds;
|
||||
in_dev_t *dev = &in_devices[i];
|
||||
|
||||
if (dev->binds == NULL || dev->drv_data == NULL)
|
||||
continue;
|
||||
|
||||
count = dev->key_count;
|
||||
binds = dev->binds;
|
||||
def_binds = binds + count * IN_BINDTYPE_COUNT;
|
||||
|
||||
ret = DRV(dev->drv_id).clean_binds(dev->drv_data, binds, def_binds);
|
||||
if (ret == 0) {
|
||||
/* no useable binds */
|
||||
free(dev->binds);
|
||||
dev->binds = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void in_debug_dump(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
lprintf("# drv probed binds name\n");
|
||||
for (i = 0; i < IN_MAX_DEVS; i++) {
|
||||
in_dev_t *d = &in_devices[i];
|
||||
if (!d->probed && d->name == NULL && d->binds == NULL)
|
||||
continue;
|
||||
lprintf("%d %3d %6c %5c %s\n", i, d->drv_id, d->probed ? 'y' : 'n',
|
||||
d->binds ? 'y' : 'n', d->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* stubs for drivers that choose not to implement something */
|
||||
|
||||
static void in_def_free(void *drv_data) {}
|
||||
static int in_def_clean_binds(void *drv_data, int *b, int *db) { return 1; }
|
||||
static int in_def_get_config(void *drv_data, int what, int *val) { return -1; }
|
||||
static int in_def_set_config(void *drv_data, int what, int val) { return -1; }
|
||||
static int in_def_update_analog(void *drv_data, int axis_id, int *result) { return -1; }
|
||||
static int in_def_update_keycode(void *drv_data, int *is_down) { return 0; }
|
||||
static int in_def_menu_translate(void *drv_data, int keycode, char *ccode) { return 0; }
|
||||
static int in_def_get_key_code(const char *key_name) { return -1; }
|
||||
static const char *in_def_get_key_name(int keycode) { return NULL; }
|
||||
|
||||
#define CHECK_ADD_STUB(d, f) \
|
||||
if (d.f == NULL) d.f = in_def_##f
|
||||
|
||||
/* to be called by drivers */
|
||||
int in_register_driver(const in_drv_t *drv, const struct in_default_bind *defbinds)
|
||||
{
|
||||
int count_new = in_driver_count + 1;
|
||||
in_drv_t *new_drivers;
|
||||
|
||||
new_drivers = realloc(in_drivers, count_new * sizeof(in_drivers[0]));
|
||||
if (new_drivers == NULL) {
|
||||
lprintf("input: in_register_driver OOM\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(&new_drivers[in_driver_count], drv, sizeof(new_drivers[0]));
|
||||
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], free);
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], clean_binds);
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], get_config);
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], set_config);
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], update_analog);
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], update_keycode);
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], menu_translate);
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_code);
|
||||
CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_name);
|
||||
if (defbinds != NULL)
|
||||
new_drivers[in_driver_count].defbinds = defbinds;
|
||||
in_drivers = new_drivers;
|
||||
in_driver_count = count_new;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void in_init(void)
|
||||
{
|
||||
in_drivers = NULL;
|
||||
memset(in_devices, 0, sizeof(in_devices));
|
||||
in_driver_count = 0;
|
||||
in_dev_count = 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int main(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
in_init();
|
||||
in_probe();
|
||||
|
||||
in_set_blocking(1);
|
||||
|
||||
#if 1
|
||||
while (1) {
|
||||
int dev = 0, down;
|
||||
ret = in_update_keycode(&dev, &down);
|
||||
lprintf("#%i: %i %i (%s)\n", dev, down, ret, in_get_key_name(dev, ret));
|
||||
}
|
||||
#else
|
||||
while (1) {
|
||||
ret = in_menu_wait_any();
|
||||
lprintf("%08x\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -1,140 +0,0 @@
|
|||
#ifndef INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc
|
||||
#define INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc 1
|
||||
|
||||
#define IN_MAX_DEVS 10
|
||||
#define IN_ABS_RANGE 1024 /* abs must be centered at 0, move upto +- this */
|
||||
|
||||
/* unified menu keys */
|
||||
#define PBTN_UP (1 << 0)
|
||||
#define PBTN_DOWN (1 << 1)
|
||||
#define PBTN_LEFT (1 << 2)
|
||||
#define PBTN_RIGHT (1 << 3)
|
||||
|
||||
#define PBTN_MOK (1 << 4)
|
||||
#define PBTN_MBACK (1 << 5)
|
||||
#define PBTN_MA2 (1 << 6) /* menu action 2 */
|
||||
#define PBTN_MA3 (1 << 7)
|
||||
|
||||
#define PBTN_L (1 << 8)
|
||||
#define PBTN_R (1 << 9)
|
||||
|
||||
#define PBTN_MENU (1 << 10)
|
||||
|
||||
#define PBTN_CHAR (1 << 11) /* character (text input) */
|
||||
|
||||
// TODO: move to pico
|
||||
#if 0
|
||||
|
||||
/* ui events */
|
||||
#define PEVB_VOL_DOWN 30
|
||||
#define PEVB_VOL_UP 29
|
||||
#define PEVB_STATE_LOAD 28
|
||||
#define PEVB_STATE_SAVE 27
|
||||
#define PEVB_SWITCH_RND 26
|
||||
#define PEVB_SSLOT_PREV 25
|
||||
#define PEVB_SSLOT_NEXT 24
|
||||
#define PEVB_MENU 23
|
||||
#define PEVB_FF 22
|
||||
#define PEVB_PICO_PNEXT 21
|
||||
#define PEVB_PICO_PPREV 20
|
||||
#define PEVB_PICO_SWINP 19
|
||||
|
||||
#define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN)
|
||||
#define PEV_VOL_UP (1 << PEVB_VOL_UP)
|
||||
#define PEV_STATE_LOAD (1 << PEVB_STATE_LOAD)
|
||||
#define PEV_STATE_SAVE (1 << PEVB_STATE_SAVE)
|
||||
#define PEV_SWITCH_RND (1 << PEVB_SWITCH_RND)
|
||||
#define PEV_SSLOT_PREV (1 << PEVB_SSLOT_PREV)
|
||||
#define PEV_SSLOT_NEXT (1 << PEVB_SSLOT_NEXT)
|
||||
#define PEV_MENU (1 << PEVB_MENU)
|
||||
#define PEV_FF (1 << PEVB_FF)
|
||||
#define PEV_PICO_PNEXT (1 << PEVB_PICO_PNEXT)
|
||||
#define PEV_PICO_PPREV (1 << PEVB_PICO_PPREV)
|
||||
#define PEV_PICO_SWINP (1 << PEVB_PICO_SWINP)
|
||||
|
||||
#define PEV_MASK 0x7ff80000
|
||||
|
||||
#endif
|
||||
|
||||
enum {
|
||||
IN_CFG_BIND_COUNT = 0,
|
||||
IN_CFG_DOES_COMBOS,
|
||||
IN_CFG_BLOCKING,
|
||||
IN_CFG_KEY_NAMES,
|
||||
IN_CFG_ABS_DEAD_ZONE, /* dead zone for analog-digital mapping */
|
||||
IN_CFG_ABS_AXIS_COUNT, /* number of abs axes (ro) */
|
||||
IN_CFG_DEFAULT_DEV,
|
||||
};
|
||||
|
||||
enum {
|
||||
IN_BINDTYPE_NONE = -1,
|
||||
IN_BINDTYPE_EMU = 0,
|
||||
IN_BINDTYPE_PLAYER12,
|
||||
IN_BINDTYPE_COUNT
|
||||
};
|
||||
|
||||
#define IN_BIND_OFFS(key, btype) \
|
||||
((key) * IN_BINDTYPE_COUNT + (btype))
|
||||
|
||||
typedef struct {
|
||||
const char *prefix;
|
||||
void (*probe)(void);
|
||||
void (*free)(void *drv_data);
|
||||
const char * const *
|
||||
(*get_key_names)(int *count);
|
||||
int (*clean_binds)(void *drv_data, int *binds, int *def_finds);
|
||||
int (*get_config)(void *drv_data, int what, int *val);
|
||||
int (*set_config)(void *drv_data, int what, int val);
|
||||
int (*update)(void *drv_data, const int *binds, int *result);
|
||||
int (*update_analog)(void *drv_data, int axis_id, int *result);
|
||||
/* return -1 on no event, -2 on error */
|
||||
int (*update_keycode)(void *drv_data, int *is_down);
|
||||
int (*menu_translate)(void *drv_data, int keycode, char *charcode);
|
||||
int (*get_key_code)(const char *key_name);
|
||||
const char * (*get_key_name)(int keycode);
|
||||
|
||||
const struct in_default_bind *defbinds;
|
||||
} in_drv_t;
|
||||
|
||||
struct in_default_bind {
|
||||
unsigned short code;
|
||||
unsigned char btype; /* IN_BINDTYPE_* */
|
||||
unsigned char bit;
|
||||
};
|
||||
|
||||
/* to be called by drivers */
|
||||
int in_register_driver(const in_drv_t *drv, const struct in_default_bind *defbinds);
|
||||
void in_register(const char *nname, int drv_fd_hnd, void *drv_data,
|
||||
int key_count, const char * const *key_names, int combos);
|
||||
void in_combos_find(const int *binds, int last_key, int *combo_keys, int *combo_acts);
|
||||
int in_combos_do(int keys, const int *binds, int last_key, int combo_keys, int combo_acts);
|
||||
|
||||
void in_init(void);
|
||||
void in_probe(void);
|
||||
int in_update(int *result);
|
||||
int in_update_analog(int dev_id, int axis_id, int *value);
|
||||
int in_update_keycode(int *dev_id, int *is_down, char *charcode, int timeout_ms);
|
||||
int in_menu_wait_any(char *charcode, int timeout_ms);
|
||||
int in_menu_wait(int interesting, char *charcode, int autorep_delay_ms);
|
||||
int in_config_parse_dev(const char *dev_name);
|
||||
int in_config_bind_key(int dev_id, const char *key, int binds, int bind_type);
|
||||
int in_get_config(int dev_id, int what, void *val);
|
||||
int in_set_config(int dev_id, int what, const void *val, int size);
|
||||
int in_get_key_code(int dev_id, const char *key_name);
|
||||
int in_name_to_id(const char *dev_name);
|
||||
int in_bind_key(int dev_id, int keycode, int mask, int bind_type, int force_unbind);
|
||||
void in_unbind_all(int dev_id, int act_mask, int bind_type);
|
||||
void in_clean_binds(void);
|
||||
void in_debug_dump(void);
|
||||
|
||||
const int *in_get_dev_binds(int dev_id);
|
||||
const int *in_get_dev_def_binds(int dev_id);
|
||||
const char *in_get_dev_name(int dev_id, int must_be_active, int skip_pfix);
|
||||
const char *in_get_key_name(int dev_id, int keycode);
|
||||
|
||||
#define in_set_config_int(dev_id, what, v) { \
|
||||
int val_ = v; \
|
||||
in_set_config(dev_id, what, &val_, sizeof(val_)); \
|
||||
}
|
||||
|
||||
#endif /* INCLUDE_uXt8Z4R7EMpuEEtvSibXjNhKH3741VNc */
|
33
platform/common/input_pico.h
Normal file
33
platform/common/input_pico.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef INCLUDE_c48097f3ff2a6a9af1cce8fd7a9b3f0c
|
||||
#define INCLUDE_c48097f3ff2a6a9af1cce8fd7a9b3f0c 1
|
||||
|
||||
/* ui events */
|
||||
#define PEVB_VOL_DOWN 30
|
||||
#define PEVB_VOL_UP 29
|
||||
#define PEVB_STATE_LOAD 28
|
||||
#define PEVB_STATE_SAVE 27
|
||||
#define PEVB_SWITCH_RND 26
|
||||
#define PEVB_SSLOT_PREV 25
|
||||
#define PEVB_SSLOT_NEXT 24
|
||||
#define PEVB_MENU 23
|
||||
#define PEVB_FF 22
|
||||
#define PEVB_PICO_PNEXT 21
|
||||
#define PEVB_PICO_PPREV 20
|
||||
#define PEVB_PICO_SWINP 19
|
||||
|
||||
#define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN)
|
||||
#define PEV_VOL_UP (1 << PEVB_VOL_UP)
|
||||
#define PEV_STATE_LOAD (1 << PEVB_STATE_LOAD)
|
||||
#define PEV_STATE_SAVE (1 << PEVB_STATE_SAVE)
|
||||
#define PEV_SWITCH_RND (1 << PEVB_SWITCH_RND)
|
||||
#define PEV_SSLOT_PREV (1 << PEVB_SSLOT_PREV)
|
||||
#define PEV_SSLOT_NEXT (1 << PEVB_SSLOT_NEXT)
|
||||
#define PEV_MENU (1 << PEVB_MENU)
|
||||
#define PEV_FF (1 << PEVB_FF)
|
||||
#define PEV_PICO_PNEXT (1 << PEVB_PICO_PNEXT)
|
||||
#define PEV_PICO_PPREV (1 << PEVB_PICO_PPREV)
|
||||
#define PEV_PICO_SWINP (1 << PEVB_PICO_SWINP)
|
||||
|
||||
#define PEV_MASK 0x7ff80000
|
||||
|
||||
#endif /* INCLUDE_c48097f3ff2a6a9af1cce8fd7a9b3f0c */
|
|
@ -1,10 +0,0 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void lprintf(const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -8,11 +8,11 @@
|
|||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "../libpicofe/input.h"
|
||||
#include "../libpicofe/plat.h"
|
||||
#include "menu_pico.h"
|
||||
#include "emu.h"
|
||||
#include "config.h"
|
||||
#include "input.h"
|
||||
#include "plat.h"
|
||||
#include <cpu/debug.h>
|
||||
#include <version.h>
|
||||
|
||||
|
@ -72,12 +72,12 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
g_argv = argv;
|
||||
|
||||
plat_early_init();
|
||||
//plat_early_init();
|
||||
|
||||
in_init();
|
||||
in_probe();
|
||||
|
||||
plat_init();
|
||||
plat_target_init();
|
||||
|
||||
emu_prep_defconfig(); // depends on input
|
||||
emu_read_config(NULL, 0);
|
||||
|
@ -142,7 +142,7 @@ int main(int argc, char *argv[])
|
|||
endloop:
|
||||
|
||||
emu_finish();
|
||||
plat_finish();
|
||||
plat_target_finish();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
* (C) Gražvydas "notaz" Ignotas, 2006-2010
|
||||
*
|
||||
* This work is licensed under the terms of any of these licenses
|
||||
* (at your option):
|
||||
* - GNU GPL, version 2 or later.
|
||||
* - GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MB_NONE = 1, /* no auto processing */
|
||||
MB_OPT_ONOFF, /* ON/OFF setting */
|
||||
MB_OPT_RANGE, /* [min-max] setting */
|
||||
MB_OPT_CUSTOM, /* custom value */
|
||||
MB_OPT_CUSTONOFF,
|
||||
MB_OPT_CUSTRANGE,
|
||||
MB_OPT_ENUM,
|
||||
} menu_behavior;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
menu_behavior beh;
|
||||
int id;
|
||||
void *var; /* for on-off/range settings */
|
||||
int mask; /* bit to toggle for on/off */
|
||||
signed short min; /* for ranged integer settings, to be sign-extended */
|
||||
signed short max;
|
||||
unsigned int enabled:1;
|
||||
unsigned int need_to_save:1;
|
||||
unsigned int selectable:1;
|
||||
int (*handler)(int id, int keys);
|
||||
const char * (*generate_name)(int id, int *offs);
|
||||
const void *data;
|
||||
const char *help;
|
||||
} menu_entry;
|
||||
|
||||
#define mee_handler_id_h(name, id, handler, help) \
|
||||
{ name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, NULL, NULL, help }
|
||||
|
||||
#define mee_handler_id(name, id, handler) \
|
||||
mee_handler_id_h(name, id, handler, NULL)
|
||||
|
||||
#define mee_handler(name, handler) \
|
||||
mee_handler_id(name, MA_NONE, handler)
|
||||
|
||||
#define mee_handler_h(name, handler, help) \
|
||||
mee_handler_id_h(name, MA_NONE, handler, help)
|
||||
|
||||
#define mee_label(name) \
|
||||
{ name, MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0, 0, NULL, NULL, NULL, NULL }
|
||||
|
||||
#define mee_label_mk(id, name_func) \
|
||||
{ "", MB_NONE, id, NULL, 0, 0, 0, 1, 0, 0, NULL, name_func, NULL, NULL }
|
||||
|
||||
#define mee_onoff_h(name, id, var, mask, help) \
|
||||
{ name, MB_OPT_ONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, NULL, NULL, help }
|
||||
|
||||
#define mee_onoff(name, id, var, mask) \
|
||||
mee_onoff_h(name, id, var, mask, NULL)
|
||||
|
||||
#define mee_range_h(name, id, var, min, max, help) \
|
||||
{ name, MB_OPT_RANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, NULL, NULL, help }
|
||||
|
||||
#define mee_range(name, id, var, min, max) \
|
||||
mee_range_h(name, id, var, min, max, NULL)
|
||||
|
||||
#define mee_range_hide(name, id, var, min, max) \
|
||||
{ name, MB_OPT_RANGE, id, &(var), 0, min, max, 0, 1, 0, NULL, NULL, NULL, NULL }
|
||||
|
||||
#define mee_cust_s_h(name, id, need_save, handler, name_func, help) \
|
||||
{ name, MB_OPT_CUSTOM, id, NULL, 0, 0, 0, 1, need_save, 1, handler, name_func, NULL, help }
|
||||
|
||||
#define mee_cust_h(name, id, handler, name_func, help) \
|
||||
mee_cust_s_h(name, id, 1, handler, name_func, help)
|
||||
|
||||
#define mee_cust(name, id, handler, name_func) \
|
||||
mee_cust_h(name, id, handler, name_func, NULL)
|
||||
|
||||
#define mee_cust_nosave(name, id, handler, name_func) \
|
||||
mee_cust_s_h(name, id, 0, handler, name_func, NULL)
|
||||
|
||||
#define mee_onoff_cust(name, id, var, mask, name_func) \
|
||||
{ name, MB_OPT_CUSTONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, name_func, NULL, NULL }
|
||||
|
||||
#define mee_range_cust(name, id, var, min, max, name_func) \
|
||||
{ name, MB_OPT_CUSTRANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, name_func, NULL, NULL }
|
||||
|
||||
#define mee_enum_h(name, id, var, names_list, help) \
|
||||
{ name, MB_OPT_ENUM, id, &(var), 0, 0, 0, 1, 1, 1, NULL, NULL, names_list, help }
|
||||
|
||||
#define mee_enum(name, id, var, names_list) \
|
||||
mee_enum_h(name, id, var, names_list, NULL)
|
||||
|
||||
#define mee_end \
|
||||
{ NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL }
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
int mask;
|
||||
} me_bind_action;
|
||||
|
||||
extern me_bind_action me_ctrl_actions[];
|
||||
extern me_bind_action emuctrl_actions[]; // platform code
|
||||
|
||||
extern void *g_menubg_src_ptr;
|
||||
extern void *g_menubg_ptr;
|
||||
extern void *g_menuscreen_ptr;
|
||||
#if MSCREEN_SIZE_FIXED
|
||||
#define g_menuscreen_w MSCREEN_WIDTH
|
||||
#define g_menuscreen_h MSCREEN_HEIGHT
|
||||
#else
|
||||
extern int g_menuscreen_w;
|
||||
extern int g_menuscreen_h;
|
||||
#endif
|
||||
|
||||
void menu_init(void);
|
||||
void text_out16(int x, int y, const char *texto, ...);
|
||||
void me_update_msg(const char *msg);
|
||||
|
||||
void menu_romload_prepare(const char *rom_name);
|
||||
void menu_romload_end(void);
|
||||
|
||||
void menu_loop(void);
|
||||
int menu_loop_tray(void);
|
||||
|
||||
menu_entry *me_list_get_first(void);
|
||||
menu_entry *me_list_get_next(void);
|
||||
|
|
@ -2,35 +2,37 @@
|
|||
|
||||
#include "emu.h"
|
||||
#include "menu_pico.h"
|
||||
#include "input_pico.h"
|
||||
|
||||
#include <version.h>
|
||||
#include <revision.h>
|
||||
|
||||
#include <pico/pico.h>
|
||||
#include <pico/patch.h>
|
||||
|
||||
// FIXME
|
||||
#define REVISION "0"
|
||||
|
||||
static const char *rom_exts[] = {
|
||||
"zip", "bin", "smd", "gen",
|
||||
"iso", "cso", "cue", NULL
|
||||
};
|
||||
|
||||
// rrrr rggg gggb bbbb
|
||||
static unsigned short fname2color(const char *fname)
|
||||
{
|
||||
const char *ext = fname + strlen(fname) - 3;
|
||||
static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso", "cue" };
|
||||
static const char *other_exts[] = { "gmv", "pat" };
|
||||
int i;
|
||||
|
||||
if (ext < fname) ext = fname;
|
||||
for (i = 0; i < array_size(rom_exts); i++)
|
||||
for (i = 0; rom_exts[i] != NULL; i++)
|
||||
if (strcasecmp(ext, rom_exts[i]) == 0) return 0xbdff; // FIXME: mk defines
|
||||
for (i = 0; i < array_size(other_exts); i++)
|
||||
if (strcasecmp(ext, other_exts[i]) == 0) return 0xaff5;
|
||||
return 0xffff;
|
||||
}
|
||||
|
||||
static const char *filter_exts[] = {
|
||||
".mp3", ".MP3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html",
|
||||
".jpg", ".gpe"
|
||||
};
|
||||
|
||||
#include "menu.c"
|
||||
#include "../libpicofe/menu.c"
|
||||
|
||||
/* platform specific options and handlers */
|
||||
#if defined(__GP2X__)
|
||||
|
@ -96,7 +98,7 @@ static void load_progress_cb(int percent)
|
|||
if (len > g_menuscreen_w)
|
||||
len = g_menuscreen_w;
|
||||
|
||||
menu_draw_begin(0);
|
||||
menu_draw_begin(0, 1);
|
||||
dst = (unsigned short *)g_menuscreen_ptr + g_menuscreen_w * me_sfont_h * 2;
|
||||
for (ln = me_sfont_h - 2; ln > 0; ln--, dst += g_menuscreen_w)
|
||||
memset(dst, 0xff, len * 2);
|
||||
|
@ -108,7 +110,7 @@ static void cdload_progress_cb(const char *fname, int percent)
|
|||
int ln, len = percent * g_menuscreen_w / 100;
|
||||
unsigned short *dst;
|
||||
|
||||
menu_draw_begin(0);
|
||||
menu_draw_begin(0, 1);
|
||||
dst = (unsigned short *)g_menuscreen_ptr + g_menuscreen_w * me_sfont_h * 2;
|
||||
memset(dst, 0xff, g_menuscreen_w * (me_sfont_h - 2) * 2);
|
||||
|
||||
|
@ -136,7 +138,7 @@ void menu_romload_prepare(const char *rom_name)
|
|||
|
||||
/* fill all buffers, callbacks won't update in full */
|
||||
for (i = 0; i < 3; i++) {
|
||||
menu_draw_begin(1);
|
||||
menu_draw_begin(1, 1);
|
||||
smalltext_out16(1, 1, "Loading", 0xffff);
|
||||
smalltext_out16(1, me_sfont_h, p, 0xffff);
|
||||
menu_draw_end();
|
||||
|
@ -152,7 +154,7 @@ void menu_romload_end(void)
|
|||
PicoCartLoadProgressCB = NULL;
|
||||
PicoCDLoadProgressCB = NULL;
|
||||
|
||||
menu_draw_begin(0);
|
||||
menu_draw_begin(0, 1);
|
||||
smalltext_out16(1, (cdload_called ? 6 : 3) * me_sfont_h,
|
||||
"Starting emulation...", 0xffff);
|
||||
menu_draw_end();
|
||||
|
@ -167,7 +169,7 @@ static void draw_patchlist(int sel)
|
|||
max_cnt = g_menuscreen_h / me_sfont_h;
|
||||
start = max_cnt / 2 - sel;
|
||||
|
||||
menu_draw_begin(1);
|
||||
menu_draw_begin(1, 0);
|
||||
|
||||
for (i = 0; i < PicoPatchCount; i++) {
|
||||
pos = start + i;
|
||||
|
@ -565,15 +567,15 @@ static int mh_saveloadcfg(int id, int keys)
|
|||
case MA_OPT_SAVECFG:
|
||||
case MA_OPT_SAVECFG_GAME:
|
||||
if (emu_write_config(id == MA_OPT_SAVECFG_GAME ? 1 : 0))
|
||||
me_update_msg("config saved");
|
||||
menu_update_msg("config saved");
|
||||
else
|
||||
me_update_msg("failed to write config");
|
||||
menu_update_msg("failed to write config");
|
||||
break;
|
||||
case MA_OPT_LOADCFG:
|
||||
ret = emu_read_config(rom_fname_loaded, 1);
|
||||
if (!ret) ret = emu_read_config(NULL, 1);
|
||||
if (ret) me_update_msg("config loaded");
|
||||
else me_update_msg("failed to load config");
|
||||
if (ret) menu_update_msg("config loaded");
|
||||
else menu_update_msg("failed to load config");
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -585,7 +587,7 @@ static int mh_saveloadcfg(int id, int keys)
|
|||
static int mh_restore_defaults(int id, int keys)
|
||||
{
|
||||
emu_set_defconfig();
|
||||
me_update_msg("defaults restored");
|
||||
menu_update_msg("defaults restored");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -759,7 +761,7 @@ static void debug_menu_loop(void)
|
|||
|
||||
while (1)
|
||||
{
|
||||
menu_draw_begin(1);
|
||||
menu_draw_begin(1, 0);
|
||||
switch (mode)
|
||||
{
|
||||
case 0: tmp = PDebugMain();
|
||||
|
@ -857,23 +859,24 @@ static const char credits[] =
|
|||
" Lordus, Exophase, Rokas,\n"
|
||||
" Nemesis, Tasco Deluxe";
|
||||
|
||||
static char *romsel_run(void)
|
||||
static const char *romsel_run(void)
|
||||
{
|
||||
char *ret, *sel_name;
|
||||
const char *ret;
|
||||
char *sel_name;
|
||||
|
||||
sel_name = malloc(sizeof(rom_fname_loaded));
|
||||
if (sel_name == NULL)
|
||||
return NULL;
|
||||
strcpy(sel_name, rom_fname_loaded);
|
||||
|
||||
ret = menu_loop_romsel(sel_name, sizeof(rom_fname_loaded));
|
||||
ret = menu_loop_romsel(sel_name, sizeof(rom_fname_loaded), rom_exts, NULL);
|
||||
free(sel_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int main_menu_handler(int id, int keys)
|
||||
{
|
||||
char *ret_name;
|
||||
const char *ret_name;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
|
@ -914,7 +917,7 @@ static int main_menu_handler(int id, int keys)
|
|||
if (rom_loaded && PicoPatches) {
|
||||
menu_loop_patches();
|
||||
PicoPatchApply();
|
||||
me_update_msg("Patches applied");
|
||||
menu_update_msg("Patches applied");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -973,7 +976,7 @@ void menu_loop(void)
|
|||
|
||||
static int mh_tray_load_cd(int id, int keys)
|
||||
{
|
||||
char *ret_name;
|
||||
const char *ret_name;
|
||||
|
||||
ret_name = romsel_run();
|
||||
if (ret_name == NULL)
|
||||
|
@ -1018,7 +1021,7 @@ int menu_loop_tray(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void me_update_msg(const char *msg)
|
||||
void menu_update_msg(const char *msg)
|
||||
{
|
||||
strncpy(menu_error_msg, msg, sizeof(menu_error_msg));
|
||||
menu_error_msg[sizeof(menu_error_msg) - 1] = 0;
|
||||
|
@ -1078,3 +1081,7 @@ menu_entry *me_list_get_next(void)
|
|||
return me_list_i;
|
||||
}
|
||||
|
||||
void menu_init(void)
|
||||
{
|
||||
menu_init_base();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
#ifndef __MENU_PICO_H__
|
||||
#define __MENU_PICO_H__
|
||||
|
||||
#include "../libpicofe/menu.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MA_NONE = 1,
|
||||
|
@ -92,3 +97,10 @@ typedef enum
|
|||
MA_CTRL_DONE,
|
||||
} menu_id;
|
||||
|
||||
void menu_init(void);
|
||||
void menu_loop(void);
|
||||
int menu_loop_tray(void);
|
||||
void menu_romload_prepare(const char *rom_name);
|
||||
void menu_romload_end(void);
|
||||
|
||||
#endif // __MENU_PICO_H__
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* stuff to be implemented by platform code */
|
||||
extern const char *renderer_names[];
|
||||
extern const char *renderer_names32x[];
|
||||
|
||||
void pemu_prep_defconfig(void);
|
||||
void pemu_validate_config(void);
|
||||
void pemu_loop_prep(void);
|
||||
void pemu_loop_end(void);
|
||||
void pemu_forced_frame(int no_scale, int do_emu); // ..to g_menubg_src_ptr
|
||||
void pemu_finalize_frame(const char *fps, const char *notice_msg);
|
||||
|
||||
void pemu_sound_start(void);
|
||||
void pemu_sound_stop(void);
|
||||
void pemu_sound_wait(void);
|
||||
|
||||
void plat_early_init(void);
|
||||
void plat_init(void);
|
||||
void plat_finish(void);
|
||||
|
||||
/* return the dir/ where configs, saves, bios, etc. are found */
|
||||
int plat_get_root_dir(char *dst, int len);
|
||||
|
||||
/* used before things blocking for a while (these funcs redraw on return) */
|
||||
void plat_status_msg_busy_first(const char *msg);
|
||||
void plat_status_msg_busy_next(const char *msg);
|
||||
void plat_status_msg_clear(void);
|
||||
|
||||
/* menu: enter (switch bpp, etc), begin/end drawing */
|
||||
void plat_video_menu_enter(int is_rom_loaded);
|
||||
void plat_video_menu_begin(void);
|
||||
void plat_video_menu_end(void);
|
||||
void plat_video_menu_leave(void);
|
||||
|
||||
void plat_video_flip(void);
|
||||
void plat_video_wait_vsync(void);
|
||||
void plat_video_toggle_renderer(int change, int menu_call);
|
||||
|
||||
void plat_update_volume(int has_changed, int is_up);
|
||||
|
||||
int plat_is_dir(const char *path);
|
||||
int plat_wait_event(int *fds_hnds, int count, int timeout_ms);
|
||||
void plat_sleep_ms(int ms);
|
||||
|
||||
void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);
|
||||
void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);
|
||||
void plat_munmap(void *ptr, size_t size);
|
||||
|
||||
/* timers, to be used for time diff and must refer to the same clock */
|
||||
unsigned int plat_get_ticks_ms(void);
|
||||
unsigned int plat_get_ticks_us(void);
|
||||
void plat_wait_till_us(unsigned int us);
|
||||
|
||||
void plat_debug_cat(char *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
/* define POSIX stuff: dirent, scandir, getcwd, mkdir */
|
||||
#if defined(__linux__) || defined(__MINGW32__)
|
||||
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#warning hacks!
|
||||
#define mkdir(pathname,mode) mkdir(pathname)
|
||||
#define d_type d_ino
|
||||
#define DT_REG 0
|
||||
#define DT_DIR 0
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#error "must provide posix"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,266 +0,0 @@
|
|||
/*
|
||||
* (C) Gražvydas "notaz" Ignotas, 2008-2011
|
||||
*
|
||||
* This work is licensed under the terms of any of these licenses
|
||||
* (at your option):
|
||||
* - GNU GPL, version 2 or later.
|
||||
* - GNU LGPL, version 2.1 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <png.h>
|
||||
#include "readpng.h"
|
||||
#include "lprintf.h"
|
||||
|
||||
int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req_h)
|
||||
{
|
||||
FILE *fp;
|
||||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytepp row_ptr = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (dest == NULL || fname == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
fp = fopen(fname, "rb");
|
||||
if (fp == NULL)
|
||||
{
|
||||
lprintf(__FILE__ ": failed to open: %s\n", fname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
lprintf(__FILE__ ": png_create_read_struct() failed\n");
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
lprintf(__FILE__ ": png_create_info_struct() failed\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
// Start reading
|
||||
png_init_io(png_ptr, fp);
|
||||
png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_STRIP_ALPHA | PNG_TRANSFORM_PACKING, NULL);
|
||||
row_ptr = png_get_rows(png_ptr, info_ptr);
|
||||
if (row_ptr == NULL)
|
||||
{
|
||||
lprintf(__FILE__ ": png_get_rows() failed\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
// lprintf("%s: %ix%i @ %ibpp\n", fname, (int)info_ptr->width, (int)info_ptr->height, info_ptr->pixel_depth);
|
||||
|
||||
switch (what)
|
||||
{
|
||||
case READPNG_BG:
|
||||
{
|
||||
int height, width, h;
|
||||
unsigned short *dst = dest;
|
||||
if (info_ptr->pixel_depth != 24)
|
||||
{
|
||||
lprintf(__FILE__ ": bg image uses %ibpp, needed 24bpp\n", info_ptr->pixel_depth);
|
||||
break;
|
||||
}
|
||||
height = info_ptr->height;
|
||||
if (height > req_h)
|
||||
height = req_h;
|
||||
width = info_ptr->width;
|
||||
if (width > req_w)
|
||||
width = req_w;
|
||||
|
||||
for (h = 0; h < height; h++)
|
||||
{
|
||||
unsigned char *src = row_ptr[h];
|
||||
int len = width;
|
||||
while (len--)
|
||||
{
|
||||
#ifdef PSP
|
||||
*dst++ = ((src[2]&0xf8)<<8) | ((src[1]&0xf8)<<3) | (src[0] >> 3); // BGR
|
||||
#else
|
||||
*dst++ = ((src[0]&0xf8)<<8) | ((src[1]&0xf8)<<3) | (src[2] >> 3); // RGB
|
||||
#endif
|
||||
src += 3;
|
||||
}
|
||||
dst += req_w - width;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case READPNG_FONT:
|
||||
{
|
||||
int x, y, x1, y1;
|
||||
unsigned char *dst = dest;
|
||||
if (info_ptr->width != req_w || info_ptr->height != req_h)
|
||||
{
|
||||
lprintf(__FILE__ ": unexpected font image size %dx%d, needed %dx%d\n",
|
||||
(int)info_ptr->width, (int)info_ptr->height, req_w, req_h);
|
||||
break;
|
||||
}
|
||||
if (info_ptr->pixel_depth != 8)
|
||||
{
|
||||
lprintf(__FILE__ ": font image uses %ibpp, needed 8bpp\n", info_ptr->pixel_depth);
|
||||
break;
|
||||
}
|
||||
for (y = 0; y < 16; y++)
|
||||
{
|
||||
for (x = 0; x < 16; x++)
|
||||
{
|
||||
/* 16x16 grid of syms */
|
||||
int sym_w = req_w / 16;
|
||||
int sym_h = req_h / 16;
|
||||
for (y1 = 0; y1 < sym_h; y1++)
|
||||
{
|
||||
unsigned char *src = row_ptr[y*sym_h + y1] + x*sym_w;
|
||||
for (x1 = sym_w/2; x1 > 0; x1--, src+=2)
|
||||
*dst++ = ((src[0]^0xff) & 0xf0) | ((src[1]^0xff) >> 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case READPNG_SELECTOR:
|
||||
{
|
||||
int x1, y1;
|
||||
unsigned char *dst = dest;
|
||||
if (info_ptr->width != req_w || info_ptr->height != req_h)
|
||||
{
|
||||
lprintf(__FILE__ ": unexpected selector image size %ix%i, needed %dx%d\n",
|
||||
(int)info_ptr->width, (int)info_ptr->height, req_w, req_h);
|
||||
break;
|
||||
}
|
||||
if (info_ptr->pixel_depth != 8)
|
||||
{
|
||||
lprintf(__FILE__ ": selector image uses %ibpp, needed 8bpp\n", info_ptr->pixel_depth);
|
||||
break;
|
||||
}
|
||||
for (y1 = 0; y1 < req_h; y1++)
|
||||
{
|
||||
unsigned char *src = row_ptr[y1];
|
||||
for (x1 = req_w/2; x1 > 0; x1--, src+=2)
|
||||
*dst++ = ((src[0]^0xff) & 0xf0) | ((src[1]^0xff) >> 4);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case READPNG_24:
|
||||
{
|
||||
int height, width, h;
|
||||
unsigned char *dst = dest;
|
||||
if (info_ptr->pixel_depth != 24)
|
||||
{
|
||||
lprintf(__FILE__ ": image uses %ibpp, needed 24bpp\n", info_ptr->pixel_depth);
|
||||
break;
|
||||
}
|
||||
height = info_ptr->height;
|
||||
if (height > req_h)
|
||||
height = req_h;
|
||||
width = info_ptr->width;
|
||||
if (width > req_w)
|
||||
width = req_w;
|
||||
|
||||
for (h = 0; h < height; h++)
|
||||
{
|
||||
int len = width;
|
||||
unsigned char *src = row_ptr[h];
|
||||
dst += (req_w - width) * 3;
|
||||
for (len = width; len > 0; len--, dst+=3, src+=3)
|
||||
dst[0] = src[2], dst[1] = src[1], dst[2] = src[0];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ret = 0;
|
||||
done:
|
||||
png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : NULL, (png_infopp)NULL);
|
||||
fclose(fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int writepng(const char *fname, unsigned short *src, int w, int h)
|
||||
{
|
||||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytepp row_pointers;
|
||||
int i, j, ret = -1;
|
||||
FILE *f;
|
||||
|
||||
f = fopen(fname, "wb");
|
||||
if (f == NULL) {
|
||||
lprintf(__FILE__ ": failed to open \"%s\"\n", fname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
row_pointers = calloc(h, sizeof(row_pointers[0]));
|
||||
if (row_pointers == NULL)
|
||||
goto end1;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
unsigned char *dst = malloc(w * 3);
|
||||
if (dst == NULL)
|
||||
goto end2;
|
||||
row_pointers[i] = dst;
|
||||
for (j = 0; j < w; j++, src++, dst += 3) {
|
||||
dst[0] = (*src & 0xf800) >> 8;
|
||||
dst[1] = (*src & 0x07e0) >> 3;
|
||||
dst[2] = (*src & 0x001f) << 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize stuff */
|
||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (png_ptr == NULL) {
|
||||
fprintf(stderr, "png_create_write_struct() failed");
|
||||
goto end2;
|
||||
}
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL) {
|
||||
fprintf(stderr, "png_create_info_struct() failed");
|
||||
goto end3;
|
||||
}
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)) != 0) {
|
||||
fprintf(stderr, "error in png code\n");
|
||||
goto end4;
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, f);
|
||||
|
||||
png_set_IHDR(png_ptr, info_ptr, w, h,
|
||||
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
||||
|
||||
png_write_info(png_ptr, info_ptr);
|
||||
png_write_image(png_ptr, row_pointers);
|
||||
png_write_end(png_ptr, NULL);
|
||||
|
||||
ret = 0;
|
||||
|
||||
end4:
|
||||
// png_destroy_info_struct(png_ptr, &info_ptr); // freed below
|
||||
end3:
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
end2:
|
||||
for (i = 0; i < h; i++)
|
||||
free(row_pointers[i]);
|
||||
free(row_pointers);
|
||||
end1:
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
typedef enum
|
||||
{
|
||||
READPNG_BG = 1,
|
||||
READPNG_FONT,
|
||||
READPNG_SELECTOR,
|
||||
READPNG_24,
|
||||
}
|
||||
readpng_what;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int readpng(void *dest, const char *fname, readpng_what what, int w, int h);
|
||||
int writepng(const char *fname, unsigned short *src, int w, int h);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,12 +0,0 @@
|
|||
platform/common/menu.o : revision.h
|
||||
|
||||
revision.h: FORCE
|
||||
ifndef NOREVISION
|
||||
@echo "#define REVISION \"`svn info -r HEAD | grep Revision | cut -c 11-`\"" > /tmp/r.tmp
|
||||
else
|
||||
@echo "#define REVISION \"0\"" > /tmp/r.tmp
|
||||
endif
|
||||
@diff -q $@ /tmp/r.tmp > /dev/null 2>&1 || mv -f /tmp/r.tmp $@
|
||||
|
||||
FORCE:
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue