disable buttons in XMB menu

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

You're not calling the previous startmodulehandler in your code. You haven't assigned the previous function pointer when setting startmodulehandler.
hyeokje
Posts: 3
Joined: Tue Aug 04, 2009 11:01 pm

Post by hyeokje »

Torch wrote:You're not calling the previous startmodulehandler in your code. You haven't assigned the previous function pointer when setting startmodulehandler.
Wow, you're very nice. Thank you very much Torch.

I got it ~!

Code: Select all

previous = sctrlHENSetStartModuleHandler(OnModuleStart);
zydeoN
Posts: 45
Joined: Sat May 09, 2009 4:01 am

Post by zydeoN »

Can you use the oldButtons (or paddata_old) method to avoid the psp executing the thread faster ? I can use it, but in this case of hooking it isnt working. I tried to use this (but it crashes and shutdown):

Code: Select all

int vshReadButtons(SceCtrlData *pad_data, int count)
{
   int ret, intc;

   ret = vshCtrlReadBufferPositive(pad_data, count);
   if&#40;ret <= 0&#41;
   &#123;
      return ret;
   &#125;
   intc = pspSdkDisableInterrupts&#40;&#41;;

   
      if&#40; pad_data&#91;0&#93;.Buttons & PSP_CTRL_NOTE &#41;
      &#123;
         //my menu on/off
         if&#40;a == 0&#41; a = 1; 
         else  a = 0; 
      &#125;
   while &#40;pad_data&#91;0&#93;.Buttons & PSP_CTRL_NOTE&#41; vshCtrlReadBufferPositive&#40;pad_data, count&#41;;

   //if my menu on block buttons
   if&#40;a == 1&#41; pad_data&#91;0&#93;.Buttons = 0;
 
   pspSdkEnableInterrupts&#40;intc&#41;;
   return ret;
&#125; 
Btw, i found that method on MDL Sample Kernel.
hyeokje
Posts: 3
Joined: Tue Aug 04, 2009 11:01 pm

Post by hyeokje »

zydeoN wrote:Can you use the oldButtons (or paddata_old) method to avoid the psp executing the thread faster ? I can use it, but in this case of hooking it isnt working. I tried to use this (but it crashes and shutdown):

Btw, i found that method on MDL Sample Kernel.
I think your problem is Note button presses repeatedly not slow thread.
This is a interrupt hooking method so it's fast enough.
Use above my post. That's fully working. See paddata_old.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

zydeoN wrote:Can you use the oldButtons (or paddata_old) method to avoid the psp executing the thread faster ? I can use it, but in this case of hooking it isnt working. I tried to use this (but it crashes and shutdown):

Btw, i found that method on MDL Sample Kernel.
Why are you calling the original function twice???

AKAIK the correct method to hook the ctrl function is like this:

Code: Select all

int vshCtrlReadBufferPositive_Patched&#40;SceCtrlData *pad_data, int count&#41;
&#123;
	int ret,i,intc;
	
	ret = vshCtrlReadBufferPositive&#40;pad_data, count&#41;;
	if&#40;ret <= 0&#41;
	&#123;
		return ret;
	&#125;

	intc = pspSdkDisableInterrupts&#40;&#41;;

	for&#40;i = 0; i < count; i++&#41;
	&#123;
		if &#40;pad_data&#91;i&#93;.Buttons & PSP_CTRL_UP&#41;
		&#123;
			pad_data&#91;i&#93;.Buttons = pad_data&#91;i&#93;.Buttons ^ PSP_CTRL_UP; //modify your buttons here
		&#125;
	&#125;

	pspSdkEnableInterrupts&#40;intc&#41;;

	return&#40;ret&#41;;
&#125;
You're supposed to loop though the pad_data array for the value of count. Though generally the value used is only 1, but you should hook safely.

For getting old buttons declare a static variable pad_dataold and store the current pad_data in it. Then in the next function call you can compare with the old buttons to see whats changed.
Post Reply