qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

honeycomb.c (2655B)


      1 #include "honeycomb.h"
      2 #include "pointing_device.h"
      3 #include "report.h"
      4 
      5 bool pointing_device_task(void){
      6 	/*report_mouse_t currentReport = {};
      7     uint32_t timeout = 0;
      8 
      9     //the m character requests the RF slave to send the mouse report
     10     uart_write('m');
     11 
     12     //trust the external inputs completely, erase old data
     13     uint8_t uart_data[5] = {0};
     14 
     15     //there are 10 bytes corresponding to 10 columns, and an end byte
     16     for (uint8_t i = 0; i < 5; i++) {
     17         //wait for the serial data, timeout if it's been too long
     18         //this only happened in testing with a loose wire, but does no
     19         //harm to leave it in here
     20         while(!uart_available()){
     21             timeout++;
     22             if (timeout > 10000){
     23 		xprintf("\r\nTIMED OUT");
     24                 break;
     25             }
     26         }
     27 	xprintf("\r\nGOT DATA for %d",i);
     28         uart_data[i] = uart_read();
     29     }
     30 
     31     //check for the end packet, bytes 1-4 are movement and scroll
     32     //but byte 5 has bits 0-3 for the scroll button state
     33 	//(1000 if pressed, 0000 if not) and bits 4-7 are always 1
     34 	//We can use this to verify the report sent properly.
     35     if (uart_data[4] == 0x0F || uart_data[4] == 0x8F)
     36     {
     37 	xprintf("\r\nREQUESTED MOUSE, RECEIVED %i, %i, %i, %i, %i",uart_data[0],uart_data[1],uart_data[2],uart_data[3],uart_data[4]);
     38 		currentReport = pointing_device_get_report();
     39         //shifting and transferring the info to the mouse report varaible
     40         //mouseReport.x = 127 max -127 min
     41 		currentReport.x = (int8_t) uart_data[0];
     42         //mouseReport.y = 127 max -127 min
     43 		currentReport.y = (int8_t) uart_data[1];
     44         //mouseReport.v = 127 max -127 min (scroll vertical)
     45 		currentReport.v = (int8_t) uart_data[2];
     46         //mouseReport.h = 127 max -127 min (scroll horizontal)
     47 		currentReport.h = (int8_t) uart_data[3];
     48         //mouseReport.buttons = 0x31 max (bitmask for mouse buttons 1-5) 0x00 min
     49 		//mouse buttons 1 and 2 are handled by the keymap, but not 3
     50 		if (uart_data[4] == 0x0F) { //then 3 is not pressed
     51 			currentReport.buttons &= ~MOUSE_BTN3; //MOUSE_BTN3 is def in report.h
     52 		} else { //3 must be pressed
     53 			currentReport.buttons |= MOUSE_BTN3;
     54 		}
     55 		pointing_device_set_report(currentReport);
     56     } else {
     57 	xprintf("\r\nRequested packet, data 4 was %d",uart_data[4]);
     58     }*/
     59     return pointing_device_send();
     60 }
     61 
     62 void led_init(void) {
     63   gpio_set_pin_output(D1);
     64   gpio_write_pin_high(D1);
     65   gpio_set_pin_output(F4);
     66   gpio_write_pin_high(F4);
     67   gpio_set_pin_output(F5);
     68   gpio_write_pin_high(F5);
     69 }
     70 
     71 void matrix_init_kb(void) {
     72 	// put your keyboard start-up code here
     73 	// runs once when the firmware starts up
     74 	matrix_init_user();
     75 	led_init();
     76 }