Mercurial > hg > index.fcgi > lj > lj046-2players
annotate src/dsjoy.c @ 0:c84446dfb3f5
initial add
author | paulo@localhost |
---|---|
date | Fri, 13 Mar 2009 00:39:12 -0700 |
parents | |
children | 80a2761bd3a4 |
rev | line source |
---|---|
paulo@0 | 1 #include "ljcontrol.h" |
paulo@0 | 2 #ifdef ARM9 |
paulo@0 | 3 #include <nds.h> |
paulo@0 | 4 #else |
paulo@0 | 5 #include <gba.h> |
paulo@0 | 6 #endif |
paulo@0 | 7 |
paulo@0 | 8 LJBits readHWKeys(void); |
paulo@0 | 9 |
paulo@0 | 10 LJBits readPad(unsigned int player) { |
paulo@0 | 11 LJBits hwKeys = readHWKeys(); |
paulo@0 | 12 LJBits out = 0; |
paulo@0 | 13 |
paulo@0 | 14 if (hwKeys & KEY_UP) { |
paulo@0 | 15 out |= VKEY_UP; |
paulo@0 | 16 } |
paulo@0 | 17 if (hwKeys & KEY_DOWN) { |
paulo@0 | 18 out |= VKEY_DOWN; |
paulo@0 | 19 } |
paulo@0 | 20 if (hwKeys & KEY_LEFT) { |
paulo@0 | 21 out |= VKEY_LEFT; |
paulo@0 | 22 } |
paulo@0 | 23 if (hwKeys & KEY_RIGHT) { |
paulo@0 | 24 out |= VKEY_RIGHT; |
paulo@0 | 25 } |
paulo@0 | 26 if (hwKeys & KEY_B) { |
paulo@0 | 27 out |= VKEY_ROTL; |
paulo@0 | 28 } |
paulo@0 | 29 if (hwKeys & KEY_A) { |
paulo@0 | 30 out |= VKEY_ROTR; |
paulo@0 | 31 } |
paulo@0 | 32 if (hwKeys & (KEY_L | KEY_R)) { |
paulo@0 | 33 out |= VKEY_HOLD; |
paulo@0 | 34 } |
paulo@0 | 35 |
paulo@0 | 36 #ifdef ARM9 |
paulo@0 | 37 if (hwKeys & KEY_X) { |
paulo@0 | 38 out |= VKEY_MACRO(3); |
paulo@0 | 39 } |
paulo@0 | 40 if (hwKeys & KEY_Y) { |
paulo@0 | 41 out |= VKEY_MACRO(2); |
paulo@0 | 42 } |
paulo@0 | 43 #endif |
paulo@0 | 44 |
paulo@0 | 45 // on the GBA and DS, we need to add the console buttons in |
paulo@0 | 46 out |= hwKeys << 16; |
paulo@0 | 47 return out; |
paulo@0 | 48 } |