Skip to content

Commit b1f3459

Browse files
committed
Added TV button swapping
1 parent 377d4c0 commit b1f3459

File tree

4 files changed

+34
-27
lines changed

4 files changed

+34
-27
lines changed

meta/meta.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<name>Swap DRC</name>
44
<coder>OatmealDome and Yahya14</coder>
55
<url>TBA</url>
6-
<version>1.0</version>
6+
<version>1.1</version>
77
<release_date>201707190000000</release_date>
88
<short_description>Switch TV display onto the gamepad</short_description>
99
<long_description>This tool installs Swap DRC, TCPGecko, and/or Cafiine into system memory.
1010

11-
Switch the TV and gamepad display (and the DRC sensor bar) by holding the L shoulder button, and then press MINUS.
11+
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.
1212

1313
Special thanks to: Maschell, dimok, NWPlayer123, Brienj, and BKOOL999!
1414
</long_description>

src/main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define PRINT_TEXT2(x, y, ...) { snprintf(msg, 80, __VA_ARGS__); OSScreenPutFontEx(0, x, y, msg); OSScreenPutFontEx(1, x, y, msg); }
2626
#define PRINT_TEXT3(x, y, _fmt, ...) { __os_snprintf(msg, 80, _fmt, __VA_ARGS__); OSScreenPutFontEx(1, x, y, msg); }
2727

28+
#define DEBUG 0
2829
#define BUILD 1.1
2930

3031

@@ -103,8 +104,9 @@ int Menu_Main()
103104
InitAXFunctionPointers();
104105
InitProcUIFunctionPointers();
105106

106-
107-
log_init("192.168.2.18");
107+
if (DEBUG) {
108+
log_init("192.168.2.18");
109+
}
108110

109111
SetupKernelCallback();
110112

@@ -240,7 +242,8 @@ int Menu_Main()
240242
PRINT_TEXT2(0,10, " <---");
241243

242244

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

246249

src/patcher/function_hooks.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
res my_ ## name(__VA_ARGS__)
3131

3232
int swapForce = 0;
33+
unsigned int homeCoolDown = 0;
3334

3435
// AX FUNCTIONS
3536
DECL(s32, AXSetVoiceDeviceMixOld, void *v, s32 device, u32 id, void *mix) {
@@ -72,8 +73,7 @@ DECL(void, AXFreeVoice, void *v) {
7273
real_AXFreeVoice(v);
7374
}
7475

75-
void swapVoices()
76-
{
76+
void swapVoices() {
7777
swapAll();
7878
for (int i = 0; i < VOICE_INFO_MAX; i++) {
7979
if (gVoiceInfos[i].voice == NULL) continue;
@@ -85,8 +85,7 @@ void swapVoices()
8585
}
8686

8787
// GX2 FUNCTIONS
88-
DECL(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan_target)
89-
{
88+
DECL(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan_target) {
9089
// GX2 destinations:
9190
// 0x1 = TV
9291
// 0x4 = 1st GamePad
@@ -96,12 +95,10 @@ DECL(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan
9695
// 0x1 = swap
9796

9897
// check drc swap and force the drcMode to default when inkstrike is activated
99-
if (drcMode == 0 || swapForce)
100-
{
98+
if (drcMode == 0 || swapForce) {
10199
real_GX2CopyColorBufferToScanBuffer(colorBuffer, scan_target);
102100
}
103-
else
104-
{
101+
else {
105102
switch (scan_target)
106103
{
107104
case 0x1:
@@ -115,40 +112,46 @@ DECL(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan
115112
}
116113

117114
//VPAD FUNCTIONS
118-
DECL(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error)
119-
{
115+
DECL(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) {
116+
int result = real_VPADRead(chan, buffer, buffer_size, error);
120117
// switch on L and SELECT
121-
if (buffer->btns_d & VPAD_BUTTON_MINUS && buffer->btns_h & VPAD_BUTTON_L && AppInBackground)
122-
{
118+
if (buffer->btns_d & VPAD_BUTTON_MINUS && buffer->btns_h & VPAD_BUTTON_L && AppInBackground) {
123119
drcSwap();
124120
}
125121

122+
// switch on TV button
123+
if (buffer->btns_h & VPAD_BUTTON_TV && homeCoolDown == 0 && AppInBackground) {
124+
homeCoolDown = 0x5A;
125+
drcSwap();
126+
}
127+
else if (homeCoolDown > 0) {
128+
homeCoolDown--;
129+
}
130+
131+
126132
// patches splatoon enhanced controls
127-
if (isSplatoon)
128-
{
133+
if (isSplatoon) {
129134
gambitPatches(buffer);
130135
gambitDRC();
131136
}
132137

133-
return real_VPADRead(chan, buffer, buffer_size, error);
138+
return result;
134139
}
135140

136-
DECL(void, VPADGetTPCalibratedPoint, int chan, VPADTPData *screen, VPADTPData *raw)
137-
{
141+
DECL(void, VPADGetTPCalibratedPoint, int chan, VPADTPData *screen, VPADTPData *raw) {
138142
real_VPADGetTPCalibratedPoint(chan, screen, raw);
139143

140-
if (isSplatoon)
144+
if (isSplatoon) {
141145
// handles modified touch input for super jumps
142146
gambitTouch(screen);
147+
}
143148
}
144149

145-
DECL(void, VPADSetSensorBar, s32 chan, bool on)
146-
{
150+
DECL(void, VPADSetSensorBar, s32 chan, bool on){
147151
real_VPADSetSensorBar(chan, on);
148152
}
149153

150-
void drcSwap()
151-
{
154+
void drcSwap() {
152155
// swap drc modes
153156
drcMode = !drcMode;
154157

src/patcher/function_hooks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern void swapVoices();
1818
extern void drcSwap();
1919

2020
int swapForce;
21+
unsigned int homeCoolDown;
2122
void PatchMethodHooks(void);
2223
void RestoreInstructions(void);
2324
unsigned int GetAddressOfFunction(const char * functionName,unsigned int library);

0 commit comments

Comments
 (0)