Ejemplo n.º 1
0
Archivo: ui.c Proyecto: InSoonPark/asf
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED1);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED1);
	}
	// Scan process running each 2ms
	cpt_sof++;
	if (2 > cpt_sof)
		return;
	cpt_sof = 0;

	// No Scan buttons

	// Look touch sensor activity for the X and Y events
	if (is_touch_sensor_2())
		udi_hid_mouse_moveX(MOUSE_MOVE_RANGE);
	if (is_touch_sensor_3())
		udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
	if (is_touch_sensor_1())
		udi_hid_mouse_moveY(MOUSE_MOVE_RANGE);
	if (is_touch_sensor_0())
		udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
}
Ejemplo n.º 2
0
Archivo: ui.c Proyecto: InSoonPark/asf
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED0_GPIO);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED0_GPIO);
	}
	// Scan process running each 2ms
	cpt_sof++;
	if (cpt_sof < 2) {
		return;
	}
	cpt_sof = 0;

	// Uses buttons to move mouse
	if (!gpio_pin_is_high(GPIO_PUSH_BUTTON_1)) {
		udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
	}
	if (!gpio_pin_is_high(GPIO_PUSH_BUTTON_2)) {
		udi_hid_mouse_moveX( MOUSE_MOVE_RANGE);
	}
}
Ejemplo n.º 3
0
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED1_GPIO);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED1_GPIO);
	}
	// Scan process running each 2ms
	cpt_sof++;
	if (2 > cpt_sof)
		return;
	cpt_sof = 0;
	// Scan move on switch 4 (right), 5 (left), 6 (down), 7 (up)
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_0))
		udi_hid_mouse_moveX(MOUSE_MOVE_RANGE);
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_1))
		udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_2))
		udi_hid_mouse_moveY(MOUSE_MOVE_RANGE);
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_3))
		udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
}
Ejemplo n.º 4
0
Archivo: ui.c Proyecto: InSoonPark/asf
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED0_GPIO);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED0_GPIO);
	}
	// Scan process running each 2ms
	cpt_sof++;
	if (cpt_sof < 2) {
		return;
	}
	cpt_sof = 0;

	// Uses buttons to move mouse
	if (!gpio_pin_is_high(GPIO_PUSH_BUTTON_1)) {
		move_count --;
		switch(move_dir) {
		case MOVE_UP:
			udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_RIGHT;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_RIGHT:
			udi_hid_mouse_moveX(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_DOWN;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_DOWN:
			udi_hid_mouse_moveY(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_LEFT;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_LEFT:
			udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_UP;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		}
	}
}
Ejemplo n.º 5
0
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED0);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED0);
	}
	/* Scan process running each 2ms */
	cpt_sof++;
	if (cpt_sof < 2) {
		return;
	}
	cpt_sof = 0;

	/* Uses buttons to move mouse */
	if (!ioport_get_pin_level(WAKEUP_PIN)) {
		move_count --;
		switch(move_dir) {
		case MOVE_UP:
			udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_RIGHT;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_RIGHT:
			udi_hid_mouse_moveX(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_DOWN;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_DOWN:
			udi_hid_mouse_moveY(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_LEFT;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_LEFT:
			udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_UP;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		}
	}
}
Ejemplo n.º 6
0
Archivo: ui.c Proyecto: InSoonPark/asf
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;
	static uint8_t gesture_state;
	static uint8_t gesture_cnt;

	if ((framenumber % 1000) == 0) {
		LED_On(LED1_GPIO);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED1_GPIO);
	}
	// Scan process running each 2ms
	cpt_sof++;
	if (2 > cpt_sof) {
		return;
	}
	cpt_sof = 0;

	// Algorithm to move the mouse on a square when button 0 is pressed
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_0)) {
		switch (gesture_state) {
			case 0:
				udi_hid_mouse_moveX(MOUSE_MOVE_RANGE);
				break;
			case 1:
				udi_hid_mouse_moveY(MOUSE_MOVE_RANGE);
				break;
			case 2:
				udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
				break;
			case 3:
				udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
				break;
			default:
				gesture_state = 0;
				break;
		}
		if(--gesture_cnt==0) {
			gesture_cnt=GESTURE_CNT_PER_STATE;
			if (++gesture_state>3) {
				gesture_state=0;
			}
		}
	} else {
		gesture_state=0;
		gesture_cnt=3;
	}


}
Ejemplo n.º 7
0
void ui_process(uint16_t framenumber)
{
	bool b_btn_state;
	static bool btn_left_last_state = HID_MOUSE_BTN_UP;
	static bool btn_right_last_state = HID_MOUSE_BTN_UP;
	static bool btn_middle_last_state = HID_MOUSE_BTN_UP;
	static uint8_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED1_GPIO);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED1_GPIO);
	}
	// Scan process running each 2ms
	cpt_sof++;
	if (2 > cpt_sof) {
		return;
	}
	cpt_sof = 0;

	// Scan buttons on switch 7 (left), 6 (middle), 4 (right)
	b_btn_state = (gpio_pin_is_low(GPIO_PUSH_BUTTON_7)) ? HID_MOUSE_BTN_DOWN
			: HID_MOUSE_BTN_UP;
	if (b_btn_state != btn_left_last_state) {
		udi_hid_mouse_btnleft(b_btn_state);
		btn_left_last_state = b_btn_state;
	}
	b_btn_state = (gpio_pin_is_low(GPIO_PUSH_BUTTON_6)) ? HID_MOUSE_BTN_DOWN
			: HID_MOUSE_BTN_UP;
	if (b_btn_state != btn_middle_last_state) {
		udi_hid_mouse_btnmiddle(b_btn_state);
		btn_middle_last_state = b_btn_state;
	}
	b_btn_state = (gpio_pin_is_low(GPIO_PUSH_BUTTON_4)) ? HID_MOUSE_BTN_DOWN
			: HID_MOUSE_BTN_UP;
	if (b_btn_state != btn_right_last_state) {
		udi_hid_mouse_btnright(b_btn_state);
		btn_right_last_state = b_btn_state;
	}
	// Scan move on switch 0 (right), 1 (left), 2 (down), 3 (up)
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_0))
		udi_hid_mouse_moveX(MOUSE_MOVE_RANGE);
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_1))
		udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_2))
		udi_hid_mouse_moveY(MOUSE_MOVE_RANGE);
	if (gpio_pin_is_low(GPIO_PUSH_BUTTON_3))
		udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
}
Ejemplo n.º 8
0
Archivo: ui.c Proyecto: Mazetti/asf
void ui_device_sof_action(void)
{
	uint16_t framenumber;
	static uint8_t cpt_sof = 0;

	if (!ui_device_b_mouse_enable) {
		return;
	}

	framenumber = udd_get_frame_number();
	if ((framenumber % 1000) == 0) {
		LED_On(LED0);
	}

	if ((framenumber % 1000) == 500) {
		LED_Off(LED0);
	}

	/* Scan process running each 2ms */
	cpt_sof++;
	if (2 > cpt_sof) {
		return;
	}

	cpt_sof = 0;

	/* Look touch sensor activity for the X and Y events */
	if (!gpio_pin_is_high(GPIO_PUSH_BUTTON_1)) {
		udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
	}
}
Ejemplo n.º 9
0
Archivo: ui.c Proyecto: scarecrowli/asf
void ui_device_sof_action(void)
{
	uint16_t framenumber;
	static uint8_t cpt_sof = 0;
	static int32_t move_count = MOUSE_MOVE_COUNT;
	static uint8_t move_dir = MOVE_UP;

	if (!ui_device_b_mouse_enable) {
		return;
	}

	framenumber = udd_get_frame_number();
	if ((framenumber % 1000) == 0) {
		LED_On();
	}

	if ((framenumber % 1000) == 500) {
		LED_Off();
	}

	/* Scan process running each 2ms */
	cpt_sof++;
	if (2 > cpt_sof) {
		return;
	}

	cpt_sof = 0;

	/* Uses buttons to move mouse */
	if (!port_pin_get_input_level(BUTTON_0_PIN)) {
		move_count--;
		switch (move_dir) {
		case MOVE_UP:
			udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_RIGHT;
				move_count = MOUSE_MOVE_COUNT;
			}

			break;

		case MOVE_RIGHT:
			udi_hid_mouse_moveX(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_DOWN;
				move_count = MOUSE_MOVE_COUNT;
			}

			break;

		case MOVE_DOWN:
			udi_hid_mouse_moveY(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_LEFT;
				move_count = MOUSE_MOVE_COUNT;
			}

			break;

		case MOVE_LEFT:
			udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_UP;
				move_count = MOUSE_MOVE_COUNT;
			}

			break;
		}
	}
}
Ejemplo n.º 10
0
void ui_process(uint16_t framenumber)
{
	bool b_btn_state, sucess;
	static bool btn_last_state = false;
	static bool sequence_running = false;
	static uint8_t u8_sequence_pos = 0;
	uint8_t u8_value;
	static uint16_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED0);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED0);
	}
	/* Scan process running each 2ms */
	cpt_sof++;
	if ((cpt_sof % 2) == 0) {
		return;
	}

	/* Uses buttons to move mouse */
	if (!ioport_get_pin_level(GPIO_PUSH_BUTTON_1)) {
		move_count --;
		switch(move_dir) {
		case MOVE_UP:
			udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_RIGHT;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_RIGHT:
			udi_hid_mouse_moveX(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_DOWN;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_DOWN:
			udi_hid_mouse_moveY(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_LEFT;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		case MOVE_LEFT:
			udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_UP;
				move_count = MOUSE_MOVE_COUNT;
			}
			break;
		}
	}
	
	/* Both buttons down to send keys sequence */
	b_btn_state = (!ioport_get_pin_level(GPIO_PUSH_BUTTON_1));
	if (b_btn_state != btn_last_state) {
		btn_last_state = b_btn_state;
		sequence_running = true;
	}

	/* Sequence process running each period */
	if (SEQUENCE_PERIOD > cpt_sof) {
		return;
	}
	cpt_sof = 0;

	if (sequence_running) {
		/* Send next key */
		u8_value = ui_sequence[u8_sequence_pos].u8_value;
		if (u8_value!=0) {
			if (ui_sequence[u8_sequence_pos].b_modifier) {
				if (ui_sequence[u8_sequence_pos].b_down) {
					sucess = udi_hid_kbd_modifier_down(u8_value);
				} else {
					sucess = udi_hid_kbd_modifier_up(u8_value);
				}
			} else {
				if (ui_sequence[u8_sequence_pos].b_down) {
					sucess = udi_hid_kbd_down(u8_value);
				} else {
					sucess = udi_hid_kbd_up(u8_value);
				}
			}
			if (!sucess) {
				return; /* Retry it on next schedule */
			}
		}
		/* Valid sequence position */
		u8_sequence_pos++;
		if (u8_sequence_pos >=
			sizeof(ui_sequence) / sizeof(ui_sequence[0])) {
			u8_sequence_pos = 0;
			sequence_running = false;
		}
	}
}
Ejemplo n.º 11
0
/**
 * @brief Notify the application when ZID report data is received from the paired device.
 *  
 * @param PairingRef Pairing reference.
 * @param num_report_records number of Report records.
 * @param *zid_report_data_record_ptr pointer to the report data received.
 * @param  RxLinkQuality    LQI value of the report data frame.
 * @param  RxFlags          Receive flags.
 */
