|
|
| version 1.2, 2003/10/21 11:22:05 | version 1.6, 2011/03/07 09:54:11 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | /** |
| #include "np2.h" | * @file joymng.cpp |
| #include "joymng.h" | * @brief Joystick manager |
| #include "menu.h" | * |
| * @author $Author$ | |
| * @date $Date$ | |
| */ | |
| #include "compiler.h" | |
| #include "np2.h" | |
| #include "joymng.h" | |
| #include "menu.h" | |
| #if !defined(__GNUC__) | |
| #pragma comment(lib, "winmm.lib") | |
| #endif // !defined(__GNUC__) | |
| enum { | |
| JOY_LEFT_BIT = 0x04, | |
| JOY_RIGHT_BIT = 0x08, | |
| JOY_UP_BIT = 0x01, | |
| JOY_DOWN_BIT = 0x02, | |
| JOY_BTN1_BIT = 0x10, | |
| JOY_BTN2_BIT = 0x20 | |
| }; | |
| static REG8 joyflag = 0xff; | |
| static UINT8 joypad1btn[4]; | |
| static int joyactive = 0; | |
| static BYTE joyflag = 0xff; | |
| #define JOY_LEFT_BIT 0x04 | void joymng_initialize(void) { |
| #define JOY_RIGHT_BIT 0x08 | |
| #define JOY_UP_BIT 0x01 | |
| #define JOY_DOWN_BIT 0x02 | |
| #define JOY_BTN1_BIT 0x10 | |
| #define JOY_BTN2_BIT 0x20 | |
| static BYTE joypad1btn[4]; // ver0.28 | |
| void joy_init(void) { | |
| JOYINFO ji; | JOYINFO ji; |
| int i; | int i; |
| if ((!joyGetNumDevs()) || | if ((!joyGetNumDevs()) || |
| (joyGetPos(JOYSTICKID1, &ji) == JOYERR_UNPLUGGED)) { | (joyGetPos(JOYSTICKID1, &ji) == JOYERR_UNPLUGGED)) { |
| // xmenu_setjoystick(np2cfg.JOYSTICK | 2); // ver0.28 | |
| np2oscfg.JOYPAD1 |= 2; | np2oscfg.JOYPAD1 |= 2; |
| } | } |
| for (i=0; i<4; i++) { // ver0.28 | for (i=0; i<4; i++) { |
| joypad1btn[i] = 0xff ^ | joypad1btn[i] = 0xff ^ |
| ((np2oscfg.JOY1BTN[i] & 3) << ((np2oscfg.JOY1BTN[i] & 4)?4:6)); | ((np2oscfg.JOY1BTN[i] & 3) << ((np2oscfg.JOY1BTN[i] & 4)?4:6)); |
| } | } |
| } | } |
| void joy_flash(void) { | void joymng_sync(void) { |
| np2oscfg.JOYPAD1 &= 0x7f; | np2oscfg.JOYPAD1 &= 0x7f; |
| joyflag = 0xff; | joyflag = 0xff; |
| } | } |
| BYTE joymng_getstat(void) { | REG8 joymng_getstat(void) { |
| JOYINFO ji; | JOYINFO ji; |