Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Port to SDL 2.0. #2

Merged
merged 1 commit into from
Oct 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ include/stamp-h1
install-sh
m4/sdl.m4
missing
m4/pkg.m4
m4/sdl2.m4
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Building the game

General Requirements
* GCC 4.xx or later
* SDL 1.2
* SDL 2.0
* SDL_net
* OpenAL
* Autoconf (when using git snapshot)
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ AS_IF([test "$audio_backend" = openal], [

AS_IF([test "$input_backend" = sdl \
|| test "$video_backend" = sdl], [
AM_PATH_SDL([], [], [
AM_PATH_SDL2([], [], [
AC_ERROR([SDL not found])
])

Expand Down
4 changes: 4 additions & 0 deletions include/vga_sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
class VgaSDL : public VgaBase
{
private:
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Texture* texture;
SDL_Surface* front;
SDL_Surface* target;
SDL_Color game_pal[VGA_PALETTE_SIZE];
SDL_Color* custom_pal;
Uint32 video_mode_flags;
Expand Down
4 changes: 2 additions & 2 deletions packaging/windows/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ SectionEnd
Section "SDL" sdl

SetOutPath "$INSTDIR"
File "lib\SDL.dll"
File "lib\SDL2.dll"

SectionEnd

Expand Down Expand Up @@ -215,7 +215,7 @@ Section "Uninstall"
Delete "$INSTDIR\COPYING"
Delete "$INSTDIR\README"
Delete "$INSTDIR\OpenAL32.dll"
Delete "$INSTDIR\SDL.dll"
Delete "$INSTDIR\SDL2.dll"
Delete "$INSTDIR\SDL_net.dll"
Delete "$INSTDIR\Uninstall.exe"

Expand Down
58 changes: 30 additions & 28 deletions src/input/sdl/OMOUSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,8 @@ void MouseSDL::poll_event()
while (SDL_PeepEvents(&event,
1,
SDL_GETEVENT,
SDL_KEYEVENTMASK |
SDL_MOUSEEVENTMASK |
SDL_JOYEVENTMASK) > 0) {
SDL_KEYDOWN,
SDL_JOYBUTTONUP)) {

MouseEvent ev;

Expand Down Expand Up @@ -813,18 +812,20 @@ void MouseSDL::poll_event()
sys.signal_exit_flag = 1;
} else if (event.key.keysym.sym == SDLK_TAB) {
bypass = 1;
SDL_WM_IconifyWindow();
SDL_Window *window = SDL_GetWindowFromID(event.key.windowID);
SDL_MinimizeWindow(window);
}
} else if (mod == KMOD_LCTRL || mod == KMOD_RCTRL) {
if (event.key.keysym.sym == SDLK_g &&
!vga.is_full_screen()) {
static int grabbed = 0;
bypass = 1;
SDL_Window *window = SDL_GetWindowFromID(event.key.windowID);
if (!grabbed) {
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_SetWindowGrab(window, SDL_TRUE);
grabbed = 1;
} else {
SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_SetWindowGrab(window, SDL_FALSE);
grabbed = 0;
}
}
Expand All @@ -839,6 +840,7 @@ void MouseSDL::poll_event()
case SDL_KEYUP:
update_skey_state();
break;
case SDL_TEXTINPUT:
case SDL_JOYAXISMOTION:
case SDL_JOYBALLMOTION:
case SDL_JOYHATMOTION:
Expand Down Expand Up @@ -1155,16 +1157,16 @@ int MouseSDL::is_key(unsigned scanCode, unsigned short skeyState, unsigned short
case 0x56: priChar = capitalChar = '<'; shiftChar = '>'; altChar = '|'; break;
#endif

case SDLK_KP7: priChar = shiftChar = capitalChar = '7'; onNumPad = 1; break;
case SDLK_KP8: priChar = shiftChar = capitalChar = '8'; onNumPad = 1; break;
case SDLK_KP9: priChar = shiftChar = capitalChar = '9'; onNumPad = 1; break;
case SDLK_KP4: priChar = shiftChar = capitalChar = '4'; onNumPad = 1; break;
case SDLK_KP5: priChar = shiftChar = capitalChar = '5'; onNumPad = 1; break;
case SDLK_KP6: priChar = shiftChar = capitalChar = '6'; onNumPad = 1; break;
case SDLK_KP1: priChar = shiftChar = capitalChar = '1'; onNumPad = 1; break;
case SDLK_KP2: priChar = shiftChar = capitalChar = '2'; onNumPad = 1; break;
case SDLK_KP3: priChar = shiftChar = capitalChar = '3'; onNumPad = 1; break;
case SDLK_KP0: priChar = shiftChar = capitalChar = '0'; onNumPad = 1; break;
case SDLK_KP_7: priChar = shiftChar = capitalChar = '7'; onNumPad = 1; break;
case SDLK_KP_8: priChar = shiftChar = capitalChar = '8'; onNumPad = 1; break;
case SDLK_KP_9: priChar = shiftChar = capitalChar = '9'; onNumPad = 1; break;
case SDLK_KP_4: priChar = shiftChar = capitalChar = '4'; onNumPad = 1; break;
case SDLK_KP_5: priChar = shiftChar = capitalChar = '5'; onNumPad = 1; break;
case SDLK_KP_6: priChar = shiftChar = capitalChar = '6'; onNumPad = 1; break;
case SDLK_KP_1: priChar = shiftChar = capitalChar = '1'; onNumPad = 1; break;
case SDLK_KP_2: priChar = shiftChar = capitalChar = '2'; onNumPad = 1; break;
case SDLK_KP_3: priChar = shiftChar = capitalChar = '3'; onNumPad = 1; break;
case SDLK_KP_0: priChar = shiftChar = capitalChar = '0'; onNumPad = 1; break;
case SDLK_KP_PERIOD: priChar = shiftChar = capitalChar = '.'; onNumPad = 1; break;

// function keys
Expand Down Expand Up @@ -1349,16 +1351,16 @@ int MouseSDL::is_key(unsigned scanCode, unsigned short skeyState, char *keyStr,
case SDLK_F11: numLockChar = priChar = "F11"; break;
case SDLK_F12: numLockChar = priChar = "F12"; break;

case SDLK_KP7: priChar = "HOME"; numLockChar = "7"; onNumPad = 1; break;
case SDLK_KP8: priChar = "UP"; numLockChar = "8"; onNumPad = 1; break;
case SDLK_KP9: priChar = "PAGE UP"; numLockChar = "9"; onNumPad = 1; break;
case SDLK_KP4: priChar = "LEFT"; numLockChar = "4"; onNumPad = 1; break;
case SDLK_KP5: priChar = "CENTER"; numLockChar = "5"; onNumPad = 1; break;
case SDLK_KP6: priChar = "RIGHT"; numLockChar = "6"; onNumPad = 1; break;
case SDLK_KP1: priChar = "END"; numLockChar = "1"; onNumPad = 1; break;
case SDLK_KP2: priChar = "DOWN"; numLockChar = "2"; onNumPad = 1; break;
case SDLK_KP3: priChar = "PAGE DOWN"; numLockChar = "3"; onNumPad = 1; break;
case SDLK_KP0: priChar = "INSERT"; numLockChar = "0"; onNumPad = 1; break;
case SDLK_KP_7: priChar = "HOME"; numLockChar = "7"; onNumPad = 1; break;
case SDLK_KP_8: priChar = "UP"; numLockChar = "8"; onNumPad = 1; break;
case SDLK_KP_9: priChar = "PAGE UP"; numLockChar = "9"; onNumPad = 1; break;
case SDLK_KP_4: priChar = "LEFT"; numLockChar = "4"; onNumPad = 1; break;
case SDLK_KP_5: priChar = "CENTER"; numLockChar = "5"; onNumPad = 1; break;
case SDLK_KP_6: priChar = "RIGHT"; numLockChar = "6"; onNumPad = 1; break;
case SDLK_KP_1: priChar = "END"; numLockChar = "1"; onNumPad = 1; break;
case SDLK_KP_2: priChar = "DOWN"; numLockChar = "2"; onNumPad = 1; break;
case SDLK_KP_3: priChar = "PAGE DOWN"; numLockChar = "3"; onNumPad = 1; break;
case SDLK_KP_0: priChar = "INSERT"; numLockChar = "0"; onNumPad = 1; break;
case SDLK_KP_PERIOD: priChar = "DELETE"; numLockChar = "."; onNumPad = 1; break;

// keys above arrow keys
Expand All @@ -1374,8 +1376,8 @@ int MouseSDL::is_key(unsigned scanCode, unsigned short skeyState, char *keyStr,
case SDLK_DELETE: priChar = numLockChar = "DELETE"; break;

// 104-key only
case SDLK_LSUPER: priChar = numLockChar = "LEFT WINDOW"; break;
case SDLK_RSUPER: priChar = numLockChar = "RIGHT WINDOW"; break;
case SDLK_LGUI: priChar = numLockChar = "LEFT WINDOW"; break;
case SDLK_RGUI: priChar = numLockChar = "RIGHT WINDOW"; break;
case SDLK_MENU: priChar = numLockChar = "APP MENU"; break;
}

Expand Down
5 changes: 4 additions & 1 deletion src/video/sdl/surface_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ int SurfaceSDL::unlock_buf()
//
int SurfaceSDL::activate_pal(SDL_Color *pal, int firstcolor, int ncolors)
{
return SDL_SetPalette(surface, SDL_LOGPAL, pal, firstcolor, ncolors);
return SDL_SetPaletteColors(surface->format->palette,
pal,
firstcolor,
ncolors);
}
//--------- End of function SurfaceSDL::activate_pal ----------//

Expand Down
Loading