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.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/library/custom-sharp.h b/library/custom-sharp.h
index a149bbd..f65d474 100644
--- a/library/custom-sharp.h
+++ b/library/custom-sharp.h
@@ -1,96 +1,116 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
1#define QPE_OWNAPM 21#define QPE_OWNAPM
2#define QPE_HAVE_TOGGLELIGHT 22#define QPE_HAVE_TOGGLELIGHT
3#define QPE_NOCIBAUD 23#define QPE_NOCIBAUD
4#define QPE_STARTMENU 24#define QPE_STARTMENU
5#include <asm/sharp_apm.h> 25#include <asm/sharp_apm.h>
6#ifndef APM_IOC_BATTERY_BACK_CHK 26#ifndef APM_IOC_BATTERY_BACK_CHK
7#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) 27#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32)
8#endif 28#endif
9#ifndef APM_IOC_BATTERY_MAIN_CHK 29#ifndef APM_IOC_BATTERY_MAIN_CHK
10#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) 30#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33)
11#endif 31#endif
12 32
13#include <unistd.h> 33#include <unistd.h>
14#include <stdio.h> 34#include <stdio.h>
15#include <signal.h> 35#include <signal.h>
16#include <fcntl.h> 36#include <fcntl.h>
17#include <sys/ioctl.h> 37#include <sys/ioctl.h>
18 38
19#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 39#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
20 40
21/* --- for SHARP_BUZZER device --- */ 41/* --- for SHARP_BUZZER device --- */
22 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 42 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
23#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 43#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
24#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 44#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
25#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 45#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
26#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 46#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
27#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 47#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
28#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 48#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
29 49
30#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 50#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
31#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 51#define SHARP_BUZ_KEYSOUND 2 /* key sound */
32#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 52#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
33#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 53#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
34#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 54#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
35#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 55#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
36#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 56#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
37#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 57#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
38#define SHARP_PDA_APPSTART 9 /* application start */ 58#define SHARP_PDA_APPSTART 9 /* application start */
39#define SHARP_PDA_APPQUIT 10 /* application ends */ 59#define SHARP_PDA_APPQUIT 10 /* application ends */
40#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 60#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
41#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 61#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
42#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 62#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
43#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 63#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
44 64
45 65
46#define CUSTOM_BUZZER( sound ) \ 66#define CUSTOM_BUZZER( sound ) \
47{ \ 67{ \
48 static int fd = open( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); \ 68 static int fd = open( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); \
49 ioctl( fd, SHARP_BUZZER_MAKESOUND, sound ); \ 69 ioctl( fd, SHARP_BUZZER_MAKESOUND, sound ); \
50} 70}
51 71
52#define CUSTOM_SOUND_ALARM CUSTOM_BUZZER( SHARP_BUZ_SCHEDULE_ALARM ) 72#define CUSTOM_SOUND_ALARM CUSTOM_BUZZER( SHARP_BUZ_SCHEDULE_ALARM )
53 73
54#include <sys/ioctl.h> 74#include <sys/ioctl.h>
55#include <asm/sharp_char.h> 75#include <asm/sharp_char.h>
56 76
57// a bit awkward, as this value is defined in emailclient.cpp aswell... 77// a bit awkward, as this value is defined in emailclient.cpp aswell...
58#define LED_MAIL 0 78#define LED_MAIL 0
59#define SHARP_LED_MAIL 9 79#define SHARP_LED_MAIL 9
60 80
61#define CUSTOM_LEDS( led, status ) \ 81#define CUSTOM_LEDS( led, status ) \
62{ \ 82{ \
63 if ( led == LED_MAIL ) \ 83 if ( led == LED_MAIL ) \
64 led = SHARP_LED_MAIL; \ 84 led = SHARP_LED_MAIL; \
65 static int fd = open( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); \ 85 static int fd = open( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); \
66 sharp_led_status leds; \ 86 sharp_led_status leds; \
67 memset(&leds, 0, sizeof(leds)); \ 87 memset(&leds, 0, sizeof(leds)); \
68 leds.which = led; \ 88 leds.which = led; \
69 leds.status = status; \ 89 leds.status = status; \
70 ioctl( fd, SHARP_LED_SETSTATUS, (char*)&leds ); \ 90 ioctl( fd, SHARP_LED_SETSTATUS, (char*)&leds ); \
71} 91}
72 92
73#define QPE_HAVE_MEMALERTER 93#define QPE_HAVE_MEMALERTER
74 94
75#define QPE_MEMALERTER_IMPL \ 95#define QPE_MEMALERTER_IMPL \
76static void sig_handler(int sig) \ 96static void sig_handler(int sig) \
77{ \ 97{ \
78 switch (sig) { \ 98 switch (sig) { \
79 case SIGHUP: \ 99 case SIGHUP: \
80 memstate = VeryLow; \ 100 memstate = VeryLow; \
81 break; \ 101 break; \
82 case SIGUSR1: \ 102 case SIGUSR1: \
83 memstate = Normal; \ 103 memstate = Normal; \
84 break; \ 104 break; \
85 case SIGUSR2: \ 105 case SIGUSR2: \
86 memstate = Low; \ 106 memstate = Low; \
87 break; \ 107 break; \
88 } \ 108 } \
89} \ 109} \
90static void initMemalerter() \ 110static void initMemalerter() \
91{ \ 111{ \
92 struct sigaction sa; \ 112 struct sigaction sa; \
93 memset(&sa, '\0', sizeof sa); \ 113 memset(&sa, '\0', sizeof sa); \
94 sa.sa_handler = sig_handler; \ 114 sa.sa_handler = sig_handler; \
95 sa.sa_flags = SA_RESTART; \ 115 sa.sa_flags = SA_RESTART; \
96 if (sigaction(SIGHUP, &sa, NULL) < 0) { \ 116 if (sigaction(SIGHUP, &sa, NULL) < 0) { \