continuing input framework integration

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@631 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-01-03 18:53:35 +00:00
parent 963b7f4f2a
commit b682092681
14 changed files with 264 additions and 506 deletions

View file

@ -29,7 +29,7 @@ else
use_cyclone = 1
endif
DEFINC = -I../.. -I. -DARM -DPANDORA
DEFINC = -I../.. -I. -DARM -DPANDORA -DIN_EVDEV
COPT_COMMON = -Wall -Winline -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a -I$(LIBROOT)/include
ifeq ($(DEBUG),)
COPT_COMMON += -O2 # -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math
@ -57,7 +57,8 @@ OBJS += pandora.o main.o emu.o asm_utils.o platform/gp2x/menu.o
# common
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \
platform/common/arm_utils.o platform/common/mp3_helix.o platform/common/arm_linux.o \
platform/common/readpng.o platform/linux/usbjoy.o platform/linux/sndout_oss.o
platform/common/readpng.o platform/common/input.o platform/linux/in_evdev.o \
platform/linux/sndout_oss.o
# Pico
ifeq "$(amalgamate)" "1"
@ -131,7 +132,7 @@ include ../common/common_arm.mak
PicoDrive : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a
@echo ">>>" $@
$(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map -lpng -L$(LIBROOT)/lib
$(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map -lpng -L$(LIBROOT)/lib -static
ifeq ($(DEBUG),)
$(STRIP) $@
endif

View file

@ -16,12 +16,13 @@
#include "../gp2x/emu.h"
#include "../gp2x/menu.h"
#include "../gp2x/gp2x.h"
#include "../common/arm_utils.h"
#include "../common/fonts.h"
#include "../common/emu.h"
#include "../common/config.h"
#include "../common/common.h"
#include "../linux/usbjoy.h"
#include "../common/input.h"
#include "../linux/sndout_oss.h"
#include "asm_utils.h"
@ -475,6 +476,7 @@ static void emu_msg_tray_open(void)
gettimeofday(&noticeMsgTime, 0);
}
#if 0
static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
{
int ret, px, py, lim_x;
@ -526,6 +528,7 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
PicoPicohw.pen_pos[0] += 0x3c;
PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
}
#endif
static void update_volume(int has_changed, int is_up)
{
@ -569,6 +572,7 @@ static void RunEvents(unsigned int which)
if ( emu_checkSaveFile(state_slot) &&
(( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load
(!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) { // save
#if 0
unsigned long keys;
blit("", (which & 0x1000) ? "LOAD STATE? (Y=yes, X=no)" : "OVERWRITE SAVE? (Y=yes, X=no)");
while ( !((keys = gp2x_joystick_read(1)) & (GP2X_X|GP2X_Y)) )
@ -577,6 +581,7 @@ static void RunEvents(unsigned int which)
while ( gp2x_joystick_read(1) & (GP2X_X|GP2X_Y) ) // wait for release
usleep(50*1024);
clearArea(0);
#endif
}
if (do_it) {
osd_text(4, SCREEN_HEIGHT-16, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");
@ -625,63 +630,11 @@ static void RunEvents(unsigned int which)
static void updateKeys(void)
{
unsigned int keys, keys2, allActions[2] = { 0, 0 }, events;
unsigned int allActions[2] = { 0, 0 }, events;
static unsigned int prevEvents = 0;
int joy, i;
keys = gp2x_joystick_read(0);
if (keys & GP2X_SELECT) {
engineState = select_exits ? PGS_Quit : PGS_Menu;
// wait until select is released, so menu would not resume game
while (gp2x_joystick_read(1) & GP2X_SELECT) usleep(50*1000);
}
keys &= CONFIGURABLE_KEYS;
keys2 = keys;
for (i = 0; i < 32; i++)
{
if (keys2 & (1 << i))
{
int pl, acts = currentConfig.KeyBinds[i];
if (!acts) continue;
pl = (acts >> 16) & 1;
if (kb_combo_keys & (1 << i))
{
int u = i+1, acts_c = acts & kb_combo_acts;
// let's try to find the other one
if (acts_c) {
for (; u < 32; u++)
if ( (keys2 & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {
allActions[pl] |= acts_c & currentConfig.KeyBinds[u];
keys2 &= ~((1 << i) | (1 << u));
break;
}
}
// add non-combo actions if combo ones were not found
if (!acts_c || u == 32)
allActions[pl] |= acts & ~kb_combo_acts;
} else {
allActions[pl] |= acts;
}
}
}
// add joy inputs
if (num_of_joys > 0)
{
usbjoy_update();
for (joy = 0; joy < num_of_joys; joy++) {
int btns = usbjoy_check2(joy);
for (i = 0; i < 32; i++) {
if (btns & (1 << i)) {
int acts = currentConfig.JoyBinds[joy][i];
int pl = (acts >> 16) & 1;
allActions[pl] |= acts;
}
}
}
}
/* FIXME: combos, player2 */
allActions[0] = in_update();
PicoPad[0] = allActions[0] & 0xfff;
PicoPad[1] = allActions[1] & 0xfff;
@ -703,8 +656,10 @@ static void updateKeys(void)
events &= ~prevEvents;
/*
if (PicoAHW == PAHW_PICO)
RunEventsPico(events, keys);
*/
if (events) RunEvents(events);
if (movie_data) emu_updateMovie();
@ -785,10 +740,46 @@ static void simpleWait(int thissec, int lim_time)
}
}
void emu_startSound(void)
{
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
int target_fps = Pico.m.pal ? 50 : 60;
PsndOut = NULL;
if (currentConfig.EmuOpt & 4)
{
int snd_excess_add;
if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)
PsndRerate(Pico.m.frame_count ? 1 : 0);
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
PicoWriteSound = updateSound;
update_volume(0, 0);
memset(sndBuffer, 0, sizeof(sndBuffer));
PsndOut = sndBuffer;
PsndRate_old = PsndRate;
PicoOpt_old = PicoOpt;
pal_old = Pico.m.pal;
}
}
void emu_endSound(void)
{
}
/* wait until we can write more sound */
void emu_waitSound(void)
{
// don't need to do anything, writes will block by themselves
}
void emu_Loop(void)
{
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
char fpsbuff[24]; // fps count c string
struct timeval tval; // timing
int pframes_done, pframes_shown, pthissec; // "period" frames, used for sync
@ -811,28 +802,7 @@ void emu_Loop(void)
target_frametime = 1000000/target_fps;
reset_timing = 1;
// prepare sound stuff
if (currentConfig.EmuOpt & 4)
{
int snd_excess_add;
if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)
PsndRerate(Pico.m.frame_count ? 1 : 0);
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
PicoWriteSound = updateSound;
update_volume(0, 0);
memset(sndBuffer, 0, sizeof(sndBuffer));
PsndOut = sndBuffer;
PsndRate_old = PsndRate;
PicoOpt_old = PicoOpt;
pal_old = Pico.m.pal;
} else {
PsndOut = NULL;
}
emu_startSound();
// prepare CD buffer
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();

View file

@ -15,6 +15,7 @@
#include "../common/menu.h"
#include "../common/emu.h"
#include "../common/config.h"
#include "../common/input.h"
#include "../gp2x/emu.h"
#include "../gp2x/version.h"
@ -77,10 +78,13 @@ int main(int argc, char *argv[])
{
g_argv = argv;
in_init();
emu_prepareDefaultConfig();
emu_ReadConfig(0, 0);
config_readlrom(PicoConfigFile);
in_probe();
in_debug_dump();
gp2x_init();
emu_Init();
menu_init();

View file

@ -12,7 +12,6 @@
#include <errno.h>
#include "../gp2x/gp2x.h"
#include "../linux/usbjoy.h"
#include "../linux/sndout_oss.h"
#include "../common/arm_linux.h"
@ -87,22 +86,6 @@ void gp2x_pd_clone_buffer2(void)
memset(gp2x_screen, 0, 800*480*2);
}
unsigned long gp2x_joystick_read(int allow_usb_joy)
{
unsigned long value = 0;
int i;
if (allow_usb_joy && num_of_joys > 0) {
// check the usb joy as well..
usbjoy_update();
for (i = 0; i < num_of_joys; i++)
value |= usbjoy_check(i);
}
return value;
}
// FIXME
#if 0
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
@ -180,9 +163,6 @@ void gp2x_init(void)
// snd
sndout_oss_init();
/* init usb joys -GnoStiC */
usbjoy_init();
printf("exitting init()\n"); fflush(stdout);
}
@ -196,7 +176,6 @@ void gp2x_deinit(void)
if (fbdev >= 0) close(fbdev);
sndout_oss_exit();
usbjoy_deinit();
printf("all done");
}