|
@@ -7,23 +7,29 @@
|
|
uint8_t mouse_button_state = 0x00;
|
|
uint8_t mouse_button_state = 0x00;
|
|
|
|
|
|
//Move the mouse to given position, range 0 - 4096 for both x and y value
|
|
//Move the mouse to given position, range 0 - 4096 for both x and y value
|
|
-void mouse_move_absolute(uint8_t x_lsb, uint8_t x_msb, uint8_t y_lsb, uint8_t y_msb) {
|
|
|
|
- uint8_t packet[12] = {
|
|
|
|
|
|
+int mouse_move_absolute(uint8_t x_lsb, uint8_t x_msb, uint8_t y_lsb, uint8_t y_msb) {
|
|
|
|
+ uint8_t packet[13] = {
|
|
0x57, 0xAB, 0x00, 0x04, 0x07, 0x02,
|
|
0x57, 0xAB, 0x00, 0x04, 0x07, 0x02,
|
|
mouse_button_state,
|
|
mouse_button_state,
|
|
x_lsb, // X LSB
|
|
x_lsb, // X LSB
|
|
x_msb, // X MSB
|
|
x_msb, // X MSB
|
|
y_lsb, // Y LSB
|
|
y_lsb, // Y LSB
|
|
y_msb, // Y MSB
|
|
y_msb, // Y MSB
|
|
|
|
+ 0x00, // Scroll
|
|
0x00 // Checksum placeholder
|
|
0x00 // Checksum placeholder
|
|
};
|
|
};
|
|
|
|
|
|
- packet[11] = calcChecksum(packet, 11);
|
|
|
|
- Serial0_writeBuf(packet, 12);
|
|
|
|
|
|
+ packet[12] = calcChecksum(packet, 12);
|
|
|
|
+ Serial0_writeBuf(packet, 13);
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
//Move the mouse to given relative position
|
|
//Move the mouse to given relative position
|
|
-void mouse_move_relative(int8_t dx, int8_t dy, int8_t wheel) {
|
|
|
|
|
|
+int mouse_move_relative(uint8_t dx, uint8_t dy, uint8_t wheel) {
|
|
|
|
+ //Make sure 0x80 is not used
|
|
|
|
+ dx = (dx == 0x80)?0x81:dx;
|
|
|
|
+ dy = (dy == 0x80)?0x81:dy;
|
|
|
|
+
|
|
uint8_t packet[11] = {
|
|
uint8_t packet[11] = {
|
|
0x57, 0xAB, 0x00, 0x05, 0x05, 0x01,
|
|
0x57, 0xAB, 0x00, 0x05, 0x05, 0x01,
|
|
mouse_button_state,
|
|
mouse_button_state,
|
|
@@ -35,6 +41,7 @@ void mouse_move_relative(int8_t dx, int8_t dy, int8_t wheel) {
|
|
|
|
|
|
packet[10] = calcChecksum(packet, 10);
|
|
packet[10] = calcChecksum(packet, 10);
|
|
Serial0_writeBuf(packet, 11);
|
|
Serial0_writeBuf(packet, 11);
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -101,4 +108,10 @@ int mouse_button_release(uint8_t opcode) {
|
|
// Send updated button state with no movement
|
|
// Send updated button state with no movement
|
|
mouse_move_relative(0, 0, 0);
|
|
mouse_move_relative(0, 0, 0);
|
|
return 0;
|
|
return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//Reset all mouse clicks state
|
|
|
|
+void mouse_reset(){
|
|
|
|
+ mouse_button_state = 0x00;
|
|
|
|
+ mouse_move_relative(0, 0, 0);
|
|
}
|
|
}
|