From: notaz Date: Fri, 17 Oct 2008 15:29:37 +0000 (+0000) Subject: extracted OSS code to sndout_oss_*, BTN->PBTN, refactoring X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3972d826fe31f82aa3382f80454e5d8ce895705;p=libpicofe.git extracted OSS code to sndout_oss_*, BTN->PBTN, refactoring git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@599 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/common/common.h b/common/common.h index 4945f5e..0b7a20f 100644 --- a/common/common.h +++ b/common/common.h @@ -3,17 +3,17 @@ #ifdef __GP2X__ #include "../gp2x/gp2x.h" -#define BTN_UP GP2X_UP -#define BTN_DOWN GP2X_DOWN -#define BTN_LEFT GP2X_LEFT -#define BTN_RIGHT GP2X_RIGHT - -#define BTN_NORTH GP2X_Y -#define BTN_SOUTH GP2X_X -#define BTN_WEST GP2X_A -#define BTN_EAST GP2X_B -#define BTN_L GP2X_L -#define BTN_R GP2X_R +#define PBTN_UP GP2X_UP +#define PBTN_DOWN GP2X_DOWN +#define PBTN_LEFT GP2X_LEFT +#define PBTN_RIGHT GP2X_RIGHT + +#define PBTN_NORTH GP2X_Y +#define PBTN_SOUTH GP2X_X +#define PBTN_WEST GP2X_A +#define PBTN_EAST GP2X_B +#define PBTN_L GP2X_L +#define PBTN_R GP2X_R unsigned long wait_for_input(unsigned long interesting); void gp2x_pd_clone_buffer2(void); @@ -43,10 +43,10 @@ void menu_flip(void); #include "../gizmondo/giz.h" -#define BTN_NORTH BTN_STOP -#define BTN_SOUTH BTN_PLAY -#define BTN_WEST BTN_REW -#define BTN_EAST BTN_FWD +#define PBTN_NORTH PBTN_STOP +#define PBTN_SOUTH PBTN_PLAY +#define PBTN_WEST PBTN_REW +#define PBTN_EAST PBTN_FWD unsigned long wait_for_input(unsigned int interesting); void menu_draw_begin(int use_bgbuff); @@ -75,10 +75,10 @@ extern void *giz_screen; #include "../psp/psp.h" -#define BTN_NORTH BTN_TRIANGLE -#define BTN_SOUTH BTN_X -#define BTN_WEST BTN_SQUARE -#define BTN_EAST BTN_CIRCLE +#define PBTN_NORTH PBTN_TRIANGLE +#define PBTN_SOUTH PBTN_X +#define PBTN_WEST PBTN_SQUARE +#define PBTN_EAST PBTN_CIRCLE unsigned long wait_for_input(unsigned int interesting, int is_key_config); void menu_draw_begin(void); @@ -106,17 +106,17 @@ void menu_draw_end(void); #include "../gp2x/gp2x.h" -#define BTN_UP 0 -#define BTN_DOWN 0 -#define BTN_LEFT 0 -#define BTN_RIGHT 0 - -#define BTN_NORTH 0 -#define BTN_SOUTH 0 -#define BTN_WEST 0 -#define BTN_EAST 0 -#define BTN_L 0 -#define BTN_R 0 +#define PBTN_UP 0 +#define PBTN_DOWN 0 +#define PBTN_LEFT 0 +#define PBTN_RIGHT 0 + +#define PBTN_NORTH 0 +#define PBTN_SOUTH 0 +#define PBTN_WEST 0 +#define PBTN_EAST 0 +#define PBTN_L 0 +#define PBTN_R 0 unsigned long wait_for_input(unsigned long interesting); void gp2x_pd_clone_buffer2(void); diff --git a/common/menu.c b/common/menu.c index 241af9f..611cee9 100644 --- a/common/menu.c +++ b/common/menu.c @@ -350,7 +350,7 @@ static void mplayer_loop(void) while (1) { PDebugZ80Frame(); - if (read_buttons_async(BTN_NORTH)) break; + if (read_buttons_async(PBTN_NORTH)) break; emu_waitSound(); } @@ -429,41 +429,41 @@ void debug_menu_loop(void) } menu_draw_end(); - inp = read_buttons(BTN_EAST|BTN_SOUTH|BTN_WEST|BTN_NORTH|BTN_L|BTN_R|BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT); - if (inp & BTN_SOUTH) return; - if (inp & BTN_L) { mode--; if (mode < 0) mode = 3; } - if (inp & BTN_R) { mode++; if (mode > 3) mode = 0; } + inp = read_buttons(PBTN_EAST|PBTN_SOUTH|PBTN_WEST|PBTN_NORTH|PBTN_L|PBTN_R|PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT); + if (inp & PBTN_SOUTH) return; + if (inp & PBTN_L) { mode--; if (mode < 0) mode = 3; } + if (inp & PBTN_R) { mode++; if (mode > 3) mode = 0; } switch (mode) { case 0: - if (inp & BTN_EAST) SekStepM68k(); - if (inp & BTN_NORTH) { - while (inp & BTN_NORTH) inp = read_buttons_async(BTN_NORTH); + if (inp & PBTN_EAST) SekStepM68k(); + if (inp & PBTN_NORTH) { + while (inp & PBTN_NORTH) inp = read_buttons_async(PBTN_NORTH); mplayer_loop(); } - if ((inp & (BTN_WEST|BTN_LEFT)) == (BTN_WEST|BTN_LEFT)) { + if ((inp & (PBTN_WEST|PBTN_LEFT)) == (PBTN_WEST|PBTN_LEFT)) { mkdir("dumps", 0777); PDebugDumpMem(); - while (inp & BTN_WEST) inp = read_buttons_async(BTN_WEST); + while (inp & PBTN_WEST) inp = read_buttons_async(PBTN_WEST); dumped = 1; } break; case 1: - if (inp & BTN_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON; - if (inp & BTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON; - if (inp & BTN_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON; - if (inp & BTN_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON; - if (inp & BTN_EAST) { + if (inp & PBTN_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON; + if (inp & PBTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON; + if (inp & PBTN_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON; + if (inp & PBTN_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON; + if (inp & PBTN_EAST) { PsndOut = NULL; // just in case PicoSkipFrame = 1; PicoFrame(); PicoSkipFrame = 0; - while (inp & BTN_EAST) inp = read_buttons_async(BTN_EAST); + while (inp & PBTN_EAST) inp = read_buttons_async(PBTN_EAST); } break; case 3: - if (inp & BTN_DOWN) spr_offs++; - if (inp & BTN_UP) spr_offs--; + if (inp & PBTN_DOWN) spr_offs++; + if (inp & PBTN_UP) spr_offs--; if (spr_offs < 0) spr_offs = 0; break; } diff --git a/gp2x/Makefile b/gp2x/Makefile index 1fa5c8b..ed4f928 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -54,14 +54,14 @@ LD = $(CROSS)ld OBJCOPY = $(CROSS)objcopy # frontend -OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o +OBJS += main.o menu.o gp2x.o emu.o squidgehack.o cpuctrl.o # 940 core control OBJS += 940ctl.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/arm_linux.o platform/common/readpng.o \ - platform/common/mp3_helix.o + platform/common/mp3_helix.o platform/linux/usbjoy.o platform/linux/sndout_oss.o # Pico ifeq "$(amalgamate)" "1" @@ -116,8 +116,8 @@ endif vpath %.c = ../.. vpath %.s = ../.. vpath %.S = ../.. -DIRS = platform platform/gp2x platform/common pico pico/cd pico/pico pico/sound pico/carthw/svp \ - zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80 +DIRS = platform platform/gp2x platform/linux platform/common pico pico/cd pico/pico pico/sound \ + pico/carthw/svp zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80 all: mkdirs PicoDrive.gpe diff --git a/gp2x/emu.c b/gp2x/emu.c index 8e726e3..c696d88 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -16,12 +16,13 @@ #include "emu.h" #include "gp2x.h" -#include "usbjoy.h" #include "menu.h" +#include "../linux/usbjoy.h" #include "../common/arm_utils.h" #include "../common/fonts.h" #include "../common/emu.h" #include "../common/config.h" +#include "../linux/sndout_oss.h" #include "cpuctrl.h" #include @@ -487,7 +488,7 @@ static void update_volume(int has_changed, int is_up) if (vol > 0) vol--; } wait_frames = 0; - gp2x_sound_volume(vol, vol); + sndout_oss_setvol(vol, vol); currentConfig.volume = vol; } sprintf(noticeMsg, "VOL: %02i", vol); @@ -614,9 +615,9 @@ static void updateKeys(void) // add joy inputs if (num_of_joys > 0) { - gp2x_usbjoy_update(); + usbjoy_update(); for (joy = 0; joy < num_of_joys; joy++) { - int btns = gp2x_usbjoy_check2(joy); + int btns = usbjoy_check2(joy); for (i = 0; i < 32; i++) { if (btns & (1 << i)) { int acts = currentConfig.JoyBinds[joy][i]; @@ -662,7 +663,7 @@ static void updateSound(int len) /* avoid writing audio when lagging behind to prevent audio lag */ if (PicoSkipFrame != 2) - gp2x_sound_write(PsndOut, len<<1); + sndout_oss_write(PsndOut, len<<1); } void emu_startSound(void) @@ -683,8 +684,8 @@ void emu_startSound(void) 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); - gp2x_start_sound(PsndRate, 16, (PicoOpt&8)>>3); - gp2x_sound_volume(currentConfig.volume, currentConfig.volume); + 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)); diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c index 0276038..89505a0 100644 --- a/gp2x/gp2x.c +++ b/gp2x/gp2x.c @@ -28,13 +28,12 @@ #include #include #include -#include -#include #include #include #include "gp2x.h" -#include "usbjoy.h" +#include "../linux/usbjoy.h" +#include "../linux/sndout_oss.h" #include "../common/arm_utils.h" #include "../common/arm_linux.h" @@ -45,7 +44,7 @@ static void *gp2x_screens[4]; static int screensel = 0; //static int memdev = 0; -static int sounddev = -1, mixerdev = -1, touchdev = -1; +static int touchdev = -1; static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 }; void *gp2x_screen; @@ -210,9 +209,9 @@ unsigned long gp2x_joystick_read(int allow_usb_joy) if (allow_usb_joy && num_of_joys > 0) { // check the usb joy as well.. - gp2x_usbjoy_update(); + usbjoy_update(); for (i = 0; i < num_of_joys; i++) - value |= gp2x_usbjoy_check(i); + value |= usbjoy_check(i); } return value; @@ -251,57 +250,6 @@ int gp2x_touchpad_read(int *x, int *y) } -static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; - -void gp2x_start_sound(int rate, int bits, int stereo) -{ - int frag = 0, bsize, buffers; - - // if no settings change, we don't need to do anything - if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) return; - - if (sounddev > 0) close(sounddev); - sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC); - if (sounddev == -1) - printf("open(\"/dev/dsp\") failed with %i\n", errno); - - ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits); - ioctl(sounddev, SNDCTL_DSP_SPEED, &rate); - ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo); - // calculate buffer size - buffers = 16; - bsize = rate / 32; - if (rate > 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding - while ((bsize>>=1)) frag++; - frag |= buffers<<16; // 16 buffers - ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag); - usleep(192*1024); - - printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n", - rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff)); - - s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo; -} - - -void gp2x_sound_write(void *buff, int len) -{ - write(sounddev, buff, len); -} - -void gp2x_sound_sync(void) -{ - ioctl(sounddev, SOUND_PCM_SYNC, 0); -} - -void gp2x_sound_volume(int l, int r) -{ - l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r; - l<<=8; l|=r; - ioctl(mixerdev, SOUND_MIXER_WRITE_PCM, &l); /*SOUND_MIXER_WRITE_VOLUME*/ -} - - /* 940 */ void Pause940(int yes) { @@ -352,7 +300,7 @@ void gp2x_init(void) memdev = open("/dev/mem", O_RDWR); if (memdev == -1) { - printf("open(\"/dev/mem\") failed with %i\n", errno); + perror("open(\"/dev/mem\")"); exit(1); } @@ -360,7 +308,7 @@ void gp2x_init(void) printf("memregs are @ %p\n", gp2x_memregs); if(gp2x_memregs == MAP_FAILED) { - printf("mmap(memregs) failed with %i\n", errno); + perror("mmap(memregs)"); exit(1); } gp2x_memregl = (unsigned long *) gp2x_memregs; @@ -370,7 +318,7 @@ void gp2x_init(void) gp2x_screens[0] = mmap(0, FRAMEBUFF_WHOLESIZE, PROT_WRITE, MAP_SHARED, memdev, FRAMEBUFF_ADDR0); if(gp2x_screens[0] == MAP_FAILED) { - printf("mmap(gp2x_screen) failed with %i\n", errno); + perror("mmap(gp2x_screen)"); exit(1); } printf("framebuffers point to %p\n", gp2x_screens[0]); @@ -390,12 +338,10 @@ void gp2x_init(void) gp2x_memset_all_buffers(0, 0, 320*240*2); // snd - mixerdev = open("/dev/mixer", O_RDWR); - if (mixerdev == -1) - printf("open(\"/dev/mixer\") failed with %i\n", errno); + sndout_oss_init(); /* init usb joys -GnoStiC */ - gp2x_usbjoy_init(); + usbjoy_init(); // touchscreen touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY); @@ -432,16 +378,15 @@ void gp2x_deinit(void) munmap(gp2x_screens[0], FRAMEBUFF_WHOLESIZE); munmap((void *)gp2x_memregs, 0x10000); close(memdev); - close(mixerdev); - if (sounddev >= 0) close(sounddev); if (touchdev >= 0) close(touchdev); - gp2x_usbjoy_deinit(); + sndout_oss_exit(); + usbjoy_deinit(); printf("all done, running "); // Zaq121's alternative frontend support from MAME - if(ext_menu && ext_state) { + if (ext_menu && ext_state) { printf("%s -state %s\n", ext_menu, ext_state); execl(ext_menu, ext_menu, "-state", ext_state, NULL); } else if(ext_menu) { diff --git a/gp2x/gp2x.h b/gp2x/gp2x.h index 3d0db13..b61b853 100644 --- a/gp2x/gp2x.h +++ b/gp2x/gp2x.h @@ -20,12 +20,6 @@ void gp2x_memcpy_all_buffers(void *data, int offset, int len); void gp2x_memset_all_buffers(int offset, int byte, int len); void gp2x_pd_clone_buffer2(void); -/* sound */ -void gp2x_start_sound(int rate, int bits, int stereo); -void gp2x_sound_write(void *buff, int len); -void gp2x_sound_volume(int l, int r); -void gp2x_sound_sync(void); - /* input */ unsigned long gp2x_joystick_read(int allow_usb_joy); int gp2x_touchpad_read(int *x, int *y); diff --git a/gp2x/menu.c b/gp2x/menu.c index e37c878..ff8cd99 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -13,7 +13,7 @@ #include "gp2x.h" #include "emu.h" #include "menu.h" -#include "usbjoy.h" +#include "../linux/usbjoy.h" #include "../common/emu.h" #include "../common/menu.h" #include "../common/arm_utils.h" @@ -90,9 +90,9 @@ static unsigned long input2_read(unsigned long interesting, int *joy) { *joy = 0; if ((ret = gp2x_joystick_read(0) & interesting)) break; - gp2x_usbjoy_update(); + usbjoy_update(); for (i = 0; i < num_of_joys; i++) { - ret = gp2x_usbjoy_check2(i); + ret = usbjoy_check2(i); if (ret) { *joy = i + 1; break; } } if (ret) break; diff --git a/linux/Makefile b/linux/Makefile index 442b50a..8000a0d 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -27,8 +27,8 @@ COPT += `pkg-config --cflags gthread-2.0` LDFLAGS += `pkg-config --libs gthread-2.0` # frontend -OBJS += platform/gp2x/main.o platform/gp2x/menu.o platform/gp2x/emu.o platform/gp2x/usbjoy.o blit.o \ - gp2x.o 940ctl_ym2612.o log_io.o +OBJS += platform/gp2x/main.o platform/gp2x/menu.o platform/gp2x/emu.o usbjoy.o blit.o \ + sndout_oss.o gp2x.o 940ctl_ym2612.o log_io.o # common OBJS += platform/common/emu.o platform/common/menu.o platform/common/config.o platform/common/fonts.o \ diff --git a/linux/gp2x.c b/linux/gp2x.c index ef21a67..bcb3ee3 100644 --- a/linux/gp2x.c +++ b/linux/gp2x.c @@ -9,15 +9,14 @@ #include #include #include -#include -#include #include #include #include "../gp2x/emu.h" #include "../gp2x/gp2x.h" -#include "../gp2x/usbjoy.h" #include "../gp2x/version.h" +#include "sndout_oss.h" +#include "usbjoy.h" #include "log_io.h" @@ -25,7 +24,6 @@ void *gp2x_screen; static int current_bpp = 8; static int current_pal[256]; static unsigned long current_keys = 0; -static int sounddev = 0, mixerdev = 0; static const char *verstring = "PicoDrive " VERSION; // dummies @@ -184,13 +182,11 @@ void gp2x_init(void) memset(gp2x_screen, 0, 320*240*2 + 320*2); // snd - mixerdev = open("/dev/mixer", O_RDWR); - if (mixerdev == -1) - printf("open(\"/dev/mixer\") failed with %i\n", errno); + sndout_oss_init(); gtk_initf(); - gp2x_usbjoy_init(); + usbjoy_init(); printf("exitting init()\n"); fflush(stdout); } @@ -198,9 +194,8 @@ void gp2x_init(void) void gp2x_deinit(void) { free(gp2x_screen); - if (sounddev > 0) close(sounddev); - close(mixerdev); - gp2x_usbjoy_deinit(); + sndout_oss_exit(); + usbjoy_deinit(); } /* video */ @@ -304,54 +299,6 @@ void gp2x_pd_clone_buffer2(void) memset(gp2x_screen, 0, 320*240*2); } -/* sound */ -static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; - -void gp2x_start_sound(int rate, int bits, int stereo) -{ - int frag = 0, bsize, buffers; - - // if no settings change, we don't need to do anything - if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) return; - - if (sounddev > 0) close(sounddev); - sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC); - if (sounddev == -1) - printf("open(\"/dev/dsp\") failed with %i\n", errno); - - ioctl(sounddev, SNDCTL_DSP_SPEED, &rate); - ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits); - ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo); - // calculate buffer size - buffers = 16; - bsize = rate / 32; - if (rate > 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding - while ((bsize>>=1)) frag++; - frag |= buffers<<16; // 16 buffers - ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag); - printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n", - rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff)); - - s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo; -} - -void gp2x_sound_write(void *buff, int len) -{ - write(sounddev, buff, len); -} - -void gp2x_sound_sync(void) -{ - ioctl(sounddev, SOUND_PCM_SYNC, 0); -} - -void gp2x_sound_volume(int l, int r) -{ - l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r; - l<<=8; l|=r; - ioctl(mixerdev, SOUND_MIXER_WRITE_PCM, &l); /*SOUND_MIXER_WRITE_VOLUME*/ -} - /* joy */ unsigned long gp2x_joystick_read(int allow_usb_joy) { @@ -360,9 +307,9 @@ unsigned long gp2x_joystick_read(int allow_usb_joy) if (allow_usb_joy && num_of_joys > 0) { // check the usb joy as well.. - gp2x_usbjoy_update(); + usbjoy_update(); for (i = 0; i < num_of_joys; i++) - value |= gp2x_usbjoy_check(i); + value |= usbjoy_check(i); } return value; diff --git a/linux/sndout_oss.c b/linux/sndout_oss.c new file mode 100644 index 0000000..e2d0bde --- /dev/null +++ b/linux/sndout_oss.c @@ -0,0 +1,96 @@ +/* sound output via OSS */ +#include +#include +#include +#include +#include +#include +#include + +#include "sndout_oss.h" + +static int sounddev = -1, mixerdev = -1; + +int sndout_oss_init(void) +{ + if (mixerdev >= 0) close(mixerdev); + mixerdev = open("/dev/mixer", O_RDWR); + if (mixerdev == -1) + { + perror("open(\"/dev/mixer\")"); + } + + return 0; +} + + +int sndout_oss_start(int rate, int bits, int stereo) +{ + static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; + int frag = 0, bsize, buffers, ret; + + // if no settings change, we don't need to do anything, + // since audio is never stopped + if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) + return 0; + + if (sounddev >= 0) close(sounddev); + sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC); + if (sounddev == -1) + { + perror("open(\"/dev/dsp\")"); + return -1; + } + + // calculate buffer size + // this is tuned for GP2X + buffers = 16; + bsize = rate / 32; + if (rate > 22050) { bsize*=4; buffers*=2; } + while ((bsize>>=1)) frag++; + frag |= buffers<<16; // 16 buffers + ret = ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag); + if (ret) perror("SNDCTL_DSP_SETFRAGMENT failed"); + + ret = ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo); + ret |= ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits); + ret |= ioctl(sounddev, SNDCTL_DSP_SPEED, &rate); + if (ret) printf("failed to set audio format\n"); + usleep(192*1024); + + printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n", + rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff)); + + s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo; + return 0; +} + + +int sndout_oss_write(const void *buff, int len) +{ + return write(sounddev, buff, len); +} + + +void sndout_oss_sync(void) +{ + ioctl(sounddev, SOUND_PCM_SYNC, 0); +} + + +void sndout_oss_setvol(int l, int r) +{ + if (mixerdev < 0) return; + + l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r; + l<<=8; l|=r; + ioctl(mixerdev, SOUND_MIXER_WRITE_PCM, &l); /*SOUND_MIXER_WRITE_VOLUME*/ +} + + +void sndout_oss_exit(void) +{ + if (sounddev >= 0) close(sounddev); sounddev = -1; + if (mixerdev >= 0) close(mixerdev); mixerdev = -1; +} + diff --git a/linux/sndout_oss.h b/linux/sndout_oss.h new file mode 100644 index 0000000..d6f285b --- /dev/null +++ b/linux/sndout_oss.h @@ -0,0 +1,6 @@ +int sndout_oss_init(void); +int sndout_oss_start(int rate, int bits, int stereo); +int sndout_oss_write(const void *buff, int len); +void sndout_oss_sync(void); +void sndout_oss_setvol(int l, int r); +void sndout_oss_exit(void); diff --git a/gp2x/usbjoy.c b/linux/usbjoy.c similarity index 88% rename from gp2x/usbjoy.c rename to linux/usbjoy.c index d92e8f6..5930038 100644 --- a/gp2x/usbjoy.c +++ b/linux/usbjoy.c @@ -321,16 +321,15 @@ int joy_close (struct usbjoy * joy) { } -/*********************************************************************/ -/* GP2X USB Joystick Handling -GnoStiC */ /*********************************************************************/ -#include "gp2x.h" +#include "../common/common.h" int num_of_joys = 0; struct usbjoy *joys[4]; -void gp2x_usbjoy_init (void) { +void usbjoy_init (void) +{ /* Open available joysticks -GnoStiC */ int i, n = 0; @@ -347,7 +346,8 @@ void gp2x_usbjoy_init (void) { printf("Found %d Joystick(s)\n",num_of_joys); } -void gp2x_usbjoy_update (void) { +void usbjoy_update (void) +{ /* Update Joystick Event Cache */ int q, foo; for (q=0; q < num_of_joys; q++) { @@ -355,45 +355,48 @@ void gp2x_usbjoy_update (void) { } } -int gp2x_usbjoy_check (int joyno) { +int usbjoy_check (int joyno) +{ /* Check Joystick */ int q, joyExKey = 0; struct usbjoy *joy = joys[joyno]; if (joy != NULL) { - if (joy_getaxe(JOYUP, joy)) { joyExKey |= GP2X_UP; } - if (joy_getaxe(JOYDOWN, joy)) { joyExKey |= GP2X_DOWN; } - if (joy_getaxe(JOYLEFT, joy)) { joyExKey |= GP2X_LEFT; } - if (joy_getaxe(JOYRIGHT, joy)) { joyExKey |= GP2X_RIGHT; } + if (joy_getaxe(JOYUP, joy)) { joyExKey |= PBTN_UP; } + if (joy_getaxe(JOYDOWN, joy)) { joyExKey |= PBTN_DOWN; } + if (joy_getaxe(JOYLEFT, joy)) { joyExKey |= PBTN_LEFT; } + if (joy_getaxe(JOYRIGHT, joy)) { joyExKey |= PBTN_RIGHT; } /* loop through joy buttons to check if they are pushed */ for (q=0; qtype == JOY_TYPE_LOGITECH) { switch (q) { - case 0: joyExKey |= GP2X_A; break; - case 1: joyExKey |= GP2X_X; break; - case 2: joyExKey |= GP2X_B; break; - case 3: joyExKey |= GP2X_Y; break; + case 0: joyExKey |= PBTN_WEST; break; + case 1: joyExKey |= PBTN_SOUTH; break; + case 2: joyExKey |= PBTN_EAST; break; + case 3: joyExKey |= PBTN_NORTH; break; } } else { switch (q) { - case 0: joyExKey |= GP2X_Y; break; - case 1: joyExKey |= GP2X_B; break; - case 2: joyExKey |= GP2X_X; break; - case 3: joyExKey |= GP2X_A; break; + case 0: joyExKey |= PBTN_NORTH; break; + case 1: joyExKey |= PBTN_EAST; break; + case 2: joyExKey |= PBTN_SOUTH; break; + case 3: joyExKey |= PBTN_WEST; break; } } switch (q) { - case 4: joyExKey |= GP2X_L; break; - case 5: joyExKey |= GP2X_R; break; - case 6: joyExKey |= GP2X_L; break; /* left shoulder button 2 */ - case 7: joyExKey |= GP2X_R; break; /* right shoulder button 2 */ + case 4: joyExKey |= PBTN_L; break; + case 5: joyExKey |= PBTN_R; break; + case 6: joyExKey |= PBTN_L; break; /* left shoulder button 2 */ + case 7: joyExKey |= PBTN_R; break; /* right shoulder button 2 */ +/* case 8: joyExKey |= GP2X_SELECT;break; case 9: joyExKey |= GP2X_START; break; case 10: joyExKey |= GP2X_PUSH; break; case 11: joyExKey |= GP2X_PUSH; break; +*/ } } } @@ -401,7 +404,8 @@ int gp2x_usbjoy_check (int joyno) { return joyExKey; } -int gp2x_usbjoy_check2 (int joyno) { +int usbjoy_check2 (int joyno) +{ /* Check Joystick, don't map to gp2x joy */ int q, to, joyExKey = 0; struct usbjoy *joy = joys[joyno]; @@ -423,7 +427,8 @@ int gp2x_usbjoy_check2 (int joyno) { -void gp2x_usbjoy_deinit (void) { +void usbjoy_deinit (void) +{ int i; for (i=0; i>>" $@ - $(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map # -lpng + $(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map -lpng -L$(LIBROOT)/lib ifeq ($(DEBUG),) $(STRIP) $@ endif diff --git a/pandora/emu.c b/pandora/emu.c index a749836..f12bac6 100644 --- a/pandora/emu.c +++ b/pandora/emu.c @@ -15,13 +15,14 @@ #include #include "../gp2x/emu.h" -#include "../gp2x/usbjoy.h" #include "../gp2x/menu.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 "../linux/sndout_oss.h" #include "asm_utils.h" #include @@ -554,7 +555,7 @@ static void update_volume(int has_changed, int is_up) if (vol > 0) vol--; } wait_frames = 0; - gp2x_sound_volume(vol, vol); + sndout_oss_setvol(vol, vol); currentConfig.volume = vol; } sprintf(noticeMsg, "VOL: %02i", vol); @@ -681,9 +682,9 @@ static void updateKeys(void) // add joy inputs if (num_of_joys > 0) { - gp2x_usbjoy_update(); + usbjoy_update(); for (joy = 0; joy < num_of_joys; joy++) { - int btns = gp2x_usbjoy_check2(joy); + int btns = usbjoy_check2(joy); for (i = 0; i < 32; i++) { if (btns & (1 << i)) { int acts = currentConfig.JoyBinds[joy][i]; @@ -729,7 +730,7 @@ static void updateSound(int len) /* avoid writing audio when lagging behind to prevent audio lag */ if (PicoSkipFrame != 2) - gp2x_sound_write(PsndOut, len<<1); + sndout_oss_write(PsndOut, len<<1); } @@ -833,8 +834,8 @@ void emu_Loop(void) 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); - gp2x_start_sound(PsndRate, 16, (PicoOpt&8)>>3); - gp2x_sound_volume(currentConfig.volume, currentConfig.volume); + 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)); diff --git a/pandora/pandora.c b/pandora/pandora.c index dd73973..b72d8b6 100644 --- a/pandora/pandora.c +++ b/pandora/pandora.c @@ -7,23 +7,20 @@ #include #include #include -#include -#include #include #include #include #include "../gp2x/gp2x.h" -#include "../gp2x/usbjoy.h" +#include "../linux/usbjoy.h" +#include "../linux/sndout_oss.h" #include "../common/arm_linux.h" static volatile unsigned int *memregs = MAP_FAILED; //static int memdev = 0; -static int fbdev = -1, sounddev = -1, mixerdev = -1, touchdev = -1; -static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 }; +static int fbdev = -1; -//#define SCREEN_MAP_SIZE (((800*(480+11)*2)+0xfff)&~0xfff) #define SCREEN_MAP_SIZE (800*480*2) static void *screen = MAP_FAILED; void *gp2x_screen; @@ -98,14 +95,18 @@ unsigned long gp2x_joystick_read(int allow_usb_joy) if (allow_usb_joy && num_of_joys > 0) { // check the usb joy as well.. - gp2x_usbjoy_update(); + usbjoy_update(); for (i = 0; i < num_of_joys; i++) - value |= gp2x_usbjoy_check(i); + value |= usbjoy_check(i); } return value; } +// FIXME +#if 0 +static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 }; + typedef struct ucb1x00_ts_event { unsigned short pressure; @@ -137,73 +138,19 @@ int gp2x_touchpad_read(int *x, int *y) return zero_seen ? event.pressure : 0; } - - -static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; - -void gp2x_start_sound(int rate, int bits, int stereo) -{ - int frag = 0, bsize, buffers; - - // if no settings change, we don't need to do anything - if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) return; - - if (sounddev > 0) close(sounddev); - sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC); - if (sounddev == -1) - printf("open(\"/dev/dsp\") failed with %i\n", errno); - - ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits); - ioctl(sounddev, SNDCTL_DSP_SPEED, &rate); - ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo); - // calculate buffer size - buffers = 16; - bsize = rate / 32; - if (rate > 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding - while ((bsize>>=1)) frag++; - frag |= buffers<<16; // 16 buffers - ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag); - usleep(192*1024); - - printf("gp2x_set_sound: %i/%ibit/%s, %i buffers of %i bytes\n", - rate, bits, stereo?"stereo":"mono", frag>>16, 1<<(frag&0xffff)); - - s_oldrate = rate; s_oldbits = bits; s_oldstereo = stereo; -} - - -void gp2x_sound_write(void *buff, int len) -{ - write(sounddev, buff, len); -} - -void gp2x_sound_sync(void) -{ -// ioctl(sounddev, SOUND_PCM_SYNC, 0); -} - -void gp2x_sound_volume(int l, int r) -{ -#if 0 - l=l<0?0:l; l=l>255?255:l; r=r<0?0:r; r=r>255?255:r; - l<<=8; l|=r; - ioctl(mixerdev, SOUND_MIXER_WRITE_PCM, &l); /*SOUND_MIXER_WRITE_VOLUME*/ +#else +int gp2x_touchpad_read(int *x, int *y) { return -1; } #endif -} - /* common */ void gp2x_init(void) { - struct fb_fix_screeninfo fbfix; - int ret; - printf("entering init()\n"); fflush(stdout); memdev = open("/dev/mem", O_RDWR); if (memdev == -1) { - printf("open(\"/dev/mem\") failed with %i\n", errno); + perror("open(\"/dev/mem\")"); exit(1); } /* @@ -217,73 +164,39 @@ void gp2x_init(void) fbdev = open("/dev/fb0", O_RDWR); if (fbdev == -1) { - printf("open(\"/dev/fb0\") failed with %i\n", errno); - exit(1); - } - - ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix); - if (ret == -1) - { - printf("ioctl(fbdev) failed with %i\n", errno); + perror("open(\"/dev/fb0\")"); exit(1); } - // squidge hack - if (fbfix.line_length != 800*2) - { - gp2x_screen = malloc(800*640*2); - return; - } - screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0); if (screen == MAP_FAILED) { - printf("mmap(fbptr) failed with %i\n", errno); + perror("mmap(fbptr)"); exit(1); } printf("fbptr %p\n", screen); -// gp2x_screen = (char *)screen + 800*10*2-64; gp2x_screen = screen; - // snd - mixerdev = open("/dev/mixer", O_RDWR); - if (mixerdev == -1) - printf("open(\"/dev/mixer\") failed with %i\n", errno); + sndout_oss_init(); /* init usb joys -GnoStiC */ - gp2x_usbjoy_init(); - - // touchscreen - touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY); - if (touchdev >= 0) { - FILE *pcf = fopen("/etc/pointercal", "r"); - if (pcf) { - fscanf(pcf, "%d %d %d %d %d %d %d", &touchcal[0], &touchcal[1], - &touchcal[2], &touchcal[3], &touchcal[4], &touchcal[5], &touchcal[6]); - fclose(pcf); - } - printf("found touchscreen/wm97xx\n"); - } + usbjoy_init(); printf("exitting init()\n"); fflush(stdout); } void gp2x_deinit(void) { - //gp2x_video_changemode(15); - if (screen != MAP_FAILED) munmap(screen, SCREEN_MAP_SIZE); if (memregs != MAP_FAILED) munmap((void *)memregs, 0x10000); close(memdev); if (fbdev >= 0) close(fbdev); - if (mixerdev >= 0) close(mixerdev); - if (sounddev >= 0) close(sounddev); - if (touchdev >= 0) close(touchdev); - gp2x_usbjoy_deinit(); + sndout_oss_exit(); + usbjoy_deinit(); printf("all done"); } @@ -302,7 +215,6 @@ void lprintf(const char *fmt, ...) /* fake GP2X */ int crashed_940 = 0; -int readpng(void *dest, const char *fname, int what) { return -1; } void set_gamma(int g100, int A_SNs_curve) {} void set_FCLK(unsigned MHZ) {} void set_LCD_custom_rate(int rate) {} diff --git a/psp/emu.c b/psp/emu.c index 015c320..a9acac7 100644 --- a/psp/emu.c +++ b/psp/emu.c @@ -750,10 +750,10 @@ static void RunEventsPico(unsigned int events, unsigned int keys) if (pico_inp_mode != 0) { PicoPad[0] &= ~0x0f; // release UDLR - if (keys & BTN_UP) { pico_pen_y--; if (pico_pen_y < 8) pico_pen_y = 8; } - if (keys & BTN_DOWN) { pico_pen_y++; if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y; } - if (keys & BTN_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; } - if (keys & BTN_RIGHT) { + if (keys & PBTN_UP) { pico_pen_y--; if (pico_pen_y < 8) pico_pen_y = 8; } + if (keys & PBTN_DOWN) { pico_pen_y++; if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y; } + if (keys & PBTN_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; } + if (keys & PBTN_RIGHT) { int lim = (Pico.video.reg[12]&1) ? 319 : 255; pico_pen_x++; if (pico_pen_x > lim-PICO_PEN_ADJUST_X) @@ -779,10 +779,10 @@ static void RunEvents(unsigned int which) int keys; sceGuSync(0,0); blit2("", (which & 0x1000) ? "LOAD STATE? (X=yes, O=no)" : "OVERWRITE SAVE? (X=yes, O=no)", 0); - while( !((keys = psp_pad_read(1)) & (BTN_X|BTN_CIRCLE)) ) + while( !((keys = psp_pad_read(1)) & (PBTN_X|PBTN_CIRCLE)) ) psp_msleep(50); - if (keys & BTN_CIRCLE) do_it = 0; - while( ((keys = psp_pad_read(1)) & (BTN_X|BTN_CIRCLE)) ) // wait for release + if (keys & PBTN_CIRCLE) do_it = 0; + while( ((keys = psp_pad_read(1)) & (PBTN_X|PBTN_CIRCLE)) ) // wait for release psp_msleep(50); clearArea(0); } @@ -836,7 +836,7 @@ static void updateKeys(void) if (keys & PSP_CTRL_HOME) sceDisplayWaitVblankStart(); - if (keys & BTN_SELECT) + if (keys & PBTN_SELECT) engineState = PGS_Menu; keys &= CONFIGURABLE_KEYS; diff --git a/psp/menu.c b/psp/menu.c index 6fe06ae..68b55b4 100644 --- a/psp/menu.c +++ b/psp/menu.c @@ -80,14 +80,14 @@ unsigned long wait_for_input(unsigned int interesting, int is_key_config) if (!is_key_config) ret |= (ret & 0xf0000000) >> 24; // use analog as d-pad - if (wait > 6 && (ret&(BTN_UP|BTN_LEFT|BTN_DOWN|BTN_RIGHT|BTN_L|BTN_R))) + if (wait > 6 && (ret&(PBTN_UP|PBTN_LEFT|PBTN_DOWN|PBTN_RIGHT|PBTN_L|PBTN_R))) wait = 6; // we don't need diagonals in menus - if ((ret&BTN_UP) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT; - if ((ret&BTN_UP) && (ret&BTN_RIGHT)) ret &= ~BTN_RIGHT; - if ((ret&BTN_DOWN) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT; - if ((ret&BTN_DOWN) && (ret&BTN_RIGHT)) ret &= ~BTN_RIGHT; + 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; } @@ -384,14 +384,14 @@ static char *romsel_loop(char *curr_path) for (;;) { draw_dirlist(curr_path, namelist, n, sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_L|BTN_R|BTN_X|BTN_CIRCLE, 0); - if(inp & BTN_UP ) { sel--; if (sel < 0) sel = n-2; } - if(inp & BTN_DOWN) { sel++; if (sel > n-2) sel = 0; } - if(inp & BTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } - if(inp & BTN_L) { sel-=24; if (sel < 0) sel = 0; } - if(inp & BTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } - if(inp & BTN_R) { sel+=24; if (sel > n-2) sel = n-2; } - if(inp & BTN_CIRCLE) // enter dir/select + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_X|PBTN_CIRCLE, 0); + if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; } + if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; } + if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } + if(inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; } + if(inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } + if(inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; } + if(inp & PBTN_CIRCLE) // enter dir/select { if (namelist[sel+1]->d_type & FIO_S_IFDIR) { @@ -424,7 +424,7 @@ static char *romsel_loop(char *curr_path) break; } } - if(inp & BTN_X) break; // cancel + if(inp & PBTN_X) break; // cancel } if (n > 0) { @@ -469,17 +469,17 @@ static void patches_menu_loop(void) for(;;) { draw_patchlist(menu_sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_L|BTN_R|BTN_X|BTN_CIRCLE, 0); - if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } - if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } - if(inp &(BTN_LEFT|BTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } - if(inp &(BTN_RIGHT|BTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } - if(inp & BTN_CIRCLE) { // action + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_X|PBTN_CIRCLE, 0); + if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } + if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } + if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } + if(inp &(PBTN_RIGHT|PBTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } + if(inp & PBTN_CIRCLE) { // action if (menu_sel < PicoPatchCount) PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active; else return; } - if(inp & BTN_X) return; + if(inp & PBTN_X) return; } } @@ -599,18 +599,18 @@ static int savestate_menu_loop(int is_loading) for(;;) { draw_savestate_menu(menu_sel, is_loading); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_X|BTN_CIRCLE, 0); - if(inp & BTN_UP ) { + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_X|PBTN_CIRCLE, 0); + if(inp & PBTN_UP ) { do { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } - if(inp & BTN_DOWN) { + if(inp & PBTN_DOWN) { do { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } - if(inp & BTN_CIRCLE) { // save/load + if(inp & PBTN_CIRCLE) { // save/load if (menu_sel < 10) { state_slot = menu_sel; PicoStateProgressCB = emu_msg_cb; /* also suitable for menu */ @@ -621,7 +621,7 @@ static int savestate_menu_loop(int is_loading) return 0; } else return 1; } - if(inp & BTN_X) return 1; + if(inp & PBTN_X) return 1; } } @@ -713,22 +713,22 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ for (;;) { draw_key_config(opts, opt_cnt, player_idx, sel); - inp = wait_for_input(CONFIGURABLE_KEYS|BTN_SELECT, 1); - if (!(inp & BTN_SELECT)) { + inp = wait_for_input(CONFIGURABLE_KEYS|PBTN_SELECT, 1); + if (!(inp & PBTN_SELECT)) { prev_select = 0; - if(inp & BTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } - if(inp & BTN_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; } + if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } + if(inp & PBTN_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; } } if (sel >= opt_cnt) { - if (inp & (BTN_X|BTN_CIRCLE)) break; + if (inp & (PBTN_X|PBTN_CIRCLE)) break; else continue; } // if we are here, we want to bind/unbind something - if ((inp & BTN_SELECT) && !prev_select) + if ((inp & PBTN_SELECT) && !prev_select) unbind_action(opts[sel].mask); - prev_select = inp & BTN_SELECT; + prev_select = inp & PBTN_SELECT; inp &= CONFIGURABLE_KEYS; - inp &= ~BTN_SELECT; + inp &= ~PBTN_SELECT; for (i = 0; i < 32; i++) if (inp & (1 << i)) { if (count_bound_keys(opts[sel].mask, player_idx) >= 2) @@ -795,13 +795,13 @@ static void kc_sel_loop(void) while (1) { draw_kc_sel(menu_sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE, 0); + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0); selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel); - if (inp & (BTN_LEFT|BTN_RIGHT)) // multi choise - me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0); - if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } - if (inp & BTN_CIRCLE) { + if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise + me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + if (inp & PBTN_CIRCLE) { int is_6button = PicoOpt & POPT_6BTN_PAD; switch (selected_id) { case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return; @@ -812,7 +812,7 @@ static void kc_sel_loop(void) default: return; } } - if (inp & BTN_X) return; + if (inp & PBTN_X) return; } } @@ -918,14 +918,14 @@ static void cd_menu_loop_options(void) for (;;) { draw_cd_menu_options(menu_sel, &bios_names); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE|BTN_START, 0); - if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE|PBTN_START, 0); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel); - if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise - if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) && + if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise + if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) && selected_id == MA_CDOPT_READAHEAD) { - if (inp & BTN_LEFT) { + if (inp & PBTN_LEFT) { PicoCDBuffers >>= 1; if (PicoCDBuffers < 2) PicoCDBuffers = 0; } else { @@ -935,12 +935,12 @@ static void cd_menu_loop_options(void) } } } - if (inp & BTN_CIRCLE) // toggleable options + if (inp & PBTN_CIRCLE) // toggleable options if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) && selected_id == MA_CDOPT_DONE) { return; } - if (inp & BTN_START) { + if (inp & PBTN_START) { switch (selected_id) { // BIOS testers case MA_CDOPT_TESTBIOS_USA: if (emu_findBios(4, &bios)) { // test US @@ -967,7 +967,7 @@ static void cd_menu_loop_options(void) break; } } - if (inp & BTN_X) return; + if (inp & PBTN_X) return; } } @@ -1081,18 +1081,18 @@ static void dispmenu_loop_options(void) for (;;) { draw_dispmenu_options(menu_sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE, 0); - if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } selected_id = me_index2id(opt3_entries, OPT3_ENTRY_COUNT, menu_sel); if (selected_id == MA_OPT3_HSCALE40 && is_32col) { is_32col = 0; menu_opt3_preview(is_32col); } if (selected_id == MA_OPT3_HSCALE32 && !is_32col) { is_32col = 1; menu_opt3_preview(is_32col); } - if (inp & (BTN_LEFT|BTN_RIGHT)) // multi choise + if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise { float *setting = NULL; int tmp; - me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0); + me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0); switch (selected_id) { case MA_OPT3_SCALE: setting = ¤tConfig.scale; break; case MA_OPT3_HSCALE40: setting = ¤tConfig.hscale40; is_32col = 0; break; @@ -1102,7 +1102,7 @@ static void dispmenu_loop_options(void) case MA_OPT3_BLACKLVL: menu_opt3_preview(is_32col); break; case MA_OPT3_VSYNC: tmp = ((currentConfig.EmuOpt>>13)&1) | ((currentConfig.EmuOpt>>15)&2); - tmp = (inp & BTN_LEFT) ? (tmp>>1) : ((tmp<<1)|1); + tmp = (inp & PBTN_LEFT) ? (tmp>>1) : ((tmp<<1)|1); if (tmp > 3) tmp = 3; currentConfig.EmuOpt &= ~0x12000; currentConfig.EmuOpt |= ((tmp&2)<<15) | ((tmp&1)<<13); @@ -1110,15 +1110,15 @@ static void dispmenu_loop_options(void) default: break; } if (setting != NULL) { - while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) { - *setting += (inp & BTN_LEFT) ? -0.01 : 0.01; + while ((inp = psp_pad_read(0)) & (PBTN_LEFT|PBTN_RIGHT)) { + *setting += (inp & PBTN_LEFT) ? -0.01 : 0.01; if (*setting <= 0) *setting = 0.01; menu_opt3_preview(is_32col); draw_dispmenu_options(menu_sel); // will wait vsync } } } - if (inp & BTN_CIRCLE) { // toggleable options + if (inp & PBTN_CIRCLE) { // toggleable options me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, 1); switch (selected_id) { case MA_OPT3_DONE: @@ -1145,7 +1145,7 @@ static void dispmenu_loop_options(void) default: break; } } - if (inp & BTN_X) return; + if (inp & PBTN_X) return; } } @@ -1195,23 +1195,23 @@ static void amenu_loop_options(void) for(;;) { draw_amenu_options(menu_sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE, 0); - if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel); - if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise - if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) && + if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise + if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) && selected_id == MA_OPT2_GAMMA) { // TODO? } } - if (inp & BTN_CIRCLE) { // toggleable options + if (inp & PBTN_CIRCLE) { // toggleable options if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) && selected_id == MA_OPT2_DONE) { return; } } - if (inp & BTN_X) return; + if (inp & PBTN_X) return; } } @@ -1375,12 +1375,12 @@ static int menu_loop_options(void) while (1) { draw_menu_options(menu_sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE, 0); - if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel); - if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise - if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0)) { + if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise + if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0)) { switch (selected_id) { case MA_OPT_RENDERER: if ((PicoOpt & 0x10) || !(currentConfig.EmuOpt & 0x80)) { @@ -1392,14 +1392,14 @@ static int menu_loop_options(void) } break; case MA_OPT_SOUND_QUALITY: - PsndRate = sndrate_prevnext(PsndRate, inp & BTN_RIGHT); + PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT); break; case MA_OPT_REGION: - region_prevnext(inp & BTN_RIGHT); + region_prevnext(inp & PBTN_RIGHT); break; case MA_OPT_CONFIRM_STATES: { int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2); - n += (inp & BTN_LEFT) ? -1 : 1; + n += (inp & PBTN_LEFT) ? -1 : 1; if (n < 0) n = 0; else if (n > 3) n = 3; n |= n << 1; n &= ~2; currentConfig.EmuOpt &= ~0xa00; @@ -1407,14 +1407,14 @@ static int menu_loop_options(void) break; } case MA_OPT_SAVE_SLOT: - if (inp & BTN_RIGHT) { + if (inp & PBTN_RIGHT) { state_slot++; if (state_slot > 9) state_slot = 0; } else {state_slot--; if (state_slot < 0) state_slot = 9; } break; case MA_OPT_CPU_CLOCKS: - while ((inp = psp_pad_read(0)) & (BTN_LEFT|BTN_RIGHT)) { - currentConfig.CPUclock += (inp & BTN_LEFT) ? -1 : 1; + while ((inp = psp_pad_read(0)) & (PBTN_LEFT|PBTN_RIGHT)) { + currentConfig.CPUclock += (inp & PBTN_LEFT) ? -1 : 1; if (currentConfig.CPUclock < 19) currentConfig.CPUclock = 19; if (currentConfig.CPUclock > 333) currentConfig.CPUclock = 333; draw_menu_options(menu_sel); // will wait vsync @@ -1423,7 +1423,7 @@ static int menu_loop_options(void) case MA_OPT_SAVECFG: case MA_OPT_SAVECFG_GAME: case MA_OPT_LOADCFG: - config_slot += (inp&BTN_RIGHT) ? 1 : -1; + config_slot += (inp&PBTN_RIGHT) ? 1 : -1; if (config_slot > 9) config_slot = 0; if (config_slot < 0) config_slot = 9; me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current); @@ -1436,7 +1436,7 @@ static int menu_loop_options(void) } } } - if (inp & BTN_CIRCLE) { + if (inp & PBTN_CIRCLE) { if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1)) { switch (selected_id) @@ -1474,7 +1474,7 @@ static int menu_loop_options(void) } } } - if(inp & BTN_X) { + if(inp & PBTN_X) { menu_options_save(); return 0; // done (update, no write) } @@ -1576,29 +1576,29 @@ static void menu_loop_root(void) /* make sure action buttons are not pressed on entering menu */ draw_menu_root(menu_sel); - while (psp_pad_read(1) & (BTN_X|BTN_CIRCLE|BTN_SELECT)) psp_msleep(50); + while (psp_pad_read(1) & (PBTN_X|PBTN_CIRCLE|PBTN_SELECT)) psp_msleep(50); for (;;) { draw_menu_root(menu_sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_X|BTN_CIRCLE|BTN_SELECT|BTN_L|BTN_R, 0); - if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } - if((inp & (BTN_L|BTN_R)) == (BTN_L|BTN_R)) debug_menu_loop(); - if( inp & (BTN_SELECT|BTN_X)) { + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_X|PBTN_CIRCLE|PBTN_SELECT|PBTN_L|PBTN_R, 0); + if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop(); + if( inp & (PBTN_SELECT|PBTN_X)) { if (rom_loaded) { - while (psp_pad_read(1) & (BTN_SELECT|BTN_X)) psp_msleep(50); // wait until released + while (psp_pad_read(1) & (PBTN_SELECT|PBTN_X)) psp_msleep(50); // wait until released engineState = PGS_Running; break; } } - if(inp & BTN_CIRCLE) { + if(inp & PBTN_CIRCLE) { menuErrorMsg[0] = 0; // clear error msg switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel)) { case MA_MAIN_RESUME_GAME: if (rom_loaded) { - while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50); + while (psp_pad_read(1) & PBTN_CIRCLE) psp_msleep(50); engineState = PGS_Running; return; } @@ -1615,7 +1615,7 @@ static void menu_loop_root(void) if (rom_loaded) { if(savestate_menu_loop(1)) continue; - while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50); + while (psp_pad_read(1) & PBTN_CIRCLE) psp_msleep(50); engineState = PGS_Running; return; } @@ -1623,7 +1623,7 @@ static void menu_loop_root(void) case MA_MAIN_RESET_GAME: if (rom_loaded) { emu_ResetGame(); - while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50); + while (psp_pad_read(1) & PBTN_CIRCLE) psp_msleep(50); engineState = PGS_Running; return; } @@ -1660,8 +1660,8 @@ static void menu_loop_root(void) draw_menu_credits(); psp_msleep(500); inp = 0; - while (!(inp & (BTN_X|BTN_CIRCLE))) - inp = wait_for_input(BTN_X|BTN_CIRCLE, 0); + while (!(inp & (PBTN_X|PBTN_CIRCLE))) + inp = wait_for_input(PBTN_X|PBTN_CIRCLE, 0); break; case MA_MAIN_EXIT: engineState = PGS_Quit; @@ -1789,15 +1789,15 @@ int menu_loop_tray(void) /* make sure action buttons are not pressed on entering menu */ draw_menu_tray(menu_sel); - while (psp_pad_read(1) & BTN_CIRCLE) psp_msleep(50); + while (psp_pad_read(1) & PBTN_CIRCLE) psp_msleep(50); for (;;) { draw_menu_tray(menu_sel); - inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_CIRCLE, 0); - if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } - if(inp & BTN_CIRCLE) { + inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_CIRCLE, 0); + if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + if(inp & PBTN_CIRCLE) { switch (menu_sel) { case 0: // select image selfname = romsel_loop(curr_path); diff --git a/psp/menu.h b/psp/menu.h index a36b2a4..24da1dc 100644 --- a/psp/menu.h +++ b/psp/menu.h @@ -9,6 +9,6 @@ void menu_romload_prepare(const char *rom_name); void menu_romload_end(void); -#define CONFIGURABLE_KEYS (BTN_UP|BTN_LEFT|BTN_RIGHT|BTN_DOWN|BTN_L|BTN_R|BTN_TRIANGLE|BTN_CIRCLE|BTN_X|BTN_SQUARE|BTN_START| \ - BTN_NUB_UP|BTN_NUB_RIGHT|BTN_NUB_DOWN|BTN_NUB_LEFT|BTN_NOTE) +#define CONFIGURABLE_KEYS (PBTN_UP|PBTN_LEFT|PBTN_RIGHT|PBTN_DOWN|PBTN_L|PBTN_R|PBTN_TRIANGLE|PBTN_CIRCLE|PBTN_X|PBTN_SQUARE|PBTN_START| \ + PBTN_NUB_UP|PBTN_NUB_RIGHT|PBTN_NUB_DOWN|PBTN_NUB_LEFT|PBTN_NOTE) diff --git a/psp/psp.c b/psp/psp.c index 1b1a1f5..9ddb952 100644 --- a/psp/psp.c +++ b/psp/psp.c @@ -224,11 +224,11 @@ unsigned int psp_pad_read(int blocking) buttons = pad.Buttons; // analog.. - buttons &= ~(BTN_NUB_UP|BTN_NUB_DOWN|BTN_NUB_LEFT|BTN_NUB_RIGHT); - if (pad.Lx < 128 - ANALOG_DEADZONE) buttons |= BTN_NUB_LEFT; - if (pad.Lx > 128 + ANALOG_DEADZONE) buttons |= BTN_NUB_RIGHT; - if (pad.Ly < 128 - ANALOG_DEADZONE) buttons |= BTN_NUB_UP; - if (pad.Ly > 128 + ANALOG_DEADZONE) buttons |= BTN_NUB_DOWN; + buttons &= ~(PBTN_NUB_UP|PBTN_NUB_DOWN|PBTN_NUB_LEFT|PBTN_NUB_RIGHT); + if (pad.Lx < 128 - ANALOG_DEADZONE) buttons |= PBTN_NUB_LEFT; + if (pad.Lx > 128 + ANALOG_DEADZONE) buttons |= PBTN_NUB_RIGHT; + if (pad.Ly < 128 - ANALOG_DEADZONE) buttons |= PBTN_NUB_UP; + if (pad.Ly > 128 + ANALOG_DEADZONE) buttons |= PBTN_NUB_DOWN; return buttons; } diff --git a/psp/psp.h b/psp/psp.h index 7269863..ef12f59 100644 --- a/psp/psp.h +++ b/psp/psp.h @@ -48,23 +48,23 @@ void psp_wait_suspend(void); void psp_resume_suspend(void); /* shorter btn names */ -#define BTN_UP PSP_CTRL_UP -#define BTN_LEFT PSP_CTRL_LEFT -#define BTN_RIGHT PSP_CTRL_RIGHT -#define BTN_DOWN PSP_CTRL_DOWN -#define BTN_L PSP_CTRL_LTRIGGER -#define BTN_R PSP_CTRL_RTRIGGER -#define BTN_TRIANGLE PSP_CTRL_TRIANGLE -#define BTN_CIRCLE PSP_CTRL_CIRCLE -#define BTN_X PSP_CTRL_CROSS -#define BTN_SQUARE PSP_CTRL_SQUARE -#define BTN_SELECT PSP_CTRL_SELECT -#define BTN_START PSP_CTRL_START -#define BTN_NOTE PSP_CTRL_NOTE // doesn't seem to work? +#define PBTN_UP PSP_CTRL_UP +#define PBTN_LEFT PSP_CTRL_LEFT +#define PBTN_RIGHT PSP_CTRL_RIGHT +#define PBTN_DOWN PSP_CTRL_DOWN +#define PBTN_L PSP_CTRL_LTRIGGER +#define PBTN_R PSP_CTRL_RTRIGGER +#define PBTN_TRIANGLE PSP_CTRL_TRIANGLE +#define PBTN_CIRCLE PSP_CTRL_CIRCLE +#define PBTN_X PSP_CTRL_CROSS +#define PBTN_SQUARE PSP_CTRL_SQUARE +#define PBTN_SELECT PSP_CTRL_SELECT +#define PBTN_START PSP_CTRL_START +#define PBTN_NOTE PSP_CTRL_NOTE // doesn't seem to work? /* fake 'nub' btns */ -#define BTN_NUB_UP (1 << 28) -#define BTN_NUB_RIGHT (1 << 29) -#define BTN_NUB_DOWN (1 << 30) -#define BTN_NUB_LEFT (1 << 31) +#define PBTN_NUB_UP (1 << 28) +#define PBTN_NUB_RIGHT (1 << 29) +#define PBTN_NUB_DOWN (1 << 30) +#define PBTN_NUB_LEFT (1 << 31)