for(i = 0; i < 12; i++) { int dev = (joypad[i] >> 12); int a = joypad[i] & 0xfff; if(dev) { dev--;  if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) { int dir = a & 3; int v = 0; switch(dir) { case 0: v = value & SDL_HAT_UP; break; case 1: v = value & SDL_HAT_DOWN; break; case 2: v = value & SDL_HAT_RIGHT; break; case 3: v = value & SDL_HAT_LEFT; break;
for(int j = 0; j < 4; j++) { for(i = 0; i < 12; i++) { int dev = (joypad[j][i] >> 12); int a = joypad[j][i] & 0xfff; if(dev) { dev--;  if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) { int dir = a & 3; int v = 0; switch(dir) { case 0: v = value & SDL_HAT_UP; break; case 1: v = value & SDL_HAT_DOWN; break; case 2: v = value & SDL_HAT_RIGHT; break; case 3: v = value & SDL_HAT_LEFT; break; } sdlButtons[j][i] = (v ? true : false);
void sdlUpdateJoyHat(int which,                     int hat,                     int value){  int i;  for(i = 0; i < 12; i++) {    int dev = (joypad[i] >> 12);    int a = joypad[i] & 0xfff;    if(dev) {      dev--;      if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {        int dir = a & 3;        int v = 0;        switch(dir) {        case 0:          v = value & SDL_HAT_UP;          break;        case 1:          v = value & SDL_HAT_DOWN;          break;        case 2:          v = value & SDL_HAT_RIGHT;          break;        case 3:          v = value & SDL_HAT_LEFT;          break;        }        sdlButtons[i] = (v ? true : false);      }    }  }  for(i = 0; i < 4; i++) {    int dev = (motion[i] >> 12);    int a = motion[i] & 0xfff;    if(dev) {      dev--;      if((dev == which) && (a>=32) && (a < 48) && (((a&15)>>2) == hat)) {        int dir = a & 3;        int v = 0;        switch(dir) {        case 0:          v = value & SDL_HAT_UP;          break;        case 1:          v = value & SDL_HAT_DOWN;          break;        case 2:          v = value & SDL_HAT_RIGHT;          break;        case 3:          v = value & SDL_HAT_LEFT;          break;        }        sdlMotionButtons[i] = (v ? true : false);      }    }  }      }