/** * \brief Gets the x and y position of this mouse event, if any. * Values are in quest size coordinates. * \param[out] mouse_xy The x and y position of the mouse in this mouse event. * \return \c false if the mouse was not inside the quest displaying during * this event. */ bool InputEvent::get_mouse_position(Point& mouse_xy) const { Debug::check_assertion(is_mouse_event(), "Event is not a mouse event"); return Video::renderer_to_quest_coordinates( Point(internal_event.button.x, internal_event.button.y), mouse_xy); }
/** * \brief Returns the x and y position of this mouse event, if any. * Values are in quest size coordinates and relative to the viewport. * \return A rectangle filled with the x and y position of the mouse, * in which the width and height are set to 1. * Returns a flat Rectangle if the position is not inside the viewport. */ Rectangle InputEvent::get_mouse_position() const { Debug::check_assertion(is_mouse_event(), "Event is not a mouse event"); return Video::get_scaled_position( Rectangle(internal_event.button.x, internal_event.button.y, 1, 1)); }
/** * \brief Returns the button that was pressed or released during * this mouse event. * * If this is not a mouse event, MOUSE_BUTTON_NONE is returned. * \return The button of this mouse event. */ InputEvent::MouseButton InputEvent::get_mouse_button() const { if (!is_mouse_event()) { return MOUSE_BUTTON_NONE; } return static_cast<MouseButton>(internal_event.button.button); }
//! Task which links mouse events with the USB HID mouse device //! void mouse_task(void) { if(Is_usb_vbus_low()) { Setup_power_down_mode(); Sleep_instruction(); } if(!Is_device_enumerated()) return; // Device not ready #if (USB_LOW_SPEED_DEVICE==DISABLE) // The SOF is used to schedule the task at the same frequency that Endpoint Interrupt frequency // This check allow to win a CPU time if(g_u8_cpt_sof<NB_IDLE_POLLING_SOF) return; // Wait a delay g_u8_cpt_sof=0; #endif if(!g_b_send_report) { // No report sending on going, then check mouse event to eventualy fill a new report if(is_mouse_event()) { // Enable sending of report g_b_send_report = TRUE; } } if((!g_b_send_report)&&(!g_b_send_ack_report)) return; // No report and ack to send //** A report or ack must be send Usb_select_endpoint(EP_MOUSE_IN); if(!Is_usb_write_enabled()) return; // Endpoint no free Led0_on(); if( g_b_send_report ) { g_b_send_report = FALSE; // Send an ack after a "clic" report only g_b_send_ack_report = (0!=g_hid_mouse_report[0]); } else { Hid_mouse_report_reset(); // Reset report to have a ack report g_b_send_ack_report = FALSE; } // Send report Usb_write_byte(g_hid_mouse_report[0]); Usb_write_byte(g_hid_mouse_report[1]); Usb_write_byte(g_hid_mouse_report[2]); Usb_write_byte(g_hid_mouse_report[3]); Usb_ack_in_ready(); Led0_off(); }