11/10/2006

PSP ButtonHook for FW2.71 v1.28 RELEASED

 
 
Download-Link #1: ButtonHook_for_FW2.71_v1.28.zip

Install
copy dh/kd/271CtrlP0okm.prx to MemoryStick
add line
ms0:/dh/kd/271CtrlP0okm.prx
to ms0:/dh/271F/flash0/kd/pspbtcnf.txt
and ms0:/dh/271F/flash0/kd/pspbtcnf_game.txt
** see pspbtcnf.txt.sample, pspbtcnf_game.txt.sample

if in MemoryStick root have CtrlP0okm.bin
then it will use it to Hook the Button

Todo
use PSP sio to add External JoyStick

changelog
v1.28 :
Add FindExAddrByNid

v0.96 :
Initial release



CtrlP0okm.bin sample
when press LTRIGGER it will Dump the Kernel Memory

main.c

// swap Buttons CIRCLE & CROSS  & FindExAddrByNid sample

/*
pad_data :
    unsigned int     TimeStamp; // The current read frame.
    unsigned int     Buttons;   // Bit mask containing zero or more of ::PspCtrlButtons.
    unsigned char    Lx;        // Analogue stick, X axis. left=0, right=255
    unsigned char    Ly;        // Analogue stick, Y axis. up=0, down=255
    unsigned char    Rsrv[6];   // Reserved.

Buttons :
    PSP_CTRL_SELECT   = 0x00000001,    // Select button.
    PSP_CTRL_START    = 0x00000008,    // Start button.
    PSP_CTRL_UP       = 0x00000010,    // Up D-Pad button.
    PSP_CTRL_RIGHT    = 0x00000020,    // Right D-Pad button.
    PSP_CTRL_DOWN     = 0x00000040,    // Down D-Pad button.
    PSP_CTRL_LEFT     = 0x00000080,    // Left D-Pad button.
    PSP_CTRL_LTRIGGER = 0x00000100,    // Left trigger.
    PSP_CTRL_RTRIGGER = 0x00000200,    // Right trigger.
    PSP_CTRL_TRIANGLE = 0x00001000,    // Triangle button.
    PSP_CTRL_CIRCLE   = 0x00002000,    // Circle button.
    PSP_CTRL_CROSS    = 0x00004000,    // Cross button.
    PSP_CTRL_SQUARE   = 0x00008000,    // Square button.
    PSP_CTRL_HOME     = 0x00010000,    // Home button.
    PSP_CTRL_HOLD     = 0x00020000,    // Hold button.
    PSP_CTRL_WLAN_UP  = 0x00040000,    // Wlan switch up.
    PSP_CTRL_REMOTE   = 0x00080000,    // Remote hold position.
    PSP_CTRL_VOLUP    = 0x00100000,    // Volume up button.
    PSP_CTRL_VOLDOWN  = 0x00200000,    // Volume down button.
    PSP_CTRL_SCREEN   = 0x00400000,    // Screen button.
    PSP_CTRL_NOTE     = 0x00800000,    // Music Note button.
    PSP_CTRL_DISC     = 0x01000000,    // Disc present.
    PSP_CTRL_MS       = 0x02000000,    // Memory stick present.

mode :
    sceCtrlPeekBufferPositive = 0x0
    sceCtrlPeekBufferNegative = 0x1
    sceCtrlReadBufferPositive = 0x2
    sceCtrlReadBufferNegative = 0x3

Buff :
    Buff[0] Reserved
    Buff[1] *pad_data
    Buff[2] count
    Buff[3] mode
    Buff[4-63] for CtrlP0okm.bin use
*/
#include <pspctrl.h>

int _start(int *pad_data, int count, int mode, int ret_data, int *Buff, int FindExAddrByNid)
{
    unsigned int (* FindExAddrByNid_k)(const char *ModName, const char *library, unsigned int nid);
    unsigned int (* sceIoOpen_k)(const char *file, int flags, unsigned int mode);
    int (* sceIoWrite_k)(unsigned int fd, void *data, unsigned int size);
    int (* sceIoClose_k)(unsigned int fd);

    if (pad_data[1] & PSP_CTRL_LTRIGGER)
    {
        Buff[0x04] = 0x49656373;    //'sceI'
        Buff[0x05] = 0x6c69464f;    //'OFil'
        Buff[0x06] = 0x6e614d65;    //'eMan'
        Buff[0x07] = 0x72656761;    //'ager'
        Buff[0x08] = 0x00000000;

        Buff[0x09] = 0x69466F49;    //'IoFi'
        Buff[0x0A] = 0x674D656C;    //'leMg'
        Buff[0x0B] = 0x726F4672;    //'rFor'
        Buff[0x0C] = 0x6E72654B;    //'Kern'
        Buff[0x0D] = 0x00006C65;    //'el..'

        Buff[0x0E] = 0x3A30736D;    //'ms0:'
        Buff[0x0F] = 0x622E6B2F;    //'/k.b'
        Buff[0x10] = 0x00006E69;    //'in..'

        FindExAddrByNid_k = (void *)FindExAddrByNid;
        sceIoOpen_k = (void *)FindExAddrByNid_k((Buff+0x04), (Buff+0x09), 0x109F50BC);
        sceIoWrite_k = (void *)FindExAddrByNid_k((Buff+0x04), (Buff+0x09), 0x42EC03AC);
        sceIoClose_k = (void *)FindExAddrByNid_k((Buff+0x04), (Buff+0x09), 0x810C4BC3);

        int fd = sceIoOpen_k((Buff+0x0E), 0x602, 0777);
        sceIoWrite_k(fd, (void *)0x88000000 , 0x00400000);
        sceIoClose_k(fd);
    }

    unsigned int Buttons = pad_data[1] & 0xFFFF9FFF; // Buttons Mask
    if (pad_data[1] & PSP_CTRL_CIRCLE)
    {
        Buttons = Buttons | PSP_CTRL_CROSS;
    }
    if (pad_data[1] & PSP_CTRL_CROSS)
    {
        Buttons = Buttons | PSP_CTRL_CIRCLE;
    }
    pad_data[1] = Buttons;

    return ret_data;
}


Makefile



PSPDEV=/usr/local/pspdev/bin
INCLUDES=-I $(PSPDEV)/../psp/sdk/include


all:    main.bin

main.bin:
    $(PSPDEV)/psp-gcc $(INCLUDES) -W -Wall -G0 -fno-pic -mno-abicalls -w -S main.c -o main.s
    $(PSPDEV)/psp-as main.s -o main.o
    $(PSPDEV)/psp-ld -T psp20bin.x main.o -o main.elf
    $(PSPDEV)/psp-objcopy -O binary main.elf CtrlP0okm.bin


psp20bin.x

OUTPUT_FORMAT("elf32-littlemips")
OUTPUT_ARCH(mips)

ENTRY(_start)

SECTIONS
{
  . = 0x00000000;
  .text.start : {
    *(.text.start)
  }
  .text : {
    *(.text)
  }
  .rodata : {
    *(.rodata)
  }
  .data : {
    *(.data)
  }
  .bss : {
    *(.bss)
  }
}

11 Comments:

At 11/10/2006 06:57:00 pm, Blogger taco said...

Ookm: Could you change the program that automatically starts HEN C to make it automatically start eLoader 099 when you turn on your psp?

 
At 11/10/2006 07:42:00 pm, Blogger 0okm said...

>> taco
yes
BUT eLoader099 didn't patch reboot.bin
when exit eLoader099 it will reboot than back to eLoader099 !!
so don't do that

 
At 11/10/2006 07:49:00 pm, Blogger ExtraKrispy said...

i would like to thank you for including your source this will be an imense help in the for fun project im working on with my friends, btw im new to all coding but html lol im getting there

 
At 11/10/2006 08:04:00 pm, Blogger Alex said...

Don't worry Ookm, I still love you no matter what happens. Great work, BTW, thanks so much.

 
At 11/12/2006 03:38:00 pm, Blogger ioanachema said...

hi everybody, i'm new in this and i have a question. my psp has the numbers IC 1003 and IC 6001 written under the UMD, so I don't know if it's a TA 082 or not. the FW is 2.71. can i downgrade it? how? thanks

 
At 11/13/2006 03:47:00 pm, Blogger MundoBizarro said...

sorry, i have stupid question, but... wut this program do?? i have hen.c ta-082 / 2.71
thanks for hen.c!

 
At 11/13/2006 08:24:00 pm, Blogger Moca said...

It switches buttons on the PSP. Pretty interesting.

Oh, and 0okm didnt make HENC. That was Dark_Alex. 0okm made the HENC auto boot so that it start when you turn you PSP on. Pretty convenient for me. Thanks for that.

 
At 11/15/2006 10:48:00 am, Blogger cause_of_chaos said...

Hi. I also have a "Hen(C) TA-082 2.71" but heard that 0okm has stopped downgrading them :(

Can I use this ButtonHook? Also would it keep the button layout, even during a hard reset?

cause_of_chaos

 
At 11/26/2006 03:31:00 am, Blogger Grizzly_cf said...

Hi 0okm.

I have a little problem with You ButtonHook. Compiled prx in archive works good, but when I'll try compile a source code then I have a error :/

That I get when I comilie old or new ver. of ButtonHook:
E:\psp\PTD\hack\key_project\ciekawe_prx\ButtonHook_old\sample>make
/usr/local/pspdev/bin/psp-gcc -I usr/local/pspdev/bin/../psp/sdk/include -W -Wa
ll -G0 -fno-pic -mno-abicalls -w -S main.c -o main.s
make: /usr/local/pspdev/bin/psp-gcc: Command not found
make: *** [main.bin] Error 127

I don't have any idea what could be wrong. I don't do any modyfications of source code. Otherwise I don't have problems with compiling "Prx Test" from PSPSDK folder for example.

Regards
Grizzly_cf

 
At 11/26/2006 08:41:00 am, Blogger 0okm said...

>> Grizzly_cf
path Error
change path in Makefile
PSPDEV=/usr/local/pspdev/bin
to where your psp-gcc's location

 
At 11/26/2006 09:18:00 pm, Blogger Grizzly_cf said...

Thanks very much!

^_^ sometimes i don't know where my mind wanders of to when i try to solve easiest of problems ;)

 

Post a Comment

<< Home