Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use SDL1.2 keysym in the config when using SDL2
It is easier for a user to keep the old SDL1.2 values for the keys in the
config instead of converting them by hand. This is extreme important when the
default (automatic) config is used.
  • Loading branch information
ecsv committed Jun 22, 2013
1 parent 84881a2 commit 58c98a0
Show file tree
Hide file tree
Showing 7 changed files with 1,251 additions and 36 deletions.
4 changes: 3 additions & 1 deletion projects/msvc11/mupen64plus-core.vcxproj
Expand Up @@ -159,6 +159,7 @@
<ClCompile Include="..\..\src\r4300\x86\rjump.c" />
<ClCompile Include="..\..\src\main\rom.c" />
<ClCompile Include="..\..\src\main\savestates.c" />
<ClCompile Include="..\..\src\main\sdl_key_converter.c" />
<ClCompile Include="..\..\src\osd\screenshot.cpp" />
<ClCompile Include="..\..\src\memory\tlb.c" />
<ClCompile Include="..\..\src\main\zip\unzip.c" />
Expand Down Expand Up @@ -219,6 +220,7 @@
<ClInclude Include="..\..\src\r4300\reset.h" />
<ClInclude Include="..\..\src\main\rom.h" />
<ClInclude Include="..\..\src\main\savestates.h" />
<ClInclude Include="..\..\src\main\sdl_key_converter.h" />
<ClInclude Include="..\..\src\osd\screenshot.h" />
<ClInclude Include="..\..\src\memory\tlb.h" />
<ClInclude Include="..\..\src\main\zip\unzip.h" />
Expand All @@ -231,4 +233,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
8 changes: 8 additions & 0 deletions projects/msvc8/mupen64plus-core.vcproj
Expand Up @@ -408,6 +408,10 @@
RelativePath="..\..\src\main\savestates.c"
>
</File>
<File
RelativePath="..\..\src\main\sdl_key_converter.c"
>
</File>
<File
RelativePath="..\..\src\osd\screenshot.cpp"
>
Expand Down Expand Up @@ -646,6 +650,10 @@
RelativePath="..\..\src\main\savestates.h"
>
</File>
<File
RelativePath="..\..\src\main\sdl_key_converter.h"
>
</File>
<File
RelativePath="..\..\src\osd\screenshot.h"
>
Expand Down
1 change: 1 addition & 0 deletions projects/unix/Makefile
Expand Up @@ -383,6 +383,7 @@ SOURCE = \
$(SRCDIR)/main/md5.c \
$(SRCDIR)/main/rom.c \
$(SRCDIR)/main/savestates.c \
$(SRCDIR)/main/sdl_key_converter.c \
$(SRCDIR)/main/workqueue.c \
$(SRCDIR)/memory/dma.c \
$(SRCDIR)/memory/flashram.c \
Expand Down
72 changes: 37 additions & 35 deletions src/main/eventloop.c
Expand Up @@ -42,6 +42,7 @@
#define SDL_SCANCODE_RETURN SDLK_RETURN
#define SDL_SCANCODE_0 SDLK_0
#define SDL_SCANCODE_9 SDLK_9
#define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN

#define SDL_SetEventFilter(func, data) SDL_SetEventFilter(func)
#define event_sdl_filter(userdata, event) event_sdl_filter(const event)
Expand All @@ -51,6 +52,7 @@
#define M64P_CORE_PROTOTYPES 1
#include "main.h"
#include "eventloop.h"
#include "sdl_key_converter.h"
#include "util.h"
#include "api/callbacks.h"
#include "api/config.h"
Expand Down Expand Up @@ -407,22 +409,22 @@ int event_set_core_defaults(void)

