diff src/dsjoy.c @ 0:c84446dfb3f5

initial add
author paulo@localhost
date Fri, 13 Mar 2009 00:39:12 -0700
parents
children 80a2761bd3a4
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/dsjoy.c	Fri Mar 13 00:39:12 2009 -0700
     1.3 @@ -0,0 +1,48 @@
     1.4 +#include "ljcontrol.h"
     1.5 +#ifdef ARM9
     1.6 +#include <nds.h>
     1.7 +#else
     1.8 +#include <gba.h>
     1.9 +#endif
    1.10 +
    1.11 +LJBits readHWKeys(void);
    1.12 +
    1.13 +LJBits readPad(unsigned int player) {
    1.14 +  LJBits hwKeys = readHWKeys();
    1.15 +  LJBits out = 0;
    1.16 +  
    1.17 +  if (hwKeys & KEY_UP) {
    1.18 +    out |= VKEY_UP;
    1.19 +  }
    1.20 +  if (hwKeys & KEY_DOWN) {
    1.21 +    out |= VKEY_DOWN;
    1.22 +  }
    1.23 +  if (hwKeys & KEY_LEFT) {
    1.24 +    out |= VKEY_LEFT;
    1.25 +  }
    1.26 +  if (hwKeys & KEY_RIGHT) {
    1.27 +    out |= VKEY_RIGHT;
    1.28 +  }
    1.29 +  if (hwKeys & KEY_B) {
    1.30 +    out |= VKEY_ROTL;
    1.31 +  }
    1.32 +  if (hwKeys & KEY_A) {
    1.33 +    out |= VKEY_ROTR;
    1.34 +  }
    1.35 +  if (hwKeys & (KEY_L | KEY_R)) {
    1.36 +    out |= VKEY_HOLD;
    1.37 +  }
    1.38 +
    1.39 +#ifdef ARM9
    1.40 +  if (hwKeys & KEY_X) {
    1.41 +    out |= VKEY_MACRO(3);
    1.42 +  }
    1.43 +  if (hwKeys & KEY_Y) {
    1.44 +    out |= VKEY_MACRO(2);
    1.45 +  }
    1.46 +#endif
    1.47 +
    1.48 +  // on the GBA and DS, we need to add the console buttons in
    1.49 +  out |= hwKeys << 16;
    1.50 +  return out;
    1.51 +}