================================================================================
=                    Linux Touch Panel Utility Sample API                      =
=                                Tp_API sample                                 =
=                                                                              =
=                                                             TPBK(LNX)        =
=                                                             CONTEC Co.,Ltd.  =
================================================================================


◆ Contents
===========
  Introduction
  Overview
  File Structure
  How to use TpAPI
  TpAPI usage sample explanation
  API function list

◆ Introduction
======================
  This commentary file describes the API library for using the touch panel
  function installed in our product in the Linux environment.
  Please use this API library as a reference when developing your application.

◆ Overview
======================
  TpAPI is a sample API library for using the command usage provided by the
  touch panel utility (Tpmouse).
  This file describes how to use this API library.
  When using the API functions provided by the Tp API library, the touch panel
  utility Tpmouse needs to be executed.
  For Tpmouse, please refer to the relevant comment file under the Tp_Utils
  directory.
  TpAPI is implemented in C language.

◆ File Structure
======================
  The TpAPI file has the following configuration.

  ./Tp_API              ... Touch panel API
    Makefile            ... Makefile for compiling and installing
                            (make | make clean | make sample | make install |
                            make uninstall)
    TpAPIman_j.txt      ... Description file for using touch panel API (Ja)
    TpAPIman_e.txt      ... Description file for using touch panel API (En)
    TpAPI.c             ... Source file of touch panel API
    TpAPI.h             ... Touch panel API header file
    run_APIsample.sh    ... Sample batch execution test script

    /APISampleCode      ... API use console sample code
      BKOFF.c           ... Sample source file that executes API to turn off
                            backlight
      BKON.c            ... Sample source file that executes API to turn on
                            backlight
      BRDOWNS.c         ... Sample source file that executes API to reduce
                            backlight brightness
      BRUPS.c           ... Sample source file that executes API to increase
                            backlight brightness
      TPBeepCtloff.c    ... Sample source file that executes API to enable beep
                            sound when touch panel operation
      TPBeepCtlon.c     ... Sample source file that executes API to disable
                            beep sound when touch panel operation
      TPMouseMode.c     ... Sample source file that executes API to switch left
                            and right click at Tpmouse input
      TPMouseModeSetL.c ... Sample source file that executes API to switch
                            Tpmouse touch input to left click
      TPMouseModeSetR.c ... Sample source file that executes API to switch
                            Tpmouse touch input to right click

◆ How to use TpAPI
======================
  ■ Use of "./Tp_API/Makefile"
    With "./Tp_API/Makefile", you can execute "make | make clean | make sample |
    make install | make uninstall".

    make:
      There are two files under "./TpAPI": an intermediate file (TpAPI.o)
      and a shared library file (libTpAPI.so.x.x).
      * In API function, in order to communicate with Tpmouse, set port tcp 5000
      as default and use it. Change the source file as needed.

    make clean：
      Delete the files created by make and make sample.

    make sample：
      The following sample executable file for API execution is generated under
      "./TpAPI".

      - BKOFF
      - BKON
      - BRDOWNS
      - BRUPS
      - TPBeepCtloff
      - TPBeepCtlon
      - TPMouseMode
      - TPMouseModeSetL
      - TPMouseModeSetR

      * When running make sample, this API library needs to be installed by make
      and make install.

    make install:
      Install libTpAPI.so.x.x under /usr/lib.
      Also, create libTpAPI.so (symbolic link to libTpAPI.so.x.x) under /usr/lib.
      Install TpAPI.h under /usr/include.

      * It is necessary to execute with root authority.
      * If the library path does not pass to the installation directory, you may
      not be able to compile and execute programs using this API. Please check
      the execution environment before using.
      * If you want to install in any directory, please check the inside of the
      Makefile, edit and execute.


    make uninstall：
      The installed file is removed from the system.
      * It is necessary to execute with root authority.

◆ TpAPI usage sample explanation
======================
  ■ Sample executable file
    This is a description of each sample executable file generated under
    "./Tp_API" after executing make sample.

      - BKOFF
        Turn off the backlight.
      - BKON
        Turn on the backlight.
      - BRDOWNS
        Increase the brightness of the backlight.
      - BRUPS
        Decrease the brightness of the backlight.
      - TPBeepCtloff
        Make sure that the beeper does not sound during touch panel operation.
      - TPBeepCtlon
        Make a beep sound when operating the touch panel.
      - TPMouseMode
        Switches each time the left and right click of touch panel input is
        executed.
      - TPMouseModeSetL
        Switch touch panel input to left-click input.
      - TPMouseModeSetR
        Switch touch panel input to right-click input.


◆ API function list
======================
This API provides the following API functions.

  ■ List of API functions with return value
    In API function with return value,
      - Returns -1 if it fails to secure a communication socket with Tpmouse.
      - Returns -2 if command transmission with Tpmouse fails.

    - Backlight ON
      int BKON( void );
        return  : 0 - Successful completion
                :-1 - Socket connection error
                :-2 - Command processing error

    - Backlight OFF
      int BKOFF( void );
        return  : 0 - Successful completion
                :-1 - Socket connection error
                :-2 - Command processing error


    - Backlight brightness UP
      int BRUPS( void );
        return  : 0 - Successful completion
                :-1 - Socket connection error
                :-2 - Command processing error

    - Backlight brightness DOWN
      int BRDOWNS( void );
        return  : 0 - Successful completion
                :-1 - Socket connection error
                :-2 - Command processing error

    - Beep sound ON/OFF switching
      int BeepCtl( int flg );
        flg     : 1 - beep on
                : 2 - beep off
        return  : 1 - beep on (Successful completion)
                : 2 - beep off (Successful completion)
                :-1 - Socket connection error
                :-2 - Command processing error
                :-3 - The input value of flg is invalid
                      (if it is a value other than 1 or 2)

    - Right and left click switching (toggle)
      int TPMouseMode( void );
        return  : 0 - Successful completion
                :-1 - Socket connection error
                :-2 - Command processing error

    - Right and left click switching
      int TPMouseModeSet( int flg );
        flg     : 1 – right click
                : 2 – Left click
        return  : 1 - right click(Successful completion)
                : 2 - Left click(Successful completion)
                :-1 - Socket connection error
                :-2 - Command processing error
                :-3 - The input value of flg is invalid
                      (if it is a value other than 1 or 2)

    * Each function for left/right click switching needs to build and setup
    Tpmouse for mouse button input, not touch input.
    Please note that by design, it will not work if Tpmouse is built and set up
    with touch input.

  ■ No return value API function list
    In addition to the above return value API functions, the following no return
    value API functions are implemented as wrapper functions for return value API
    functions.
    * This function is prepared for compatibility with the old API function.
    When creating an application, it is recommended to use the function with the
    above return value.

    - Backlight ON
      void BKON_( void );

    - Backlight OFF
      void BKOFF_( void );

    - Backlight brightness UP
      void BRUPS_( void );

    - Backlight brightness DOWN
      void BRDOWNS_( void );

    - Beep sound ON/OFF switching
      void BeepCtl_( int flg );
        flg   :1 - beep on
              :2 - beep off

    - Right and left click switching (toggle)
      void TPMouseMode_( void );

    - Right and left click switching
      int TPMouseModeSet_( int flg );
        flg   :1 – right click
              :2 – Left click
