g13 tux logo   g13

device.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2009 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the g13 library.                                 *
00006  *                                                                         *
00007  *   The g13 library is free software; you can redistribute it and/or      *
00008  *   modify it under the terms of the GNU General Public License           *
00009  *   version 3 as published by the Free Software Foundation.               *
00010  *                                                                         *
00011  *   The g13 library is distributed in the hope that it will be            *
00012  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty   *
00013  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00014  *   General Public License for more details.                              *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this software. If not see <http://www.gnu.org/licenses/>.  *
00018  ***************************************************************************/
00019 #ifndef G13MM_DEVICE_H
00020 #define G13MM_DEVICE_H
00021 
00022 #include <string>
00023 #include <g13/udev.h>
00024 #include <g13/leds.h>
00025 #include <g13mm/pointer.h>
00026 
00029 namespace G13 {
00030 
00034     typedef enum LED {
00035         LED_M1 = G13_LED_M1,
00036         LED_M2 = G13_LED_M2,
00037             LED_M3 = G13_LED_M3,
00038             LED_MR = G13_LED_MR,
00039     } LED;
00040 
00044     struct Color {
00045         Color(unsigned red=0, unsigned green=0, unsigned blue=0): r(red), g(green), b(blue) { }
00046         unsigned r;
00047         unsigned g;
00048         unsigned b;
00049     };
00050     
00054     class Device {
00055         protected:
00056             Device(g13_device* cobj);
00057         public:
00058             typedef G13Pointer<Device> pointer;
00059 
00060             static pointer create(g13_device* cobj);
00061             static pointer create(g13_list_entry* list_entry);
00062             static pointer create(const std::string& name);
00063 
00064             ~Device();
00065 
00066             std::string name();
00067 
00068             int set_name(const std::string& name);
00069 
00070             int led(int which);
00071 
00072             int set_led(int which, bool on=true);
00073 
00074             int set_m1(bool enabled=true);
00075 
00076             int set_m2(bool enabled=true);
00077 
00078             int set_m3(bool enabled=true);
00079 
00080             int set_mr(bool enabled=true);
00081 
00082             Color backlight();
00083 
00084             int set_backlight(const Color& color);
00085 
00086             int set_backlight(unsigned r, unsigned g, unsigned b);
00087 
00088             g13_device* cobj();
00089 
00090         protected:
00091             g13_device* m_cobj;
00092     };
00093     
00094 }
00095 
00096 #endif

Generated on Wed Mar 24 10:13:17 2010 for g13 by doxygen 1.6.1