PSP 개발자료 – 키 입력 받는 소스

2026. 6. 24. 12:48·Programming/Game Dev

키 입력 받는 소스

예전에 PSP 개발을 함참할때 만들었던 소스를 찾아서 포스팅합니다.
이걸 지금 사용하는 분들이 있을지 모르겠네요!!!


pspinput.cpp 소스

///////////////////////////////////////////////////////////////////////////////
//   PSP Input Lib 
//   By 선경선향아빠
///////////////////////////////////////////////////////////////////////////////
#include <pspctrl.h>
 
static unsigned long psp_key_pressed = 0;       //list of buttons pressed in current loop 
static unsigned long psp_key_pressed_old = 0;   //list of buttons pressed in previous loop 
static unsigned long psp_key_down = 0;          //list of buttons with key-down event 
static unsigned long psp_key_up = 0;            //list of buttons with key-up event 
 
int SetKeyStatus() 
{ 
   unsigned long k; 
   SceCtrlData ctl; 
   sceCtrlReadBufferPositive(&ctl,1);    
 
   psp_key_pressed = ctl.Buttons; 
   psp_key_down = 0; 
   psp_key_up = 0; 
 
   for(k = 0x0001 ; k <= 0x8000 ; k <<= 1) 
   { 
      if((psp_key_pressed_old & k) && !(psp_key_pressed & k))    
         psp_key_up |= k; 
      if(!(psp_key_pressed_old & k) && (psp_key_pressed & k))    
         psp_key_down |= k; 
   } 
   psp_key_pressed_old = psp_key_pressed;    
   return 0; 
} 
 
unsigned long GetKeyUp(int type) 
{ 
   if (type == 0) 
      SetKeyStatus(); 
   return psp_key_up; 
} 
 
unsigned long GetKeyDown(int type) 
{ 
   if (type == 0) 
      SetKeyStatus(); 
   return psp_key_down; 
} 
 
unsigned long GetKeyPressed(int type) 
{ 
   if (type == 0) 
      SetKeyStatus(); 
   return psp_key_pressed; 
} 
 
void KeyInit()
{
    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
}

 

pspinput.h 소스파일

#ifndef _PSP_INPUT_INCLUDED
#define _PSP_INPUT_INCLUDED
 
int SetKeyStatus();
unsigned long GetKeyUp(int type);
unsigned long GetKeyDown(int type);
unsigned long GetKeyPressed(int type);
void KeyInit();
 
#endif // _PSP_INPUT_INCLUDED

 

사용법

KeyInit(); // Key 입력 받기 설정
 
unsigned long key;
key = GetKeyDown(0);
if (key & PSP_CTRL_UP) {
    //십자키 위
}
if (key & PSP_CTRL_DOWN) {
    //십자키 아래
}

'Programming > Game Dev' 카테고리의 다른 글

PSP 홈브류에 리모콘 사용하기  (0) 2026.06.30
PSP Homebrew – 한글출력, 이미지처리, 키입력 소스  (0) 2026.06.25
PSP SDK 프로그래밍  (0) 2026.06.23
PSP 개발환경 – PSPToolKit  (0) 2026.06.19
'Programming/Game Dev' 카테고리의 다른 글
  • PSP 홈브류에 리모콘 사용하기
  • PSP Homebrew – 한글출력, 이미지처리, 키입력 소스
  • PSP SDK 프로그래밍
  • PSP 개발환경 – PSPToolKit
레이조(RayCho)
레이조(RayCho)
개발자 레이조(RayCho)의 블로그입니다. 똑똑하게 배우고 기록하는 공간
  • 레이조(RayCho)
    레이(Ray)의 개발이야기
    레이조(RayCho)
  • 전체
    오늘
    어제
    • 분류 전체보기 (73) N
      • Programming (73) N
        • Python (5)
        • Flutter (4)
        • Delphi (25)
        • Lazarus (1)
        • C#.NET (13) N
        • ASP.NET (5)
        • Database (6)
        • Game Dev (5)
        • Web (6)
        • ETC (3)
  • 블로그 메뉴

    • 홈
    • Introduce
    • 태그
    • 방명록
  • 링크

    • Naver Blog
    • Diary Blog
  • 공지사항

  • 인기 글

  • 태그

    mssql
    delphi
    C#
    objectpascal
    Python
    POST
    웹프로그래밍
    C++
    VCL
    PSP
    ASP.NET
    기초
    프로그래밍
    csharp
    소스코드
    iis
    Web
    델파이
    개발환경
    Flutter
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.5
레이조(RayCho)
PSP 개발자료 – 키 입력 받는 소스
상단으로

티스토리툴바