Skip to content

Commit

Permalink
Function patcher fix (v1.1)
Browse files Browse the repository at this point in the history
So little trick, READ HEADER SOURCE PLEASE. Thanks!
  • Loading branch information
Fangal-Airbag committed Apr 11, 2023
1 parent ab68e12 commit 1c9a8d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 162 deletions.
151 changes: 0 additions & 151 deletions source/function_patcher.c

This file was deleted.

26 changes: 21 additions & 5 deletions source/main.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#include "main.h"
#include <vpad/input.h>

#include <wups.h>
#include <wups/config/WUPSConfigItemIntegerRange.h>
#include <wups/config/WUPSConfigItemBoolean.h>

WUPS_PLUGIN_NAME("Gamepad Volume Changer");
WUPS_PLUGIN_DESCRIPTION("This plugin allows changes to the GamePad's volume!");
WUPS_PLUGIN_VERSION("v1.0");
WUPS_PLUGIN_DESCRIPTION("This plugin allows changes to the Gamepad's volume!");
WUPS_PLUGIN_VERSION("v1.1");
WUPS_PLUGIN_AUTHOR("Fangal");
WUPS_PLUGIN_LICENSE("GPLv3");

#define VOLUME_SET_CONFIG_ID "VolumeSet"
#define VOLUME_ENABLE_CONFIG_ID "VolumeEnable"

WUPS_USE_WUT_DEVOPTAB();
WUPS_USE_STORAGE("volume_set");
WUPS_USE_STORAGE("Gamepad_Volume_Changer");

bool enable = true;
int volume = 15;

extern uint32_t VPADSetAudioVolumeOverride(VPADChan chan, bool override, int vol);

INITIALIZE_PLUGIN() {
// Open storage to read values
WUPSStorageError storageRes = WUPS_OpenStorage();
Expand Down Expand Up @@ -67,4 +69,18 @@ WUPS_GET_CONFIG() {

WUPS_CONFIG_CLOSED() {
WUPS_CloseStorage();
}
}

DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffers, uint32_t count, VPADReadError *err)
{
int32_t result = real_VPADRead(chan, buffers, count, err);

if (enable)
VPADSetAudioVolumeOverride(VPAD_CHAN_0, true, (volume * 17));
else
VPADSetAudioVolumeOverride(VPAD_CHAN_0, false, 0);

return result;
}

WUPS_MUST_REPLACE_FOR_PROCESS(VPADRead, WUPS_LOADER_LIBRARY_VPAD, VPADRead, WUPS_FP_TARGET_PROCESS_ALL);
6 changes: 0 additions & 6 deletions source/main.h

This file was deleted.

0 comments on commit 1c9a8d9

Please sign in to comment.