2 * Copyright (c) 2007 Alejandro R Sedeno. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
17 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
23 * OF THE POSSIBILITY OF SUCH DAMAGE.
30 void dbg_beep(int, int);
31 void dbg_beep(int hz, int ms)
34 UInt16 volume = PrefGetPreference(prefGameSoundVolume);
35 snd.cmd = sndCmdFreqDurationAmp;
37 snd.param1 = hz; // frequency in Hz
38 snd.param2 = ms; // duration in ms
39 snd.param3 = volume; // volume [0..sndMaxAmp]
40 SndDoCmd(NULL, &snd, false);
43 static int deviceTreo6x0 = 0;
45 uint32_t CheckDeviceTreo_stub(uint32_t *);
46 uint32_t CheckDeviceTreo_stub(uint32_t *param) {
47 uint32_t companyID = 0;
48 uint32_t deviceID = 0;
49 FtrGet(sysFtrCreator, sysFtrNumOEMCompanyID, &companyID);
50 FtrGet(sysFtrCreator, sysFtrNumOEMDeviceID, &deviceID);
52 if (((companyID == 'hspr') &&
53 (deviceID == 'H101' /* Tro 600 */
54 || deviceID == 'H102' /* Treo 650 */
56 (companyID == 'Palm' &&
57 (deviceID == 'D052' /* Treo 700p*/
58 || deviceID == 'D053' /* Treo 680 */
59 || deviceID == 'D060' /* Treo 755p */
60 || deviceID == 'D061' /* Centro 685 */
61 || deviceID == 'D062' /* Centro 690 */
68 /* Alternate keymap for alt key */
70 static unsigned char altsym_symbol_map[32] = {
71 /* SP */ ' ', /* ! */ '|', /* " */ '~', /* # */ '{',
72 /* $ */ '%', /* % */ '%', /* & */ '&', /* ' */ '`',
73 /* ( */ '[', /* ) */ ']', /* * */ '^', /* + */ '=',
74 /* , */ '<', /* - */ '_', /* . */ '>', /* / */ '\\',
75 /* 0 */ ')', /* 1 */ '!', /* 2 */ '@', /* 3 */ '#',
76 /* 4 */ '$', /* 5 */ '%', /* 6 */ '^', /* 7 */ '&',
77 /* 8 */ '*', /* 9 */ '(', /* : */ ';', /* ; */ ':',
78 /* < */ ',', /* = */ '+', /* > */ '.', /* ? */ '}'
81 static unsigned char altsym_treo_map[26] = {
82 /* A */ '&', /* B */ '{', /* C */ '*', /* D */ '$', /* E */ '!',
83 /* F */ '%', /* G */ '^', /* H */ '%', /* I */ '&', /* J */ '|',
84 /* K */ ';', /* L */ '`', /* M */ '<', /* N */ '}', /* O */ '~',
85 /* P */ '%', /* Q */ '\\', /* R */ '@', /* S */ '_', /* T */ '#',
86 /* U */ ']', /* V */ '(', /* W */ '=', /* X */ '&', /* Y */ '[',
90 static unsigned char altsym_tungsten_map[26] = {
91 /* A */ ';', /* B */ '|', /* C */ ']', /* D */ '=', /* E */ '#',
92 /* F */ '_', /* G */ '^', /* H */ '-', /* I */ '*', /* J */ '~',
93 /* K */ '`', /* L */ '&', /* M */ '}', /* N */ '<', /* O */ '(',
94 /* P */ ')', /* Q */ '!', /* R */ '$', /* S */ '\\', /* T */ '%',
95 /* U */ '&', /* V */ '{', /* W */ '@', /* X */ '[', /* Y */ '^',
100 uint32_t altsym_character_stub(unsigned char *);
101 uint32_t altsym_character_stub(unsigned char *c) {
102 if (*c == '@') return '&';
103 if (*c == '_') return '-';
104 if (*c >= 0x20 && *c < 0x40) return (uint32_t) altsym_symbol_map[*c - 0x20];
106 if (*c >= 'A' && *c <= 'Z') return (uint32_t) altsym_treo_map[*c - 'A'];
107 if (*c >= 'a' && *c <= 'z') return (uint32_t) altsym_treo_map[*c - 'a'];
109 // for now, use tungsten layout on all but treo
110 // note there is currently no way to get altPressed on the tungsten
111 if (*c >= 'A' && *c <= 'Z') return (uint32_t) altsym_tungsten_map[*c - 'A'];
112 if (*c >= 'a' && *c <= 'z') return (uint32_t) altsym_tungsten_map[*c - 'a'];
114 return (uint32_t) *c;
117 uint32_t control_character_stub(unsigned char *);
118 uint32_t control_character_stub(unsigned char *c) {
119 if (*c == ' ' || *c == '@') return '\0'; // C-space, C-@
120 if (*c >= 'a' && *c <= 'z') return *c - 'a' + 1; // C-a .. C-z
121 if (*c >= 'A' && *c <= 'Z') return *c - 'A' + 1; // C-A .. C-Z
122 if (*c >= '[' && *c <= '_') return *c - 'A' + 1; // C-[ .. C-_
123 if (*c >= '{' && *c <= '}') return *c - 'a' + 1; // C-{ .. C-} (no C-~)