diff options
| author | SND\ckain_cp <SND\ckain_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-04-16 21:58:47 +0000 |
|---|---|---|
| committer | SND\ckain_cp <SND\ckain_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-04-16 21:58:47 +0000 |
| commit | 32a5e70e9134f933756a96e547dcdd718b8d5f1e (patch) | |
| tree | 0ba88391433d9157f96eb484d6de5975ff097181 /plugins/dfinput/sdljoy.c | |
| parent | 733612551879e081161604a6e10b7e5fdfe0f89e (diff) | |
| download | pcsxr-32a5e70e9134f933756a96e547dcdd718b8d5f1e.tar.gz | |
GTK: dfinput added emulator key (hotkey) mapping to keyboard or controller. Existing hotkeys are hard coded like F1 for savestate, but now it can have an alias hotkey on keyboard s button for example. These can be configured from dfinput dialog. Also added support for fastforward key (tilde / section key). Currently only dfxvideo supports it by full extent. Hopefully someone can merge these changes to Windows build.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@84102 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfinput/sdljoy.c')
| -rwxr-xr-x | plugins/dfinput/sdljoy.c | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/plugins/dfinput/sdljoy.c b/plugins/dfinput/sdljoy.c index cd93a17c..92db9f4a 100755 --- a/plugins/dfinput/sdljoy.c +++ b/plugins/dfinput/sdljoy.c @@ -84,13 +84,18 @@ int JoyHapticRumble(int pad, uint32_t low, uint32_t high) void InitSDLJoy() { uint8_t i; - + uint8_t emukeydev; g.PadState[0].JoyKeyStatus = 0xFFFF; g.PadState[1].JoyKeyStatus = 0xFFFF; for (i = 0; i < 2; i++) { if (g.cfg.PadDef[i].DevNum >= 0) { g.PadState[i].JoyDev = SDL_JoystickOpen(g.cfg.PadDef[i].DevNum); + + // Saves an extra call to SDL joystick open + if (g.cfg.E.DevNum == g.cfg.PadDef[i].DevNum) { + g.cfg.E.EmuKeyDev = g.PadState[i].JoyDev; + } } else { g.PadState[i].JoyDev = NULL; } @@ -107,6 +112,10 @@ void InitSDLJoy() { } #endif + if (g.cfg.E.EmuKeyDev == 0 && g.cfg.E.DevNum >= 0) { + g.cfg.E.EmuKeyDev = SDL_JoystickOpen(g.cfg.E.DevNum); + } + SDL_JoystickEventState(SDL_IGNORE); InitAnalog(); @@ -133,6 +142,7 @@ void DestroySDLJoy() { for (i = 0; i < 2; i++) { g.PadState[i].JoyDev = NULL; } + g.cfg.E.EmuKeyDev = NULL; } static void bdown(int pad, int bit) @@ -210,6 +220,71 @@ void CheckJoy() { } } + // Check for emulator button states + for (i=(g.cfg.E.EmuKeyDev == NULL ? EMU_TOTAL : 0) ; i < EMU_TOTAL ; i++) { + switch (g.cfg.E.EmuDef[i].Mapping.JoyEvType) { + case BUTTON: + if (SDL_JoystickGetButton(g.cfg.E.EmuKeyDev, g.cfg.E.EmuDef[i].Mapping.J.Button)) { + if (g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending == 0) { + //printf("%x %x %x %x\n", g.cfg.E.EmuKeyDev, i, g.cfg.E.EmuDef[i].Mapping.J.Button, g.cfg.E.EmuDef[i].EmuKeyEvent); + g.KeyLeftOver = g.cfg.E.EmuDef[i].EmuKeyEvent; + g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending = 1; + } + } else if (g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending) { + //printf("%x %x %x %x\n", g.cfg.E.EmuKeyDev, i, g.cfg.E.EmuDef[i].Mapping.J.Button, g.cfg.E.EmuDef[i].EmuKeyEvent); + g.KeyLeftOver = ( g.cfg.E.EmuDef[i].EmuKeyEvent | 0x40000000l ); + g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending = 0; + } + break; + case HAT: + n = (g.cfg.E.EmuDef[i].Mapping.J.Hat >> 8); + if (SDL_JoystickGetHat(g.cfg.E.EmuKeyDev, n) & (g.cfg.E.EmuDef[i].Mapping.J.Hat & 0xFF)) { + if (g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending == 0) { + //printf("%x %x %x %x\n", g.cfg.E.EmuKeyDev, i, g.cfg.E.EmuDef[i].Mapping.J.Button, g.cfg.E.EmuDef[i].EmuKeyEvent); + g.KeyLeftOver = g.cfg.E.EmuDef[i].EmuKeyEvent; + g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending = 1; + } + } else if (g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending) { + //printf("%x %x %x %x\n", g.cfg.E.EmuKeyDev, i, g.cfg.E.EmuDef[i].Mapping.J.Button, g.cfg.E.EmuDef[i].EmuKeyEvent); + g.KeyLeftOver = ( g.cfg.E.EmuDef[i].EmuKeyEvent | 0x40000000l ); + g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending = 0; + } + break; + case AXIS: + n = abs(g.cfg.E.EmuDef[i].Mapping.J.Axis) - 1; + + if (g.cfg.E.EmuDef[i].Mapping.J.Axis > 0) { + if (SDL_JoystickGetAxis(g.cfg.E.EmuKeyDev, n) > 16383) { + if (g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending == 0) { + //printf("push1 %x %x %x %x\n", g.cfg.E.EmuKeyDev, i, g.cfg.E.EmuDef[i].Mapping.J.Axis, g.cfg.E.EmuDef[i].EmuKeyEvent); + g.KeyLeftOver = g.cfg.E.EmuDef[i].EmuKeyEvent; + g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending = 1; + } + } else if (g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending) { + //printf("rel1 %x %x %x %x\n", g.cfg.E.EmuKeyDev, i, g.cfg.E.EmuDef[i].Mapping.J.Button, g.cfg.E.EmuDef[i].EmuKeyEvent); + g.KeyLeftOver = ( g.cfg.E.EmuDef[i].EmuKeyEvent | 0x40000000l ); + g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending = 0; + } + } else if (g.cfg.E.EmuDef[i].Mapping.J.Axis < 0) { + if (SDL_JoystickGetAxis(g.cfg.E.EmuKeyDev, n) < -16383) { + if (g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending == 0) { + //printf("push2 %x %x %x %x\n", g.cfg.E.EmuKeyDev, i, g.cfg.E.EmuDef[i].Mapping.J.Axis, g.cfg.E.EmuDef[i].EmuKeyEvent); + g.KeyLeftOver = g.cfg.E.EmuDef[i].EmuKeyEvent; + g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending = 1; + } + } else if (g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending) { + //printf("rel2 %x %x %x %x\n", g.cfg.E.EmuKeyDev, i, g.cfg.E.EmuDef[i].Mapping.J.Button, g.cfg.E.EmuDef[i].EmuKeyEvent); + g.KeyLeftOver = ( g.cfg.E.EmuDef[i].EmuKeyEvent | 0x40000000l ); + g.cfg.E.EmuDef[i].Mapping.ReleaseEventPending = 0; + } + } + break; + default: + break; + + } + } + CheckAnalog(); for (i = 0; i < 2; i++) { |