static void zid_report_data_indication(uint8_t PairingRef, uint8_t num_report_records,
                                                zid_report_data_record_t *zid_report_data_record_ptr, uint8_t RxLinkQuality, uint8_t RxFlags)
{          
   
                  
                  
     for(uint8_t i=0;i<num_report_records;i++)
     {  
    
         switch(zid_report_data_record_ptr->report_desc_identifier)
         {
         case MOUSE:
         {
            
             mouse_desc_t *mouse_desc;
             mouse_desc = (mouse_desc_t *)zid_report_data_record_ptr->report_data;
			 
				udi_hid_mouse_btnleft(mouse_desc->button0); 
				udi_hid_mouse_btnright(mouse_desc->button1);
			   
				if((0x80==(mouse_desc->button2)))
				{   
					udi_hid_mouse_moveScroll((mouse_desc->y_coordinate));
					mouse_desc->y_coordinate = 0;
				}
				else if(0x01==(mouse_desc->button2))
				{ 
					udi_hid_mouse_btnmiddle(0x01);
				}
				udi_hid_mouse_moveX((mouse_desc->x_coordinate));
				udi_hid_mouse_moveY((mouse_desc->y_coordinate));
			 
          
             break;
         }
         case KEYBOARD:
         {
             if(zid_report_data_record_ptr->report_type == INPUT)
             {
                 
                 keyboard_input_desc_t *keyboard_input_desc;
                 keyboard_input_desc = (keyboard_input_desc_t *)zid_report_data_record_ptr->report_data;
                    if(main_b_kbd_enable)
                    {   
						if(keyboard_input_desc->modifier_keys)
						{
							udi_hid_kbd_modifier_down(keyboard_input_desc->modifier_keys);
							udi_hid_kbd_modifier_up(keyboard_input_desc->modifier_keys);
						}
					                    
						for(uint8_t j=0;j<4;j++)
						{  
							if(keyboard_input_desc->key_code[j])
							{    
								udi_hid_kbd_down(keyboard_input_desc->key_code[j]);
								udi_hid_kbd_up(keyboard_input_desc->key_code[j]);
							}   
                   
						}
						uint16_t u_value;
						u_value= convert_byte_array_to_16_bit(&(keyboard_input_desc->key_code[4]));
						if(u_value)
						{   
							udi_hid_mkbd_modifier_down(u_value);
							udi_hid_mkbd_modifier_up(u_value);
						}
					}
              
             }
             else
             {
                /* Application can implement for other report types.*/
             }
             break;
         }
         default:
		 break;
         }
         zid_report_data_record_ptr++;
     }

    RxLinkQuality = RxLinkQuality;
    RxFlags = RxFlags;

}
Ejemplo n.º 12
0
void ui_process(uint16_t framenumber)
{
    bool b_btn_state, sucess;
    static bool btn_last_state = false;
    static bool sequence_running = false;
    static uint8_t u8_sequence_pos = 0;
    uint8_t u8_value;
    static uint16_t cpt_sof = 0;

    if ((framenumber % 1000) == 0) {
        LED_On(LED0_GPIO);
    }
    if ((framenumber % 1000) == 500) {
        LED_Off(LED0_GPIO);
    }
    // Scan process running each 2ms
    cpt_sof++;
    if ((cpt_sof % 2) == 0) {
        return;
    }

    // Uses buttons to move mouse
    if (!gpio_pin_is_high(GPIO_PUSH_BUTTON_1)) {
        udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
    }
    if (!gpio_pin_is_high(GPIO_PUSH_BUTTON_2)) {
        udi_hid_mouse_moveX( MOUSE_MOVE_RANGE);
    }

    // Both buttons down to send keys sequence
    b_btn_state = (!gpio_pin_is_high(GPIO_PUSH_BUTTON_1)
                   && !gpio_pin_is_high(GPIO_PUSH_BUTTON_2));
    if (b_btn_state != btn_last_state) {
        btn_last_state = b_btn_state;
        sequence_running = true;
    }

    // Sequence process running each period
    if (SEQUENCE_PERIOD > cpt_sof) {
        return;
    }
    cpt_sof = 0;

    if (sequence_running) {
        // Send next key
        u8_value = ui_sequence[u8_sequence_pos].u8_value;
        if (u8_value!=0) {
            if (ui_sequence[u8_sequence_pos].b_modifier) {
                if (ui_sequence[u8_sequence_pos].b_down) {
                    sucess = udi_hid_kbd_modifier_down(u8_value);
                } else {
                    sucess = udi_hid_kbd_modifier_up(u8_value);
                }
            } else {
                if (ui_sequence[u8_sequence_pos].b_down) {
                    sucess = udi_hid_kbd_down(u8_value);
                } else {
                    sucess = udi_hid_kbd_up(u8_value);
                }
            }
            if (!sucess) {
                return; // Retry it on next schedule
            }
        }
        // Valid sequence position
        u8_sequence_pos++;
        if (u8_sequence_pos >=
                sizeof(ui_sequence) / sizeof(ui_sequence[0])) {
            u8_sequence_pos = 0;
            sequence_running = false;
        }
    }
}
Ejemplo n.º 13
0
Archivo: ui.c Proyecto: kerichsen/asf
/**
 * \brief Process the user interface
 *
 * This function processes user touch events and updates the display.
 *
 * The first registered touch is used to control the cursor. Its presence is
 * indicated with a red frame around the display. When the cursor touch moves,
 * its movement is visualized with a trace on the display.
 *
 * The second registered touch is used to control mouse buttons, and is
 * indicated with an inner frame of which the color depends on which side the
 * touch is for: blue for left and green for right button click. The frame is
 * shown until the touch is released.
 * To detect which side click it is, the position relative to the cursor touch
 * is used, i.e., a touch to the left of the first touch will cause a left
 * mouse click.
 *
 * \param framenumber Current USB frame number
 *
 * \note This function should be called every millisecond, e.g., for each USB
 * frame.
 */
