| njGetPeripheral | Japanese |
|---|---|
--|INDEX|-> | |
| Gets information of input device(peripheral). | |
#include <NinjaWin.h> NJS_PERIPHERAL *njGetPeripheral(port) Uint32 port
| NJD_PORT_SYSKEYBOARD | System keyboard |
| NJD_PORT_SYSMOUSE | System mouse |
| NJD_PORT_JOYSTICK1 | Joystick port 1 |
| : | |
|---|---|
| NJD_PORT_JOYSTICK16 | Joystick port 16 |
| NJD_DEV_NODEVICE | Disconnected |
| NJD_DEV_SYSKEYBOARD | System keyboard |
| NJD_DEV_SYSMOUSE | System mouse |
| NJD_DEV_JOYSTICK | Joystick |
| NJD_DEV_UNDEFINED | Undefined |
![]() |
Do not mix them up with peripheral port numbers. |
Gets ON/OFF of buttons using AND with the following macro.
| NJD_DGT_KU | Directional key Up |
| NJD_DGT_KD | Directional key Down |
| NJD_DGT_KL | Directional key Left |
| NJD_DGT_KR | Directional key Right |
| NJD_DGT_TA | A button |
| NJD_DGT_TB | B button |
| NJD_DGT_TC | C button |
| NJD_DGT_TX | X button |
| NJD_DGT_TY | Y button |
| NJD_DGT_TZ | Z button |
| NJD_DGT_TL | L button |
| NJD_DGT_TR | R button |
| NJD_DGT_ST | START button |
| Digital Pad | Keyboard |
|---|---|
| Direction key UP | Cursol UP or Ten key 8 |
| Direction key DOWN | Cursol DOWN or Ten key 2 |
| Direction key LEFT | Cursol LEFT or Ten key 4 |
| Direction key RIGHT | Cursol RIGHT or Ten key 6 |
| A Button | Z Key |
| B Button | X Key |
| C Button | C Key |
| X Button | A Key |
| Y Button | S Key |
| Z Button | D Key |
| L Button | Q Key |
| R Button | E Key |
| START Button | SPACE Key or RETURN Key |
Sint32 njUserMain(void)
{
NJS_PERIPHERAL* per;
/* Gets information of peripheral which is
* connected to joystick port1.
*/
per = njGetPeripheral(NJD_DEV_JOYSTICK1);
if(per->id == NJD_DEV_NODEVICE){
/* Peripheral disconnected */
}
if(per->push & NJD_DGT_ST){
/* Start button is pushed (edge) */
}
if(per->on & NJD_DGT_KU){
/* Directional key is pushed */
}
if((per->on & (NJD_DGT_TA | NJD_DGT_TB))==(NJD_DGT_TA | NJD_DGT_TB){
/* Judgement for some buttons pushed
* simultaneously - Both buttons A and B are pushed.
*/
}
return NJS_USER_CONTINUE;
}
| njGetPeripheral | --|INDEX|-> |
|---|