Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Added TV button swapping
Browse files Browse the repository at this point in the history
  • Loading branch information
yahya14 committed Jul 23, 2017
1 parent 377d4c0 commit b1f3459
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
4 changes: 2 additions & 2 deletions meta/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<name>Swap DRC</name>
<coder>OatmealDome and Yahya14</coder>
<url>TBA</url>
<version>1.0</version>
<version>1.1</version>
<release_date>201707190000000</release_date>
<short_description>Switch TV display onto the gamepad</short_description>
<long_description>This tool installs Swap DRC, TCPGecko, and/or Cafiine into system memory.

Switch the TV and gamepad display (and the DRC sensor bar) by holding the L shoulder button, and then press MINUS.
Switch the TV and gamepad display (and the DRC sensor bar) by holding the L shoulder button, and then press MINUS. Pressing the TV button also works.

Special thanks to: Maschell, dimok, NWPlayer123, Brienj, and BKOOL999!
</long_description>
Expand Down
9 changes: 6 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define PRINT_TEXT2(x, y, ...) { snprintf(msg, 80, __VA_ARGS__); OSScreenPutFontEx(0, x, y, msg); OSScreenPutFontEx(1, x, y, msg); }
#define PRINT_TEXT3(x, y, _fmt, ...) { __os_snprintf(msg, 80, _fmt, __VA_ARGS__); OSScreenPutFontEx(1, x, y, msg); }

#define DEBUG 0
#define BUILD 1.1


Expand Down Expand Up @@ -103,8 +104,9 @@ int Menu_Main()
InitAXFunctionPointers();
InitProcUIFunctionPointers();


log_init("192.168.2.18");
if (DEBUG) {
log_init("192.168.2.18");
}

SetupKernelCallback();

Expand Down Expand Up @@ -240,7 +242,8 @@ int Menu_Main()
PRINT_TEXT2(0,10, " <---");


PRINT_TEXT2(0,13, "Hold L then press Minus to swap displays.");
PRINT_TEXT2(0, 13, "Hold L then press Minus to swap displays.");
PRINT_TEXT2(0, 14, "You can also press the TV button.");
PRINT_TEXT2(0, 15, "Press B to return to the menu.");


Expand Down
47 changes: 25 additions & 22 deletions src/patcher/function_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
res my_ ## name(__VA_ARGS__)

int swapForce = 0;
unsigned int homeCoolDown = 0;

// AX FUNCTIONS
DECL(s32, AXSetVoiceDeviceMixOld, void *v, s32 device, u32 id, void *mix) {
Expand Down Expand Up @@ -72,8 +73,7 @@ DECL(void, AXFreeVoice, void *v) {
real_AXFreeVoice(v);
}

void swapVoices()
{
void swapVoices() {
swapAll();
for (int i = 0; i < VOICE_INFO_MAX; i++) {
if (gVoiceInfos[i].voice == NULL) continue;
Expand All @@ -85,8 +85,7 @@ void swapVoices()
}

// GX2 FUNCTIONS
DECL(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan_target)
{
DECL(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan_target) {
// GX2 destinations:
// 0x1 = TV
// 0x4 = 1st GamePad
Expand All @@ -96,12 +95,10 @@ DECL(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan
// 0x1 = swap

// check drc swap and force the drcMode to default when inkstrike is activated
if (drcMode == 0 || swapForce)
{
if (drcMode == 0 || swapForce) {
real_GX2CopyColorBufferToScanBuffer(colorBuffer, scan_target);
}
else
{
else {
switch (scan_target)
{
case 0x1:
Expand All @@ -115,40 +112,46 @@ DECL(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan
}

//VPAD FUNCTIONS
DECL(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error)
{
DECL(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) {
int result = real_VPADRead(chan, buffer, buffer_size, error);
// switch on L and SELECT
if (buffer->btns_d & VPAD_BUTTON_MINUS && buffer->btns_h & VPAD_BUTTON_L && AppInBackground)
{
if (buffer->btns_d & VPAD_BUTTON_MINUS && buffer->btns_h & VPAD_BUTTON_L && AppInBackground) {
drcSwap();
}

// switch on TV button
if (buffer->btns_h & VPAD_BUTTON_TV && homeCoolDown == 0 && AppInBackground) {
homeCoolDown = 0x5A;
drcSwap();
}
else if (homeCoolDown > 0) {
homeCoolDown--;
}


// patches splatoon enhanced controls
if (isSplatoon)
{
if (isSplatoon) {
gambitPatches(buffer);
gambitDRC();
}

return real_VPADRead(chan, buffer, buffer_size, error);
return result;
}

DECL(void, VPADGetTPCalibratedPoint, int chan, VPADTPData *screen, VPADTPData *raw)
{
DECL(void, VPADGetTPCalibratedPoint, int chan, VPADTPData *screen, VPADTPData *raw) {
real_VPADGetTPCalibratedPoint(chan, screen, raw);

if (isSplatoon)
if (isSplatoon) {
// handles modified touch input for super jumps
gambitTouch(screen);
}
}

DECL(void, VPADSetSensorBar, s32 chan, bool on)
{
DECL(void, VPADSetSensorBar, s32 chan, bool on){
real_VPADSetSensorBar(chan, on);
}

void drcSwap()
{
void drcSwap() {
// swap drc modes
drcMode = !drcMode;

Expand Down
1 change: 1 addition & 0 deletions src/patcher/function_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern void swapVoices();
extern void drcSwap();

int swapForce;
unsigned int homeCoolDown;
void PatchMethodHooks(void);
void RestoreInstructions(void);
unsigned int GetAddressOfFunction(const char * functionName,unsigned int library);
Expand Down

0 comments on commit b1f3459

Please sign in to comment.