Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for up to 16bit stick axis values, and signed values (aroma) #44

Open
wants to merge 2 commits into
base: aroma
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Adaptoid_N64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Wish Technologies Adaptoid N64-to-USB-HID converter
// Must be mapped to GamePad for the buffering to work properly (not to a Pro Controller)
[vid=0x06F7,pid=0x0001]

// A / B / L / R buttons
VPAD_BUTTON_A = 0x03, 0x01
// VPAD_BUTTON_B = 0x03, 0x08
VPAD_BUTTON_X = 0x03, 0x08 // Wii U SM64 port uses X rather than B
VPAD_BUTTON_L = 0x03, 0x40
VPAD_BUTTON_R = 0x03, 0x80

// N64 Start button mapped to Wii U + button
VPAD_BUTTON_PLUS = 0x04, 0x01

// N64 Z trigger mapped to Wii U ZL trigger
VPAD_BUTTON_ZL = 0x04, 0x02

// N64 C buttons mapped to Wii U right stick
VPAD_R_STICK_UP = 0x03, 0x20
VPAD_R_STICK_DOWN = 0x03, 0x02
VPAD_R_STICK_LEFT = 0x03, 0x10
VPAD_R_STICK_RIGHT = 0x03, 0x04

// N64 Dpad mapped to Wii U Dpad
VPAD_BUTTON_UP = 0x04, 0x04
VPAD_BUTTON_DOWN = 0x04, 0x08
VPAD_BUTTON_LEFT = 0x04, 0x10
VPAD_BUTTON_RIGHT = 0x04, 0x20

