Skip to content

Commit

Permalink
Another recode, using NeonMan/xfakeinput this time. Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
kozec committed Jul 30, 2017
1 parent 5d40f03 commit f93c41e
Show file tree
Hide file tree
Showing 17 changed files with 1,655 additions and 661 deletions.
42 changes: 32 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Important stuff
CFLAGS =
LIBS = -ldxguid -ldinput -ldinput8
LIBS = -luuid -ldxguid -ldinput -ldinput8

# (maybe) distro-specific stuff
MINGW32 = i686-w64-mingw32
Expand All @@ -12,30 +12,52 @@ INCLUDE = include/ # used in as ${USR}/${MINGWxy}/${INCLUDE}

# Computed
GCC32 = ${BIN}/${MINGW32}-gcc
INCLUDE_DIR32 = -I${USR}/${MINGW32}/include
INCLUDE_DIR32 = -I${USR}/${MINGW32}/include -Idumbxinputemu
LIB_DIR32 = -L{USR}/${MINGW32}/lib/

GCC64 = ${BIN}/x86_64-w64-mingw32-gcc -D _WXI_MINGW
INCLUDE_DIR64 = -I${USR}/${MINGW64}/include
INCLUDE_DIR64 = -I${USR}/${MINGW64}/include -Idumbxinputemu
LIB_DIR64 = -L{USR}/${MINGW64}/lib/

.PHONY: default
default: all

# ---- Targets -------

build/32/xinput1_3.dll: xinput1_3/xinput1_3.def xinput1_3/xinput1_3_main.c
%.32.o: %.c
${GCC32} ${CFLAGS} ${INCLUDE_DIR32} ${LIB_DIR32} -c $? -o $@

%.64.o: %.c
${GCC64} ${CFLAGS} ${INCLUDE_DIR64} ${LIB_DIR64} -c $? -o $@

build/32/xinput1_3.dll: xinput1_3/exports.def dumbxinputemu/dinput_input.32.o xinput1_3/xinput1_3.32.o
mkdir -p build/32/
${GCC32} --shared ${CFLAGS} ${INCLUDE_DIR32} ${LIB_DIR32} $? ${LIBS} -o $@

build/32/xinput9_1_0.dll: xinput9_1_0/exports.def dumbxinputemu/dinput_input.32.o xinput9_1_0/xinput9_1_0.32.o
mkdir -p build/32/
${GCC32} --shared ${CFLAGS} ${INCLUDE_DIR32} ${LIB_DIR32} $? ${LIBS} -o $@

build/64/xinput1_3.dll: xinput1_3/xinput1_3.def xinput1_3/xinput1_3_main.c
build/64/xinput1_3.dll: xinput1_3/exports.def dumbxinputemu/dinput_input.64.o xinput1_3/xinput1_3.64.o
mkdir -p build/64/
${GCC64} --shared ${CFLAGS} ${INCLUDE_DIR64} ${LIB_DIR64} $? ${LIBS} -o $@

build/64/xinput9_1_0.dll: xinput9_1_0/exports.def dumbxinputemu/dinput_input.64.o xinput9_1_0/xinput9_1_0.64.o
mkdir -p build/64/
${GCC64} -shared ${CFLAGS} ${INCLUDE_DIR64} ${LIB_DIR64} $? ${LIBS} -o $@
${GCC64} --shared ${CFLAGS} ${INCLUDE_DIR64} ${LIB_DIR64} $? ${LIBS} -o $@

clean:
rm -f *.o *.dll
rm -f dumbxinputemu/*.o
rm -f xinput1_1/*.o
rm -f xinput1_2/*.o
rm -f xinput1_3/*.o
rm -f xinput1_4/*.o
rm -f xinput9_1_0/*.o
rm -f build/32/*
rm -f build/64/*

32bit: build/32/xinput1_3.dll
32bit: build/32/xinput1_3.dll build/32/xinput9_1_0.dll

64bit: build/64/xinput1_3.dll
64bit: build/64/xinput1_3.dll build/64/xinput9_1_0.dll

all: build/32/xinput1_3.dll
all: 32bit
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Dumb xinput Emulator
xinput dll reimplementation compatibile with DirectInput controllers. Think x360ce without configuration.

##### Usage
Copy xinput1_3.dll next to game executable and start the game.
Copy xinput1_3.dll next to game executable and start the game. For recent games, try copying xinput9_1_0.dll as well if first one doesn't works.

##### Why in the...?
This is meant mainly for using Steam Controller or XBox 360 pad with Wine.
Expand All @@ -15,4 +15,4 @@ This is meant mainly for using Steam Controller or XBox 360 pad with Wine.
- run `make` or `make 64bit` for 64bit version

##### Credits
Based on xinput1_3.dll implementation in Wine and [wine-xinput patch by 00cpxxx](https://github.com/00cpxxx/wine-xinput)
Based on xinput1_3.dll implementation in Wine, [wine-xinput patch by 00cpxxx](https://github.com/00cpxxx/wine-xinput) and [xfakeinput by NeonMan](https://github.com/NeonMan/xfakeinput)
90 changes: 60 additions & 30 deletions xinput1_3/xinput1_3.h → dumbxinputemu/Xinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/

#ifndef __XINPUT1_3_H
#define __XINPUT1_3_H
#ifndef __WINE_XINPUT_H
#define __WINE_XINPUT_H

#include <windef.h>

#define EXPORT __declspec(dllexport)

/*
* Bitmasks for the joysticks buttons, determines what has
* been pressed on the joystick, these need to be mapped
Expand Down Expand Up @@ -55,6 +53,56 @@
#define XINPUT_KEYSTROKE_KEYUP 0x0002
#define XINPUT_KEYSTROKE_REPEAT 0x0004

/*
* Defines the codes which are returned by XInputGetKeystroke
*/

