File: CGremlinsStubs.cpp

package info (click to toggle)
pose 3.0a3-3
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 15,500 kB
  • ctags: 20,548
  • sloc: ansic: 72,579; cpp: 50,198; perl: 1,336; python: 1,242; sh: 363; makefile: 290
file content (178 lines) | stat: -rw-r--r-- 5,556 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* -*- mode: C++; tab-width: 4 -*- */
/* ================================================================================== */
/* Copyright (c) 1998-1999 3Com Corporation or its subsidiaries. All rights reserved. */
/* ================================================================================== */

#include "EmulatorCommon.h"
#include "CGremlinsStubs.h"

#include "Platform.h"			// Platform::ViewDrawLine

// ---------------------------------------------------------------------------
//		 StubEnqueuePt
// ---------------------------------------------------------------------------
// This is a stub routine that called the application object's method that
// enqueues a point.

void	StubAppEnqueuePt(PointType* pen)
{
	::EvtEnqueuePenPoint(pen);
}


// ---------------------------------------------------------------------------
//		 StubAppEnqueueKey
// ---------------------------------------------------------------------------
// This is a stub routine that called the Application object's method that
// enqueues a key.

void StubAppEnqueueKey (UInt16 ascii, UInt16 keycode, UInt16 modifiers)
{
	switch (ascii)
	{
		// This translates some control characters into system chars
		case 0x01:	// control-A
			ascii = menuChr;
			modifiers = commandKeyMask;
			break;
		case 0x02:	// control-B
			ascii = lowBatteryChr;
			modifiers = commandKeyMask;
			break;			
		case 0x03:	// control-C
			ascii = commandChr;
			modifiers = commandKeyMask;
			break;
		case 0x04:	// control-D
			ascii = confirmChr;
			modifiers = commandKeyMask;
			break;
		case 0x05:	// control-E
			ascii = launchChr;
			modifiers = commandKeyMask;
			break;
		case 0x06:	// control-F
			ascii = keyboardChr;
			modifiers = commandKeyMask;
			break;
		case 0x0D:	// control-M
			ascii = linefeedChr;
			break;
		case 0x0E:	// control-N
			ascii = nextFieldChr;
			modifiers = commandKeyMask;
			break;			
		case 0x13:	// control-S
			ascii = autoOffChr;
			modifiers = commandKeyMask;
			break;			
		case 0x14:	// control-T
			ascii = hardContrastChr;
			modifiers = commandKeyMask;
			break;			
		case 0x15:	// control-U
			ascii = backlightChr;
			modifiers = commandKeyMask;
			break;
	}


	// If this is one of the hard keys, send it through the Key Manager so that
	//  it can do the right things concering double-taps, etc.
	if ((modifiers & commandKeyMask) &&
			(ascii > hardKeyMin || (ascii == pageUpChr) || (ascii == pageDownChr)))
	{

		DWord		status = 0;

		switch (ascii)
		{
			case hard1Chr: 		status = keyBitHard1; break;
			case hard2Chr: 		status = keyBitHard2; break;
			case hard3Chr: 		status = keyBitHard3; break;
			case hard4Chr: 		status = keyBitHard4; break;
			case hardPowerChr: 	status = keyBitPower; break;
			case pageUpChr: 	status = keyBitPageUp; break;
			case pageDownChr: 	status = keyBitPageDown; break;
		}

		// I'm dubious that this is the correct thing to do in the emulator.
		// This is an interrupt routine that we're calling directly.  But
		// what if a "real" interrupt is triggered from some other source
		// while this call is executing (for instance, the user clicks on
		// one of the "keyboard buttons", thus generating a keyboard
		// interrupt)?  It's possible that the two will stomp on each other.
		// The best thing to do is to post events the emulator way.
		// However, I'm hard-pressed to do that.  That would require calling
		// Hardware_ButtonEvent twice (once to signal the keyboard
		// interrupt, and another to clear it), but I don't know how to give
		// the processor time in between to respond to the first call.

		if (status != 0)
			::KeyHandleInterrupt (false, status);
	}

	// For other keys, enqueue them directly.
	else
	{
		::EvtEnqueueKey (ascii, keycode, modifiers);

		// Added - during Gremlin runs, we found that the timeout
		// could get set to 30 seconds and that a Gremlin may type
		// characters for more than 30 seconds at a time. EvtEnqueueKey
		// doesn't reset the event timer, so it was possible for the
		// device to go to sleep, even when typing was occuring.

		::EvtResetAutoOffTimer ();
	}
}


// ---------------------------------------------------------------------------
//		 StubAppGremlinsOn
// ---------------------------------------------------------------------------
// Stub routine that update the Gremlins menu an the global variable the
// keeps track of the ????

void StubAppGremlinsOn (void)
{
	// Called from Gremlins::Initialize.
}


// ---------------------------------------------------------------------------
//		 StubAppGremlinsOff
// ---------------------------------------------------------------------------
// Stub routine that update the Gremlins menu an the global variable the
// keeps track of the ????

void StubAppGremlinsOff (void)
{
	// Called by Gremlins when counter > until.
}


// ---------------------------------------------------------------------------
//		 StubViewDrawLine
// ---------------------------------------------------------------------------
// This is a stub routine that called the View object's method that draw
// a line.

void StubViewDrawLine (int xStart, int yStart, int xEnd, int yEnd)
{
	Platform::ViewDrawLine (xStart, yStart, xEnd, yEnd);
}


// ---------------------------------------------------------------------------
//		 StubViewDrawPixel
// ---------------------------------------------------------------------------
// This is a stub routine that called the View object's method that draw
// a pixel.

void StubViewDrawPixel (int xPos, int yPos)
{
	Platform::ViewDrawPixel (xPos, yPos);
}