Merge branch 'master' into ICPad

Integrating upstream changes into PixelMap modifications
This commit is contained in:
Jacob Alexander 2016-04-19 15:02:01 -07:00
commit 8ed4daa2c6
20 changed files with 531 additions and 178 deletions

View file

@ -309,37 +309,33 @@ static uint8_t sys_ctrl_report_desc[] = {
static uint8_t mouse_report_desc[] = {
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)
0xa1, 0x01, // Collection (Application)
0xA1, 0x01, // Collection (Application)
0x09, 0x02, // Usage (Mouse)
0xa1, 0x02, // Collection (Logical)
0xA1, 0x02, // Collection (Logical)
0x09, 0x01, // Usage (Pointer)
// Buttons (5 bits)
0xa1, 0x00, // Collection (Physical) - Buttons
// Buttons (16 bits)
0xA1, 0x00, // Collection (Physical) - Buttons
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (Button 1)
0x29, 0x05, // Usage Maximum (Button 5)
0x29, 0x10, // Usage Maximum (Button 16)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x05, // Report Count (5)
0x95, 0x10, // Report Count (16)
0x81, 0x02, // Input (Data,Var,Abs)
// Padding (3 bits)
0x75, 0x03, // Report Size (3)
0x95, 0x01, // Report Count (1)
0x81, 0x03, // Input (Cnst,Var,Abs)
// Pointer (16 bits)
// Pointer (32 bits)
0x05, 0x01, // Usage PAGE (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7f, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x16, 0x01, 0x80, // Logical Minimum (-32 767)
0x26, 0xFF, 0x7F, // Logical Maximum (32 767)
0x75, 0x10, // Report Size (16)
0x95, 0x02, // Report Count (2)
0x81, 0x06, // Input (Data,Var,Rel)
/*
// Vertical Wheel
// - Multiplier (2 bits)
0xa1, 0x02, // Collection (Logical)
@ -382,6 +378,7 @@ static uint8_t mouse_report_desc[] = {
0x81, 0x06, // Input (Data,Var,Rel)
0xc0, // End Collection - Horizontal Wheel
*/
0xc0, // End Collection - Buttons
0xc0, // End Collection - Mouse Logical
0xc0 // End Collection - Mouse Application

View file

@ -1,7 +1,7 @@
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2013 PJRC.COM, LLC.
* Modified by Jacob Alexander (2015)
* Modified by Jacob Alexander (2015-2016)
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -115,38 +115,78 @@
// ----- Variables -----
// which buttons are currently pressed
uint8_t usb_mouse_buttons_state=0;
static uint8_t transmit_previous_timeout = 0;
static uint16_t usb_mouse_resolution_x=DEFAULT_XRES;
static uint16_t usb_mouse_resolution_y=DEFAULT_YRES;
static uint16_t usb_mouse_position_x=DEFAULT_XRES/2;
static uint16_t usb_mouse_position_y=DEFAULT_YRES/2;
static uint32_t usb_mouse_scale_x=DEFAULT_XSCALE;
static uint32_t usb_mouse_scale_y=DEFAULT_YSCALE;
static uint32_t usb_mouse_offset_x=DEFAULT_XSCALE/2-1;
static uint32_t usb_mouse_offset_y=DEFAULT_YSCALE/2-1;
// which buttons are currently pressed
uint8_t usb_mouse_buttons_state = 0;
static uint16_t usb_mouse_resolution_x = DEFAULT_XRES;
static uint16_t usb_mouse_resolution_y = DEFAULT_YRES;
static uint16_t usb_mouse_position_x = DEFAULT_XRES / 2;
static uint16_t usb_mouse_position_y = DEFAULT_YRES / 2;
static uint32_t usb_mouse_scale_x = DEFAULT_XSCALE;
static uint32_t usb_mouse_scale_y = DEFAULT_YSCALE;
static uint32_t usb_mouse_offset_x = DEFAULT_XSCALE / 2 - 1;
static uint32_t usb_mouse_offset_y = DEFAULT_YSCALE / 2 - 1;
// ----- Functions -----
// Set the mouse buttons. To create a "click", 2 calls are needed,
// one to push the button down and the second to release it
int usb_mouse_buttons(uint8_t left, uint8_t middle, uint8_t right)
// Process pending mouse commands
// XXX Missing mouse movement and wheels
// Proper support will require KLL generation of the USB descriptors
// Similar support will be required for joystick control
void usb_mouse_send()
{
uint8_t mask=0;
uint32_t wait_count = 0;
usb_packet_t *tx_packet;
if (left) mask |= 1;
if (middle) mask |= 4;
if (right) mask |= 2;
usb_mouse_buttons_state = mask;
return usb_mouse_move(0, 0, 0);
// Wait till ready
while ( 1 )
{
if ( !usb_configuration )
{
erro_print("USB not configured...");
return;
}
// Attempt to acquire a USB packet for the mouse endpoint
if ( usb_tx_packet_count( MOUSE_ENDPOINT ) < TX_PACKET_LIMIT )
{
tx_packet = usb_malloc();
if ( tx_packet )
break;
}
if ( ++wait_count > TX_TIMEOUT || transmit_previous_timeout )
{
transmit_previous_timeout = 1;
warn_print("USB Transmit Timeout...");
return;
}
yield();
}
transmit_previous_timeout = 0;
// Prepare USB Mouse Packet
// TODO Dynamically generate this code based on KLL requirements
uint16_t *packet_data = (uint16_t*)(&tx_packet->buf[0]);
packet_data[0] = USBMouse_Buttons;
packet_data[1] = USBMouse_Relative_x;
packet_data[2] = USBMouse_Relative_y;
tx_packet->len = 6;
usb_tx( MOUSE_ENDPOINT, tx_packet );
// Clear status and state
USBMouse_Buttons = 0;
USBMouse_Relative_x = 0;
USBMouse_Relative_y = 0;
USBMouse_Changed = 0;
}
static uint8_t transmit_previous_timeout=0;
// Move the mouse. x, y and wheel are -127 to 127. Use 0 for no movement.
int usb_mouse_move(int8_t x, int8_t y, int8_t wheel)
{

View file

@ -1,7 +1,7 @@
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2013 PJRC.COM, LLC.
* Modified by Jacob Alexander (2015)
* Modified by Jacob Alexander (2015-2016)
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -43,16 +43,11 @@
// ----- Functions -----
// Proces pending mouse commands
void usb_mouse_send();
// TODO - More generic
int usb_mouse_buttons( uint8_t left, uint8_t middle, uint8_t right );
int usb_mouse_move( int8_t x, int8_t y, int8_t wheel );
int usb_mouse_position( uint16_t x, uint16_t y );
void usb_mouse_screen_size( uint16_t width, uint16_t height, uint8_t mac );
extern uint8_t usb_mouse_buttons_state;
// TODO - Move
#define MOUSE_LEFT 1
#define MOUSE_MIDDLE 4
#define MOUSE_RIGHT 2
#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)