/* Copyright 2020 Jay Greco * * 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 "remote_kb.h" //todo: remove master/slave uint8_t msg[UART_MSG_LEN], msg_idx = 0; bool is_master = true; bool vbus_detect(void) { //returns true if VBUS is present, false otherwise. USBCON |= (1 << OTGPADE); //enables VBUS pad _delay_us(10); return (USBSTA & (1<> 8) & 0xFF; msg[IDX_PRESSED] = pressed; msg[IDX_CHECKSUM] = chksum8(msg, UART_MSG_LEN-1); for (int i=0; ievent.pressed); } #else //auto check with VBUS if (is_master) { // for future reverse link use } else { if (IS_HID_KC(keycode) || IS_RM_KC(keycode)) { dprintf("Remote: send [%u]\n", keycode); send_msg(keycode, record->event.pressed); } } #endif } void matrix_scan_remote_kb(void) { #if defined(KEYBOARD_MASTER) get_msg(); #elif defined (KEYBOARD_SLAVE) // for future reverse link use #else //auto check with VBUS if (is_master) { get_msg(); } else { // for future reverse link use } #endif }