kekw
Dependencies: mbed C12832_lcd MMA7660
USBMouse/USBMouse.cpp@2:b07d155d316c, 2020-01-19 (annotated)
- Committer:
- gri
- Date:
- Sun Jan 19 14:57:41 2020 +0000
- Revision:
- 2:b07d155d316c
KEKw
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gri | 2:b07d155d316c | 1 | #include "USBMouse.h" |
gri | 2:b07d155d316c | 2 | |
gri | 2:b07d155d316c | 3 | USBMouse::USBMouse() { |
gri | 2:b07d155d316c | 4 | _buttons = 0; |
gri | 2:b07d155d316c | 5 | } |
gri | 2:b07d155d316c | 6 | |
gri | 2:b07d155d316c | 7 | void USBMouse::move(int x, int y) { |
gri | 2:b07d155d316c | 8 | while(x > 127) { |
gri | 2:b07d155d316c | 9 | mouse(127, 0, _buttons, 0); |
gri | 2:b07d155d316c | 10 | x = x - 127; |
gri | 2:b07d155d316c | 11 | } |
gri | 2:b07d155d316c | 12 | while(x < -128) { |
gri | 2:b07d155d316c | 13 | mouse(-128, 0, _buttons, 0); |
gri | 2:b07d155d316c | 14 | x = x + 128; |
gri | 2:b07d155d316c | 15 | } |
gri | 2:b07d155d316c | 16 | while(y > 127) { |
gri | 2:b07d155d316c | 17 | mouse(0, 127, _buttons, 0); |
gri | 2:b07d155d316c | 18 | y = y - 127; |
gri | 2:b07d155d316c | 19 | } |
gri | 2:b07d155d316c | 20 | while(y < -128) { |
gri | 2:b07d155d316c | 21 | mouse(0, -128, _buttons, 0); |
gri | 2:b07d155d316c | 22 | y = y + 128; |
gri | 2:b07d155d316c | 23 | } |
gri | 2:b07d155d316c | 24 | mouse(x, y, _buttons, 0); |
gri | 2:b07d155d316c | 25 | } |
gri | 2:b07d155d316c | 26 | |
gri | 2:b07d155d316c | 27 | void USBMouse::scroll(int z) { |
gri | 2:b07d155d316c | 28 | while(z > 127) { |
gri | 2:b07d155d316c | 29 | mouse(0, 0, _buttons, 127); |
gri | 2:b07d155d316c | 30 | z = z - 127; |
gri | 2:b07d155d316c | 31 | } |
gri | 2:b07d155d316c | 32 | while(z < -128) { |
gri | 2:b07d155d316c | 33 | mouse(0, 0, _buttons, -128); |
gri | 2:b07d155d316c | 34 | z = z + 128; |
gri | 2:b07d155d316c | 35 | } |
gri | 2:b07d155d316c | 36 | mouse(0, 0, _buttons, z); |
gri | 2:b07d155d316c | 37 | } |
gri | 2:b07d155d316c | 38 | |
gri | 2:b07d155d316c | 39 | void USBMouse::buttons(int left, int middle, int right) { |
gri | 2:b07d155d316c | 40 | int _buttons = 0; |
gri | 2:b07d155d316c | 41 | if(left) { |
gri | 2:b07d155d316c | 42 | _buttons |= MOUSE_L; |
gri | 2:b07d155d316c | 43 | } |
gri | 2:b07d155d316c | 44 | if(middle) { |
gri | 2:b07d155d316c | 45 | _buttons |= MOUSE_M; |
gri | 2:b07d155d316c | 46 | } |
gri | 2:b07d155d316c | 47 | if(right) { |
gri | 2:b07d155d316c | 48 | _buttons |= MOUSE_R; |
gri | 2:b07d155d316c | 49 | } |
gri | 2:b07d155d316c | 50 | mouse(0,0, _buttons, 0); |
gri | 2:b07d155d316c | 51 | } |