qmk_firmware

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

digitizer.h (2033B)


      1 /* Copyright 2021
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 2 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  */
     16 
     17 #pragma once
     18 
     19 #include <stdbool.h>
     20 
     21 /**
     22  * \file
     23  *
     24  * defgroup digitizer HID Digitizer
     25  * \{
     26  */
     27 
     28 typedef struct {
     29     bool  in_range : 1;
     30     bool  tip : 1;
     31     bool  barrel : 1;
     32     float x;
     33     float y;
     34     bool  dirty;
     35 } digitizer_t;
     36 
     37 extern digitizer_t digitizer_state;
     38 
     39 /**
     40  * \brief Send the digitizer report to the host if it is marked as dirty.
     41  */
     42 void digitizer_flush(void);
     43 
     44 /**
     45  * \brief Assert the "in range" indicator, and flush the report.
     46  */
     47 void digitizer_in_range_on(void);
     48 
     49 /**
     50  * \brief Deassert the "in range" indicator, and flush the report.
     51  */
     52 void digitizer_in_range_off(void);
     53 
     54 /**
     55  * \brief Assert the tip switch, and flush the report.
     56  */
     57 void digitizer_tip_switch_on(void);
     58 
     59 /**
     60  * \brief Deassert the tip switch, and flush the report.
     61  */
     62 void digitizer_tip_switch_off(void);
     63 
     64 /**
     65  * \brief Assert the barrel switch, and flush the report.
     66  */
     67 void digitizer_barrel_switch_on(void);
     68 
     69 /**
     70  * \brief Deassert the barrel switch, and flush the report.
     71  */
     72 void digitizer_barrel_switch_off(void);
     73 
     74 /**
     75  * \brief Set the absolute X and Y position of the digitizer contact, and flush the report.
     76  *
     77  * \param x The X value of the contact position, from 0 to 1.
     78  * \param y The Y value of the contact position, from 0 to 1.
     79  */
     80 void digitizer_set_position(float x, float y);
     81 
     82 void host_digitizer_send(digitizer_t *digitizer);
     83 
     84 /** \} */