First version for Raspberry Pi

This commit is contained in:
Chips-fr 2015-05-14 15:18:43 +00:00
parent a2c4a0734c
commit 3e6e55dc20
26 changed files with 145 additions and 279 deletions

View file

@ -67,7 +67,13 @@ namespace sdl
//-------------------------------------------------
// Create new screen for GUI
//-------------------------------------------------
#if defined (RASPBERRY)
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
printf("Current resolution: %d x %d %d bpp\n",videoInfo->current_w, videoInfo->current_h, videoInfo->vfmt->BitsPerPixel);
gui_screen = SDL_SetVideoMode(videoInfo->current_w,videoInfo->current_h,16,SDL_SWSURFACE |SDL_FULLSCREEN);
#else
gui_screen = SDL_SetVideoMode(GUI_WIDTH, GUI_HEIGHT, 16, SDL_SWSURFACE);
#endif
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_ShowCursor(SDL_ENABLE);
@ -328,7 +334,8 @@ namespace widgets
// Create container for main page
//-------------------------------------------------
gui_top = new gcn::Container();
gui_top->setDimension(gcn::Rectangle(0, 0, GUI_WIDTH, GUI_HEIGHT));
//gui_top->setDimension(gcn::Rectangle(0, 0, GUI_WIDTH, GUI_HEIGHT));
gui_top->setDimension(gcn::Rectangle((gui_screen->w - GUI_WIDTH) / 2, (gui_screen->h - GUI_HEIGHT) / 2, GUI_WIDTH, GUI_HEIGHT));
gui_top->setBaseColor(gui_baseCol);
uae_gui->setTop(gui_top);

View file

@ -57,11 +57,12 @@ void read_joystick(int nr, unsigned int *dir, int *button)
if (!triggerR /*R+dpad = arrow keys*/ && currprefs.pandora_custom_dpad==0)
{
// get joystick direction via dPad or joystick
if (dpadRight || SDL_JoystickGetAxis(joy, 0) > 0) right=1;
if (dpadLeft || SDL_JoystickGetAxis(joy, 0) < 0) left=1;
if (dpadUp || SDL_JoystickGetAxis(joy, 1) < 0) top=1;
if (dpadDown || SDL_JoystickGetAxis(joy, 1) > 0) bot=1;
// get joystick direction via dPad or joystick
int hat=SDL_JoystickGetHat(joy,0);
if ((hat & SDL_HAT_RIGHT) || dpadRight || SDL_JoystickGetAxis(joy, 0) > 0) right=1;
if ((hat & SDL_HAT_LEFT) || dpadLeft || SDL_JoystickGetAxis(joy, 0) < 0) left=1;
if ((hat & SDL_HAT_UP) || dpadUp || SDL_JoystickGetAxis(joy, 1) < 0) top=1;
if ((hat & SDL_HAT_DOWN) || dpadDown || SDL_JoystickGetAxis(joy, 1) > 0) bot=1;
if (currprefs.pandora_joyConf)
{
if ((buttonX && currprefs.pandora_jump > -1) || SDL_JoystickGetButton(joy, currprefs.pandora_jump))
@ -150,7 +151,17 @@ void read_joystick(int nr, unsigned int *dir, int *button)
*button |= ((buttonB || SDL_JoystickGetButton(joy, currprefs.pandora_button2)) & 1) << 1;
}
// normal joystick movement
#ifdef SIX_AXIS_WORKAROUND
*button |= (SDL_JoystickGetButton(joy, 13)) & 1;
*button |= ((SDL_JoystickGetButton(joy, 14)) & 1) << 1;
if (SDL_JoystickGetButton(joy, 4)) top=1;
if (SDL_JoystickGetButton(joy, 5)) right=1;
if (SDL_JoystickGetButton(joy, 6)) bot=1;
if (SDL_JoystickGetButton(joy, 7)) left=1;
#endif
// normal joystick movement
if (left)
top = !top;
if (right)
@ -205,11 +216,19 @@ void init_joystick(void)
int i;
nr_joysticks = SDL_NumJoysticks ();
if (nr_joysticks > 0)
uae4all_joy0 = SDL_JoystickOpen (0);
{
uae4all_joy0 = SDL_JoystickOpen (0);
printf(" Joystick%d : %s\n",i,SDL_JoystickName(0));
printf(" Buttons: %i Axis: %i Hats: %i\n",SDL_JoystickNumButtons(uae4all_joy0),SDL_JoystickNumAxes(uae4all_joy0),SDL_JoystickNumHats(uae4all_joy0));
}
if (nr_joysticks > 1)
uae4all_joy1 = SDL_JoystickOpen (1);
{
uae4all_joy1 = SDL_JoystickOpen (1);
printf(" Joystick%d : %s\n",i,SDL_JoystickName(1));
printf(" Buttons: %i Axis: %i Hats: %i\n",SDL_JoystickNumButtons(uae4all_joy1),SDL_JoystickNumAxes(uae4all_joy1),SDL_JoystickNumHats(uae4all_joy1));
}
else
uae4all_joy1 = NULL;
uae4all_joy1 = NULL;
}
void close_joystick(void)

View file

@ -315,10 +315,16 @@ void gui_exit(void)
void gui_purge_events(void)
{
int counter = 0;
SDL_Event event;
SDL_Delay(150);
while(SDL_PollEvent(&event))
// Strangely PS3 controller always send events, so we need a maximum number of event to purge.
while(SDL_PollEvent(&event) && counter < 50)
{
counter++;
SDL_Delay(10);
}
keybuf_init();
}