PSP开发--[C++]接收按键控制

 

padctrl.cpp

  
  
#include < pspkernel.h >
#include
< pspdebug.h >
#include
< pspdisplay.h >
#include
< pspctrl.h >

#include
< iostream >

PSP_MODULE_INFO(
" Hello World " , 0 , 1 , 1 );

#define printf pspDebugScreenPrintf

using namespace std;

/* Exit callback */
int exit_callback( int arg1, int arg2, void * common) {
sceKernelExitGame();
return 0 ;
}

/* Callback thread */
int CallbackThread(SceSize args, void * argp) {
int cbid;
// Create callback
cbid = sceKernelCreateCallback( " Exit Callback " , exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);

// Sleep thread but service any callbacks as necessary.
sceKernelSleepThreadCB();

return 0 ;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks() {
int thid = 0 ;

// Create a thread.
thid = sceKernelCreateThread( " update_thread " , CallbackThread, 0x11 , 0xFA0 , 0 , 0 );
if (thid >= 0 ) {
// Start a created thread.
sceKernelStartThread(thid, 0 , 0 );
}

return thid;
}

int main( int argc, char ** argv)
{
// Initialise the debug screen.
pspDebugScreenInit();
// setup callback;
SetupCallbacks();

// 按键struct
SceCtrlData pad;

printf(
" Press [X] To Start the Timer " );

while ( 1 )
{
// Read buffer positive.
sceCtrlReadBufferPositive( & pad, 1 );

if (pad.Buttons & PSP_CTRL_CROSS)
{
printf(
" you pressed X " );
break ;
}
// 清屏
pspDebugScreenClear();
}

// Sleep thread
sceKernelSleepThread();

return 0 ;
}

makefile

  
  
TARGET = padctrl
OBJS
= padctrl.o

BUILD_PRX
= 1
PSP_FW_VERSION
= 371

# C编译器参数
CFLAGS
= -O2 -G0 -Wall
# C++编译器参数
CXXFLAGS
= $(CFLAGS) -fno-exceptions -fno-rtti
# 汇编编译器参数
ASFLAGS
= $(CFLAGS)

# 引用的库 -l stdC++
LIBS
= -lstdc++

EXTRA_TARGETS
= EBOOT.PBP
PSP_EBOOT_TITLE
= pad control

PSPSDK
= $(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak




 按键的枚举

PSP_CTRL_SELECT Select button.
PSP_CTRL_START Start button.
PSP_CTRL_UP Up D-Pad button.
PSP_CTRL_RIGHT Right D-Pad button.
PSP_CTRL_DOWN Down D-Pad button.
PSP_CTRL_LEFT Left D-Pad button.
PSP_CTRL_LTRIGGER Left trigger.
PSP_CTRL_RTRIGGER Right trigger.
PSP_CTRL_TRIANGLE Triangle button.
PSP_CTRL_CIRCLE Circle button.
PSP_CTRL_CROSS Cross button.
PSP_CTRL_SQUARE Square button.
PSP_CTRL_HOME Home button.
PSP_CTRL_HOLD Hold button.
PSP_CTRL_NOTE Music Note button.

 

接收按键需要一个while(1)来接受系统事件。
然后通过sceCtrlReadBufferPositive(&pad, 1); 来读取按键内容。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值