core: Mouse buttons state integration #101
This allows users to use mousekey buttons with PS/2, ADB or Serial pointing device.
This commit is contained in:
parent
b981b8e266
commit
5f7d388dee
12 changed files with 86 additions and 0 deletions
|
|
@ -414,6 +414,11 @@ void adb_mouse_task(void)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t adb_mouse_buttons(void)
|
||||||
|
{
|
||||||
|
return mouse_report.buttons;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t matrix_scan(void)
|
uint8_t matrix_scan(void)
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,14 @@ action_t action_for_key(uint8_t layer, keypos_t key)
|
||||||
return (action_t){ .code = pgm_read_word(&actionmaps[(layer)][key.row & 0x07][key.col & 0x0F]) };
|
return (action_t){ .code = pgm_read_word(&actionmaps[(layer)][key.row & 0x07][key.col & 0x0F]) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IBMPC_MOUSE_ENABLE
|
||||||
|
static uint8_t last_buttons;
|
||||||
|
uint8_t ibmpc_mouse_buttons(void)
|
||||||
|
{
|
||||||
|
return last_buttons;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void IBMPCConverter::set_led(uint8_t usb_led)
|
void IBMPCConverter::set_led(uint8_t usb_led)
|
||||||
{
|
{
|
||||||
|
|
@ -607,6 +615,7 @@ MOUSE_DONE:
|
||||||
mouse_report.v = -CHOP8(v);
|
mouse_report.v = -CHOP8(v);
|
||||||
mouse_report.h = CHOP8(h);
|
mouse_report.h = CHOP8(h);
|
||||||
host_mouse_send(&mouse_report);
|
host_mouse_send(&mouse_report);
|
||||||
|
last_buttons = mouse_report.buttons;
|
||||||
xprintf("M[x:%d y:%d v:%d h:%d b:%02X]\n", mouse_report.x, mouse_report.y,
|
xprintf("M[x:%d y:%d v:%d h:%d b:%02X]\n", mouse_report.x, mouse_report.y,
|
||||||
mouse_report.v, mouse_report.h, mouse_report.buttons);
|
mouse_report.v, mouse_report.h, mouse_report.buttons);
|
||||||
break; }
|
break; }
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@
|
||||||
#define ROW(code) ((code>>4)&0x07)
|
#define ROW(code) ((code>>4)&0x07)
|
||||||
#define COL(code) (code&0x0F)
|
#define COL(code) (code&0x0F)
|
||||||
|
|
||||||
|
#ifdef IBMPC_MOUSE_ENABLE
|
||||||
|
extern "C" uint8_t ibmpc_mouse_buttons(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class IBMPCConverter {
|
class IBMPCConverter {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#ifdef MOUSEKEY_ENABLE
|
||||||
|
# include "mousekey.h"
|
||||||
|
#endif
|
||||||
|
#ifdef PS2_MOUSE_ENABLE
|
||||||
|
# include "ps2_mouse.h"
|
||||||
|
#endif
|
||||||
|
#ifdef SERIAL_MOUSE_ENABLE
|
||||||
|
# include "serial_mouse.h"
|
||||||
|
#endif
|
||||||
|
#ifdef ADB_MOUSE_ENABLE
|
||||||
|
# include "adb.h"
|
||||||
|
#endif
|
||||||
|
#ifdef IBMPC_MOUSE_ENABLE
|
||||||
|
uint8_t ibmpc_mouse_buttons(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE)
|
#if defined(NKRO_ENABLE) || defined(NKRO_6KRO_ENABLE)
|
||||||
bool keyboard_nkro = true;
|
bool keyboard_nkro = true;
|
||||||
|
|
@ -70,7 +86,26 @@ void host_mouse_send(report_mouse_t *report)
|
||||||
report->boot_x = (report->x > 127) ? 127 : ((report->x < -127) ? -127 : report->x);
|
report->boot_x = (report->x > 127) ? 127 : ((report->x < -127) ? -127 : report->x);
|
||||||
report->boot_y = (report->y > 127) ? 127 : ((report->y < -127) ? -127 : report->y);
|
report->boot_y = (report->y > 127) ? 127 : ((report->y < -127) ? -127 : report->y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Mouse buttons integration */
|
||||||
|
uint8_t b = report->buttons;
|
||||||
|
#ifdef MOUSEKEY_ENABLE
|
||||||
|
report->buttons |= mousekey_buttons();
|
||||||
|
#endif
|
||||||
|
#ifdef PS2_MOUSE_ENABLE
|
||||||
|
report->buttons |= ps2_mouse_buttons();
|
||||||
|
#endif
|
||||||
|
#ifdef SERIAL_MOUSE_ENABLE
|
||||||
|
report->buttons |= serial_mouse_buttons();
|
||||||
|
#endif
|
||||||
|
#ifdef ADB_MOUSE_ENABLE
|
||||||
|
report->buttons |= adb_mouse_buttons();
|
||||||
|
#endif
|
||||||
|
#ifdef IBMPC_MOUSE_ENABLE
|
||||||
|
report->buttons |= ibmpc_mouse_buttons();
|
||||||
|
#endif
|
||||||
(*driver->send_mouse)(report);
|
(*driver->send_mouse)(report);
|
||||||
|
report->buttons = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void host_system_send(uint16_t report)
|
void host_system_send(uint16_t report)
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,11 @@ void mousekey_clear(void)
|
||||||
mousekey_accel = 0;
|
mousekey_accel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t mousekey_buttons(void)
|
||||||
|
{
|
||||||
|
return mouse_report.buttons;
|
||||||
|
}
|
||||||
|
|
||||||
static void mousekey_debug(void)
|
static void mousekey_debug(void)
|
||||||
{
|
{
|
||||||
if (!debug_mouse) return;
|
if (!debug_mouse) return;
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ void mousekey_on(uint8_t code);
|
||||||
void mousekey_off(uint8_t code);
|
void mousekey_off(uint8_t code);
|
||||||
void mousekey_clear(void);
|
void mousekey_clear(void);
|
||||||
void mousekey_send(void);
|
void mousekey_send(void);
|
||||||
|
uint8_t mousekey_buttons(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ void adb_host_reset_hard(void);
|
||||||
void adb_host_kbd_led(uint8_t addr, uint8_t led);
|
void adb_host_kbd_led(uint8_t addr, uint8_t led);
|
||||||
void adb_mouse_task(void);
|
void adb_mouse_task(void);
|
||||||
void adb_mouse_init(void);
|
void adb_mouse_init(void);
|
||||||
|
uint8_t adb_mouse_buttons(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
static report_mouse_t mouse_report = {};
|
static report_mouse_t mouse_report = {};
|
||||||
|
static uint8_t last_buttons;
|
||||||
|
|
||||||
|
|
||||||
static void print_usb_data(void);
|
static void print_usb_data(void);
|
||||||
|
|
@ -161,6 +162,7 @@ void ps2_mouse_task(void)
|
||||||
|
|
||||||
|
|
||||||
host_mouse_send(&mouse_report);
|
host_mouse_send(&mouse_report);
|
||||||
|
last_buttons = mouse_report.buttons;
|
||||||
print_usb_data();
|
print_usb_data();
|
||||||
}
|
}
|
||||||
// clear report
|
// clear report
|
||||||
|
|
@ -171,6 +173,11 @@ void ps2_mouse_task(void)
|
||||||
mouse_report.buttons = 0;
|
mouse_report.buttons = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t ps2_mouse_buttons(void)
|
||||||
|
{
|
||||||
|
return last_buttons;
|
||||||
|
}
|
||||||
|
|
||||||
static void print_usb_data(void)
|
static void print_usb_data(void)
|
||||||
{
|
{
|
||||||
if (!debug_mouse) return;
|
if (!debug_mouse) return;
|
||||||
|
|
|
||||||
|
|
@ -62,5 +62,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
uint8_t ps2_mouse_init(void);
|
uint8_t ps2_mouse_init(void);
|
||||||
void ps2_mouse_task(void);
|
void ps2_mouse_task(void);
|
||||||
|
uint8_t ps2_mouse_buttons(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -29,5 +29,6 @@ static inline uint8_t serial_mouse_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_mouse_task(void);
|
void serial_mouse_task(void);
|
||||||
|
uint8_t serial_mouse_buttons(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#endif
|
#endif
|
||||||
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
|
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
|
||||||
|
|
||||||
|
static uint8_t last_buttons;
|
||||||
static void print_usb_data(const report_mouse_t *report);
|
static void print_usb_data(const report_mouse_t *report);
|
||||||
|
|
||||||
void serial_mouse_task(void)
|
void serial_mouse_task(void)
|
||||||
|
|
@ -71,6 +72,7 @@ void serial_mouse_task(void)
|
||||||
|
|
||||||
print_usb_data(&report);
|
print_usb_data(&report);
|
||||||
host_mouse_send(&report);
|
host_mouse_send(&report);
|
||||||
|
last_buttons = report.buttons;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,6 +113,12 @@ void serial_mouse_task(void)
|
||||||
|
|
||||||
print_usb_data(&report);
|
print_usb_data(&report);
|
||||||
host_mouse_send(&report);
|
host_mouse_send(&report);
|
||||||
|
last_buttons = report.buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t serial_mouse_buttons(void)
|
||||||
|
{
|
||||||
|
return last_buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_usb_data(const report_mouse_t *report)
|
static void print_usb_data(const report_mouse_t *report)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//#define SERIAL_MOUSE_CENTER_SCROLL
|
//#define SERIAL_MOUSE_CENTER_SCROLL
|
||||||
|
|
||||||
|
static uint8_t last_buttons;
|
||||||
static void print_usb_data(const report_mouse_t *report);
|
static void print_usb_data(const report_mouse_t *report);
|
||||||
|
|
||||||
void serial_mouse_task(void)
|
void serial_mouse_task(void)
|
||||||
|
|
@ -78,6 +79,7 @@ void serial_mouse_task(void)
|
||||||
|
|
||||||
print_usb_data(&report);
|
print_usb_data(&report);
|
||||||
host_mouse_send(&report);
|
host_mouse_send(&report);
|
||||||
|
last_buttons = report.buttons;
|
||||||
|
|
||||||
if (buffer[3] || buffer[4]) {
|
if (buffer[3] || buffer[4]) {
|
||||||
report.h = MAX((int8_t)buffer[3], -127);
|
report.h = MAX((int8_t)buffer[3], -127);
|
||||||
|
|
@ -85,6 +87,7 @@ void serial_mouse_task(void)
|
||||||
|
|
||||||
print_usb_data(&report);
|
print_usb_data(&report);
|
||||||
host_mouse_send(&report);
|
host_mouse_send(&report);
|
||||||
|
last_buttons = report.buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
@ -117,9 +120,15 @@ void serial_mouse_task(void)
|
||||||
|
|
||||||
print_usb_data(&report);
|
print_usb_data(&report);
|
||||||
host_mouse_send(&report);
|
host_mouse_send(&report);
|
||||||
|
last_buttons = report.buttons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t serial_mouse_buttons(void)
|
||||||
|
{
|
||||||
|
return last_buttons;
|
||||||
|
}
|
||||||
|
|
||||||
static void print_usb_data(const report_mouse_t *report)
|
static void print_usb_data(const report_mouse_t *report)
|
||||||
{
|
{
|
||||||
if (!debug_mouse)
|
if (!debug_mouse)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue