ãã®èšäºãæžãå§ãããšããç§ã¯ã³ã³ãããŒã©ãŒã®ç« ãããã«ãªãªãŒã¹ãããããšã«æ°ä»ããŸããã
ããã¯ããžã§ã€ã¹ãã£ãã¯èªäœã2çªç®ã®ãžã§ã€ã¹ãã£ãã¯ããã€ãã¬ãŒã·ã§ã³ããã«ãã¿ããïŒ4ã€ã®ãžã§ã€ã¹ãã£ãã¯ã1ã€ã®ããŒãã«æ¥ç¶ããããã®ããã€ã¹ïŒã§ãã
ãžã§ã€ã¹ãã£ãã¯èªäœã«ã¯ãããããç¬èªã®æ å ±ãæäŸãã2ã€ã®ã©ã€ãã©ãªããããŸãã
ç§ã¯2ã€ã®ãªãªãžãã«Dual Shock 2ãžã§ã€ã¹ãã£ãã¯ã䜿çšããŠããŸããã2ã€ã®éãªãªãžãã«ãžã§ã€ã¹ãã£ãã¯ïŒç¹å¥ãªããã€ã¹ãŸãã¯4人ã®ãã«ãã¿ãããä»ããŠã³ã³ãã¥ãŒã¿ãŒã«æ¥ç¶ããããã«äœ¿çšïŒããããŸãã
åã³ã³ãããŒã©ãŒã«ã¯ãããããã¿ãŒããã«ã³ã³ãããŒã©ãŒããããŸããããã¯ãã³ã³ãããŒã©ãŒã«ã¢ã¯ã»ã¹ããããã®å®éã®ããŒãã§ãã
ã³ã³ãããŒã©ãå¶åŸ¡ããããã«ããã¿ã³ããã®ããŒã¿ãæäŸããç¹å¥ãªã©ã€ãã©ãªlibpadããããã³ã³ãããŒã©ã¢ãŒããšæ¯åãå€æŽããŸãã
ãéåžžã®ãlibmtapã©ã€ãã©ãªããããŸãã ã©ã¡ãã®ã©ã€ãã©ãªããã«ãã¿ããã§æ©èœããŸãã
ã©ã€ãã©ãªã¯ãPS1ããã³PS2ããã®æ¬¡ã®ã³ã³ãããŒã©ãŒããµããŒãããŸãã
éåžžã®ããžã¿ã«ã³ã³ãããŒã©ãŒïŒã¢ããã°ãªãïŒïŒ ID = 4 ;
ãã¥ã¢ã«ã·ã§ãã¯1ããã³ãã¥ã¢ã«ã·ã§ãã¯2ïŒ ID = 7 ;
NeGconã³ã³ãããŒã©ãŒïŒ ID = 2 ;
éåžžã®ã¢ããã°ã¹ãã£ãã¯ïŒ ID = 5 ;
ãã ã³é ïŒ ID = 6 ;
ãžã§ã°ã³ã³ãããŒã©ãŒãšãã£ãã·ã³ã°ã³ã³ãããŒã©ãŒïŒã®ã¿ãŒãããã«å«ãŸããŠããããã§ãïŒïŒ ã¹ãã·ã£ã«ã æ¡åŒµID
æ®ãã«ã€ããŠã¯ãéäžã§æ å ±ãè£å ããŸãã
ããŒããšã¹ããã
PS2ã§ã¯ãããŒããšã¹ãããã®æŠå¿µã¯2ã€ã®ç°ãªããã®ã§ãã
ããŒãã¯ã¡ã€ã³ã³ã³ãããŒã©ãŒãæããŸã-PS2èªäœã®æåãš2çªç®ã®ãžã§ã€ã¹ãã£ãã¯çšã§ãã
ã¹ãããã¯ãã»ãšãã©ã®å ŽåãMultiTapããããšãã«äœ¿çšãããŸãã è€æ°ã®ãžã§ã€ã¹ãã£ãã¯ã1ã€ã®ããŒãã«æ¥ç¶ããã«ã¯ããã«ãã¿ãããå¿ èŠã§ãïŒæ倧-4ïŒã éåžžãã²ãŒã ã§ã¯ããã¯ãžã§ã€ã¹ãã£ãã¯1Aããžã§ã€ã¹ãã£ãã¯1Bãªã©ãšããŠè¡šç€ºãããŸãã
ãã«ãã¿ããããªãå Žåã¯ãååãšããŠãããŒã0ãã¹ããã0-æåã®ãžã§ã€ã¹ãã£ãã¯ãããŒã1ãã¹ããã0-2çªç®ã®ãžã§ã€ã¹ãã£ãã¯ãç ©ãããªãã§ãã ããã
ãã«ãã¿ããã§ã¯ã2çªç®ã®ããŒãã«ãã«ãã¿ãããæ¿å ¥ãããã¹ãããAã§ãžã§ã€ã¹ãã£ãã¯ãæ¥ç¶ãããŠããå ŽåãããŒã1ãã¹ããã0ã䜿çšããŠã¢ã¯ã»ã¹ããå¿ èŠããããŸãã
ããã¯ç»åã§ååã«è©³çŽ°ã«èŠãããšãã§ããŸãïŒ
å°æ¥çã«ã¯ãã¡ã¢ãªã«ãŒãã§ã®äœæ¥ãçºçãããšèšããŸãã
ãžã§ã€ã¹ãã£ãã¯
libpadã䜿çšããã«ã¯ãã©ã€ãã©ãªãlibpad.aããšããããŒãã¡ã€ã«ãlibpad.hããæ¥ç¶ããå¿ èŠããããŸãã
éå§ããã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã®èµ·åæã«ãsceSifLoadModuleïŒïŒãé¢æ°ã䜿çšããå¿ èŠããããŸãã
ãâlpadããã©ã¡ãŒã¿ãŒãã¡ã€ã¯ãã¡ã€ã«ã«è¿œå ããå¿ èŠããããŸãã
ã³ã³ãããŒã©ãŒã䜿çšããããã®åºæ¬æé ïŒ
scePadInitïŒïŒ-ã©ã€ãã©ãªã®åæåã ãã©ã¡ãŒã¿ãŒã¯0ã§ãã
scePadPortOpenïŒïŒ-ã³ã³ãããŒã©ãŒããŒããéããŸãã æ»ãå€ãã©ã¡ãŒã¿ã¯ã䜿çšããããŒããã¹ãããããããã¡ã§ãã ãµã€ãºã¯64ãã€ãã§ãªããã°ãªããŸããã ãã¥ãŒã宣èšããŸãã
static u_long128 pad_dma_buf[scePadDmaBufferMax] __attribute__((aligned (64)));
scePadDmaBufferMaxã¯ã宣èšããå¿ èŠã®ãªãå®æ°ã§ãã
inté¢æ°ã¯æ»ããŸããããã«ããããžã§ã€ã¹ãã£ãã¯ãæ¿å ¥ãããŠããããšã確èªã§ããŸããæ¿å ¥ãããŠããªãå Žåããã©ã¡ãŒã¿ãŒã¯0ã«ãªããŸãã
ããã«ãã©ã€ãã©ãªãŒã¯ãã³ã³ãããŒã©ãŒã®é»æºãå ¥ããŠéããšãã³ã³ãããŒã©ãŒãšèªåçã«éä¿¡ãå§ããŸãã ããã«ã2ã€ã®æ©èœããããŸãã
scePadReadïŒïŒ-ãã¿ã³ã®èªã¿åãã«äœ¿çšãããŸãã
ãã®é¢æ°ã«ã¯ãããŒããšã¹ããããããã³çµæãä¿åããããã®ãããã¡ãŒã®3ã€ã®ãã©ã¡ãŒã¿ãŒããããŸãã
ãããã¡ã¯ç¬Šå·ãªãæåãããã¡ã§ã[32]ã
é¢æ°ã¯çµæãè¿ããŸãã ãŒãã«çããå Žåãèªã¿åãã¯ãããããŒã«ãªããŸãã
次ã«ããããã¡ãèªã¿åãå¿ èŠããããŸãããå®éã«ã¯ç°¡åã§ã¯ãããŸããã
scePadGetStateïŒïŒ-ããã䜿çšããŠãã³ã³ãããŒã©ãŒãèœã¡çããç¶æ ã«ãããã©ããã確èªã§ããŸãã ããŒããšã¹ãããã®ãã©ã¡ãŒã¿ãŒãåãå ¥ããŸãã
ã³ã³ãããŒã©ã®ã¹ããŒã¿ã¹ãè¿ããŸãã ã¹ããŒã¿ã¹ããŒã以äžã§ã7以äžã§ããå Žåãäœããèµ·ãããŸããã
ã³ã³ãããŒã©ãŒãéããã«ã¯ãscePadPortCloseïŒïŒé¢æ°ã䜿çšããŸãããã®é¢æ°ã§ã¯ãããŒããšã¹ãããã®ãã©ã¡ãŒã¿ãŒã䜿çšããscePadEndïŒïŒã®åŸã«ã©ã€ãã©ãªãŒããªãã«ããŸãã éåžžããããã®2ã€ã®é¢æ°ã¯äœ¿çšãããŸããã
ãããã®æ©èœã¯ãã¹ãŠãã¢ãŒãããªã³ã®å Žåã«ã®ã¿ã¢ããã°ã®èªã¿åãã«ã䜿çšãããããšãè¿œå ããŸãã
æãäžè¬çãªäŸã¯æ¬¡ã®ããã«ãªããŸãã
main(){<br> unsigned char rdata[32];<br> u_long128 pad_dma_buff[scePadDmaBufferMax] __attribute__((aligned(64)));<br> scePadInit();<br> scePadPortOpen(0, 0, pad_dma_buff);<br> while (1) {<br> scePadRead(0,0,rdata);<br> // <br> }<br> scePadPortClose(0,0);<br> scePadEnd();<br>} <br> * This source code was highlighted with Source Code Highlighter .
DualShockããã³ã¿ããæ床
æåã«ãscePadSetMainModeïŒïŒé¢æ°ã§ã¢ããã°ã¢ãŒããæå¹ã«ããå¿ èŠããããŸãã ãã©ã¡ãŒã¿ãŒã®ããŒããã¹ãããã1ãããã³0ãåããŸãã0ãŸãã¯1ã®åœ¢åŒã§çµæãè¿ããŸããã€ãŸãããããããªã³ãŸãã¯ãªãã«ãªããŸãã
ã³ã³ãããŒã©ãŒãå®éã«DualShockã§ããããšã確èªããã«ã¯ãscePadInfoPressModeïŒïŒé¢æ°ãåŒã³åºãå¿ èŠããããŸãã ããŒããšã¹ãããã®ãã©ã¡ãŒã¿ãŒãåãåããçµæã0ãŸãã¯1ãšããŠè¿ããŸãã
ã¢ãŒãèªäœã®æå¹åã¯ãscePadEnterPressModeïŒïŒé¢æ°ã«ãã£ãŠè¡ãããŸãã ãã©ã¡ãŒã¿ãåãåããåã®é¢æ°ãšåãããã«è¿ããŸãã
ããã«ããããã¡ã®scePadReadïŒïŒé¢æ°ãä»ããŠãããã«1ãã€ããåãåããŸãããã®ãã€ãã«ã¯ããã¿ã³ãæŒã床åãã0ã255ã®å€ã§è¡šç€ºãããŸãã0ã¯ããã¿ã³ãæŒãããªãããšãšåãã§ãã
ã¡ã¢ãšããŠãæåã®ãžã§ã€ã¹ãã£ãã¯ã¯ãšãã©ãæ倧3åæŒãåã瀺ãããšããããŸãã
ä»æ§ã«ããã°ãã¢ããã°ã®åãã®å®å šã«éåžžã®èª€å·®ã¯ãã©ã¹ãŸãã¯ãã€ãã¹25ã§ãã
scePadExitPressModeïŒïŒé¢æ°ã䜿çšããŠãããŒæ床ã¢ãŒããçµäºã§ããŸãã ããŒããšã¹ããããåãå ¥ããŸãã ã¡ãã¥ãŒã«åãæ¿ããå¿ èŠãããå ŽåããããŸãã
ãŠãŒã¶ãŒãé«æ床ã¢ãŒãäžã«ã¢ããã°ãã¿ã³ãæŒããšãæ床ãªãã§éåžžã®ããžã¿ã«ã¢ãŒãã«åãæ¿ãããŸãã ã¢ããã°ãã¿ã³ãããäžåºŠæŒããŠãããžã§ã€ã¹ãã£ãã¯ã¯æ床ã¢ãŒãã«æ»ããŸãã ã
æ¯å
ãžã§ã€ã¹ãã£ãã¯ã®æ¯åã¯éåžžã«ç°¡åã§ãããåæã«ããã§ã¯ãããŸããã
å¥ã®ã©ã€ãã©ãªãæ¥ç¶ããããlibpadã«å«ãŸãã2ã€ã®é¢æ°ã®ã¿ã䜿çšã§ããŸãã
次åãå¥ã®ãã€ãã¬ãŒã·ã§ã³ã©ã€ãã©ãªã«ã€ããŠèª¬æããŸããããã«2ã€ã®ç°¡åãªæ©èœã«ã€ããŠèª¬æããŸãããããã¯scePadSetActAlignïŒïŒããã³scePadSetActDirectïŒïŒã§ãããŒããã¹ããããããã³6ãã€ãã®ããããåãå ¥ããŸãã
æåã®ãã€ãã§ã¯ã匷ãã¢ãŒã¿ãŒãŸãã¯åŒ±ãã¢ãŒã¿ãŒã瀺ããŸãã
2çªç®ã®ãã€ãã§ã¯ã匱ãã¢ãŒã¿ãŒã¯å€0ãŸãã¯1ãåããŸããããã¯ãåæ¢ãŸãã¯ããããæå³ããŸãã 匷åãªã¢ãŒã¿ãŒã¯ã2çªç®ã®ãã€ãã«1ã255ãŸãã¯0ã®å€ãåããŸããããã¯ããããåãŸãã¯åæ¢ãæå³ããŸãã
scePadSetActDirectïŒïŒé¢æ°ã¯ãæ¯åæäœã®å®äºã瀺ãtrueãŸãã¯falseãè¿ããŸãã æ®ãã®ãã€ãã¯ã䜿çšããªãå Žåã¯0xffã§åããããšããå§ãããŸãã
ãã®åŸããŠãŒã¶ãŒã®ãžã§ã€ã¹ãã£ãã¯ã¯ãæ¯åæäœã®ããã«10åã®çŸåšã®ãŠããããåãåããŸãã
çŸåšã®ãŠãããæ°ã20ã«å¢ããã«ã¯ãæ®ãã®å€0x00ãå ¥åããŸãã
éèŠïŒ
åããŒãã¯ãçŸåšã®ãŠãããã®æ倧æ°ã§ãã60ã«å¶éãããŠããããšãç¥ã£ãŠããå¿ èŠããããŸãã60ãè¶ ãããšãã³ã³ãœãŒã«ããªããŒããããŸã§ããŒãããããã¯ãããŸãïŒå éšãªããã¿ãŒãããªã¬ãŒãããŸãïŒã
ãããã£ãŠããã«ãã¿ããã䜿çšããŠããã1Aã1Bãããã³1Cãžã§ã€ã¹ãã£ãã¯ã«20ãŠãããã®é»æµãéä¿¡ããå Žåã1Dãžã§ã€ã¹ãã£ãã¯ã«ãããè¡ãããšã¯ã§ããŸãããããããªããšãããŒãããããã¯ã§ããŸãã ãããã£ãŠãé»æµäŸçµŠãå¢ããããšã¯ãå§ãããŸããã
ãŸãããããã®æ©èœã¯é·ãæ¯åã«ã¯äœ¿çšã§ããªãããšãä»ãå ããŠãã ããã
éåæé¢æ°
次ã®é¢æ°ã¯éåæã§ãã 圌ãã¯ããªãã«çµæãåæã«è¿ããªããããããŸããã ãã®å Žåãé¢æ°scePadGetStateïŒïŒãŸãã¯scePadGetReqStateïŒïŒã䜿çšããŠå®è¡çµæãååŸã§ããŸãã
scePadSetMainMode-å ¥åã¢ãŒãã®åãæ¿ãã
scePadSetActAlign-æ¯åæ©èœ;
scePadEnterPressMode-ãã¿ã³æ床ã¢ãŒããžã®ãšã³ããªã
scePadExitPressMode-ãã¿ã³ã®æ床ã¢ãŒããçµäºããŸãã
çµããã«è¿ã
äžè¬ã«ããžã§ã€ã¹ãã£ãã¯ãåé€ïŒãªãïŒãããŠããŠããååãšããŠãã¢ããªã±ãŒã·ã§ã³ã¯ããŒããšã¹ãããã§åŒãç¶ãåäœããŸãã scePadStateDisconnectãè¿ãscePadGetStateïŒïŒã䜿çšããŠããžã§ã€ã¹ãã£ãã¯ãåé€ãããããšãããã°ã©ã ã§ç¢ºèªããŸãã
åãã¬ãŒã ã®åã«ãã³ã³ãããŒã©ãŒã®ã¹ããŒã¿ã¹ã確èªããããšããå§ãããŸããããã«ããããžã§ã€ã¹ãã£ãã¯ã誀ã£ãŠãªãã«ãªãç¶æ³ããªããªããŸãã
ãŸããDualShockãŸãã¯DualShock 2ã³ã³ãããŒã©ãŒã®ããŒãžã§ã³ã«ãã£ãŠã¯ãã¢ããã°ã®ä»æ§ãå€æŽãããå¯èœæ§ãããããããžã§ã€ã¹ãã£ãã¯ã®èªåãã£ãªãã¬ãŒã·ã§ã³ã«äŸåããªãã§ãã ããã ãããã£ãŠãã»ãšãã©ã®å Žåãã¢ããã°ã127x127ã§åæ¢ããªãã£ããšããäºå®ãä¿®æ£ããå¿ èŠããããŸãã
以äžã§ãã ãžã§ã€ã¹ãã£ãã¯ã«é¢ãã次ã®è©³çŽ°ãªèšäºã§ãäŒãããŸãããã
PS ïŒãããã¯ã®é¢é£æ§ãèŠãŠãç§ã¯ãã®èšäºãåå€ãšæã«æžããŸããã SDKã次ã®èšäºã®æºåãã§ããŠããå Žåã¯ããžã§ã€ã¹ãã£ãã¯ã®ä»£ããã«ã€ã³ã¹ããŒã«ã®èª¬æããããŸãã
æŽæ° ïŒscePadInitïŒïŒé¢æ°ã¯ãç§ã話ããŠããEEã䜿çšããå Žåã«ã®ã¿å¿ èŠã§ãã IOPã¯ã©ã€ãã©ãªèªäœãåæåããŸãã