Adding basic mouse button support
- Full Mouse support will have to wait for KLL 0.6 * This will include dynamic HID descriptor generation for many wheels and axis depending on the KLL needs - HID descriptor is currently limited to 8 buttons - Technically mouse movement also works (tested by accident), but it's disable for now (needs some API thought) - Adding additional udev rules - Added KRO mode default define
This commit is contained in:
parent
0102d05c86
commit
3c9a97d51a
@ -2,20 +2,26 @@
|
|||||||
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{ID_MM_DEVICE_IGNORE}="1"
|
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||||
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{MTP_NO_PROBE}="1"
|
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{MTP_NO_PROBE}="1"
|
||||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666"
|
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666"
|
||||||
|
|
||||||
# Kiibohd Serial Interface
|
# Kiibohd Serial Interface
|
||||||
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", SYMLINK+="kiibohd", MODE:="0666",
|
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", SYMLINK+="kiibohd", MODE:="0666",
|
||||||
KERNEL=="ttyACM*", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b04d", SYMLINK+="kiibohd", MODE:="0666"
|
KERNEL=="ttyACM*", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b04d", SYMLINK+="kiibohd", MODE:="0666"
|
||||||
KERNEL=="ttyACM*", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="f05c", SYMLINK+="kiibohd", MODE:="0666"
|
KERNEL=="ttyACM*", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="f05c", SYMLINK+="kiibohd", MODE:="0666"
|
||||||
|
|
||||||
# Kiibohd Device
|
# Kiibohd Device
|
||||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b04d", MODE:="0666"
|
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b04d", MODE:="0666"
|
||||||
|
|
||||||
# DFU Bootloader (MCHCK)
|
# DFU Bootloader (MCHCK)
|
||||||
ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", ENV{ID_MM_DEVICE_IGNORE}="1"
|
ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||||
ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", ENV{MTP_NO_PROBE}="1"
|
ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", ENV{MTP_NO_PROBE}="1"
|
||||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", MODE:="0666"
|
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", MODE:="0666"
|
||||||
|
|
||||||
# Kiibohd DFU Bootloader
|
# Kiibohd DFU Bootloader
|
||||||
ATTRS{idVendor}=="1C11", ATTRS{idProduct}=="b007", ENV{ID_MM_DEVICE_IGNORE}="1"
|
ATTRS{idVendor}=="1C11", ATTRS{idProduct}=="b007", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||||
ATTRS{idVendor}=="1C11", ATTRS{idProduct}=="b007", ENV{MTP_NO_PROBE}="1"
|
ATTRS{idVendor}=="1C11", ATTRS{idProduct}=="b007", ENV{MTP_NO_PROBE}="1"
|
||||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b007", MODE:="0666"
|
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b007", MODE:="0666"
|
||||||
|
|
||||||
# Kiibohd Force Gauge
|
# Kiibohd Force Gauge
|
||||||
SUBSYSTEM=="tty", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="f05c", GROUP="users", MODE="0666", SYMLINK+="force"
|
SUBSYSTEM=="tty", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="f05c", GROUP="users", MODE="0666", SYMLINK+="force"
|
||||||
|
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="f05c", MODE:="0666"
|
||||||
|
|
||||||
|
@ -314,22 +314,17 @@ static uint8_t mouse_report_desc[] = {
|
|||||||
0xa1, 0x02, // Collection (Logical)
|
0xa1, 0x02, // Collection (Logical)
|
||||||
0x09, 0x01, // Usage (Pointer)
|
0x09, 0x01, // Usage (Pointer)
|
||||||
|
|
||||||
// Buttons (5 bits)
|
// Buttons (8 bits)
|
||||||
0xa1, 0x00, // Collection (Physical) - Buttons
|
0xa1, 0x00, // Collection (Physical) - Buttons
|
||||||
0x05, 0x09, // Usage Page (Button)
|
0x05, 0x09, // Usage Page (Button)
|
||||||
0x19, 0x01, // Usage Minimum (Button 1)
|
0x19, 0x01, // Usage Minimum (Button 1)
|
||||||
0x29, 0x05, // Usage Maximum (Button 5)
|
0x29, 0x08, // Usage Maximum (Button 8)
|
||||||
0x15, 0x00, // Logical Minimum (0)
|
0x15, 0x00, // Logical Minimum (0)
|
||||||
0x25, 0x01, // Logical Maximum (1)
|
0x25, 0x01, // Logical Maximum (1)
|
||||||
0x75, 0x01, // Report Size (1)
|
0x75, 0x01, // Report Size (1)
|
||||||
0x95, 0x05, // Report Count (5)
|
0x95, 0x08, // Report Count (8)
|
||||||
0x81, 0x02, // Input (Data,Var,Abs)
|
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 (16 bits)
|
||||||
0x05, 0x01, // Usage PAGE (Generic Desktop)
|
0x05, 0x01, // Usage PAGE (Generic Desktop)
|
||||||
0x09, 0x30, // Usage (X)
|
0x09, 0x30, // Usage (X)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* Teensyduino Core Library
|
/* Teensyduino Core Library
|
||||||
* http://www.pjrc.com/teensy/
|
* http://www.pjrc.com/teensy/
|
||||||
* Copyright (c) 2013 PJRC.COM, LLC.
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@ -115,38 +115,78 @@
|
|||||||
|
|
||||||
// ----- Variables -----
|
// ----- Variables -----
|
||||||
|
|
||||||
// which buttons are currently pressed
|
static uint8_t transmit_previous_timeout = 0;
|
||||||
uint8_t usb_mouse_buttons_state=0;
|
|
||||||
|
|
||||||
static uint16_t usb_mouse_resolution_x=DEFAULT_XRES;
|
// which buttons are currently pressed
|
||||||
static uint16_t usb_mouse_resolution_y=DEFAULT_YRES;
|
uint8_t usb_mouse_buttons_state = 0;
|
||||||
static uint16_t usb_mouse_position_x=DEFAULT_XRES/2;
|
|
||||||
static uint16_t usb_mouse_position_y=DEFAULT_YRES/2;
|
static uint16_t usb_mouse_resolution_x = DEFAULT_XRES;
|
||||||
static uint32_t usb_mouse_scale_x=DEFAULT_XSCALE;
|
static uint16_t usb_mouse_resolution_y = DEFAULT_YRES;
|
||||||
static uint32_t usb_mouse_scale_y=DEFAULT_YSCALE;
|
static uint16_t usb_mouse_position_x = DEFAULT_XRES / 2;
|
||||||
static uint32_t usb_mouse_offset_x=DEFAULT_XSCALE/2-1;
|
static uint16_t usb_mouse_position_y = DEFAULT_YRES / 2;
|
||||||
static uint32_t usb_mouse_offset_y=DEFAULT_YSCALE/2-1;
|
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 -----
|
// ----- Functions -----
|
||||||
|
|
||||||
// Set the mouse buttons. To create a "click", 2 calls are needed,
|
// Process pending mouse commands
|
||||||
// one to push the button down and the second to release it
|
// XXX Missing mouse movement and wheels
|
||||||
int usb_mouse_buttons(uint8_t left, uint8_t middle, uint8_t right)
|
// 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;
|
// Wait till ready
|
||||||
if (middle) mask |= 4;
|
while ( 1 )
|
||||||
if (right) mask |= 2;
|
{
|
||||||
usb_mouse_buttons_state = mask;
|
if ( !usb_configuration )
|
||||||
return usb_mouse_move(0, 0, 0);
|
{
|
||||||
|
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 Document each byte
|
||||||
|
// TODO Dynamically generate this code based on KLL requirements
|
||||||
|
*(tx_packet->buf + 0) = USBMouse_Buttons;
|
||||||
|
*(tx_packet->buf + 1) = 0;
|
||||||
|
*(tx_packet->buf + 2) = 0;
|
||||||
|
*(tx_packet->buf + 3) = 0;
|
||||||
|
*(tx_packet->buf + 4) = 0;
|
||||||
|
tx_packet->len = 5;
|
||||||
|
usb_tx( MOUSE_ENDPOINT, tx_packet );
|
||||||
|
|
||||||
|
// Clear status and state
|
||||||
|
USBMouse_Buttons = 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.
|
// 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)
|
int usb_mouse_move(int8_t x, int8_t y, int8_t wheel)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* Teensyduino Core Library
|
/* Teensyduino Core Library
|
||||||
* http://www.pjrc.com/teensy/
|
* http://www.pjrc.com/teensy/
|
||||||
* Copyright (c) 2013 PJRC.COM, LLC.
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@ -43,16 +43,11 @@
|
|||||||
|
|
||||||
// ----- Functions -----
|
// ----- Functions -----
|
||||||
|
|
||||||
|
// Proces pending mouse commands
|
||||||
|
void usb_mouse_send();
|
||||||
|
|
||||||
// TODO - More generic
|
// 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_move( int8_t x, int8_t y, int8_t wheel );
|
||||||
int usb_mouse_position( uint16_t x, uint16_t y );
|
int usb_mouse_position( uint16_t x, uint16_t y );
|
||||||
void usb_mouse_screen_size( uint16_t width, uint16_t height, uint8_t mac );
|
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)
|
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
Name = pjrcUSBCapabilities;
|
Name = pjrcUSBCapabilities;
|
||||||
Version = 0.6;
|
Version = 0.7;
|
||||||
Author = "HaaTa (Jacob Alexander) 2014-2015";
|
Author = "HaaTa (Jacob Alexander) 2014-2016";
|
||||||
KLL = 0.3c;
|
KLL = 0.3d;
|
||||||
|
|
||||||
# Modified Date
|
# Modified Date
|
||||||
Date = 2015-08-21;
|
Date = 2016-03-20;
|
||||||
|
|
||||||
|
|
||||||
# Output capabilities
|
# Output capabilities
|
||||||
@ -12,6 +12,7 @@ consCtrlOut => Output_consCtrlSend_capability( consCode : 2 );
|
|||||||
noneOut => Output_noneSend_capability();
|
noneOut => Output_noneSend_capability();
|
||||||
sysCtrlOut => Output_sysCtrlSend_capability( sysCode : 1 );
|
sysCtrlOut => Output_sysCtrlSend_capability( sysCode : 1 );
|
||||||
usbKeyOut => Output_usbCodeSend_capability( usbCode : 1 );
|
usbKeyOut => Output_usbCodeSend_capability( usbCode : 1 );
|
||||||
|
mouseOut => Output_usbMouse_capability( mouseCode : 2 );
|
||||||
|
|
||||||
# Configuration capabilities
|
# Configuration capabilities
|
||||||
kbdProtocolBoot => Output_kbdProtocolBoot_capability();
|
kbdProtocolBoot => Output_kbdProtocolBoot_capability();
|
||||||
@ -21,6 +22,12 @@ kbdProtocolNKRO => Output_kbdProtocolNKRO_capability();
|
|||||||
keyboardLocale => KeyboardLocale_define;
|
keyboardLocale => KeyboardLocale_define;
|
||||||
keyboardLocale = 0;
|
keyboardLocale = 0;
|
||||||
|
|
||||||
|
# Default KRO Mode
|
||||||
|
# Set to 0 for Boot Mode (6KRO)
|
||||||
|
# Set to 1 for NKRO Mode (default)
|
||||||
|
usbProtocol => USBProtocol_define;
|
||||||
|
usbProtocol = 1;
|
||||||
|
|
||||||
# Bootloader Mode capability
|
# Bootloader Mode capability
|
||||||
# XXX
|
# XXX
|
||||||
# By default this is disabled on purpose
|
# By default this is disabled on purpose
|
||||||
|
@ -37,8 +37,12 @@
|
|||||||
#include "arm/usb_dev.h"
|
#include "arm/usb_dev.h"
|
||||||
#include "arm/usb_keyboard.h"
|
#include "arm/usb_keyboard.h"
|
||||||
#include "arm/usb_serial.h"
|
#include "arm/usb_serial.h"
|
||||||
|
#include "arm/usb_mouse.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// KLL
|
||||||
|
#include <kll_defs.h>
|
||||||
|
|
||||||
// Local Includes
|
// Local Includes
|
||||||
#include "output_com.h"
|
#include "output_com.h"
|
||||||
|
|
||||||
@ -47,14 +51,15 @@
|
|||||||
// ----- Macros -----
|
// ----- Macros -----
|
||||||
|
|
||||||
// Used to build a bitmap lookup table from a byte addressable array
|
// Used to build a bitmap lookup table from a byte addressable array
|
||||||
#define byteLookup( byte ) case (( byte ) * ( 8 )): bytePosition = byte; byteShift = 0; break; \
|
#define byteLookup( byte ) \
|
||||||
case (( byte ) * ( 8 ) + ( 1 )): bytePosition = byte; byteShift = 1; break; \
|
case (( byte ) * ( 8 )): bytePosition = byte; byteShift = 0; break; \
|
||||||
case (( byte ) * ( 8 ) + ( 2 )): bytePosition = byte; byteShift = 2; break; \
|
case (( byte ) * ( 8 ) + ( 1 )): bytePosition = byte; byteShift = 1; break; \
|
||||||
case (( byte ) * ( 8 ) + ( 3 )): bytePosition = byte; byteShift = 3; break; \
|
case (( byte ) * ( 8 ) + ( 2 )): bytePosition = byte; byteShift = 2; break; \
|
||||||
case (( byte ) * ( 8 ) + ( 4 )): bytePosition = byte; byteShift = 4; break; \
|
case (( byte ) * ( 8 ) + ( 3 )): bytePosition = byte; byteShift = 3; break; \
|
||||||
case (( byte ) * ( 8 ) + ( 5 )): bytePosition = byte; byteShift = 5; break; \
|
case (( byte ) * ( 8 ) + ( 4 )): bytePosition = byte; byteShift = 4; break; \
|
||||||
case (( byte ) * ( 8 ) + ( 6 )): bytePosition = byte; byteShift = 6; break; \
|
case (( byte ) * ( 8 ) + ( 5 )): bytePosition = byte; byteShift = 5; break; \
|
||||||
case (( byte ) * ( 8 ) + ( 7 )): bytePosition = byte; byteShift = 7; break
|
case (( byte ) * ( 8 ) + ( 6 )): bytePosition = byte; byteShift = 6; break; \
|
||||||
|
case (( byte ) * ( 8 ) + ( 7 )): bytePosition = byte; byteShift = 7; break
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -111,15 +116,21 @@ uint8_t USBKeys_SentCLI = 0;
|
|||||||
// 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana
|
// 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana
|
||||||
volatile uint8_t USBKeys_LEDs = 0;
|
volatile uint8_t USBKeys_LEDs = 0;
|
||||||
|
|
||||||
|
// Currently pressed mouse buttons, bitmask, 0 represents no buttons pressed
|
||||||
|
volatile uint16_t USBMouse_Buttons = 0;
|
||||||
|
|
||||||
// Protocol setting from the host.
|
// Protocol setting from the host.
|
||||||
// 0 - Boot Mode
|
// 0 - Boot Mode
|
||||||
// 1 - NKRO Mode (Default, unless set by a BIOS or boot interface)
|
// 1 - NKRO Mode (Default, unless set by a BIOS or boot interface)
|
||||||
volatile uint8_t USBKeys_Protocol = 1;
|
volatile uint8_t USBKeys_Protocol = USBProtocol_define;
|
||||||
|
|
||||||
// Indicate if USB should send update
|
// Indicate if USB should send update
|
||||||
// OS only needs update if there has been a change in state
|
// OS only needs update if there has been a change in state
|
||||||
USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None;
|
USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None;
|
||||||
|
|
||||||
|
// Indicate if USB should send update
|
||||||
|
uint8_t USBMouse_Changed = 0;
|
||||||
|
|
||||||
// the idle configuration, how often we send the report to the
|
// the idle configuration, how often we send the report to the
|
||||||
// host (ms * 4) even when it hasn't changed
|
// host (ms * 4) even when it hasn't changed
|
||||||
uint8_t USBKeys_Idle_Config = 125;
|
uint8_t USBKeys_Idle_Config = 125;
|
||||||
@ -505,6 +516,48 @@ void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *arg
|
|||||||
Output_firmwareReload();
|
Output_firmwareReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sends a mouse command over the USB Output buffer
|
||||||
|
// XXX This function *will* be changing in the future
|
||||||
|
// If you use it, be prepared that your .kll files will break in the future (post KLL 0.5)
|
||||||
|
// Argument #1: USB Mouse Button #
|
||||||
|
void Output_usbMouse_capability( uint8_t state, uint8_t stateType, uint8_t *args )
|
||||||
|
{
|
||||||
|
// Display capability name
|
||||||
|
if ( stateType == 0xFF && state == 0xFF )
|
||||||
|
{
|
||||||
|
print("Output_usbMouse(mouseButton)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine which mouse button was sent
|
||||||
|
// The USB spec defines up to a max of 0xFFFF buttons
|
||||||
|
// The usual are:
|
||||||
|
// 1 - Button 1 - (Primary)
|
||||||
|
// 2 - Button 2 - (Secondary)
|
||||||
|
// 3 - Button 3 - (Tertiary)
|
||||||
|
uint16_t mouse_button = *(uint16_t*)(&args[0]);
|
||||||
|
|
||||||
|
// If set to zero, ignore
|
||||||
|
if ( mouse_button == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Adjust for bit shift
|
||||||
|
mouse_button -= 1;
|
||||||
|
|
||||||
|
// Only send mouse button if in press or hold state
|
||||||
|
if ( stateType == 0x00 && state == 0x03 ) // Release state
|
||||||
|
{
|
||||||
|
USBMouse_Buttons &= ~(1 << mouse_button);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
USBMouse_Buttons |= (1 << mouse_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Add more states when adding full support
|
||||||
|
USBMouse_Changed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----- Functions -----
|
// ----- Functions -----
|
||||||
@ -552,6 +605,10 @@ inline void Output_send()
|
|||||||
for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ )
|
for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ )
|
||||||
USBKeys_Keys[c] = 0;
|
USBKeys_Keys[c] = 0;
|
||||||
|
|
||||||
|
// Process mouse actions
|
||||||
|
while ( USBMouse_Changed )
|
||||||
|
usb_mouse_send();
|
||||||
|
|
||||||
// Send keypresses while there are pending changes
|
// Send keypresses while there are pending changes
|
||||||
while ( USBKeys_Changed )
|
while ( USBKeys_Changed )
|
||||||
usb_keyboard_send();
|
usb_keyboard_send();
|
||||||
|
@ -72,11 +72,14 @@ extern uint16_t USBKeys_ConsCtrl; // 1KRO container for Consumer Contro
|
|||||||
|
|
||||||
extern volatile uint8_t USBKeys_Protocol; // 0 - Boot Mode, 1 - NKRO Mode
|
extern volatile uint8_t USBKeys_Protocol; // 0 - Boot Mode, 1 - NKRO Mode
|
||||||
|
|
||||||
|
extern volatile uint16_t USBMouse_Buttons; // Bitmask for mouse buttons
|
||||||
|
|
||||||
// Misc variables (XXX Some are only properly utilized using AVR)
|
// Misc variables (XXX Some are only properly utilized using AVR)
|
||||||
extern uint8_t USBKeys_Idle_Config;
|
extern uint8_t USBKeys_Idle_Config;
|
||||||
extern uint8_t USBKeys_Idle_Count;
|
extern uint8_t USBKeys_Idle_Count;
|
||||||
|
|
||||||
extern USBKeyChangeState USBKeys_Changed;
|
extern USBKeyChangeState USBKeys_Changed;
|
||||||
|
extern uint8_t USBMouse_Changed;
|
||||||
|
|
||||||
extern volatile uint8_t Output_Available; // 0 - Output module not fully functional, 1 - Output module working
|
extern volatile uint8_t Output_Available; // 0 - Output module not fully functional, 1 - Output module working
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user