I was looking the remapsp source and I figured out that I have to patch differents functions than the vshCtrlReadBufferPositive to disable the buttons in game, the functions are (to do what I want to do):
sceCtrlPeekBufferPositive
sceCtrlReadBufferPositive
Is it correct???
Supposing it is, how can this be achieve??? because I have tried various ways to do it.
Basically what I do is this:
Code: Select all
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <psppower.h>
#include <systemctrl.h>
#include <stdio.h>
#include "blit.h"
#define STATE_OFF 0
#define STATE_ON 1
PSP_MODULE_INFO("test", 0x1000, 1, 0);
int printState=STATE_OFF;
int scePeekPositiveControl(SceCtrlData *pad_data, int count)
	{
		int res = sceCtrlPeekBufferPositive(pad_data, count);
	
		int k1 = pspSdkSetK1(0);
   
		if (pad_data->Buttons & PSP_CTRL_LTRIGGER) 
			{
				if(printState==STATE_OFF)
					printState=STATE_ON;
				else
					printState=STATE_OFF;			
			}
	
		if(printState==STATE_ON)
			pad_data->Buttons=0;
		
		pspSdkSetK1(k1);
   
		return res;
	}
int sceReadPositiveControl(SceCtrlData *pad_data, int count)
	{
		int res = sceCtrlReadBufferPositive(pad_data, count);
	
		int k1 = pspSdkSetK1(0);
   
		if (pad_data->Buttons & PSP_CTRL_LTRIGGER) 
			{
				if(printState==STATE_OFF)
					printState=STATE_ON;
				else
					printState=STATE_OFF;			
			}
	
		if(printState==STATE_ON)
			pad_data->Buttons=0;
		
		pspSdkSetK1(k1);
   
		return res;
	}
void display_thread(SceSize args, void *argp)
	{
		while(1)
			{
				if(printState==STATE_ON)
					{
						blit_string(0, 0, "Buttons Disabled", 0xffffff, 0x000000);
					}
				sceKernelDelayThreadCB(10);
			}
	}
int module_start(SceSize args, void *argp)
	{	
		sctrlHENPatchSyscall(sctrlHENFindFunction("sceController_Service", "sceCtrl", 0x3A622550),scePeekPositiveControl);;
		sctrlHENPatchSyscall(sctrlHENFindFunction("sceController_Service", "sceCtrl", 0x1F803938),sceReadPositiveControl);;
	
		sceKernelDcacheWritebackAll();
		sceKernelIcacheClearAll();
	
		int display_thid = sceKernelCreateThread("mydisplay", display_thread, 1, 0x1000, 0, NULL);
		if(display_thid >= 0) sceKernelStartThread(display_thid, args, argp);
   	
		return 0;
	}Code: Select all
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <psppower.h>
#include <systemctrl.h>
#include <stdio.h>
#include <string.h>
#include "blit.h"
#define STATE_OFF 0
#define STATE_ON 1
PSP_MODULE_INFO("hooktest", 0x1000, 1, 0);
int (* vshCtrlReadBufferPositive)(SceCtrlData *pad_data, int count);
int printState=STATE_OFF;
void (* PatchSyscall)(u32 funcaddr, void *newfunc);
int vshreadControl(SceCtrlData *pad_data, int count)
	{
		int res = vshCtrlReadBufferPositive(pad_data, count);
   
		int k1 = pspSdkSetK1(0);
   
		if ((pad_data->Buttons & PSP_CTRL_LTRIGGER) && (pad_data->Buttons & PSP_CTRL_RTRIGGER)) 
			{
				if(printState==STATE_OFF)
					printState=STATE_ON;
				else
					{
						printState=STATE_OFF;
						pad_data->Buttons=0;
					}
			}
	
		if(printState==STATE_ON)
			pad_data->Buttons=0;
		
		pspSdkSetK1(k1);
   
		return res;
	}
STMOD_HANDLER previous = NULL;
u32 orgaddr;
int OnModuleStart(SceModule2 *mod)
	{	
		if (strcmp(mod->modname, "sceVshBridge_Driver") == 0)
			{	
				orgaddr=sctrlHENFindFunction("sceVshBridge_Driver", "sceVshBridge", 0xC6395C03);
				vshCtrlReadBufferPositive = (void *)orgaddr;
				sctrlHENPatchSyscall(orgaddr, vshreadControl);
	 
				sceKernelDcacheWritebackAll();
				sceKernelIcacheClearAll();
			}
   
		if (!previous)
			return 0;
   
		return previous(mod);
	}
void display_thread(SceSize args, void *argp)
	{
		while(1)
			{
				if(printState==STATE_ON)
					blit_string(0, 0, "Buttons Disabled", 0xffffff, 0x000000);
					
				sceKernelDelayThreadCB(10);
			}
	}
int module_start(SceSize args, void *argp)
{	
	
	previous = sctrlHENSetStartModuleHandler(OnModuleStart);
		
	int display_thid = sceKernelCreateThread("mydisplay", display_thread, 1, 0x1000, 0, NULL);
	if(display_thid >= 0) 
		sceKernelStartThread(display_thid, args, argp);
   	
   return 0;
} 