/* ljoy_get_joystick: [primary thread] * * Returns the address of a ALLEGRO_JOYSTICK structure for the device * number NUM. */ static ALLEGRO_JOYSTICK *ljoy_get_joystick(int num) { ALLEGRO_JOYSTICK *ret = NULL; unsigned i; ASSERT(num >= 0); al_lock_mutex(config_mutex); for (i = 0; i < _al_vector_size(&joysticks); i++) { ALLEGRO_JOYSTICK_LINUX **slot = _al_vector_ref(&joysticks, i); ALLEGRO_JOYSTICK_LINUX *joy = *slot; if (ACTIVE_STATE(joy->config_state)) { if (num == 0) { ret = (ALLEGRO_JOYSTICK *)joy; break; } num--; } } al_unlock_mutex(config_mutex); return ret; }
/* joydx_get_joystick: [primary thread] * * Returns the address of a ALLEGRO_JOYSTICK structure for the device * number NUM. */ static ALLEGRO_JOYSTICK *joydx_get_joystick(int num) { ALLEGRO_JOYSTICK *ret = NULL; unsigned i; ASSERT(num >= 0); EnterCriticalSection(&joydx_thread_cs); for (i = 0; i < MAX_JOYSTICKS; i++) { ALLEGRO_JOYSTICK_DIRECTX *joy = &joydx_joystick[i]; if (ACTIVE_STATE(joy->config_state)) { if (num == 0) { ret = (ALLEGRO_JOYSTICK *)joy; break; } num--; } } LeaveCriticalSection(&joydx_thread_cs); #if 0 /* is this needed? */ if (ret) { ALLEGRO_DISPLAY *display = al_get_current_display(); if (display) _al_win_joystick_dinput_grab(display); } #endif return ret; }
void imx233_pwm_setup(int channel, int period, int cdiv, int active, int active_state, int inactive, int inactive_state) { /* stop */ bool enable = imx233_pwm_is_enabled(channel); if(enable) imx233_pwm_enable(channel, false); /* setup pin */ imx233_pinctrl_setup_vpin(VPIN_PWM(channel), "pwm", PINCTRL_DRIVE_4mA, false); /* watch the order ! active THEN period * NOTE: the register value is period-1 */ HW_PWM_ACTIVEn(channel) = BF_OR2(PWM_ACTIVEn, ACTIVE(active), INACTIVE(inactive)); HW_PWM_PERIODn(channel) = BF_OR4(PWM_PERIODn, PERIOD(period - 1), ACTIVE_STATE(active_state), INACTIVE_STATE(inactive_state), CDIV(cdiv)); /* restore */ imx233_pwm_enable(channel, enable); }
static bool ljoy_get_active(ALLEGRO_JOYSTICK *joy_) { ALLEGRO_JOYSTICK_LINUX *joy = (ALLEGRO_JOYSTICK_LINUX *)joy_; return ACTIVE_STATE(joy->config_state); }
static bool joydx_get_active(ALLEGRO_JOYSTICK *joy) { ALLEGRO_JOYSTICK_DIRECTX *joydx = (ALLEGRO_JOYSTICK_DIRECTX *)joy; return ACTIVE_STATE(joydx->config_state); }