summaryrefslogtreecommitdiff
path: root/doc/devel/PenButtons.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/devel/PenButtons.txt')
-rw-r--r--doc/devel/PenButtons.txt218
1 files changed, 218 insertions, 0 deletions
diff --git a/doc/devel/PenButtons.txt b/doc/devel/PenButtons.txt
new file mode 100644
index 0000000..ee35c21
--- /dev/null
+++ b/doc/devel/PenButtons.txt
@@ -0,0 +1,218 @@
+----------------------------------------------
+xf86-input-tc1kpen Pen Button events resolving
+----------------------------------------------
+
+As the implemented algorithm for button 3 emulaton
+is quite complex (in meaning of compression of
+semantics), I shall describe its derivation, here.
+The HW mode is quite straightforward and doesn't
+require closer explanation as well as the 3-button
+extension to the following algorithm, I guess.
+
+
+
+Emulating button 3 with pen tap while pen button pressed
+--------------------------------------------------------
+
+From now on, I shall use term button for both the pen tip
+and pen button (they are both buttons in terms of functionality).
+
+
+First, what happens upon a button press/release:
+
+1/ If a button is pressed, 2 packets are sent to the serial
+ device:
+
+ i) STATUS bit set, BUTTON bit clear
+ ii) STATUS bit clear, BUTTON bit set
+
+2/ From that moment, the BUTTON bit stays set until the
+ button is released. Then, 2 packets are sent. The first
+ of those may differ regarding current state of the other
+ button:
+
+ i) STATUS bit set, BUTTON bit clear if the other btn is released
+ BUTTON bit set if the other btn is pressed
+ ii) STATUS bit clear, BUTTON bit clear
+
+The following image describes that:
+
+ PRESS RELEASE
+ V V
+ PACKET #: i i+1 j-1 j j+1
+ -------------------------------------~----------------------------------
+
+ 1 +------+ +------+
+ | | | |
+ STAT bit: 0 -----+ +----------> ---+-----+ +------+------>
+
+ -------------------------------------~----------------------------------
+
+ Other btn. not pressed:
+
+ 1 +------+---> ---+-----+
+ | |
+ BTN bit: 0 -----+------+ +------+------+------>
+
+ -------------------------------------~----------------------------------
+
+ Other btn. pressed:
+
+
+ 1 +------+---> ---+-----+------+
+ | |
+ BTN bit: 0 -----+------+ +------+------>
+
+ -------------------------------------~----------------------------------
+
+
+
+Now, assuming that we watch the STATUS bit changes,
+this leads to the following algorithm:
+
+ +-------------------+
+ | STATUS bit change |
+ +---------+---------+
+ |
+ |
+ V
+ TRUE +-------------------+ FALSE
+ +----------+ STATUS bit set +-------+
+ | +-------------------+ |
+ | |
+ | |
+ V V
+ FALSE +---------------+ TRUE +---------------+ FALSE
+ X<--------+ button > 0 | +---------+ button > 0 +----+
+ +-------+-------+ | +---------------+ |
+ | TRUE | |
+ | | |
+ V V V
+ TRUE +----------------+ +----------------+ T F +----------------+
+ X<-------+ btn 1 bit set | | btn 1 bit set +--->X<---+ btn 1 bit set |
+ +--------+-------+ +--------+-------+ +--------+-------+
+ | FALSE | FALSE | TRUE
+ | | |
+ +--------------------+ V
+ | TRUE +----------------+
+ | +-----------+ btn 2 bit set |
+ V | +--------+-------+
+ +--------------------+ | | FALSE
+ | Release(button); | V V
+ | button = 0; | +-------------+ +----------------+
+ +----------+---------+ | button = 3; | | button = 1; |
+ | +--------+----+ +--------+-------+
+ | | |
+ V +--------------------+
+ X |
+ V
+ +-----------------+
+ | Press(button); |
+ +--------+--------+
+ |
+ V
+ X
+
+ ('X' points mean exit).
+
+The algorithm is obviously far from being efficient.
+Minimalization follows:
+
+The original algorithm in table form:
+=============+==============+=============+=============+====================
+ STATUS bit | button > 0 | btn 1 bit | btn 2 bit | result
+=============+==============+=============+=============+====================
+ 0 | FALSE | 0 | 0 |
+-------------+--------------+-------------+-------------+
+ 0 | FALSE | 0 | 1 |
+-------------+--------------+-------------+-------------+--------------------
+ 0 | FALSE | 1 | 0 | Press(1)
+-------------+--------------+-------------+-------------+--------------------
+ 0 | FALSE | 1 | 1 | Press(3)
+=============+==============+=============+=============+====================
+ 0 | TRUE | 0 | 0 |
+-------------+--------------+-------------+-------------+ Release(button);
+ 0 | TRUE | 0 | 1 |
+-------------+--------------+-------------+-------------+--------------------
+ 0 | TRUE | 1 | 0 |
+-------------+--------------+-------------+-------------+
+ 0 | TRUE | 1 | 1 |
+=============+==============+=============+=============+====================
+ 1 | FALSE | 0 | 0 |
+-------------+--------------+-------------+-------------+
+ 1 | FALSE | 0 | 1 |
+-------------+--------------+-------------+-------------+
+ 1 | FALSE | 1 | 0 |
+-------------+--------------+-------------+-------------+
+ 1 | FALSE | 1 | 1 |
+=============+==============+=============+=============+====================
+ 1 | TRUE | 0 | 0 |
+-------------+--------------+-------------+-------------+ Release(button);
+ 1 | TRUE | 0 | 1 |
+-------------+--------------+-------------+-------------+--------------------
+ 1 | TRUE | 1 | 0 |
+-------------+--------------+-------------+-------------+
+ 1 | TRUE | 1 | 1 |
+=============+==============+=============+=============+====================
+
+
+
+Minimized table:
+
+=============+==============+=============+=============+====================
+ STATUS bit | button > 0 | btn 1 bit | btn 2 bit | result
+=============+==============+=============+=============+====================
+ 0 | FALSE | 1 | 0 | Press(1);
+-------------+--------------+-------------+-------------+--------------------
+ 0 | FALSE | 1 | 1 | Press(3);
+=============+==============+=============+=============+====================
+ ? | TRUE | 0 | ? | Release(button);
+=============+==============+=============+=============+====================
+ ? | TRUE | 1 | ? |
+-------------+--------------+-------------+-------------+
+ 1 | FALSE | ? | ? |
+-------------+--------------+-------------+-------------+
+ 0 | FALSE | 0 | ? |
+=============+==============+=============+=============+====================
+
+
+The minimized table may be effectively represented
+by the following algorithm:
+
+
+ +-------------------+
+ | STATUS bit change |
+ +---------+---------+
+ |
+ |
+ V
+ FALSE +--------------------------------+
+ X<---------+ button XOR btn 1 bit set |
+ +---------------+----------------+
+ | TRUE
+ |
+ V
+ TRUE +---------------+ FALSE
+ +-------------+ button > 0 +--------------+
+ | +---------------+ |
+ | |
+ V V
+ +-----------------------+ TRUE +-------------------+
+ | Release(button); | X<---------+ STATUS bit set |
+ | button = 0; | +---------+---------+
+ +---------+-------------+ | FALSE
+ | |
+ V V
+ X +--------------------------------------+
+ | button = (btn 1 bit) | (btn 2 bit); |
+ | Press(button); |
+ +--------------------+-----------------+
+ |
+ V
+ X
+
+ Note that the btn bits can be used like this ^^^ because they are in fact
+ 2^0 and 2^1, so the bit OR equals to 1 (btn 1 bit set, btn 2 bit clear)
+ or 3 (btn 1 bit set, btn 2 bit set).
+ This was also conveniently used in the implementation.
+