3rd CtrlP0okm.bin sample
Download-Link #1: 3rd.CtrlP0okm.sample.src.zip
hook the d-Pad with AnalogStick
3rd.CtrlP0okm.bin sample
main.c
// auto press Buttons CIRCLE & CROSS 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)
{
unsigned int Buttons = pad_data[1];
unsigned char Lx = pad_data[2] & 0x000000FF;
unsigned char Ly = (pad_data[2] & 0x0000FF00) >> 8;
if (Lx > 0xC0)
{
Buttons = Buttons | PSP_CTRL_RIGHT;
}
if (Lx < 0x40)
{
Buttons = Buttons | PSP_CTRL_LEFT;
}
if (Ly > 0xC0)
{
Buttons = Buttons | PSP_CTRL_DOWN;
}
if (Ly < 0x40)
{
Buttons = Buttons | PSP_CTRL_UP;
}
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)
}
}
0 Comments:
Post a Comment
<< Home