MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Handler

Function Handler

Kernel/src/arch/x86_64/mouse.cpp:35–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 bool dataUpdated = false;
34
35 void Handler(void*, regs64_t* regs) {
36 switch (mouseCycle)
37 {
38 case 0:
39 mouseData[0] = inportb(0x60);
40
41 if(!(mouseData[0] & 0x8)) break;
42
43 mouseCycle++;
44 break;
45 case 1:
46 mouseData[1] = inportb(0x60);
47 mouseCycle++;
48 break;
49 case 2: {
50 mouseData[2] = inportb(0x60);
51 mouseCycle = 0;
52
53 if(packetCount >= PACKET_QUEUE_SIZE) break; // Drop packet
54
55 MousePacket pkt;
56 pkt.buttons = mouseData[0] & (MOUSE_BUTTON_LEFT | MOUSE_BUTTON_MIDDLE | MOUSE_BUTTON_RIGHT);
57
58 pkt.xMovement = mouseData[1];
59 pkt.yMovement = -mouseData[2];
60
61 // Add packet to queue
62 packetQueue[packetQueueEnd] = pkt;
63
64 packetQueueEnd++;
65
66 if(packetQueueEnd >= PACKET_QUEUE_SIZE) {
67 packetQueueEnd = 0;
68 }
69
70 packetCount++;
71
72 break;
73 } default: {
74 mouseCycle = 0;
75 break;
76 }
77 }
78 }
79
80 inline void Wait(uint8_t type)
81 {

Callers

nothing calls this directly

Calls 1

inportbFunction · 0.85

Tested by

no test coverage detected