// N64 Stick mapped to Wii U Left Stick
VPad_L_Stick_X = 0x00, 0x00
// VPad_L_Stick_X_Default_MSB = 0x00 // Most significant byte - not needed, since zero
VPad_L_Stick_X_Bit_Length = 0x0C // 12bit HID axis report
VPad_L_Stick_X_Signed = True // Range includes negative values
VPad_L_Stick_X_MinMax = 0x50, 0xB0 // -1200 to 1200 expressed as s16 type (two's complement, i.e. 0xFB50 to 0x04B0)
VPad_L_Stick_X_MinMax_MSB = 0xFB, 0x04 // Most significant bytes
VPad_L_Stick_Y = 0x01, 0x00
// VPad_L_Stick_Y_Default_MSB = 0x00
VPad_L_Stick_Y_Bit_Length = 0x0C
VPad_L_Stick_Y_Bit_Offset = 0x04 // Second 12bit stick axis report is not byte-aligned
VPad_L_Stick_Y_Signed = True
VPad_L_Stick_Y_MinMax = 0x50, 0xB0
VPad_L_Stick_Y_MinMax_MSB = 0xFB, 0x04
VPad_L_Stick_Y_Invert = True
VPad_L_Stick_X_Deadzone = 0x20 // Customize for your controller wear state
VPad_L_Stick_Y_Deadzone = 0x20
6 changes: 3 additions & 3 deletions include/controller_patcher/ControllerPatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class ControllerPatcher {
static CONTROLLER_PATCHER_RESULT_OR_ERROR UpdateSamplingFunctionAddress();

/**
Disbale the Controller mapping. Afterwards all connected controllers will be used for the gamepad.
Disable the Controller mapping. Afterwards all connected controllers will be used for the gamepad.
@return When the functions failed result < 0 is returned. If the result is == 0 the function was successful.
**/
static CONTROLLER_PATCHER_RESULT_OR_ERROR disableControllerMapping();
Expand Down Expand Up @@ -173,7 +173,7 @@ class ControllerPatcher {
static BOOL isControllerConnectedAndActive(UController_Type type, int32_t mapping_slot = 0);

/**
Search for a connected mouse and returns a pointer to it's data.
Search for a connected mouse and returns a pointer to its data.
@return A pointer to the first connected mouse that is found. NULL if no mouse is connected.
**/
static HID_Mouse_Data *getMouseData();
Expand Down Expand Up @@ -241,7 +241,7 @@ class ControllerPatcher {

static CONTROLLER_PATCHER_RESULT_OR_ERROR setKPADConnectedCallback(int32_t chan, WPADConnectCallback callback);

static CONTROLLER_PATCHER_RESULT_OR_ERROR setKPADExtensionCallback(int32_t chan, WPADConnectCallback callback);
static CONTROLLER_PATCHER_RESULT_OR_ERROR setKPADExtensionCallback(int32_t chan, WPADExtensionCallback callback);

static CONTROLLER_PATCHER_RESULT_OR_ERROR setWPADConnectCallback(int32_t chan, WPADConnectCallback callback);

Expand Down
23 changes: 23 additions & 0 deletions include/controller_patcher/ControllerPatcherDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,29 @@ enum Controller_Patcher_Settings {
CONTRPS_PAD4_FILTER, //!
CONTRPS_PAD5_FILTER, //!
CONTRPS_MOUSE_STICK,

/* Additions for multi-byte stick encoding */
CONTRPS_VPAD_BUTTON_L_STICK_X_BIT_LENGTH, //! 8 / 12 / 16bits, code defaults to 8
CONTRPS_VPAD_BUTTON_L_STICK_Y_BIT_LENGTH,
CONTRPS_VPAD_BUTTON_R_STICK_X_BIT_LENGTH,
CONTRPS_VPAD_BUTTON_R_STICK_Y_BIT_LENGTH,
CONTRPS_VPAD_BUTTON_L_STICK_X_BIT_OFFSET, //! Data may not be byte-aligned
CONTRPS_VPAD_BUTTON_L_STICK_Y_BIT_OFFSET,
CONTRPS_VPAD_BUTTON_R_STICK_X_BIT_OFFSET,
CONTRPS_VPAD_BUTTON_R_STICK_Y_BIT_OFFSET,
CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX_MSB, //! MinMax most significant bytes for >8 bit length values
CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX_MSB,
CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX_MSB,
CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX_MSB,
CONTRPS_VPAD_BUTTON_L_STICK_X_DEFAULT_MSB, //! Stick default value most significant byte for >8 bit length values
CONTRPS_VPAD_BUTTON_L_STICK_Y_DEFAULT_MSB,
CONTRPS_VPAD_BUTTON_R_STICK_X_DEFAULT_MSB,
CONTRPS_VPAD_BUTTON_R_STICK_Y_DEFAULT_MSB,
CONTRPS_VPAD_BUTTON_L_STICK_X_SIGNED, //! Is the data signed (two's complement)?
CONTRPS_VPAD_BUTTON_L_STICK_Y_SIGNED,
CONTRPS_VPAD_BUTTON_R_STICK_X_SIGNED,
CONTRPS_VPAD_BUTTON_R_STICK_Y_SIGNED,

CONTRPS_MAX_VALUE
};
/**
Expand Down
2 changes: 1 addition & 1 deletion source/ControllerPatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADConnectedCallback(i
return CONTROLLER_PATCHER_ERROR_NONE;
}

CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADExtensionCallback(int32_t chan, WPADConnectCallback callback) {
CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::setKPADExtensionCallback(int32_t chan, WPADExtensionCallback callback) {
if (chan >= 4) {
return CONTROLLER_PATCHER_ERROR_INVALID_CHAN;
}
Expand Down
22 changes: 22 additions & 0 deletions source/config/ConfigValues.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,28 @@ class ConfigValues {
CONTPRStringToValueSingle["VPAD_R_STICK_X_INVERT"] = CONTRPS_VPAD_BUTTON_R_STICK_X_INVERT;
CONTPRStringToValueSingle["VPAD_R_STICK_Y_INVERT"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_INVERT;

/* Additions for multi-byte stick encoding */
CONTPRStringToValueSingle["VPAD_L_STICK_X_BIT_LENGTH"] = CONTRPS_VPAD_BUTTON_L_STICK_X_BIT_LENGTH;
CONTPRStringToValueSingle["VPAD_L_STICK_Y_BIT_LENGTH"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_BIT_LENGTH;
CONTPRStringToValueSingle["VPAD_R_STICK_X_BIT_LENGTH"] = CONTRPS_VPAD_BUTTON_R_STICK_X_BIT_LENGTH;
CONTPRStringToValueSingle["VPAD_R_STICK_Y_BIT_LENGTH"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_BIT_LENGTH;
CONTPRStringToValueSingle["VPAD_L_STICK_X_BIT_OFFSET"] = CONTRPS_VPAD_BUTTON_L_STICK_X_BIT_OFFSET;
CONTPRStringToValueSingle["VPAD_L_STICK_Y_BIT_OFFSET"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_BIT_OFFSET;
CONTPRStringToValueSingle["VPAD_R_STICK_X_BIT_OFFSET"] = CONTRPS_VPAD_BUTTON_R_STICK_X_BIT_OFFSET;
CONTPRStringToValueSingle["VPAD_R_STICK_Y_BIT_OFFSET"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_BIT_OFFSET;
CONTPRStringToValue["VPAD_L_STICK_X_MINMAX_MSB"] = CONTRPS_VPAD_BUTTON_L_STICK_X_MINMAX_MSB;
CONTPRStringToValue["VPAD_L_STICK_Y_MINMAX_MSB"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_MINMAX_MSB;
CONTPRStringToValue["VPAD_R_STICK_X_MINMAX_MSB"] = CONTRPS_VPAD_BUTTON_R_STICK_X_MINMAX_MSB;
CONTPRStringToValue["VPAD_R_STICK_Y_MINMAX_MSB"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_MINMAX_MSB;
CONTPRStringToValueSingle["VPAD_L_STICK_X_DEFAULT_MSB"] = CONTRPS_VPAD_BUTTON_L_STICK_X_DEFAULT_MSB;
CONTPRStringToValueSingle["VPAD_L_STICK_Y_DEFAULT_MSB"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_DEFAULT_MSB;
CONTPRStringToValueSingle["VPAD_R_STICK_X_DEFAULT_MSB"] = CONTRPS_VPAD_BUTTON_R_STICK_X_DEFAULT_MSB;
CONTPRStringToValueSingle["VPAD_R_STICK_Y_DEFAULT_MSB"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_DEFAULT_MSB;
CONTPRStringToValueSingle["VPAD_L_STICK_X_SIGNED"] = CONTRPS_VPAD_BUTTON_L_STICK_X_SIGNED;
CONTPRStringToValueSingle["VPAD_L_STICK_Y_SIGNED"] = CONTRPS_VPAD_BUTTON_L_STICK_Y_SIGNED;
CONTPRStringToValueSingle["VPAD_R_STICK_X_SIGNED"] = CONTRPS_VPAD_BUTTON_R_STICK_X_SIGNED;
CONTPRStringToValueSingle["VPAD_R_STICK_Y_SIGNED"] = CONTRPS_VPAD_BUTTON_R_STICK_Y_SIGNED;

CONTPRStringToValueSingle["DOUBLE_USE"] = CONTRPS_DOUBLE_USE;
CONTPRStringToValueSingle["PAD_COUNT"] = CONTRPS_PAD_COUNT;

Expand Down
Loading