summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_beagle.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_beagle.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_beagle.cpp156
1 files changed, 156 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/odevice_beagle.cpp b/libopie2/opiecore/device/odevice_beagle.cpp
new file mode 100644
index 0000000..9cf640a
--- a/dev/null
+++ b/libopie2/opiecore/device/odevice_beagle.cpp
@@ -0,0 +1,156 @@
1/*
2                 This file is part of the Opie Project
3              Copyright (C) 2004 The Opie Team <opie-devel@handhelds.org>
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#include "odevicebutton.h"
31#include "odevice_beagle.h"
32
33#include <qpe/resource.h>
34
35#include <sys/types.h>
36#include <sys/ioctl.h>
37#include <fcntl.h>
38#include <unistd.h>
39
40
41
42 #define _SA1100_FL_IOCTL_ON 1
43 #define _SA1100_FL_IOCTL_OFF 2
44 #define _SA1100_FL_IOCTL_INTENSITY3
45#define _SA1100_FL_IOCTL_BACKLIGHT 4
46 #define _SA1100_FL_IOCTL_CONTRAST5
47#define _SA1100_FL_IOCTL_GET_BACKLIGHT 6
48#define _SA1100_FL_IOCTL_GET_CONTRAST 7
49// added by Sean Hsieh
50 #define _SA1100_FL_IOCTL_PWR_TOGGLE 8
51 #define _SA1100_FL_IOCTL_AUTOLIGHT 10
52
53#define FL_MAJOR 60
54#define FL_NAME "sa1100-fl"
55#define FL_FILE "/dev/sa1100-fl"
56
57namespace Opie {
58namespace Core {
59namespace Internal {
60
61struct b_button {
62 uint model;
63 Qt::Key code;
64 char *utext;
65 char *pix;
66 char *fpressedservice;
67 char *fpressedaction;
68 char *fheldservice;
69 char *fheldaction;
70};
71
72struct b_button beagle_buttons [] = {
73 { Model_Beagle_PA100,
74 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
75 "devicebuttons/beagle_calendar",
76 "datebook", "nextView()",
77 "today", "raise()" },
78 { Model_Beagle_PA100,
79 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
80 "devicebuttons/beagle_contact",
81 "addressbook", "raise()",
82 "addressbook", "beamBusinessCard()" },
83 { Model_Beagle_PA100,
84 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"),
85 "devicebuttons/beagle_todo",
86 "todolist", "raise()",
87 "QPE/TaskBar", "toggleMenu()" },
88 { Model_Beagle_PA100,
89 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
90 "devicebuttons/beagle_home",
91 "QPE/Launcher", "home()",
92 "buttonsettings", "raise()" },
93};
94
95
96Beagle::Beagle()
97{
98 qWarning( "Created Beagle" );
99}
100Beagle::~Beagle() {}
101
102void Beagle::init( const QString&) {
103 /*
104 * No other assabat model yet
105 */
106 d->m_vendorstr = "Tradesquare.NL";
107 d->m_vendor = Vendor_MasterIA;
108 d->m_modelstr = "Tuxpda 1";
109 d->m_rotation = Rot0;
110}
111
112void Beagle::initButtons() {
113 if ( d->m_buttons )
114 return;
115
116 d->m_buttons = new QValueList<ODeviceButton>;
117 uint length = sizeof( beagle_buttons )/ sizeof( b_button );
118 for ( uint i = 0; i < length; ++i ) {
119 b_button *bb = &beagle_buttons[i];
120 ODeviceButton b;
121 b.setKeycode( bb->code );
122 b.setUserText( QObject::tr( "Button", bb->utext ) );
123 b.setPixmap( Resource::loadPixmap( bb->pix ) );
124 b.setFactoryPresetPressedAction( OQCopMessage( makeChannel( bb->fpressedservice ), bb->fpressedaction ) );
125 b.setFactoryPresetHeldAction( OQCopMessage( makeChannel( bb->fheldservice ), bb->fheldaction ) );
126 d->m_buttons->append( b );
127 }
128
129 reloadButtonMapping();
130}
131
132bool Beagle::setDisplayStatus( bool on ) {
133 int fd = ::open(FL_FILE, O_WRONLY);
134
135 if ( fd < 0 )
136 return false;
137
138 return ( ::ioctl(fd, on ? _SA1100_FL_IOCTL_ON : _SA1100_FL_IOCTL_OFF, 0 ) == -1 );
139}
140
141int Beagle::displayBrightnessResolution()const {
142 return 100;
143}
144
145bool Beagle::setDisplayBrightness( int brightness ) {
146 int fd = ::open(FL_FILE, O_WRONLY);
147
148 if ( fd < 0 )
149 return false;
150
151 return ( ::ioctl(fd, _SA1100_FL_IOCTL_INTENSITY, brightness%101 ) == 0 );
152}
153
154}
155}
156}