/* 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<