Skip to content

Commit

Permalink
Merge branch 'pr/148' into Electronicks/sdl2
Browse files Browse the repository at this point in the history
  • Loading branch information
JibbSmart committed Mar 8, 2021
2 parents 59bd82a + b2f88e6 commit 411a2d5
Show file tree
Hide file tree
Showing 27 changed files with 3,583 additions and 958 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
Most recent updates will appear first.
This is a summary of new features and bugfixes. Read the README to learn how to use the features mentioned here.

## 3.0.0
Nicolas added ViGEm support for virtual xbox and DS4 for buttons, triggers and sticks as well as rumble forwarding.
Added colored console lines
Added DS4 rumble commands and light bar setting
Added hair trigger soft press as a negative threshold and trigger modes SCROLL_WHEEL and NO_SKIP_EXCLUSIVE
Added ability to hide JSM from the taskbar when minimized, with a checkbox in the tray icon
Added help strings for button mapping
Handle drag n drop files into the console better
Improve command error handling

### Features
* New Bindings: TOUCH, T1-T25 touch buttons, Touch stick bindings
* New settings for touch joystick such as mode, inner deadzone, and stick radius
* Assigning a negative value to trigger threshold enables hair trigger
* New setting HIDE_MINIMIZED will hide JSM when set to ON. OFF is default

## 2.2.0
Nicolas added more keybinds. Robin fixed issues with building on Linux and improved PlayStation controller support.