ConfigSetDefaultFloat(l_CoreEventsConfig, "Version", CONFIG_PARAM_VERSION, "Mupen64Plus CoreEvents config parameter set version number. Please don't change this version number.");
/* Keyboard presses mapped to core functions */
ConfigSetDefaultInt(l_CoreEventsConfig, kbdStop, SDL_SCANCODE_ESCAPE, "SDL keysym for stopping the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdFullscreen, SDL_NUM_SCANCODES, "SDL keysym for switching between fullscreen/windowed modes");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdSave, SDL_SCANCODE_F5, "SDL keysym for saving the emulator state");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdLoad, SDL_SCANCODE_F7, "SDL keysym for loading the emulator state");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdIncrement, 0, "SDL keysym for advancing the save state slot");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdReset, SDL_SCANCODE_F9, "SDL keysym for resetting the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdSpeeddown, SDL_SCANCODE_F10, "SDL keysym for slowing down the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdSpeedup, SDL_SCANCODE_F11, "SDL keysym for speeding up the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdScreenshot, SDL_SCANCODE_F12, "SDL keysym for taking a screenshot");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdPause, SDL_SCANCODE_P, "SDL keysym for pausing the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdMute, SDL_SCANCODE_M, "SDL keysym for muting/unmuting the sound");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdIncrease, SDL_SCANCODE_RIGHTBRACKET,"SDL keysym for increasing the volume");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdDecrease, SDL_SCANCODE_LEFTBRACKET, "SDL keysym for decreasing the volume");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdForward, SDL_SCANCODE_F, "SDL keysym for temporarily going really fast");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdAdvance, SDL_SCANCODE_SLASH, "SDL keysym for advancing by one frame when paused");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdGameshark, SDL_SCANCODE_G, "SDL keysym for pressing the game shark button");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdStop, sdl_native2keysym(SDL_SCANCODE_ESCAPE), "SDL keysym for stopping the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdFullscreen, sdl_native2keysym(SDL_NUM_SCANCODES), "SDL keysym for switching between fullscreen/windowed modes");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdSave, sdl_native2keysym(SDL_SCANCODE_F5), "SDL keysym for saving the emulator state");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdLoad, sdl_native2keysym(SDL_SCANCODE_F7), "SDL keysym for loading the emulator state");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdIncrement, sdl_native2keysym(SDL_SCANCODE_UNKNOWN), "SDL keysym for advancing the save state slot");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdReset, sdl_native2keysym(SDL_SCANCODE_F9), "SDL keysym for resetting the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdSpeeddown, sdl_native2keysym(SDL_SCANCODE_F10), "SDL keysym for slowing down the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdSpeedup, sdl_native2keysym(SDL_SCANCODE_F11), "SDL keysym for speeding up the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdScreenshot, sdl_native2keysym(SDL_SCANCODE_F12), "SDL keysym for taking a screenshot");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdPause, sdl_native2keysym(SDL_SCANCODE_P), "SDL keysym for pausing the emulator");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdMute, sdl_native2keysym(SDL_SCANCODE_M), "SDL keysym for muting/unmuting the sound");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdIncrease, sdl_native2keysym(SDL_SCANCODE_RIGHTBRACKET),"SDL keysym for increasing the volume");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdDecrease, sdl_native2keysym(SDL_SCANCODE_LEFTBRACKET), "SDL keysym for decreasing the volume");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdForward, sdl_native2keysym(SDL_SCANCODE_F), "SDL keysym for temporarily going really fast");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdAdvance, sdl_native2keysym(SDL_SCANCODE_SLASH), "SDL keysym for advancing by one frame when paused");
ConfigSetDefaultInt(l_CoreEventsConfig, kbdGameshark, sdl_native2keysym(SDL_SCANCODE_G), "SDL keysym for pressing the game shark button");
/* Joystick events mapped to core functions */
ConfigSetDefaultString(l_CoreEventsConfig, JoyCmdName[joyStop], "", "Joystick event string for stopping the emulator");
ConfigSetDefaultString(l_CoreEventsConfig, JoyCmdName[joyFullscreen], "", "Joystick event string for switching between fullscreen/windowed modes");
Expand Down Expand Up @@ -455,37 +457,37 @@ void event_sdl_keydown(int keysym, int keymod)
else if (keysym >= SDL_SCANCODE_0 && keysym <= SDL_SCANCODE_9)
main_state_set_slot(keysym - SDL_SCANCODE_0);
/* check all of the configurable commands */
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdStop))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdStop)))
main_stop();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdFullscreen))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdFullscreen)))
gfx.changeWindow();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdSave))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdSave)))
main_state_save(0, NULL); /* save in mupen64plus format using current slot */
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdLoad))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdLoad)))
main_state_load(NULL); /* load using current slot */
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdIncrement))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdIncrement)))
main_state_inc_slot();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdReset))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdReset)))
reset_soft();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdSpeeddown))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdSpeeddown)))
main_speeddown(5);
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdSpeedup))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdSpeedup)))
main_speedup(5);
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdScreenshot))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdScreenshot)))
main_take_next_screenshot(); /* screenshot will be taken at the end of frame rendering */
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdPause))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdPause)))
main_toggle_pause();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdMute))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdMute)))
main_volume_mute();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdIncrease))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdIncrease)))
main_volume_up();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdDecrease))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdDecrease)))
main_volume_down();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdForward))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdForward)))
main_set_fastforward(1);
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdAdvance))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdAdvance)))
main_advance_one();
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdGameshark))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdGameshark)))
event_set_gameshark(1);
else
{
Expand All @@ -497,15 +499,15 @@ void event_sdl_keydown(int keysym, int keymod)

void event_sdl_keyup(int keysym, int keymod)
{
if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdStop))
if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdStop)))
{
return;
}
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdForward))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdForward)))
{
main_set_fastforward(0);
}
else if (keysym == ConfigGetParamInt(l_CoreEventsConfig, kbdGameshark))
else if (keysym == sdl_keysym2native(ConfigGetParamInt(l_CoreEventsConfig, kbdGameshark)))
{
event_set_gameshark(0);
}
Expand Down

0 comments on commit 58c98a0

Please sign in to comment.