void ui_process(uint16_t framenumber)
{
	static bool process_traces = false;
	static bool register_trace = false;
	static bool left_press = true;
	static gfx_coord_t old_x;
	static gfx_coord_t old_y;
	uint16_t blink_frame;
	uint8_t new_x_pos;
	uint8_t new_y_pos;

	/* Blink LED1 at 1 Hz (toggle every 500 frames) */
	blink_frame = framenumber % 1000;
	if (blink_frame == 0) {
		LED_On(LED1_GPIO);
	} else if (blink_frame == 500) {
		LED_Off(LED1_GPIO);
	}

	/* Interleave processing of traces and touch events so they are each
	 * handled every 2 milliseconds.
	 */
	if (process_traces) {
		process_traces = false;

		/* Is there a new trace to register? */
		if (register_trace) {
			handle_trace(old_x, old_y);
		/* No new trace, clear an old one */
		} else {
			handle_trace(0, 0);
		}

		/* Return now, don't process touches */
		return;
	}

	/* Process traces in next iteration */
	process_traces = true;
	register_trace = false;

	/* Process new touch, if it was flagged */
	if (ui_new_touch_event) {
		ui_new_touch_event = false;

		/* Is event for first finger on display? */
		if (ui_touch_event.id == 0) {
			/* Upon new press, draw red frame */
			if (ui_touch_event.status & MXT_PRESS_EVENT) {
				old_x = ui_touch_event.x;
				old_y = ui_touch_event.y;
				draw_frame(0, 2, GFX_COLOR_RED);

			/* Upon release, erase red frame */
			} else if (ui_touch_event.status & MXT_RELEASE_EVENT) {
				draw_frame(0, 2, COLOR_BACKGROUND);

			/* Upon move, update mouse position and display trace */
			} else if (ui_touch_event.status & MXT_DETECT_EVENT) {
				/* Scale the relative position down to get a
				 * sensible cursor speed.
				 */
				new_x_pos = (ui_touch_event.x - old_x) >> 2;
				new_y_pos = (ui_touch_event.y - old_y) >> 2;

				udi_hid_mouse_moveX(new_x_pos);
				udi_hid_mouse_moveY(new_y_pos);

				old_x = ui_touch_event.x;
				old_y = ui_touch_event.y;

				register_trace = true;
			}
		}

		/* Is event for second finger on display? */
		if (ui_touch_event.id == 1) {
			/* For new press, signal a left or right mouse button
			 * press depending on which side of the cursor it's on
			 */
			if (ui_touch_event.status & MXT_PRESS_EVENT) {
				/* Left click? */
				if (ui_touch_event.x <= old_x) {
					left_press = true;
					udi_hid_mouse_btnleft(HID_MOUSE_BTN_DOWN);

					/* Draw a blue inner-frame */
					draw_frame(2, 2, GFX_COLOR_BLUE);

				/* Must otherwise be a right click. */
				} else {
					left_press = false;
					udi_hid_mouse_btnright(HID_MOUSE_BTN_DOWN);

					/* Draw a green inner-frame */
					draw_frame(2, 2, GFX_COLOR_GREEN);
				}
			}

			/* For release, signal release of the mouse button */
			if (ui_touch_event.status & MXT_RELEASE_EVENT) {
				if (left_press) {
					udi_hid_mouse_btnleft(HID_MOUSE_BTN_UP);
				} else {
					udi_hid_mouse_btnright(HID_MOUSE_BTN_UP);
				}

				/* Erase blue/green inner-frame */
				draw_frame(2, 2, COLOR_BACKGROUND);
			}
		}
	}