#include "util.h" // debug_isr
#include "pic.h" // eoi_pic2
#include "bregs.h" // struct bregs
-#include "ps2port.h" // aux_command
+#include "ps2port.h" // ps2_mouse_command
+#include "usb-hid.h" // usb_mouse_command
void
mouse_setup(void)
SETBITS_BDA(equipment_list_flags, 0x04);
}
+static inline int
+mouse_command(int command, u8 *param)
+{
+ if (usb_mouse_active())
+ return usb_mouse_command(command, param);
+ return ps2_mouse_command(command, param);
+}
+
#define RET_SUCCESS 0x00
#define RET_EINVFUNCTION 0x01
#define RET_EINVINPUT 0x02
#define RET_ENEEDRESEND 0x04
#define RET_ENOHANDLER 0x05
-static int
-disable_mouse(u16 ebda_seg)
-{
- u8 ps2ctr = GET_EBDA2(ebda_seg, ps2ctr);
- ps2ctr |= I8042_CTR_AUXDIS;
- ps2ctr &= ~I8042_CTR_AUXINT;
- SET_EBDA2(ebda_seg, ps2ctr, ps2ctr);
-
- return aux_command(PSMOUSE_CMD_DISABLE, NULL);
-}
-
// Disable Mouse
static void
mouse_15c20000(struct bregs *regs)
{
- u16 ebda_seg = get_ebda_seg();
- int ret = disable_mouse(ebda_seg);
+ int ret = mouse_command(PSMOUSE_CMD_DISABLE, NULL);
if (ret)
set_code_invalid(regs, RET_ENEEDRESEND);
else
static void
mouse_15c20001(struct bregs *regs)
{
- u16 ebda_seg = get_ebda_seg();
- u8 mouse_flags_2 = GET_EBDA2(ebda_seg, mouse_flag2);
+ u8 mouse_flags_2 = GET_EBDA(mouse_flag2);
if ((mouse_flags_2 & 0x80) == 0) {
set_code_invalid(regs, RET_ENOHANDLER);
return;
}
- u8 ps2ctr = GET_EBDA2(ebda_seg, ps2ctr);
- ps2ctr &= ~I8042_CTR_AUXDIS;
- ps2ctr |= I8042_CTR_AUXINT;
- SET_EBDA2(ebda_seg, ps2ctr, ps2ctr);
-
- int ret = aux_command(PSMOUSE_CMD_ENABLE, NULL);
+ int ret = mouse_command(PSMOUSE_CMD_ENABLE, NULL);
if (ret)
set_code_invalid(regs, RET_ENEEDRESEND);
else
mouse_15c201(struct bregs *regs)
{
u8 param[2];
- int ret = aux_command(PSMOUSE_CMD_RESET_BAT, param);
+ int ret = mouse_command(PSMOUSE_CMD_RESET_BAT, param);
if (ret) {
set_code_invalid(regs, RET_ENEEDRESEND);
return;
return;
}
u8 mouse_data1 = GET_GLOBAL(sample_rates[regs->bh]);
- int ret = aux_command(PSMOUSE_CMD_SETRATE, &mouse_data1);
+ int ret = mouse_command(PSMOUSE_CMD_SETRATE, &mouse_data1);
if (ret)
set_code_invalid(regs, RET_ENEEDRESEND);
else
return;
}
u8 param = regs->bh;
- int ret = aux_command(PSMOUSE_CMD_SETRES, ¶m);
+ int ret = mouse_command(PSMOUSE_CMD_SETRES, ¶m);
if (ret)
set_code_invalid(regs, RET_ENEEDRESEND);
else
mouse_15c204(struct bregs *regs)
{
u8 param[2];
- int ret = aux_command(PSMOUSE_CMD_GETID, param);
+ int ret = mouse_command(PSMOUSE_CMD_GETID, param);
if (ret) {
set_code_invalid(regs, RET_ENEEDRESEND);
return;
mouse_15c20600(struct bregs *regs)
{
u8 param[3];
- int ret = aux_command(PSMOUSE_CMD_GETINFO, param);
+ int ret = mouse_command(PSMOUSE_CMD_GETINFO, param);
if (ret) {
set_code_invalid(regs, RET_ENEEDRESEND);
return;
static void
mouse_15c20601(struct bregs *regs)
{
- int ret = aux_command(PSMOUSE_CMD_SETSCALE11, NULL);
+ int ret = mouse_command(PSMOUSE_CMD_SETSCALE11, NULL);
if (ret)
set_code_invalid(regs, RET_ENEEDRESEND);
else
static void
mouse_15c20602(struct bregs *regs)
{
- int ret = aux_command(PSMOUSE_CMD_SETSCALE21, NULL);
+ int ret = mouse_command(PSMOUSE_CMD_SETSCALE21, NULL);
if (ret)
set_code_invalid(regs, RET_ENEEDRESEND);
else
/* remove handler */
if ((mouse_flags_2 & 0x80) != 0) {
mouse_flags_2 &= ~0x80;
- disable_mouse(ebda_seg);
+ mouse_command(PSMOUSE_CMD_DISABLE, NULL);
}
} else {
/* install handler */