JoystickFeature(const JOYSTICK_FEATURE& feature) : m_name(feature.name ? feature.name : ""), m_type(feature.type) { switch (m_type) { case JOYSTICK_FEATURE_TYPE_SCALAR: SetPrimitive(feature.scalar.primitive); break; case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: SetUp(feature.analog_stick.up); SetDown(feature.analog_stick.down); SetRight(feature.analog_stick.right); SetLeft(feature.analog_stick.left); break; case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: SetPositiveX(feature.accelerometer.positive_x); SetPositiveY(feature.accelerometer.positive_y); SetPositiveZ(feature.accelerometer.positive_z); break; case JOYSTICK_FEATURE_TYPE_MOTOR: SetPrimitive(feature.motor.primitive); break; default: break; } }
void Button::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam) { // inherited Control::MouseInput(rMouse, iButton, iX, iY, dwKeyParam); // process left down and up if (fEnabled) switch (iButton) { case C4MC_Button_LeftDown: // mark button as being down SetDown(); // remember drag target // no dragging movement will be done w/o drag component assigned // but it should be remembered if the user leaves the button with the mouse down // and then re-enters w/o having released the button if (!rMouse.pDragElement) rMouse.pDragElement = this; break; case C4MC_Button_LeftUp: // only if button was down... (might have dragged here) if (fDown) { // it's now up :) SetUp(true); // process event OnPress(); } break; }; }
void ButtonWindow::OnCancelMode() { dragging = false; SetDown(false); PaintWindow::OnCancelMode(); }
void Button::MouseEnter(CMouse &rMouse) { Control::MouseEnter(rMouse); // remember mouse state for button highlight fMouseOver = true; // mouse re-enters with left button down? if (rMouse.pDragElement == this) if (fEnabled) SetDown(); }
bool Button::KeyButtonDown() { // not on disabled if (!fEnabled) return false; // space downs button SetDown(); return true; }
bool ButtonWindow::OnMouseMove(PixelScalar x, PixelScalar y, unsigned keys) { if (dragging) { SetDown(IsInside(x, y)); return true; } else return PaintWindow::OnMouseMove(x, y, keys); }
bool ButtonWindow::OnMouseDown(PixelScalar x, PixelScalar y) { if (IsTabStop()) SetFocus(); SetDown(true); SetCapture(); dragging = true; return true; }
void wxSpeedButton::OnKey(wxKeyEvent& event) { int n; wxString s; n = event.GetKeyCode(); if ((n == '\n') || ( n == '\r') || (n == ' ')) { mButtonFocused = true; SetDown(! mButtonDown); SendEvent(true); Redraw(); //Refresh(false); }; event.Skip(); }
bool ButtonWindow::OnKeyDown(unsigned key_code) { switch (key_code) { case KEY_RETURN: case KEY_SPACE: SetDown(false); if (!OnClicked() && id != 0 && parent != nullptr) parent->OnCommand(id, 0); return true; default: return PaintWindow::OnKeyDown(key_code); } }
bool ButtonWindow::OnMouseUp(PixelScalar x, PixelScalar y) { if (!dragging) return true; dragging = false; ReleaseCapture(); if (!down) return true; SetDown(false); if (!OnClicked() && id != 0 && parent != nullptr) parent->OnCommand(id, 0); return true; }
void wxSpeedButton::OnMouseEvents(wxMouseEvent& event) { wxWindow *win; // our underlying window win = (wxWindow *) this; // any mouse button down if (event.LeftDown() || event.RightDown()) { if (!HasCapture()) CaptureMouse(); mMouseDown = true; mButtonFocused = true; win->SetFocus(); Redraw(); } // any mouse button up // this is where we send a click event else if (event.LeftUp() || event.RightUp()) { if (HasCapture()) ReleaseMouse(); mMouseDown = false; mButtonFocused = true; win->SetFocus(); SetDown(! mButtonDown); SendEvent(event.LeftUp()); Redraw(); } // mouse over else if (event.Entering()) { mMouseOver = true; Redraw(); } else if (event.Leaving()) { mMouseOver = false; Redraw(); }; }
/*! This is called in order to call the correct methods of the datalink protocols, ie. it will translate address changes to net_datalink_protocol::change_address(), and IFF_UP changes to net_datalink_protocol::interface_up(), and interface_down(). Everything else is passed unchanged to net_datalink_protocol::control(). */ status_t Interface::Control(net_domain* domain, int32 option, ifreq& request, ifreq* userRequest, size_t length) { switch (option) { case SIOCSIFFLAGS: { if (length != sizeof(ifreq)) return B_BAD_VALUE; uint32 requestFlags = request.ifr_flags; uint32 oldFlags = flags; status_t status = B_OK; request.ifr_flags &= ~(IFF_UP | IFF_LINK | IFF_BROADCAST); if ((requestFlags & IFF_UP) != (flags & IFF_UP)) { if ((requestFlags & IFF_UP) != 0) status = _SetUp(); else SetDown(); } if (status == B_OK) { // TODO: maybe allow deleting IFF_BROADCAST on the interface // level? flags &= IFF_UP | IFF_LINK | IFF_BROADCAST; flags |= request.ifr_flags; } if (oldFlags != flags) { TRACE("Interface %p: flags changed from %" B_PRIx32 " to %" B_PRIx32 "\n", this, oldFlags, flags); notify_interface_changed(this, oldFlags, flags); } return status; } case B_SOCKET_SET_ALIAS: { if (length != sizeof(ifaliasreq)) return B_BAD_VALUE; RecursiveLocker locker(fLock); ifaliasreq aliasRequest; if (user_memcpy(&aliasRequest, userRequest, sizeof(ifaliasreq)) != B_OK) return B_BAD_ADDRESS; InterfaceAddress* address = NULL; if (aliasRequest.ifra_index < 0) { if (!domain->address_module->is_empty_address( (const sockaddr*)&aliasRequest.ifra_addr, false)) { // Find first address that matches the local address address = AddressForLocal(domain, (const sockaddr*)&aliasRequest.ifra_addr); } if (address == NULL) { // Find first address for family address = FirstForFamily(domain->family); } if (address == NULL) { // Create new on the fly address = new(std::nothrow) InterfaceAddress(this, domain); if (address == NULL) return B_NO_MEMORY; status_t status = AddAddress(address); if (status != B_OK) { delete address; return status; } // Note, even if setting the address failed, the empty // address added here will still be added to the interface. address->AcquireReference(); } } else address = AddressAt(aliasRequest.ifra_index); if (address == NULL) return B_BAD_VALUE; status_t status = B_OK; if (!domain->address_module->equal_addresses( (sockaddr*)&aliasRequest.ifra_addr, address->local)) { status = _ChangeAddress(locker, address, SIOCSIFADDR, address->local, (sockaddr*)&aliasRequest.ifra_addr); } if (status == B_OK && !domain->address_module->equal_addresses( (sockaddr*)&aliasRequest.ifra_mask, address->mask) && !domain->address_module->is_empty_address( (sockaddr*)&aliasRequest.ifra_mask, false)) { status = _ChangeAddress(locker, address, SIOCSIFNETMASK, address->mask, (sockaddr*)&aliasRequest.ifra_mask); } if (status == B_OK && !domain->address_module->equal_addresses( (sockaddr*)&aliasRequest.ifra_destination, address->destination) && !domain->address_module->is_empty_address( (sockaddr*)&aliasRequest.ifra_destination, false)) { status = _ChangeAddress(locker, address, (domain->address_module->flags & NET_ADDRESS_MODULE_FLAG_BROADCAST_ADDRESS) != 0 ? SIOCSIFBRDADDR : SIOCSIFDSTADDR, address->destination, (sockaddr*)&aliasRequest.ifra_destination); } address->ReleaseReference(); return status; } case SIOCSIFADDR: case SIOCSIFNETMASK: case SIOCSIFBRDADDR: case SIOCSIFDSTADDR: case SIOCDIFADDR: { if (length != sizeof(ifreq)) return B_BAD_VALUE; RecursiveLocker locker(fLock); InterfaceAddress* address = NULL; sockaddr_storage newAddress; size_t size = max_c(request.ifr_addr.sa_len, sizeof(sockaddr)); if (size > sizeof(sockaddr_storage)) size = sizeof(sockaddr_storage); if (user_memcpy(&newAddress, &userRequest->ifr_addr, size) != B_OK) return B_BAD_ADDRESS; if (option == SIOCDIFADDR) { // Find referring address - we can't use the hash, as another // interface might use the same address. AddressList::Iterator iterator = fAddresses.GetIterator(); while ((address = iterator.Next()) != NULL) { if (address->domain == domain && domain->address_module->equal_addresses( address->local, (sockaddr*)&newAddress)) break; } if (address == NULL) return B_BAD_VALUE; } else { // Just use the first address for this family address = _FirstForFamily(domain->family); if (address == NULL) { // Create new on the fly address = new(std::nothrow) InterfaceAddress(this, domain); if (address == NULL) return B_NO_MEMORY; status_t status = AddAddress(address); if (status != B_OK) { delete address; return status; } // Note, even if setting the address failed, the empty // address added here will still be added to the interface. } } return _ChangeAddress(locker, address, option, *address->AddressFor(option), option != SIOCDIFADDR ? (sockaddr*)&newAddress : NULL); } default: // pass the request into the datalink protocol stack domain_datalink* datalink = DomainDatalink(domain->family); if (datalink->first_info != NULL) { return datalink->first_info->control( datalink->first_protocol, option, userRequest, length); } break; } return B_BAD_VALUE; }
void Button::Click() { SetDown(false); OnClicked(); }
void wxSpeedButton::DoClick(bool inLeft) { SetDown(! mButtonDown); SendEvent(inLeft); Refresh(false); }
void wxSpeedButton::SetValue(bool inDown) { SetDown(inDown); }