summaryrefslogtreecommitdiff
path: root/gp2x
diff options
context:
space:
mode:
authornotaz2011-09-04 19:51:03 +0300
committernotaz2011-09-04 20:19:13 +0300
commit43c24b301dc8c0c5952e1d22bad865f4304d01f8 (patch)
tree3f34d652835f957fcd8105c29c8e61c1372fe744 /gp2x
parent2455b6a30e7d58cddfa7f196c4553e008996d46a (diff)
downloadpicogpsp-43c24b301dc8c0c5952e1d22bad865f4304d01f8.tar.gz
picogpsp-43c24b301dc8c0c5952e1d22bad865f4304d01f8.tar.bz2
picogpsp-43c24b301dc8c0c5952e1d22bad865f4304d01f8.zip
refactor GP2X stuff for pandora reuse
Diffstat (limited to 'gp2x')
-rw-r--r--gp2x/gp2x.c90
-rw-r--r--gp2x/gp2x.h9
2 files changed, 89 insertions, 10 deletions
diff --git a/gp2x/gp2x.c b/gp2x/gp2x.c
index d36dd08..8bad610 100644
--- a/gp2x/gp2x.c
+++ b/gp2x/gp2x.c
@@ -28,17 +28,57 @@
#include <unistd.h>
#include <ctype.h>
#include "gp2x.h"
-#include "warm.h"
#include "pollux_dpc_set.h"
-u32 gp2x_audio_volume = 74/2;
-u32 gpsp_gp2x_dev_audio = 0;
-u32 gpsp_gp2x_dev = 0;
-u32 gpsp_gp2x_gpiodev = 0;
+static u32 gpsp_gp2x_dev_audio;
+static u32 gpsp_gp2x_dev;
+static u32 gpsp_gp2x_gpiodev;
+
+static u32 gp2x_audio_volume = 74/2;
static volatile u16 *gpsp_gp2x_memregs;
static volatile u32 *gpsp_gp2x_memregl;
+u32 button_plat_mask_to_config[] =
+{
+ GP2X_UP,
+ GP2X_LEFT,
+ GP2X_DOWN,
+ GP2X_RIGHT,
+ GP2X_START,
+ GP2X_SELECT,
+ GP2X_L,
+ GP2X_R,
+ GP2X_A,
+ GP2X_B,
+ GP2X_X,
+ GP2X_Y,
+ GP2X_VOL_DOWN,
+ GP2X_VOL_UP,
+ GP2X_PUSH,
+ GP2X_VOL_MIDDLE
+};
+
+u32 gamepad_config_map[16] =
+{
+ BUTTON_ID_UP, // Up
+ BUTTON_ID_LEFT, // Left
+ BUTTON_ID_DOWN, // Down
+ BUTTON_ID_RIGHT, // Right
+ BUTTON_ID_START, // Start
+ BUTTON_ID_SELECT, // Select
+ BUTTON_ID_L, // Ltrigger
+ BUTTON_ID_R, // Rtrigger
+ BUTTON_ID_FPS, // A
+ BUTTON_ID_A, // B
+ BUTTON_ID_B, // X
+ BUTTON_ID_MENU, // Y
+ BUTTON_ID_VOLDOWN, // Vol down
+ BUTTON_ID_VOLUP, // Vol up
+ BUTTON_ID_FPS, // Push
+ BUTTON_ID_MENU // Vol middle
+};
+
#ifdef WIZ_BUILD
#include <linux/fb.h>
void *gpsp_gp2x_screen;
@@ -224,7 +264,7 @@ static int get_romdir(char *buff, size_t size)
return r;
}
-void gp2x_init()
+void gpsp_plat_init(void)
{
char buff[256];
@@ -245,7 +285,7 @@ void gp2x_init()
gp2x_sound_volume(1);
}
-void gp2x_quit()
+void gpsp_plat_quit(void)
{
char buff1[256], buff2[256];
@@ -292,7 +332,7 @@ void gp2x_sound_volume(u32 volume_up)
ioctl(gpsp_gp2x_dev_audio, SOUND_MIXER_WRITE_PCM, &volume);
}
-u32 gpsp_gp2x_joystick_read(void)
+u32 gpsp_plat_joystick_read(void)
{
#ifdef WIZ_BUILD
u32 value = 0;
@@ -323,6 +363,40 @@ u32 gpsp_gp2x_joystick_read(void)
#endif
}
+u32 gpsp_plat_buttons_to_cursor(u32 buttons)
+{
+ gui_action_type new_button = CURSOR_NONE;
+
+ if(buttons & GP2X_A)
+ new_button = CURSOR_BACK;
+
+ if(buttons & GP2X_X)
+ new_button = CURSOR_EXIT;
+
+ if(buttons & GP2X_B)
+ new_button = CURSOR_SELECT;
+
+ if(buttons & GP2X_UP)
+ new_button = CURSOR_UP;
+
+ if(buttons & GP2X_DOWN)
+ new_button = CURSOR_DOWN;
+
+ if(buttons & GP2X_LEFT)
+ new_button = CURSOR_LEFT;
+
+ if(buttons & GP2X_RIGHT)
+ new_button = CURSOR_RIGHT;
+
+ if(buttons & GP2X_L)
+ new_button = CURSOR_L;
+
+ if(buttons & GP2X_R)
+ new_button = CURSOR_R;
+
+ return new_button;
+}
+
// Fout = (m * Fin) / (p * 2^s)
void set_FCLK(u32 MHZ)
{
diff --git a/gp2x/gp2x.h b/gp2x/gp2x.h
index ab8dd4c..9218704 100644
--- a/gp2x/gp2x.h
+++ b/gp2x/gp2x.h
@@ -24,11 +24,16 @@ enum
GP2X_VOL_UP = 1 << 23,
GP2X_PUSH = 1 << 27,
#endif
+ GP2X_VOL_MIDDLE = (1 << 24), // fake, menu enter
};
+void gpsp_plat_init(void);
+void gpsp_plat_quit(void);
-extern u32 gpsp_gp2x_dev_audio;
-extern u32 gpsp_gp2x_dev;
+u32 gpsp_plat_joystick_read(void);
+u32 gpsp_plat_buttons_to_cursor(u32 buttons);
+
+extern u32 button_plat_mask_to_config[];
void gp2x_sound_volume(u32 volume_up);
void gp2x_quit();