Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #8 from KoKuToru/new
Browse files Browse the repository at this point in the history
Version 1.1.0
  • Loading branch information
KoKuToru committed Mar 6, 2016
2 parents 1cd65db + 6f4a265 commit 922c6bc
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 621 deletions.
45 changes: 37 additions & 8 deletions CMakeLists.txt 100644 → 100755
@@ -1,14 +1,43 @@
PROJECT(koku-xinput-wine)
cmake_minimum_required(VERSION 2.8)

project(koku-xinput-wine)
ADD_LIBRARY(koku-xinput-wine SHARED main.cpp config.cpp xinput.cpp device.cpp)
# Check for C++11
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

#For SDL:
target_link_libraries(koku-xinput-wine SDL)
set(CMAKE_CXX_FLAGS "-std=c++0x -m32")
# Check for 32bit version
option(BUILD_M32 "Build library in 32Bit mode" ON)
if(BUILD_M32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif()

#For SDL2:
#target_link_libraries(koku-xinput-wine SDL2)
#set(CMAKE_CXX_FLAGS "-std=c++0x -m32 -DUSE_SDL2")
ADD_LIBRARY(koku-xinput-wine SHARED main.cpp xinput.cpp device.cpp)

# Pull in pkgconfig
include(FindPkgConfig)

# - Try to find SDL
# Once done this will define
#
# SDL_FOUND - system has libSDL
# SDL_INCLUDE_DIRS - the libSDL include directory
# SDL_LIBRARIES - The libSDL libraries
if(PKG_CONFIG_FOUND)
pkg_check_modules (SDL REQUIRED sdl2)
else()
find_package(SDL2 REQURIED)
list(APPEND SDL_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
list(APPEND SDL_LIBRARIES ${SDL2_LIBRARIES})
endif()

# Link SDL
target_link_libraries(koku-xinput-wine ${SDL_LIBRARY})
set_target_properties(koku-xinput-wine PROPERTIES PREFIX "")
51 changes: 5 additions & 46 deletions README.md
Expand Up @@ -2,16 +2,17 @@ koku-xinput-wine
================

Adds xinput support to wine, without changing the source of wine.
Modified to use SDL2 gamepad mappings

Install
---------------------
If you are on 64Bit you will need 32Bit tool-chain (multilib)

Because this will generate 32Bit code, no 64Bit support !

It depens on SDL1.2-Librarys.
It depens on SDL2-Librarys.

[user@host code]$git clone https://github.com/KoKuToru/koku-xinput-wine
[user@host code]$git clone https://github.com/KoKuToru/koku-xinput-wine.git
[user@host code]$cd koku-xinput-wine
[user&host code]$cmake .
[user@host code]$make
Expand All @@ -29,49 +30,7 @@ Of course it would be wiser to put this code into wine..

Config
---------------------
File at ~/.config/koku-xinput-wine.ini, gets auto generated at first usage.

XINPUT_GAMEPAD_LEFT_THUMB_X = A01
XINPUT_GAMEPAD_LEFT_THUMB_Y = A02*-1
...
XINPUT_GAMEPAD_DPAD_UP = H01&0x0001
...
XINPUT_GAMEPAD_Y = B04

### First config-parameter
XINPUT_GAMEPAD_DPAD_UP

i thinks this parameters pretty much explain itself.. if you don't understand, feel free to ask me.
You can add sdl2 gamepad mappings by putting them in file named "gamecontrollerdb.txt" and place it next to your game executable, or via the *SDL_GAMECONTROLLERCONFIG* environment variable.

### Second config-parameter
The first letter stands for:

A = Axis
B = Buttons
H = Hats

Follwing with a number, which explains the id.

A10
Axi with id 10.

### Third config-parameter (optional)

Starts with a '&', followed by a 16-Bit hex number.
Bit mask are useful for hats, hats return 1 value for 4 different directions.

0x0001 = SDL_HAT_UP
0x0002 = SDL_HAT_RIGHT
0x0004 = SDL_HAT_DOWN
0x0008 = SLD_HAT_LEFT

### Forth config-parameter (optional)

Starts with a '*', followed by a integer number.
Multiplys the result with the value.

A02*-1

Flips the Axi Nr. 2.
You can find a premade gamecontrollerdb.txt with a lot of mappings [here](https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt)
56 changes: 0 additions & 56 deletions config.cpp

This file was deleted.

35 changes: 0 additions & 35 deletions config.h

This file was deleted.

1 change: 1 addition & 0 deletions main.cpp
Expand Up @@ -3,6 +3,7 @@
#include "main.h"
#include "device.h"
#include <iostream>
#include <stdlib.h>
using namespace std;

#ifdef __LP64__
Expand Down

0 comments on commit 922c6bc

Please sign in to comment.