]> asedeno.scripts.mit.edu Git - pssh.git/blob - arm/forms/form_armcalls.c
updates to device ids
[pssh.git] / arm / forms / form_armcalls.c
1 /**********
2  * Copyright (c) 2007 Alejandro R Sedeno.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
12  *
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.
24  **********/
25
26 #include "includes.h"
27 #include "pealstub.h"
28
29 /*
30 void dbg_beep(int, int);
31 void dbg_beep(int hz, int ms)
32 {
33      SndCommandType snd;
34      UInt16 volume = PrefGetPreference(prefGameSoundVolume);
35      snd.cmd = sndCmdFreqDurationAmp;
36      snd.reserved = 0;
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);
41 }
42 */
43 static int deviceTreo6x0 = 0;
44
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);
51   
52   if (((companyID == 'hspr') &&
53        (deviceID == 'H101' /* Tro 600 */
54         || deviceID == 'H102' /* Treo 650 */
55             )) ||
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 */
62             ))) {
63     deviceTreo6x0 = 1;
64   }
65   return deviceTreo6x0;
66 }
67
68 /* Alternate keymap for alt key */
69
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     /* <  */ ',',     /* =  */ '+',     /* >  */ '.',     /* ?  */ '}'
79 };
80
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 */ '[',
87     /* Z */ '^'
88 };
89
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 */ '^',
96     /* Z */ '%'
97
98 };
99
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];
105   if (deviceTreo6x0) {
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'];
108   } else {
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'];
113   }
114   return (uint32_t) *c;
115 }
116
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-~)
124   return c;
125 }