Expand Down
139 changes: 104 additions & 35 deletions JoyShockMapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_executable (
src/operators.cpp
src/CmdRegistry.cpp
src/quatMaths.cpp
src/ButtonHelp.cpp
include/InputHelpers.h
include/PlatformDefinitions.h
include/TrayIcon.h
Expand All @@ -27,41 +28,88 @@ add_executable (
include/JSMVariable.hpp
include/Whitelister.h
include/JoyShockMapper.h
include/ColorCodes.h
include/GamepadMotion.hpp
)

if (WINDOWS)
target_sources (
${BINARY_NAME} PRIVATE
src/win32/InputHelpers.cpp
include/win32/resource.h
src/win32/PlatformDefinitions.cpp
src/win32/WindowsTrayIcon.cpp include/win32/WindowsTrayIcon.h
src/win32/WindowsTrayIcon.cpp include/win32/WindowsTrayIcon.h
src/win32/Whitelister.cpp
"Win32 Dialog.rc"
src/win32/Gamepad.cpp include/win32/Gamepad.h
"Win32 Dialog.rc" include/win32/resource.h
)

if(SDL)
target_sources (
${BINARY_NAME} PRIVATE
src/JoyShockLibrary.cpp include/JoyShockLibrary.h
)
endif()

set_target_properties (
${BINARY_NAME}
PROPERTIES WIN32_EXECUTABLE ON
${BINARY_NAME} PROPERTIES
WIN32_EXECUTABLE ON
VS_STARTUP_PROJECT "${BINARY_NAME}"
VS_DEBUGGER_WORKING_DIRECTORY "$(ProjectDir)/$(Configuration)/"
)

# ViGEmClient
CPMAddPackage (
NAME ViGEmClient
GITHUB_REPOSITORY ViGEm/ViGEmClient
VERSION 1.16.107.0
)

include_external_msproject(ViGEmClient
"_deps/vigemclient-src/src/ViGEmClient.vcxproj")

SET(ViGEmClient_GUID_CMAKE "7DB06674-1F4F-464B-8E1C-172E9587F9DC" CACHE INTERNAL "Project GUID")

set_target_properties(ViGEmClient PROPERTIES
MAP_IMPORTED_CONFIG_DEBUG DEBUG_LIB
MAP_IMPORTED_CONFIG_RELEASE RELEASE_LIB
)

set_target_properties(ViGEmClient PROPERTIES
VS_PLATFORM_TOOLSET "v141"
IMPORTED_LOCATION "${PROJECT_BINARY_DIR}/lib/debug/$(PlatformShortName)/ViGEmClient.lib"
INTERFACE_INCLUDE_DIRECTORIES "${PROJECT_BINARY_DIR}/_deps/vigemclient-src/include"
)

add_dependencies(${BINARY_NAME} ViGEmClient)

set_target_properties (
${BINARY_NAME}
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY
"$(ProjectDir)/$(Configuration)/"
${BINARY_NAME} PROPERTIES
LINK_LIBRARIES "${PROJECT_BINARY_DIR}/lib/debug/$(PlatformShortName)/ViGEmClient.lib"
)

set (BUILD_SHARED_LIBS ON)

add_custom_command(
TARGET ${BINARY_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"$<TARGET_FILE:SDL2>"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/$<TARGET_FILE_NAME:SDL2>"

target_include_directories (
${BINARY_NAME} PUBLIC
"${PROJECT_BINARY_DIR}/_deps/vigemclient-src/include"
)

if(SDL)
add_custom_command(
TARGET ${BINARY_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"$<TARGET_FILE:SDL2>"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/$<TARGET_FILE_NAME:SDL2>"
)
else()
add_custom_command(
TARGET ${BINARY_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"$<TARGET_FILE:JoyShockLibrary>"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/$<TARGET_FILE_NAME:JoyShockLibrary>"
)
endif()

add_definitions(/bigobj)
endif ()

Expand All @@ -88,24 +136,45 @@ target_include_directories (
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}/include"
)

CPMAddPackage (
NAME SDL2
GITHUB_REPOSITORY libsdl-org/SDL
VERSION 2.0.15
# 2.0.15 hasn't released yet, so let's use a specific commit
GIT_TAG c287087fcce57af086c0a52f74fcdb74e9084c55
)

target_link_libraries (
${BINARY_NAME} PRIVATE
Platform::Dependencies
SDL2
)

install (
TARGETS ${BINARY_NAME} SDL2
)

if(SDL)
# SDL2
CPMAddPackage (
NAME SDL2
GITHUB_REPOSITORY libsdl-org/SDL
VERSION 2.0.15
# 2.0.15 hasn't released yet, so let's use a specific commit
GIT_TAG c287087fcce57af086c0a52f74fcdb74e9084c55
)
target_link_libraries (
${BINARY_NAME} PRIVATE
Platform::Dependencies
SDL2
)

install (
TARGETS ${BINARY_NAME} SDL2
)
else()
# JoyShockLibrary
CPMAddPackage (
NAME JoyShockLibrary
GITHUB_REPOSITORY JibbSmart/JoyShockLibrary
VERSION 2.1.0
)

target_link_libraries (
${BINARY_NAME} PRIVATE
Platform::Dependencies
JoyShockLibrary
)

install (
TARGETS ${BINARY_NAME} JoyShockLibrary
)
endif()


# magic_enum
CPMAddPackage (
NAME magic_enum
GITHUB_REPOSITORY Neargye/magic_enum
Expand Down
9 changes: 7 additions & 2 deletions JoyShockMapper/include/CmdRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,18 @@ class CmdRegistry
public:
CmdRegistry();

bool loadConfigFile(in_string fileName);
// Not in_string because the string is modified inside
bool loadConfigFile(string fileName);

// Add a command to the registry. The regisrty takes ownership of the memory of this pointer.
// You can use _ASSERT() on the return value of this function to make sure the commands are
// accepted.
bool Add(JSMCommand* newCommand);

bool Remove(in_string name);

bool hasCommand(in_string name) const;

bool isCommandValid(in_string line);

// Process a command entered by the user
Expand All @@ -117,7 +122,7 @@ class JSMMacro : public JSMCommand
{
public:
// A Macro function has it's command object passed as argument.
typedef function<void(JSMMacro *macro, in_string arguments)> MacroDelegate;
typedef function<bool(JSMMacro *macro, in_string arguments)> MacroDelegate;

protected:
// The macro function to call when the command is recognized.
Expand Down
156 changes: 156 additions & 0 deletions JoyShockMapper/include/ColorCodes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#pragma once

#include <map>
#include <string>
#include <stdint.h>

// https://www.rapidtables.com/web/color/RGB_Color.html#color-table
// Can't use magic enum because it only supports base type up to 16b and I need 32b
static map<std::string, uint32_t> colorCodeMap
{
{"OFF", 0x000000},
{"MAROON", 0x800000},
{"DARK_RED", 0x8B0000},
{"BROWN", 0xA52A2A},
{"FIREBRICK", 0xB22222},
{"CRIMSON", 0xDC143C},
{"RED", 0xFF0000},
{"TOMATO", 0xFF6347},
{"CORAL", 0xFF7F50},
{"INDIAN_RED", 0xCD5C5C},
{"LIGHT_CORAL", 0xF08080},
{"DARK_SALMON", 0xE9967A},
{"SALMON", 0xFA8072},
{"LIGHT_SALMON", 0xFFA07A},
{"ORANGE_RED", 0xFF4500},
{"DARK_ORANGE", 0xFF8C00},
{"ORANGE", 0xFFA500},
{"GOLD", 0xFFD700},
{"DARK_GOLDEN_ROD", 0xB8860B},
{"GOLDEN_ROD", 0xDAA520},
{"PALE_GOLDEN_ROD", 0xEEE8AA},
{"DARK_KHAKI", 0xBDB76B},
{"KHAKI", 0xF0E68C},
{"OLIVE", 0x808000},
{"YELLOW", 0xFFFF00},
{"YELLOW_GREEN", 0x9ACD32},
{"DARK_OLIVE_GREEN", 0x556B2F},
{"OLIVE_DRAB", 0x6B8E23},
{"LAWN_GREEN", 0x7CFC00},
{"CHART_REUSE", 0x7FFF00},
{"GREEN_YELLOW", 0xADFF2F},
{"DARK_GREEN", 0x006400},
{"GREEN", 0x008000},
{"FOREST_GREEN", 0x228B22},
{"LIME", 0x00FF00},
{"LIME_GREEN", 0x32CD32},
{"LIGHT_GREEN", 0x90EE90},
{"PALE_GREEN", 0x98FB98},
{"DARK_SEA_GREEN", 0x8FBC8F},
{"MEDIUM_SPRING_GREEN", 0x00FA9A},
{"SPRING_GREEN", 0x00FF7F},
{"SEA_GREEN", 0x2E8B57},
{"MEDIUM_AQUA_MARINE", 0x66CDAA},
{"MEDIUM_SEA_GREEN", 0x3CB371},
{"LIGHT_SEA_GREEN", 0x20B2AA},
{"DARK_SLATE_GRAY", 0x2F4F4F},
{"TEAL", 0x008080},
{"DARK_CYAN", 0x008B8B},
{"AQUA", 0x00FFFF},
{"CYAN", 0x00FFFF},
{"LIGHT_CYAN", 0xE0FFFF},
{"DARK_TURQUOISE", 0x00CED1},
{"TURQUOISE", 0x40E0D0},
{"MEDIUM_TURQUOISE", 0x48D1CC},
{"PALE_TURQUOISE", 0xAFEEEE},
{"AQUA_MARINE", 0x7FFFD4},
{"POWDER_BLUE", 0xB0E0E6},
{"CADET_BLUE", 0x5F9EA0},
{"STEEL_BLUE", 0x4682B4},
{"CORN_FLOWER_BLUE", 0x6495ED},
{"DEEP_SKY_BLUE", 0x00BFFF},
{"DODGER_BLUE", 0x1E90FF},
{"LIGHT_BLUE", 0xADD8E6},
{"SKY_BLUE", 0x87CEEB},
{"LIGHT_SKY_BLUE", 0x87CEFA},
{"MIDNIGHT_BLUE", 0x191970},
{"NAVY", 0x000080},
{"DARK_BLUE", 0x00008B},
{"MEDIUM_BLUE", 0x0000CD},
{"BLUE", 0x0000FF},
{"ROYAL_BLUE", 0x4169E1},
{"BLUE_VIOLET", 0x8A2BE2},
{"INDIGO", 0x4B0082},
{"DARK_SLATE_BLUE", 0x483D8B},
{"SLATE_BLUE", 0x6A5ACD},
{"MEDIUM_SLATE_BLUE", 0x7B68EE},
{"MEDIUM_PURPLE", 0x9370DB},
{"DARK_MAGENTA", 0x8B008B},
{"DARK_VIOLET", 0x9400D3},
{"DARK_ORCHID", 0x9932CC},
{"MEDIUM_ORCHID", 0xBA55D3},
{"PURPLE", 0x800080},
{"THISTLE", 0xD8BFD8},
{"PLUM", 0xDDA0DD},
{"VIOLET", 0xEE82EE},
{"MAGENTA", 0xFF00FF},
{"FUCHSIA", 0xFF00FF},
{"ORCHID", 0xDA70D6},
{"MEDIUM_VIOLET_RED", 0xC71585},
{"PALE_VIOLET_RED", 0xDB7093},
{"DEEP_PINK", 0xFF1493},
{"HOT_PINK", 0xFF69B4},
{"LIGHT_PINK", 0xFFB6C1},
{"PINK", 0xFFC0CB},
{"ANTIQUE_WHITE", 0xFAEBD7},
{"BEIGE", 0xF5F5DC},
{"BISQUE", 0xFFE4C4},
{"BLANCHED_ALMOND", 0xFFEBCD},
{"WHEAT", 0xF5DEB3},
{"CORN_SILK", 0xFFF8DC},
{"LEMON_CHIFFON", 0xFFFACD},
{"LIGHT_GOLDEN_ROD_YELLOW", 0xFAFAD2},
{"LIGHT_YELLOW", 0xFFFFE0},
{"SADDLE_BROWN", 0x8B4513},
{"SIENNA", 0xA0522D},
{"CHOCOLATE", 0xD2691E},
{"PERU", 0xCD853F},
{"SANDY_BROWN", 0xF4A460},
{"BURLY_WOOD", 0xDEB887},
{"TAN", 0xD2B48C},
{"ROSY_BROWN", 0xBC8F8F},
{"MOCCASIN", 0xFFE4B5},
{"NAVAJO_WHITE", 0xFFDEAD},
{"PEACH_PUFF", 0xFFDAB9},
{"MISTY_ROSE", 0xFFE4E1},
{"LAVENDER_BLUSH", 0xFFF0F5},
{"LINEN", 0xFAF0E6},
{"OLD_LACE", 0xFDF5E6},
{"PAPAYA_WHIP", 0xFFEFD5},
{"SEA_SHELL", 0xFFF5EE},
{"MINT_CREAM", 0xF5FFFA},
{"SLATE_GRAY", 0x708090},
{"LIGHT_SLATE_GRAY", 0x778899},
{"LIGHT_STEEL_BLUE", 0xB0C4DE},
{"LAVENDER", 0xE6E6FA},
{"FLORAL_WHITE", 0xFFFAF0},
{"ALICE_BLUE", 0xF0F8FF},
{"GHOST_WHITE", 0xF8F8FF},
{"HONEYDEW", 0xF0FFF0},
{"IVORY", 0xFFFFF0},
{"AZURE", 0xF0FFFF},
{"SNOW", 0xFFFAFA},
{"BLACK", 0x000000},
{"DIM_GRAY", 0x696969},
{"DIM_GREY", 0x696969},
{"GRAY", 0x808080},
{"GREY", 0x808080},
{"DARK_GRAY", 0xA9A9A9},
{"DARK_GREY", 0xA9A9A9},
{"SILVER", 0xC0C0C0},
{"LIGHT_GRAY", 0xD3D3D3},
{"LIGHT_GREY", 0xD3D3D3},
{"GAINSBORO", 0xDCDCDC},
{"WHITE_SMOKE", 0xF5F5F5},
{"WHITE", 0xFFFFFF},
};
Loading

0 comments on commit 411a2d5

Please sign in to comment.