static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { uint64_t buttons = iohidmanager_hid_joypad_get_buttons(data, port); if (joykey == NO_BTN) return false; /* Check hat. */ if (GET_HAT_DIR(joykey)) return false; /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) return ((buttons & (1 << joykey)) != 0); return false; }
static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { retro_bits_t buttons; iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; unsigned hat_dir = GET_HAT_DIR(joykey); iohidmanager_hid_joypad_get_buttons(data, port, &buttons); /* Check hat. */ if (hat_dir) { unsigned h = GET_HAT(joykey); if(h >= 1) return false; switch(hat_dir) { case HAT_LEFT_MASK: return hid->hats[port][0] < 0; case HAT_RIGHT_MASK: return hid->hats[port][0] > 0; case HAT_UP_MASK: return hid->hats[port][1] < 0; case HAT_DOWN_MASK: return hid->hats[port][1] > 0; } return 0; } /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) return (BIT256_GET(buttons, joykey) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0); return false; }