Skip to content

Commit

Permalink
Don't use Synaptics PS/2 Touchpad as a joystick
Browse files Browse the repository at this point in the history
  • Loading branch information
zaps166 committed Jul 18, 2016
1 parent e3dcfc9 commit d87d09b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/DInput.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ extern uint32_t windowsForceFeedbackDevice;

extern uint32_t mousePositionX, mousePositionY;

extern int32_t touchpadJoyIdx;

#define CONVERT(x) (((x)*0x7FFF)/10000)
#define CONVERT_LENGTH(x) (((x) == (SDL_HAPTIC_INFINITY)) ? (SDL_HAPTIC_INFINITY) : ((x) / 1000))

Expand Down Expand Up @@ -534,6 +536,8 @@ static REALIGN STDCALL uint32_t EnumDevices(void **this, uint32_t devType, DIENU
uint32_t i, n = SDL_NumJoysticks();
for (i = 0; i < n; ++i)
{
if (i == touchpadJoyIdx)
continue;
deviceInstance.guidInstance.a = JOYSTICK;
deviceInstance.guidInstance.b = i;
if (!callback(&deviceInstance, ref))
Expand Down
2 changes: 1 addition & 1 deletion src/Version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define WRAPPER_VERSION "1.0.2"
#define WRAPPER_VERSION "1.0.3"
22 changes: 18 additions & 4 deletions src/Wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ BOOL linearSoundInterpolation = false, useGlBleginGlEnd = false, keepAspectRatio
uint32_t fullScreenFlag = SDL_WINDOW_FULLSCREEN_DESKTOP, broadcast = 0xFFFFFFFF;
uint16_t PORT1 = 1030, PORT2 = 1029;

int32_t touchpadJoyIdx = -1;

static void initializeSDL2()
{
extern const char binaryGameVersion;
Expand All @@ -281,6 +283,17 @@ static void initializeSDL2()

if (SDL_Init(SDL_INIT_EVERYTHING & ~SDL_INIT_GAMECONTROLLER) < 0)
fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());

const int n = SDL_NumJoysticks();
for (int i = 0; i < n; ++i)
{
const char *name = SDL_JoystickNameForIndex(i);
if (name && strstr(name, "SynPS/2"))
{
touchpadJoyIdx = i;
break;
}
}
}

#ifdef SWAP_WINDOW_AND_GL_THREAD
Expand Down Expand Up @@ -599,15 +612,16 @@ REALIGN STDCALL SDL_Window *WrapperCreateWindow(WindowProc windowProc)
return sdlWin;
}

REALIGN int32_t SDL_NumJoysticks_wrap(void)
{
return SDL_NumJoysticks() - (touchpadJoyIdx >= 0);
}

/* Wrapper for functions called from Assembly code for stack realignment */

#include <stdarg.h>
#include <time.h>

REALIGN int32_t SDL_NumJoysticks_wrap(void)
{
return SDL_NumJoysticks();
}
REALIGN uint32_t SDL_GetTicks_wrap(void)
{
return SDL_GetTicks();
Expand Down

0 comments on commit d87d09b

Please sign in to comment.