bool JoystickInfo::PollButtons(u32 &pkey) { // MAKE sure to look for changes in the state!! for (int i = 0; i < GetNumButtons(); ++i) { int but = SDL_JoystickGetButton(GetJoy(), i); if (but != GetButtonState(i)) { // Pressure sensitive button are detected as both button (digital) and axes (analog). So better // drop the button to emulate the pressure sensiblity of the ds2 :) // Trick: detect the release of the button. It avoid all races condition between axes and buttons :) // If the button support pressure it will be detected as an axis when it is pressed. if (but) { SetButtonState(i, but); return false; } pkey = button_to_key(i); return true; } } return false; }
bool JoystickInfo::PollButtons(u32 &pkey) { // MAKE sure to look for changes in the state!! for (int i = 0; i < GetNumButtons(); ++i) { int but = SDL_JoystickGetButton(GetJoy(), i); if (but != GetButtonState(i)) { if (!but) // released, we don't really want this { continue; } // Pressure sensitive button are detected as both button (digital) and axes (analog). So better // drop the button to emulate the pressure sensiblity of the ds2 :) -- Gregory u32 pkey_dummy; if (PollAxes(pkey_dummy)) return false; pkey = button_to_key(i); return true; } } return false; }
float GSGUI_DROPDOWN::GetCurrentHeight() const { if (IsActive()) { return static_cast<float>(GetNumButtons()+1)*m_size; } return m_size; }
GSGUI_BUTTON GSGUI_BUTTONLIST::PlaceMenu(Vector2 v2Pos) { GSGUI_BUTTON r; if (!m_video) return r; m_video->SetZBuffer(false); m_video->SetZWrite(false); Vector2 v2TextAdd(m_size/4.0f, 0.0f), v2ButtonSize = Vector2(m_width, m_size); if (!m_buttons.empty()) { bool newSingleSet = false; int focus=-1; int t=0; GSGUI_BUTTON_ITERATOR iter; for (iter = m_buttons.begin(); iter != m_buttons.end(); ++iter) { if (!iter->visible) continue; Vector2 v2ButtonPos = Vector2(v2Pos.x, v2Pos.y+((float)t*m_size)); GS_DWORD top, bottom, text; iter->onFocus = MouseOver(v2ButtonPos, v2ButtonSize); if (iter->onFocus) { top = m_style.focused_top; bottom = m_style.focused_bottom; text = m_style.active_text; focus = t; if (m_input->GetLeftClickState() == GSKS_HIT) { if (m_unselect) iter->active = !(iter->active); else iter->active = true; if (m_singleSelect) { newSingleSet = true; m_single.text = iter->text; } r.text = iter->text; r.active = iter->active; } } else { top = m_style.inactive_top; bottom = m_style.inactive_bottom; text = m_style.inactive_text; } if (iter->active) { top = m_style.active_top; bottom = m_style.active_bottom; text = m_style.active_text; } m_video->DrawRectangle(v2ButtonPos, v2ButtonSize, top, top, bottom, bottom); str_type::stringstream ss; ss << iter->text << iter->extText; m_video->DrawBitmapText( v2ButtonPos + v2TextAdd, ss.str().c_str(), GS_L("Verdana14_shadow.fnt"), text ); t++; } if (newSingleSet) { for (iter = m_buttons.begin(); iter != m_buttons.end(); ++iter) { if (m_single.text == iter->text) continue; iter->active = false; } newSingleSet = false; } if (m_autoUnclick) { for (iter = m_buttons.begin(); iter != m_buttons.end(); ++iter) { iter->active = false; } } } if (MouseOver(v2Pos, Vector2(m_width, m_size*(float)m_buttons.size()))) { m_mouseOver = true; DrawOutline(v2Pos, Vector2(m_width, m_size*(float)GetNumButtons())); } else { m_mouseOver = false; } return r; }