aboutsummaryrefslogtreecommitdiff
path: root/int15ps2.h
diff options
context:
space:
mode:
Diffstat (limited to 'int15ps2.h')
-rw-r--r--int15ps2.h54
1 files changed, 41 insertions, 13 deletions
diff --git a/int15ps2.h b/int15ps2.h
index dfc5b3a..de8a260 100644
--- a/int15ps2.h
+++ b/int15ps2.h
@@ -22,6 +22,7 @@
#include <stdbool.h>
#include <stdint.h>
+#include "utils.h"
/** Standard PS/2 mouse IRQ. At least on VirtualBox. */
#define PS2_MOUSE_IRQ 12
@@ -49,19 +50,27 @@ enum ps2m_status {
enum ps2m_packet_size {
PS2M_PACKET_SIZE_STREAMING = 1,
- PS2M_PACKET_SIZE_PLAIN = 3,
+ PS2M_PACKET_SIZE_STD = 3,
PS2M_PACKET_SIZE_EXT = 4,
};
enum ps2m_device_ids {
/** Standard PS/2 mouse, 2 buttons. */
- PS2M_DEVICE_ID_PLAIN = 0,
+ PS2M_DEVICE_ID_STD = 0,
/** IntelliMouse PS/2, with wheel. */
- PS2M_DEVICE_ID_IMPS2 = 3,
+ PS2M_DEVICE_ID_IMPS2 = 3,
/** IntelliMouse Explorer, wheel and 5 buttons. */
- PS2M_DEVICE_ID_IMEX = 4,
+ PS2M_DEVICE_ID_IMEX = 4,
/** IntelliMouse Explorer, wheel, 5 buttons, and horizontal scrolling. */
- PS2M_DEVICE_ID_IMEX_HORZ = 5
+ PS2M_DEVICE_ID_IMEX_HORZ = 5
+};
+
+/** Additional bits set in 4th byte of IMEX protocol. */
+enum ps2m_imex_ext_byte_bits {
+ PS2M_IMEX_BUTTON_4 = 1 << 4,
+ PS2M_IMEX_BUTTON_5 = 1 << 5,
+ PS2M_IMEX_HORIZONTAL_SCROLL = 1 << 6,
+ PS2M_IMEX_VERTICAL_SCROLL = 1 << 7
};
/** Valid PS/2 mouse resolutions in DPI. */
@@ -200,7 +209,7 @@ static ps2m_err ps2m_enable(bool enable);
__value [ah] \
__modify [ax]
-/** Sends the magic sequence to switch the mouse to the IMPS2 protocol. */
+/** Sends the magic sequence to switch the mouse to the IntelliMouse protocol. */
static void ps2m_send_imps2_sequence(void)
{
ps2m_set_sample_rate(PS2M_SAMPLE_RATE_200);
@@ -208,8 +217,28 @@ static void ps2m_send_imps2_sequence(void)
ps2m_set_sample_rate(PS2M_SAMPLE_RATE_80);
}
-/** Detects whether we have a IMPS2 mouse with wheel support. */
-static bool ps2m_detect_wheel(void)
+/** Sends the magic sequence to switch the mouse to the IntelliMouse Explorer protocol. */
+static void ps2m_send_imex_sequence(void)
+{
+ ps2m_set_sample_rate(PS2M_SAMPLE_RATE_200);
+ ps2m_set_sample_rate(PS2M_SAMPLE_RATE_200);
+ ps2m_set_sample_rate(PS2M_SAMPLE_RATE_80);
+}
+
+/** Sends the magic sequence to switch the mouse to the IntelliMouse Explorer
+ * with horz. wheel protocol. Note: unclear if mouse changes device_id after this. */
+static void ps2m_send_imex_horz_sequence(void)
+{
+ ps2m_set_sample_rate(PS2M_SAMPLE_RATE_200);
+ ps2m_set_sample_rate(PS2M_SAMPLE_RATE_80);
+ ps2m_set_sample_rate(PS2M_SAMPLE_RATE_40);
+}
+
+/** Detects whether we have a IMPS2 mouse with wheel support.
+ *
+ * @return true if we have at least imps/2 with 1 wheel support.
+ */
+static bool ps2m_detect_imps2(void)
{
int err;
uint8_t device_id;
@@ -220,14 +249,14 @@ static bool ps2m_detect_wheel(void)
return false;
}
- if (device_id == PS2M_DEVICE_ID_IMPS2) {
+ if (device_id == PS2M_DEVICE_ID_IMPS2
+ || device_id == PS2M_DEVICE_ID_IMEX
+ || device_id == PS2M_DEVICE_ID_IMEX_HORZ) {
// Already wheel
return true;
}
- if (device_id != PS2M_DEVICE_ID_PLAIN) {
- // TODO: Likely we have to accept more device IDs here
- dprintf("Unknown initial mouse device_id=0x%x\n", device_id);
+ if (device_id != PS2M_DEVICE_ID_STD) {
return false;
}
@@ -236,7 +265,6 @@ static bool ps2m_detect_wheel(void)
// Now check if the device id has changed
err = ps2m_get_device_id(&device_id);
-
return err == 0 && device_id == PS2M_DEVICE_ID_IMPS2;
}