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:
tmk 2021-11-13 08:03:45 +09:00
parent b981b8e266
commit 5f7d388dee
12 changed files with 86 additions and 0 deletions

View file

@ -109,6 +109,7 @@ void adb_host_reset_hard(void);
void adb_host_kbd_led(uint8_t addr, uint8_t led);
void adb_mouse_task(void);
void adb_mouse_init(void);
uint8_t adb_mouse_buttons(void);
#endif

View file

@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static report_mouse_t mouse_report = {};
static uint8_t last_buttons;
static void print_usb_data(void);
@ -161,6 +162,7 @@ void ps2_mouse_task(void)
host_mouse_send(&mouse_report);
last_buttons = mouse_report.buttons;
print_usb_data();
}
// clear report
@ -171,6 +173,11 @@ void ps2_mouse_task(void)
mouse_report.buttons = 0;
}
uint8_t ps2_mouse_buttons(void)
{
return last_buttons;
}
static void print_usb_data(void)
{
if (!debug_mouse) return;

View file

@ -62,5 +62,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
uint8_t ps2_mouse_init(void);
void ps2_mouse_task(void);
uint8_t ps2_mouse_buttons(void);
#endif

View file

@ -29,5 +29,6 @@ static inline uint8_t serial_mouse_init(void)
}
void serial_mouse_task(void);
uint8_t serial_mouse_buttons(void);
#endif

View file

@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
static uint8_t last_buttons;
static void print_usb_data(const report_mouse_t *report);
void serial_mouse_task(void)
@ -71,6 +72,7 @@ void serial_mouse_task(void)
print_usb_data(&report);
host_mouse_send(&report);
last_buttons = report.buttons;
return;
}
@ -111,6 +113,12 @@ void serial_mouse_task(void)
print_usb_data(&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)

View file

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define SERIAL_MOUSE_CENTER_SCROLL
static uint8_t last_buttons;
static void print_usb_data(const report_mouse_t *report);
void serial_mouse_task(void)
@ -78,6 +79,7 @@ void serial_mouse_task(void)
print_usb_data(&report);
host_mouse_send(&report);
last_buttons = report.buttons;
if (buffer[3] || buffer[4]) {
report.h = MAX((int8_t)buffer[3], -127);
@ -85,6 +87,7 @@ void serial_mouse_task(void)
print_usb_data(&report);
host_mouse_send(&report);
last_buttons = report.buttons;
}
return;
@ -117,9 +120,15 @@ void serial_mouse_task(void)
print_usb_data(&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)
{
if (!debug_mouse)