From a074364c3731d66b56d988c8a6c960a83ea0e0a1 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 10 Apr 2015 01:32:04 +0900 Subject: Squashed 'tmk_core/' content from commit 05caacc git-subtree-dir: tmk_core git-subtree-split: 05caaccec92694bb24c8c3c3a9940b96efd4605c --- protocol/ps2_mouse.c | 220 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 protocol/ps2_mouse.c (limited to 'protocol/ps2_mouse.c') diff --git a/protocol/ps2_mouse.c b/protocol/ps2_mouse.c new file mode 100644 index 0000000000..c3e8b3c1c3 --- /dev/null +++ b/protocol/ps2_mouse.c @@ -0,0 +1,220 @@ +/* +Copyright 2011,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include "ps2.h" +#include "ps2_mouse.h" +#include "report.h" +#include "host.h" +#include "timer.h" +#include "print.h" +#include "debug.h" + + +static report_mouse_t mouse_report = {}; + + +static void print_usb_data(void); + + +/* supports only 3 button mouse at this time */ +uint8_t ps2_mouse_init(void) { + uint8_t rcv; + + ps2_host_init(); + + _delay_ms(1000); // wait for powering up + + // send Reset + rcv = ps2_host_send(0xFF); + print("ps2_mouse_init: send Reset: "); + phex(rcv); phex(ps2_error); print("\n"); + + // read completion code of BAT + rcv = ps2_host_recv_response(); + print("ps2_mouse_init: read BAT: "); + phex(rcv); phex(ps2_error); print("\n"); + + // read Device ID + rcv = ps2_host_recv_response(); + print("ps2_mouse_init: read DevID: "); + phex(rcv); phex(ps2_error); print("\n"); + + // send Set Remote mode + rcv = ps2_host_send(0xF0); + print("ps2_mouse_init: send 0xF0: "); + phex(rcv); phex(ps2_error); print("\n"); + + return 0; +} + +#define X_IS_NEG (mouse_report.buttons & (1<