summaryrefslogtreecommitdiff
path: root/library/custom-sharp.h
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /library/custom-sharp.h
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'library/custom-sharp.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/custom-sharp.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/library/custom-sharp.h b/library/custom-sharp.h
new file mode 100644
index 0000000..a149bbd
--- a/dev/null
+++ b/library/custom-sharp.h
@@ -0,0 +1,127 @@
1#define QPE_OWNAPM
2#define QPE_HAVE_TOGGLELIGHT
3#define QPE_NOCIBAUD
4#define QPE_STARTMENU
5#include <asm/sharp_apm.h>
6#ifndef APM_IOC_BATTERY_BACK_CHK
7#define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32)
8#endif
9#ifndef APM_IOC_BATTERY_MAIN_CHK
10#define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33)
11#endif
12
13#include <unistd.h>
14#include <stdio.h>
15#include <signal.h>
16#include <fcntl.h>
17#include <sys/ioctl.h>
18
19#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
20
21/* --- for SHARP_BUZZER device --- */
22 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
23#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
24#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
25#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
26#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
27#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
28#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
29
30#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
31#define SHARP_BUZ_KEYSOUND 2 /* key sound */
32#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
33#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
34#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
35#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
36#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
37#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
38#define SHARP_PDA_APPSTART 9 /* application start */
39#define SHARP_PDA_APPQUIT 10 /* application ends */
40#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
41#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
42#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
43#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
44
45
46#define CUSTOM_BUZZER( sound ) \
47{ \
48 static int fd = open( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); \
49 ioctl( fd, SHARP_BUZZER_MAKESOUND, sound ); \
50}
51
52#define CUSTOM_SOUND_ALARM CUSTOM_BUZZER( SHARP_BUZ_SCHEDULE_ALARM )
53
54#include <sys/ioctl.h>
55#include <asm/sharp_char.h>
56
57// a bit awkward, as this value is defined in emailclient.cpp aswell...
58#define LED_MAIL 0
59#define SHARP_LED_MAIL 9
60
61#define CUSTOM_LEDS( led, status ) \
62{ \
63 if ( led == LED_MAIL ) \
64 led = SHARP_LED_MAIL; \
65 static int fd = open( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); \
66 sharp_led_status leds; \
67 memset(&leds, 0, sizeof(leds)); \
68 leds.which = led; \
69 leds.status = status; \
70 ioctl( fd, SHARP_LED_SETSTATUS, (char*)&leds ); \
71}
72
73#define QPE_HAVE_MEMALERTER
74
75#define QPE_MEMALERTER_IMPL \
76static void sig_handler(int sig) \
77{ \
78 switch (sig) { \
79 case SIGHUP: \
80 memstate = VeryLow; \
81 break; \
82 case SIGUSR1: \
83 memstate = Normal; \
84 break; \
85 case SIGUSR2: \
86 memstate = Low; \
87 break; \
88 } \
89} \
90static void initMemalerter() \
91{ \
92 struct sigaction sa; \
93 memset(&sa, '\0', sizeof sa); \
94 sa.sa_handler = sig_handler; \
95 sa.sa_flags = SA_RESTART; \
96 if (sigaction(SIGHUP, &sa, NULL) < 0) { \
97 return; \
98 } \
99 if (sigaction(SIGUSR1, &sa, NULL) < 0) { \
100 return; \
101 } \
102 if (sigaction(SIGUSR2, &sa, NULL) < 0) { \
103 return; \
104 } \
105 FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \
106 \
107 if (!fo) \
108 return; \
109 fprintf(fo, "qpe\n"); \
110 fclose(fo); \
111}
112
113#define QPE_INITIAL_NUMLOCK_STATE \
114{ \
115 bool numLock = FALSE; \
116 sharp_kbdctl_modifstat st; \
117 int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \
118 if( dev >= 0 ) { \
119 memset(&st, 0, sizeof(st)); \
120 st.which = 3; \
121 int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \
122 if( !ret ) \
123 numLock = (bool)st.stat; \
124 ::close(dev); \
125 } \
126 return numLock; \
127}