Revision 150
mouse files
proj.c | ||
---|---|---|
8 | 8 |
#include "i8254.h" |
9 | 9 |
#include "kbc_macros.h" |
10 | 10 |
#include "graphics_macros.h" |
11 |
#include "mouse_macros.h" |
|
11 | 12 |
#include "proj_macros.h" |
12 | 13 |
#include "errors.h" |
13 | 14 |
|
... | ... | |
15 | 16 |
#include "graphics.h" |
16 | 17 |
#include "timer.h" |
17 | 18 |
#include "keyboard.h" |
19 |
#include "mouse.h" |
|
18 | 20 |
#include "utils.h" |
19 | 21 |
|
20 | 22 |
int main(int argc, char* argv[]) { |
... | ... | |
58 | 60 |
return 1; |
59 | 61 |
} |
60 | 62 |
|
63 |
/// Mouse interrupt handling |
|
64 |
uint8_t mouse_irq_bit = MOUSE_IRQ; |
|
65 |
int mouse_id = 0; |
|
66 |
int mouse_irq = BIT(mouse_irq_bit); |
|
67 |
|
|
68 |
if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1; // subscribes mouse interrupts in exclusive mode |
|
69 |
if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications |
|
70 |
if (mouse_set_data_report(true)) return 1; // enables mouse data reporting |
|
71 |
if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications |
|
72 |
|
|
61 | 73 |
/// cycle |
62 | 74 |
int good = 1; |
63 | 75 |
while (good) { |
... | ... | |
76 | 88 |
if (msg.m_notify.interrupts & timer_irq) { /* subscribed interrupt */ |
77 | 89 |
timer_int_handler(); |
78 | 90 |
} |
91 |
|
|
92 |
if (msg.m_notify.interrupts & mouse_irq) { /* subscribed interrupt */ |
|
93 |
mouse_ih(); |
|
94 |
} |
|
79 | 95 |
break; |
80 | 96 |
default: |
81 | 97 |
break; /* no other notifications expected: do nothing */ |
... | ... | |
95 | 111 |
return 1; |
96 | 112 |
} |
97 | 113 |
|
114 |
// Unsubscribe Mouse Interrupts |
|
115 |
if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications |
|
116 |
if (mouse_set_data_report(false)) return 1; // enables mouse data reporting |
|
117 |
if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications |
|
118 |
if (unsubscribe_interrupt(&mouse_id)) return 1; // unsubscribes interrupts |
|
119 |
|
|
98 | 120 |
return 0; |
99 | 121 |
} |
Also available in: Unified diff