summaryrefslogtreecommitdiff
path: root/library/custom-sharp.h
Unidiff
Diffstat (limited to 'library/custom-sharp.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/custom-sharp.h53
1 files changed, 0 insertions, 53 deletions
diff --git a/library/custom-sharp.h b/library/custom-sharp.h
index 08f8a6f..3dab34f 100644
--- a/library/custom-sharp.h
+++ b/library/custom-sharp.h
@@ -1,150 +1,97 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QPE_OWNAPM 21#define QPE_OWNAPM
22#define QPE_HAVE_TOGGLELIGHT 22#define QPE_HAVE_TOGGLELIGHT
23#define QPE_NOCIBAUD 23#define QPE_NOCIBAUD
24#define QPE_STARTMENU 24#define QPE_STARTMENU
25#include <asm/sharp_apm.h> 25#include <asm/sharp_apm.h>
26#ifndef APM_IOC_BATTERY_BACK_CHK 26#ifndef APM_IOC_BATTERY_BACK_CHK
27#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) 27#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32)
28#endif 28#endif
29#ifndef APM_IOC_BATTERY_MAIN_CHK 29#ifndef APM_IOC_BATTERY_MAIN_CHK
30#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) 30#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33)
31#endif 31#endif
32 32
33#include <unistd.h> 33#include <unistd.h>
34#include <stdio.h> 34#include <stdio.h>
35#include <signal.h> 35#include <signal.h>
36#include <fcntl.h> 36#include <fcntl.h>
37#include <sys/ioctl.h> 37#include <sys/ioctl.h>
38 38
39#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
40
41/* --- for SHARP_BUZZER device --- */
42#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
43#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
44#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
45#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
46#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
47#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
48#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
49
50#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
51#define SHARP_BUZ_KEYSOUND 2 /* key sound */
52#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
53#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
54#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
55#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
56#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
57#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
58#define SHARP_PDA_APPSTART 9 /* application start */
59#define SHARP_PDA_APPQUIT 10 /* application ends */
60#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
61#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
62#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
63#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
64
65
66#define CUSTOM_BUZZER( sound ) \
67{ \
68 static int fd = open( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); \
69 ioctl( fd, SHARP_BUZZER_MAKESOUND, sound ); \
70}
71
72#define CUSTOM_SOUND_ALARM CUSTOM_BUZZER( SHARP_BUZ_SCHEDULE_ALARM )
73#define CUSTOM_SOUND_KEYCLICK CUSTOM_BUZZER( SHARP_BUZ_KEYSOUND )
74#define CUSTOM_SOUND_TOUCH CUSTOM_BUZZER( SHARP_BUZ_TOUCHSOUND )
75
76 39
77#include <sys/ioctl.h> 40#include <sys/ioctl.h>
78#include <asm/sharp_char.h> 41#include <asm/sharp_char.h>
79 42
80// a bit awkward, as this value is defined in emailclient.cpp aswell...
81#define LED_MAIL 0
82#define SHARP_LED_MAIL 9
83
84#define CUSTOM_LEDS( led, status ) \
85{ \
86 if ( led == LED_MAIL ) \
87 led = SHARP_LED_MAIL; \
88 static int fd = open( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); \
89 sharp_led_status leds; \
90 memset(&leds, 0, sizeof(leds)); \
91 leds.which = led; \
92 leds.status = status; \
93 ioctl( fd, SHARP_LED_SETSTATUS, (char*)&leds ); \
94}
95
96#define QPE_HAVE_MEMALERTER 43#define QPE_HAVE_MEMALERTER
97 44
98#define QPE_MEMALERTER_IMPL \ 45#define QPE_MEMALERTER_IMPL \
99static void sig_handler(int sig) \ 46static void sig_handler(int sig) \
100{ \ 47{ \
101 switch (sig) { \ 48 switch (sig) { \
102 case SIGHUP: \ 49 case SIGHUP: \
103 memstate = VeryLow; \ 50 memstate = VeryLow; \
104 break; \ 51 break; \
105 case SIGUSR1: \ 52 case SIGUSR1: \
106 memstate = Normal; \ 53 memstate = Normal; \
107 break; \ 54 break; \
108 case SIGUSR2: \ 55 case SIGUSR2: \
109 memstate = Low; \ 56 memstate = Low; \
110 break; \ 57 break; \
111 } \ 58 } \
112} \ 59} \
113static void initMemalerter() \ 60static void initMemalerter() \
114{ \ 61{ \
115 struct sigaction sa; \ 62 struct sigaction sa; \
116 memset(&sa, '\0', sizeof sa); \ 63 memset(&sa, '\0', sizeof sa); \
117 sa.sa_handler = sig_handler; \ 64 sa.sa_handler = sig_handler; \
118 sa.sa_flags = SA_RESTART; \ 65 sa.sa_flags = SA_RESTART; \
119 if (sigaction(SIGHUP, &sa, NULL) < 0) { \ 66 if (sigaction(SIGHUP, &sa, NULL) < 0) { \
120 return; \ 67 return; \
121 } \ 68 } \
122 if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ 69 if (sigaction(SIGUSR1, &sa, NULL) < 0) { \
123 return; \ 70 return; \
124 } \ 71 } \
125 if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ 72 if (sigaction(SIGUSR2, &sa, NULL) < 0) { \
126 return; \ 73 return; \
127 } \ 74 } \
128 FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ 75 FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \
129 \ 76 \
130 if (!fo) \ 77 if (!fo) \
131 return; \ 78 return; \
132 fprintf(fo, "qpe\n"); \ 79 fprintf(fo, "qpe\n"); \
133 fclose(fo); \ 80 fclose(fo); \
134} 81}
135 82
136#define QPE_INITIAL_NUMLOCK_STATE \ 83#define QPE_INITIAL_NUMLOCK_STATE \
137{ \ 84{ \
138 bool numLock = FALSE; \ 85 bool numLock = FALSE; \
139 sharp_kbdctl_modifstat st; \ 86 sharp_kbdctl_modifstat st; \
140 int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \ 87 int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \
141 if( dev >= 0 ) { \ 88 if( dev >= 0 ) { \
142 memset(&st, 0, sizeof(st)); \ 89 memset(&st, 0, sizeof(st)); \
143 st.which = 3; \ 90 st.which = 3; \
144 int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \ 91 int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \
145 if( !ret ) \ 92 if( !ret ) \
146 numLock = (bool)st.stat; \ 93 numLock = (bool)st.stat; \
147 ::close(dev); \ 94 ::close(dev); \
148 } \ 95 } \
149 return numLock; \ 96 return numLock; \
150} 97}