-/* Parts used from cpuctrl */
-/* cpuctrl for GP2X
- Copyright (C) 2005 Hermes/PS2Reality
+/*
+ Parts used from cpuctrl, Copyright (C) 2005 Hermes/PS2Reality
+ Portions Copyright (C) 2009 notaz
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-#define _BSD_SOURCE
#define _GNU_SOURCE
+#include "../common.h"
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <sys/types.h>
#include <unistd.h>
-#include "../common.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;
+#ifdef WIZ_BUILD
+static u32 gpsp_gp2x_gpiodev;
+#endif
+
+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[PLAT_BUTTON_COUNT] =
+{
+ 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[PLAT_BUTTON_COUNT] =
+{
+ 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;
return r;
}
-void gp2x_init()
+void gpsp_plat_init(void)
{
char buff[256];
gpsp_gp2x_dev = open("/dev/mem", O_RDWR);
gpsp_gp2x_dev_audio = open("/dev/mixer", O_RDWR);
- gpsp_gp2x_memregl =
- (unsigned long *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED,
+ gpsp_gp2x_memregl = (u32 *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED,
gpsp_gp2x_dev, 0xc0000000);
- gpsp_gp2x_memregs = (unsigned short *)gpsp_gp2x_memregl;
+ gpsp_gp2x_memregs = (u16 *)gpsp_gp2x_memregl;
warm_init();
#ifdef WIZ_BUILD
gpsp_gp2x_gpiodev = open("/dev/GPIO", O_RDONLY);
gp2x_sound_volume(1);
}
-void gp2x_quit()
+void gpsp_plat_quit(void)
{
char buff1[256], buff2[256];
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;
#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)
{