#define VK_PAD_A 0x5800
#define VK_PAD_B 0x5801
#define VK_PAD_X 0x5802
#define VK_PAD_Y 0x5803
#define VK_PAD_RSHOULDER 0x5804
#define VK_PAD_LSHOULDER 0x5805
#define VK_PAD_LTRIGGER 0x5806
#define VK_PAD_RTRIGGER 0x5807
#define VK_PAD_DPAD_UP 0x5810
#define VK_PAD_DPAD_DOWN 0x5811
#define VK_PAD_DPAD_LEFT 0x5812
#define VK_PAD_DPAD_RIGHT 0x5813
#define VK_PAD_START 0x5814
#define VK_PAD_BACK 0x5815
#define VK_PAD_LTHUMB_PRESS 0x5816
#define VK_PAD_RTHUMB_PRESS 0x5817
#define VK_PAD_LTHUMB_UP 0x5820
#define VK_PAD_LTHUMB_DOWN 0x5821
#define VK_PAD_LTHUMB_RIGHT 0x5822
#define VK_PAD_LTHUMB_LEFT 0x5823
#define VK_PAD_LTHUMB_UPLEFT 0x5824
#define VK_PAD_LTHUMB_UPRIGHT 0x5825
#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
#define VK_PAD_LTHUMB_DOWNLEFT 0x5827
#define VK_PAD_RTHUMB_UP 0x5830
#define VK_PAD_RTHUMB_DOWN 0x5831
#define VK_PAD_RTHUMB_RIGHT 0x5832
#define VK_PAD_RTHUMB_LEFT 0x5833
#define VK_PAD_RTHUMB_UPLEFT 0x5834
#define VK_PAD_RTHUMB_UPRIGHT 0x5835
#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
#define VK_PAD_RTHUMB_DOWNLEFT 0x5837

/*
* Deadzones are for analogue joystick controls on the joypad
* which determine when input should be assumed to be in the
* middle of the pad. This is a threshold to stop a joypad
* controlling the game when the player isn't touching the
* controls.
*/

#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30


/*
* Defines what type of abilities the type of joystick has
* DEVTYPE_GAMEPAD is available for all joysticks, however
Expand Down Expand Up @@ -122,27 +170,11 @@ typedef struct _XINPUT_GAMEPAD {
SHORT sThumbRY;
} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;

typedef struct _XINPUT_GAMEPAD_EX {
WORD wButtons;
BYTE bLeftTrigger;
BYTE bRightTrigger;
SHORT sThumbLX;
SHORT sThumbLY;
SHORT sThumbRX;
SHORT sThumbRY;
DWORD dwPaddingReserved;
} XINPUT_GAMEPAD_EX, *PXINPUT_GAMEPAD_EX;

typedef struct _XINPUT_STATE {
DWORD dwPacketNumber;
XINPUT_GAMEPAD Gamepad;
} XINPUT_STATE, *PXINPUT_STATE;

typedef struct _XINPUT_STATE_EX {
DWORD dwPacketNumber;
XINPUT_GAMEPAD_EX Gamepad;
} XINPUT_STATE_EX, *PXINPUT_STATE_EX;

/*
* Defines the structure of how much vibration is set on both the
* right and left motors in a joystick. If you're not using a 360
Expand Down Expand Up @@ -192,18 +224,16 @@ typedef struct _XINPUT_BATTERY_INFORMATION
extern "C" {
#endif

void EXPORT XInputEnable(BOOL);
DWORD EXPORT XInputSetState(DWORD, XINPUT_VIBRATION*);
DWORD EXPORT XInputGetState(DWORD, XINPUT_STATE*);
DWORD EXPORT XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
DWORD EXPORT XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
DWORD EXPORT XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
DWORD EXPORT XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);

DWORD EXPORT XInputGetStateEx(DWORD, XINPUT_STATE_EX*);
void WINAPI XInputEnable(WINBOOL);
DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*);
DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*);
DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);

#ifdef __cplusplus
}
#endif

#endif /* __XINPUT1_3_H */
#endif /* __WINE_XINPUT_H */
Loading

0 comments on commit f93c41e

Please sign in to comment.