Advertisement
Guest User

functions

a guest
Apr 5th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.16 KB | None | 0 0
  1. /*
  2.     This file is part of g15tools.
  3.  
  4.     g15tools is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation; either version 2 of the License, or
  7.     (at your option) any later version.
  8.  
  9.     g15tools is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with g15lcd; if not, write to the Free Software
  16.     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17.    
  18.     (c) 2006 - 2007 The G15tools Project - g15tools.sf.net
  19.    
  20.     $Revision: 292 $ -  $Date: 2008-11-11 08:51:25 -0500 (Tue, 11 Nov 2008) $ $Author: aneurysm9 $
  21. */
  22.  
  23. #ifndef _LIBG15_H_
  24. #define _LIBG15_H_
  25.  
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30.  
  31. #define G15_LCD 1
  32. #define G15_KEYS 2
  33. #define G15_DEVICE_IS_SHARED 4
  34. #define G15_DEVICE_5BYTE_RETURN 8
  35.  
  36. #define G15_KEY_READ_LENGTH 9
  37.  
  38. typedef struct libg15_devices_t libg15_devices_t;
  39.  
  40. struct libg15_devices_t {
  41.   const char *name; // name - can be anything, only used for informational purposes
  42.   unsigned int vendorid;
  43.   unsigned int productid;
  44.   unsigned int caps; // capability bitfield - G15_LCD|G15_KEYS;
  45. };
  46.  
  47. #define DEVICE(name, vendorid, productid, caps) { \
  48.     name, \
  49.     vendorid, \
  50.     productid, \
  51.     caps \
  52. }
  53.  
  54.   /* allow for api changes */
  55. #define LIBG15_VERSION 1201
  56.  
  57.   enum
  58.   {
  59.     G15_LOG_INFO = 1,
  60.     G15_LOG_WARN
  61.   };
  62.  
  63.   enum
  64.   {
  65.     G15_NO_ERROR = 0,
  66.     G15_ERROR_OPENING_USB_DEVICE,
  67.     G15_ERROR_WRITING_PIXMAP,
  68.     G15_ERROR_TIMEOUT,
  69.     G15_ERROR_READING_USB_DEVICE,
  70.     G15_ERROR_TRY_AGAIN,
  71.     G15_ERROR_WRITING_BUFFER,
  72.     G15_ERROR_UNSUPPORTED
  73.   };
  74.  
  75.   enum
  76.   {
  77.     G15_LCD_OFFSET = 32,
  78.     G15_LCD_HEIGHT = 43,
  79.     G15_LCD_WIDTH = 160
  80.   };
  81.  
  82.   enum
  83.   {
  84.     G15_BUFFER_LEN = 0x03e0
  85.   };
  86.  
  87.   enum
  88.   {
  89.     G15_LED_M1=1<<0,
  90.     G15_LED_M2=1<<1,
  91.     G15_LED_M3=1<<2,
  92.     G15_LED_MR=1<<3
  93.   };
  94.  
  95.   enum
  96.   {
  97.     G15_CONTRAST_LOW=0,
  98.     G15_CONTRAST_MEDIUM,
  99.     G15_CONTRAST_HIGH    
  100.   };
  101.  
  102.   enum
  103.   {
  104.     G15_BRIGHTNESS_DARK=0,
  105.     G15_BRIGHTNESS_MEDIUM,
  106.     G15_BRIGHTNESS_BRIGHT
  107.   };
  108.  
  109.   enum
  110.   {
  111.     G15_KEY_G1  = 1<<0,
  112.     G15_KEY_G2  = 1<<1,
  113.     G15_KEY_G3  = 1<<2,
  114.     G15_KEY_G4  = 1<<3,
  115.     G15_KEY_G5  = 1<<4,
  116.     G15_KEY_G6  = 1<<5,
  117.     G15_KEY_G7  = 1<<6,
  118.     G15_KEY_G8  = 1<<7,
  119.     G15_KEY_G9  = 1<<8,
  120.     G15_KEY_G10 = 1<<9,
  121.     G15_KEY_G11 = 1<<10,
  122.     G15_KEY_G12 = 1<<11,
  123.     G15_KEY_G13 = 1<<12,
  124.     G15_KEY_G14 = 1<<13,
  125.     G15_KEY_G15 = 1<<14,
  126.     G15_KEY_G16 = 1<<15,
  127.     G15_KEY_G17 = 1<<16,
  128.     G15_KEY_G18 = 1<<17,
  129.    
  130.     G15_KEY_M1  = 1<<18,
  131.     G15_KEY_M2  = 1<<19,
  132.     G15_KEY_M3  = 1<<20,
  133.     G15_KEY_MR  = 1<<21,
  134.    
  135.     G15_KEY_L1  = 1<<22,
  136.     G15_KEY_L2  = 1<<23,
  137.     G15_KEY_L3  = 1<<24,
  138.     G15_KEY_L4  = 1<<25,
  139.     G15_KEY_L5  = 1<<26,
  140.    
  141.     G15_KEY_LIGHT = 1<<27
  142.   };
  143.  
  144.  
  145.   /* this one return G15_NO_ERROR on success, something
  146.    * else otherwise (for instance G15_ERROR_OPENING_USB_DEVICE */
  147.   int initLibG15();
  148.   /* re-initialise a previously unplugged keyboard ie ENODEV was returned at some point */
  149.   int re_initLibG15();
  150.  
  151.   int exitLibG15();
  152.   /* enable or disable debugging */
  153.   void libg15Debug(int option);
  154.  
  155.   int writePixmapToLCD(unsigned char const *data);
  156.   int setLCDContrast(unsigned int level);
  157.   int setLEDs(unsigned int leds);
  158.   int setLCDBrightness(unsigned int level);
  159.   int setKBBrightness(unsigned int level);  
  160.  
  161.   /* Please be warned
  162.    * the g15 sends two different usb msgs for each key press
  163.    * but only one of these two is used here. Since we do not want to wait
  164.    * longer than timeout we will return on any msg recieved. in the good
  165.    * case you will get G15_NO_ERROR and ORd keys in pressed_keys
  166.    * in the bad case you will get G15_ERROR_TRY_AGAIN -> try again
  167.    */
  168.   int getPressedKeys(unsigned int *pressed_keys, unsigned int timeout);
  169.  
  170.  
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174.    
  175. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement