mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
rewrote the ps/2 mouse driver. it works now :)
svn path=/trunk/; revision=6192
This commit is contained in:
parent
4dba9c4e26
commit
99bf2fc3b8
6 changed files with 614 additions and 590 deletions
|
@ -18,7 +18,7 @@
|
|||
* Process a PS2++ or PS2T++ packet.
|
||||
*/
|
||||
|
||||
void ps2pp_process_packet(PDEVICE_EXTENSION DeviceExtension, PMOUSE_INPUT_DATA Input)
|
||||
void PS2PPProcessPacket(PDEVICE_EXTENSION DeviceExtension, PMOUSE_INPUT_DATA Input, int *wheel)
|
||||
{
|
||||
unsigned char *packet = DeviceExtension->MouseBuffer;
|
||||
|
||||
|
@ -32,16 +32,16 @@ void ps2pp_process_packet(PDEVICE_EXTENSION DeviceExtension, PMOUSE_INPUT_DATA I
|
|||
input_report_rel(dev, packet[2] & 0x80 ? REL_HWHEEL : REL_WHEEL,
|
||||
(int) (packet[2] & 8) - (int) (packet[2] & 7)); */
|
||||
|
||||
Input->ButtonData = (UINT)((WHEEL_DELTA) * ((int)(packet[2] & 8) - (int)(packet[2] & 7)));
|
||||
Input->RawButtons |= ((packet[2] >> 4) & 1) ? GPM_B_FOURTH : 0;
|
||||
Input->RawButtons |= ((packet[2] >> 5) & 1) ? GPM_B_FIFTH : 0;
|
||||
*wheel = (int)(packet[2] & 8) - (int)(packet[2] & 7);
|
||||
Input->RawButtons |= (((packet[2] >> 4) & 1) ? GPM_B_FOURTH : 0);
|
||||
Input->RawButtons |= (((packet[2] >> 5) & 1) ? GPM_B_FIFTH : 0);
|
||||
|
||||
break;
|
||||
|
||||
case 0x0e: /* buttons 4, 5, 6, 7, 8, 9, 10 info */
|
||||
|
||||
Input->RawButtons |= (packet[2] & 1) ? GPM_B_FOURTH : 0;
|
||||
Input->RawButtons |= ((packet[2] >> 1) & 1) ? GPM_B_FIFTH : 0;
|
||||
Input->RawButtons |= ((packet[2] & 1) ? GPM_B_FOURTH : 0);
|
||||
Input->RawButtons |= (((packet[2] >> 1) & 1) ? GPM_B_FIFTH : 0);
|
||||
|
||||
/* FIXME - support those buttons???
|
||||
input_report_key(dev, BTN_BACK, (packet[2] >> 3) & 1);
|
||||
|
@ -57,7 +57,7 @@ void ps2pp_process_packet(PDEVICE_EXTENSION DeviceExtension, PMOUSE_INPUT_DATA I
|
|||
input_report_rel(dev, packet[2] & 0x08 ? REL_HWHEEL : REL_WHEEL,
|
||||
(int) ((packet[2] >> 4) & 8) - (int) ((packet[2] >> 4) & 7)); */
|
||||
|
||||
Input->ButtonData = (UINT)((WHEEL_DELTA) *((int) ((packet[2] >> 4) & 8) - (int) ((packet[2] >> 4) & 7)));
|
||||
*wheel = (int) ((packet[2] >> 4) & 8) - (int) ((packet[2] >> 4) & 7);
|
||||
|
||||
packet[0] = packet[2] | 0x08;
|
||||
break;
|
||||
|
@ -86,16 +86,16 @@ static int ps2pp_cmd(PDEVICE_EXTENSION DeviceExtension, unsigned char *param, un
|
|||
unsigned char d;
|
||||
int i;
|
||||
|
||||
if (psmouse_command(DeviceExtension, NULL, PSMOUSE_CMD_SETSCALE11))
|
||||
if (SendCommand(DeviceExtension, NULL, PSMOUSE_CMD_SETSCALE11))
|
||||
return -1;
|
||||
|
||||
for (i = 6; i >= 0; i -= 2) {
|
||||
d = (command >> i) & 3;
|
||||
if(psmouse_command(DeviceExtension, &d, PSMOUSE_CMD_SETRES))
|
||||
if(SendCommand(DeviceExtension, &d, PSMOUSE_CMD_SETRES))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (psmouse_command(DeviceExtension, param, PSMOUSE_CMD_POLL))
|
||||
if (SendCommand(DeviceExtension, param, PSMOUSE_CMD_POLL))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -116,18 +116,18 @@ static void ps2pp_set_smartscroll(PDEVICE_EXTENSION DeviceExtension)
|
|||
ps2pp_cmd(DeviceExtension, param, 0x32);
|
||||
|
||||
param[0] = 0;
|
||||
psmouse_command(DeviceExtension, param, PSMOUSE_CMD_SETRES);
|
||||
psmouse_command(DeviceExtension, param, PSMOUSE_CMD_SETRES);
|
||||
psmouse_command(DeviceExtension, param, PSMOUSE_CMD_SETRES);
|
||||
SendCommand(DeviceExtension, param, PSMOUSE_CMD_SETRES);
|
||||
SendCommand(DeviceExtension, param, PSMOUSE_CMD_SETRES);
|
||||
SendCommand(DeviceExtension, param, PSMOUSE_CMD_SETRES);
|
||||
|
||||
if (DeviceExtension->psmouse_smartscroll == 1)
|
||||
if (DeviceExtension->SmartScroll == 1)
|
||||
param[0] = 1;
|
||||
else
|
||||
if (DeviceExtension->psmouse_smartscroll > 2)
|
||||
if (DeviceExtension->SmartScroll > 2)
|
||||
return;
|
||||
|
||||
/* else leave param[0] == 0 to disable */
|
||||
psmouse_command(DeviceExtension, param, PSMOUSE_CMD_SETRES);
|
||||
SendCommand(DeviceExtension, param, PSMOUSE_CMD_SETRES);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -136,13 +136,13 @@ static void ps2pp_set_smartscroll(PDEVICE_EXTENSION DeviceExtension)
|
|||
* also good reasons to use it, let the user decide).
|
||||
*/
|
||||
|
||||
void ps2pp_set_800dpi(PDEVICE_EXTENSION DeviceExtension)
|
||||
void PS2PPSet800dpi(PDEVICE_EXTENSION DeviceExtension)
|
||||
{
|
||||
unsigned char param = 3;
|
||||
psmouse_command(DeviceExtension, NULL, PSMOUSE_CMD_SETSCALE11);
|
||||
psmouse_command(DeviceExtension, NULL, PSMOUSE_CMD_SETSCALE11);
|
||||
psmouse_command(DeviceExtension, NULL, PSMOUSE_CMD_SETSCALE11);
|
||||
psmouse_command(DeviceExtension, ¶m, PSMOUSE_CMD_SETRES);
|
||||
SendCommand(DeviceExtension, NULL, PSMOUSE_CMD_SETSCALE11);
|
||||
SendCommand(DeviceExtension, NULL, PSMOUSE_CMD_SETSCALE11);
|
||||
SendCommand(DeviceExtension, NULL, PSMOUSE_CMD_SETSCALE11);
|
||||
SendCommand(DeviceExtension, ¶m, PSMOUSE_CMD_SETRES);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -150,7 +150,7 @@ void ps2pp_set_800dpi(PDEVICE_EXTENSION DeviceExtension)
|
|||
* touchpad.
|
||||
*/
|
||||
|
||||
int ps2pp_detect_model(PDEVICE_EXTENSION DeviceExtension, unsigned char *param)
|
||||
int PS2PPDetectModel(PDEVICE_EXTENSION DeviceExtension, unsigned char *param)
|
||||
{
|
||||
int i;
|
||||
//char *vendor, *name;
|
||||
|
@ -162,7 +162,7 @@ int ps2pp_detect_model(PDEVICE_EXTENSION DeviceExtension, unsigned char *param)
|
|||
|
||||
//vendor = "Logitech";
|
||||
//DbgPrint("Vendor: %s, name: %s\n", vendor, name);
|
||||
DeviceExtension->model = ((param[0] >> 4) & 0x07) | ((param[0] << 3) & 0x78);
|
||||
DeviceExtension->MouseModel = ((param[0] >> 4) & 0x07) | ((param[0] << 3) & 0x78);
|
||||
|
||||
/*if (param[1] < 3)
|
||||
clear_bit(BTN_MIDDLE, DeviceExtension->dev.keybit);
|
||||
|
@ -172,23 +172,23 @@ int ps2pp_detect_model(PDEVICE_EXTENSION DeviceExtension, unsigned char *param)
|
|||
DeviceExtension->MouseType = PSMOUSE_PS2;
|
||||
|
||||
for (i = 0; logitech_ps2pp[i] != -1; i++)
|
||||
if (logitech_ps2pp[i] == DeviceExtension->model)
|
||||
if (logitech_ps2pp[i] == DeviceExtension->MouseModel)
|
||||
DeviceExtension->MouseType = PSMOUSE_PS2PP;
|
||||
|
||||
if (DeviceExtension->MouseType == PSMOUSE_PS2PP) {
|
||||
|
||||
/* for (i = 0; logitech_4btn[i] != -1; i++)
|
||||
if (logitech_4btn[i] == psmouse->model)
|
||||
if (logitech_4btn[i] == DeviceExtension->MouseModel)
|
||||
set_bit(BTN_SIDE, psmouse->dev.keybit);
|
||||
*/
|
||||
for (i = 0; logitech_wheel[i] != -1; i++)
|
||||
if (logitech_wheel[i] == DeviceExtension->model) {
|
||||
if (logitech_wheel[i] == DeviceExtension->MouseModel) {
|
||||
// set_bit(REL_WHEEL, psmouse->dev.relbit);
|
||||
//name = "Wheel Mouse";DbgPrint("Vendor: %s, name: %s\n", vendor, name);
|
||||
}
|
||||
|
||||
for (i = 0; logitech_mx[i] != -1; i++)
|
||||
if (logitech_mx[i] == DeviceExtension->model) {
|
||||
if (logitech_mx[i] == DeviceExtension->MouseModel) {
|
||||
/* set_bit(BTN_SIDE, psmouse->dev.keybit);
|
||||
set_bit(BTN_EXTRA, psmouse->dev.keybit);
|
||||
set_bit(BTN_BACK, psmouse->dev.keybit);
|
||||
|
@ -201,20 +201,20 @@ int ps2pp_detect_model(PDEVICE_EXTENSION DeviceExtension, unsigned char *param)
|
|||
* Do Logitech PS2++ / PS2T++ magic init.
|
||||
*/
|
||||
|
||||
if (DeviceExtension->model == 97) { /* TouchPad 3 */
|
||||
if (DeviceExtension->MouseModel == 97) { /* TouchPad 3 */
|
||||
|
||||
// set_bit(REL_WHEEL, psmouse->dev.relbit);
|
||||
// set_bit(REL_HWHEEL, psmouse->dev.relbit);
|
||||
|
||||
param[0] = 0x11; param[1] = 0x04; param[2] = 0x68; /* Unprotect RAM */
|
||||
psmouse_command(DeviceExtension, param, 0x30d1);
|
||||
SendCommand(DeviceExtension, param, 0x30d1);
|
||||
param[0] = 0x11; param[1] = 0x05; param[2] = 0x0b; /* Enable features */
|
||||
psmouse_command(DeviceExtension, param, 0x30d1);
|
||||
SendCommand(DeviceExtension, param, 0x30d1);
|
||||
param[0] = 0x11; param[1] = 0x09; param[2] = 0xc3; /* Enable PS2++ */
|
||||
psmouse_command(DeviceExtension, param, 0x30d1);
|
||||
SendCommand(DeviceExtension, param, 0x30d1);
|
||||
|
||||
param[0] = 0;
|
||||
if (!psmouse_command(DeviceExtension, param, 0x13d1) &&
|
||||
if (!SendCommand(DeviceExtension, param, 0x13d1) &&
|
||||
param[0] == 0x06 && param[1] == 0x00 && param[2] == 0x14) {
|
||||
//name = "TouchPad 3";DbgPrint("Vendor: %s, name: %s\n", vendor, name);
|
||||
return PSMOUSE_PS2TPP;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,51 +1,7 @@
|
|||
// All or parts of this file are from CHAOS (http://www.se.chaosdev.org/).
|
||||
// CHAOS is also under the GNU General Public License.
|
||||
|
||||
// Mouse commands
|
||||
#define MOUSE_SET_RESOLUTION 0xE8 // Set resolution
|
||||
#define MOUSE_SET_SCALE11 0xE6 // Set 1:1 scaling
|
||||
#define MOUSE_SET_SCALE21 0xE7 // Set 2:1 scaling
|
||||
#define MOUSE_GET_SCALE 0xE9 // Get scaling factor
|
||||
#define MOUSE_SET_STREAM 0xEA // Set stream mode
|
||||
#define MOUSE_READ_DEVICETYPE 0xF2 // Read Device Type
|
||||
#define MOUSE_SET_SAMPLE_RATE 0xF3 /* Set sample rate (number of times
|
||||
* the controller will poll the port
|
||||
* per second */
|
||||
#define MOUSE_ENABLE_DEVICE 0xF4 // Enable mouse device
|
||||
#define MOUSE_DISABLE_DEVICE 0xF5 // Disable mouse device
|
||||
#define MOUSE_RESET 0xFF // Reset aux device
|
||||
#define MOUSE_ACK 0xFA // Command byte ACK
|
||||
|
||||
#define MOUSE_INTERRUPTS_OFF (CONTROLLER_MODE_KCC | \
|
||||
CONTROLLER_MODE_DISABLE_MOUSE | \
|
||||
CONTROLLER_MODE_SYS | \
|
||||
CONTROLLER_MODE_KEYBOARD_INTERRUPT)
|
||||
|
||||
#define MOUSE_INTERRUPTS_ON (CONTROLLER_MODE_KCC | \
|
||||
CONTROLLER_MODE_SYS | \
|
||||
CONTROLLER_MODE_MOUSE_INTERRUPT | \
|
||||
CONTROLLER_MODE_KEYBOARD_INTERRUPT)
|
||||
|
||||
// Used with mouse buttons
|
||||
#define GPM_B_LEFT 1
|
||||
#define GPM_B_RIGHT 2
|
||||
#define GPM_B_MIDDLE 4
|
||||
#define GPM_B_FOURTH 0x10
|
||||
#define GPM_B_FIFTH 0x20
|
||||
|
||||
// Some aux operations take long time
|
||||
#define MAX_RETRIES 60
|
||||
|
||||
// Hardware defines
|
||||
#define MOUSE_IRQ 12
|
||||
#define MOUSE_WRAP_MASK 0x1F
|
||||
|
||||
#define MOUSE_ISINTELLIMOUSE 0x03
|
||||
#define MOUSE_ISINTELLIMOUSE5BUTTONS 0x04
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define WHEEL_DELTA 120
|
||||
#define WHEEL_DELTA (120)
|
||||
|
||||
#define PSMOUSE_CMD_SETSCALE11 0x00e6
|
||||
#define PSMOUSE_CMD_SETRES 0x10e8
|
||||
|
@ -62,6 +18,24 @@
|
|||
#define PSMOUSE_RET_ACK 0xfa
|
||||
#define PSMOUSE_RET_NAK 0xfe
|
||||
|
||||
#define MOUSE_INTERRUPTS_OFF (CONTROLLER_MODE_KCC | \
|
||||
CONTROLLER_MODE_DISABLE_MOUSE | \
|
||||
CONTROLLER_MODE_SYS | \
|
||||
CONTROLLER_MODE_KEYBOARD_INTERRUPT)
|
||||
|
||||
#define MOUSE_INTERRUPTS_ON (CONTROLLER_MODE_KCC | \
|
||||
CONTROLLER_MODE_SYS | \
|
||||
CONTROLLER_MODE_MOUSE_INTERRUPT | \
|
||||
CONTROLLER_MODE_KEYBOARD_INTERRUPT)
|
||||
|
||||
// Used with mouse buttons
|
||||
#define GPM_B_LEFT 0x01
|
||||
#define GPM_B_RIGHT 0x02
|
||||
#define GPM_B_MIDDLE 0x04
|
||||
#define GPM_B_FOURTH 0x10
|
||||
#define GPM_B_FIFTH 0x20
|
||||
|
||||
// Mouse types
|
||||
#define PSMOUSE_PS2 1
|
||||
#define PSMOUSE_PS2PP 2
|
||||
#define PSMOUSE_PS2TPP 3
|
||||
|
@ -70,7 +44,15 @@
|
|||
#define PSMOUSE_IMEX 6
|
||||
#define PSMOUSE_SYNAPTICS 7
|
||||
|
||||
#define input_regs(a,b) do { (a)->regs = (b); } while (0)
|
||||
// Some aux operations take long time
|
||||
#define MAX_RETRIES 60
|
||||
|
||||
// Hardware defines
|
||||
#define MOUSE_IRQ 12
|
||||
#define MOUSE_WRAP_MASK 0x1F
|
||||
|
||||
#define MOUSE_ISINTELLIMOUSE 0x03
|
||||
#define MOUSE_ISINTELLIMOUSE5BUTTONS 0x04
|
||||
|
||||
static PIRP CurrentIrp;
|
||||
static ULONG MouseDataRead;
|
||||
|
|
|
@ -230,7 +230,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
|||
UNICODE_STRING SymlinkName;
|
||||
PDEVICE_EXTENSION DeviceExtension;
|
||||
|
||||
if (detect_ps2_port() == TRUE) {
|
||||
if (DetectPS2Port() == TRUE) {
|
||||
DbgPrint("PS2 Port Driver version 0.0.2\n");
|
||||
} else {
|
||||
DbgPrint("PS2 port not found.\n");
|
||||
|
@ -244,7 +244,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
|||
|
||||
DeviceObject = AllocatePointerDevice(DriverObject);
|
||||
|
||||
mouse_init(DeviceObject);
|
||||
SetupMouse(DeviceObject, RegistryPath);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <ddk/iotypes.h>
|
||||
typedef struct _DEVICE_EXTENSION {
|
||||
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
|
@ -7,29 +5,24 @@ typedef struct _DEVICE_EXTENSION {
|
|||
ULONG ActiveQueue;
|
||||
ULONG InputDataCount[2];
|
||||
MOUSE_INPUT_DATA MouseInputData[2][MOUSE_BUFFER_SIZE];
|
||||
BOOL HasMouse;
|
||||
|
||||
unsigned char MouseType;
|
||||
unsigned char model;
|
||||
|
||||
unsigned char MouseBuffer[8];
|
||||
unsigned char pkt[8];
|
||||
unsigned char MouseType;
|
||||
unsigned char MouseModel;
|
||||
unsigned char ack, acking;
|
||||
ULONG SmartScroll;
|
||||
ULONG NoExtensions;
|
||||
UINT MouseBufferPosition;
|
||||
UINT MouseBufferSize;
|
||||
UINT Resolution;
|
||||
|
||||
unsigned char cmdbuf[8];
|
||||
unsigned char cmdcnt;
|
||||
unsigned char pktcnt;
|
||||
char acking;
|
||||
volatile char ack;
|
||||
|
||||
int psmouse_noext;
|
||||
int psmouse_smartscroll;
|
||||
|
||||
UINT RepliesExpected;
|
||||
ULONG PreviousButtons;
|
||||
|
||||
|
||||
CLASS_INFORMATION ClassInformation;
|
||||
|
||||
PKINTERRUPT MouseInterrupt;
|
||||
KDPC IsrDpc;
|
||||
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
||||
|
||||
|
|
|
@ -402,7 +402,7 @@ void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
|
|||
|
||||
#else
|
||||
|
||||
int synaptics_init(PDEVICE_EXTENSION DeviceExtension)
|
||||
int InitSynaptics(PDEVICE_EXTENSION DeviceExtension)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue