usim

Check-in [822c10cf21]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Break out some duplicate code in "allup" routines.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ams/sdl
Files: files | file ages | folders
SHA3-256: 822c10cf212c71890e11f3cf2eab87f4ee9bccc08ed6fc4c3c961ed654f48653
User & Date: ams 2024-06-18 14:49:48
Context
2024-06-18
15:01
README.md, lmdf.text: Update. check-in: bfcbe36d94 user: ams tags: ams/sdl
14:49
Break out some duplicate code in "allup" routines. check-in: 822c10cf21 user: ams tags: ams/sdl
13:34
Bunch of SDL1 hackery ... implement allup for SDL1. check-in: 3959f89bbc user: ams tags: ams/sdl
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to cadet.c.

83
84
85
86
87
88
89

















































90
91
92
93
94
95
96

void
cadet_queue_all_keys_up(void)
{
	cadet_shifts = CADET_IX_UNSHIFT;	/* Hmm... */
	kbd_queue_key_event((1 << 15) | 0);
}


















































#ifdef WITH_X11
/*
 * Check if all keys are up - too expensive?
 */
static bool
cadet_allup_key(void)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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

void
cadet_queue_all_keys_up(void)
{
	cadet_shifts = CADET_IX_UNSHIFT;	/* Hmm... */
	kbd_queue_key_event((1 << 15) | 0);
}

void
cadet_press_bucky(int bucky, int *mods, int *shifts)
{
	switch (bucky) {
	case KBD_SHIFT:
		*mods |= CADET_ALLUP_SHIFT;
		*shifts |= (1 << CADET_IX_SHIFT);
		break;
	case KBD_TOP:
		*mods |= CADET_ALLUP_TOP;
		*shifts |= (1 << CADET_IX_TOP);
		break;
	case KBD_CONTROL:
		*mods |= CADET_ALLUP_CONTROL;
		break;
	case KBD_META:
		*mods |= CADET_ALLUP_META;
		break;
	case KBD_SHIFT_LOCK:
		*mods |= CADET_ALLUP_CAPS_LOCK;
		break;
	case KBD_MODE_LOCK:
		*mods |= CADET_ALLUP_MODELOCK;
		break;
	case KBD_GREEK:
		*mods |= CADET_ALLUP_GREEK;
		*shifts |= (1 << CADET_IX_GREEK);
		break;
	case KBD_REPEAT:
		break;
	case KBD_ALT_LOCK:
		*mods |= CADET_ALLUP_ALTLOCK;
		break;
	case KBD_HYPER:
		*mods |= CADET_ALLUP_HYPER;
		break;
	case KBD_SUPER:
		*mods |= CADET_ALLUP_SUPER;
		break;
	default:
		WARNING(TRACE_KBD, "kbd (cadet): unknown bucky key: 0%o\n", bucky);
		/* Hack: ignore modifier key which isn't bound */
//			if (i >= SDLK_NUMLOCK && i <= SDLK_COMPOSE)
//				break;
//			allup = false;
		break;
	}
}

#ifdef WITH_X11
/*
 * Check if all keys are up - too expensive?
 */
static bool
cadet_allup_key(void)
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
		for (int i = 0; i < modmap->max_keypermod; i++) {
			KeyCode keycode;

			keycode = modmap->modifiermap[modifier * modmap->max_keypermod + i];
			if (keymap[keycode / 8] & (1 << keycode % 8)) {
				keymap[keycode / 8] &= ~(1 << keycode % 8);	/* Clear the key in KEYMAP. */
				DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d); keycode = %d\n", bucky, keycode);
				switch (bucky) {
				case KBD_SHIFT:
					mods |= CADET_ALLUP_SHIFT;
					shifts |= (1 << CADET_IX_SHIFT);
					break;
				case KBD_TOP:
					mods |= CADET_ALLUP_TOP;
					shifts |= (1 << CADET_IX_TOP);
					break;
				case KBD_CONTROL:
					mods |= CADET_ALLUP_CONTROL;
					break;
				case KBD_META:
					mods |= CADET_ALLUP_META;
					break;
				case KBD_SHIFT_LOCK:
					mods |= CADET_ALLUP_CAPS_LOCK;
					break;
				case KBD_MODE_LOCK:
					mods |= CADET_ALLUP_MODELOCK;
					break;
				case KBD_GREEK:
					mods |= CADET_ALLUP_GREEK;
					shifts |= (1 << CADET_IX_GREEK);
					break;
				case KBD_REPEAT:
					break;
				case KBD_ALT_LOCK:
					mods |= CADET_ALLUP_ALTLOCK;
					break;
				case KBD_HYPER:
					mods |= CADET_ALLUP_HYPER;
					break;
				case KBD_SUPER:
					mods |= CADET_ALLUP_SUPER;
					break;
				default:
					WARNING(TRACE_KBD, "kbd (cadet): unknown bucky key: 0%o\n", modifier_map[modifier]);
					break;
				}
			}
		}
	}
	XFreeModifiermap(modmap);
	/*
	 * Check if any other key than modifiers (that got cleared
	 * above) are set.  If that is the case, do not generate an







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







170
171
172
173
174
175
176
177







































178
179
180
181
182
183
184
		for (int i = 0; i < modmap->max_keypermod; i++) {
			KeyCode keycode;

			keycode = modmap->modifiermap[modifier * modmap->max_keypermod + i];
			if (keymap[keycode / 8] & (1 << keycode % 8)) {
				keymap[keycode / 8] &= ~(1 << keycode % 8);	/* Clear the key in KEYMAP. */
				DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d); keycode = %d\n", bucky, keycode);
				cadet_press_bucky(bucky, &mods, &shifts);







































			}
		}
	}
	XFreeModifiermap(modmap);
	/*
	 * Check if any other key than modifiers (that got cleared
	 * above) are set.  If that is the case, do not generate an
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
	for (int i = 0; allup && i < statesize; i++) {
		int bucky;

		if (state[i] != 1)
			continue;
		bucky = modifier_map[i];
		DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
		switch (bucky) {
		case KBD_SHIFT:
			mods |= CADET_ALLUP_SHIFT;
			shifts |= (1 << CADET_IX_SHIFT);
			break;
		case KBD_TOP:
			mods |= CADET_ALLUP_TOP;
			shifts |= (1 << CADET_IX_TOP);
			break;
		case KBD_CONTROL:
			mods |= CADET_ALLUP_CONTROL;
			break;
		case KBD_META:
			mods |= CADET_ALLUP_META;
			break;
		case KBD_SHIFT_LOCK:
			mods |= CADET_ALLUP_CAPS_LOCK;
			break;
		case KBD_MODE_LOCK:
			mods |= CADET_ALLUP_MODELOCK;
			break;
		case KBD_GREEK:
			mods |= CADET_ALLUP_GREEK;
			shifts |= (1 << CADET_IX_GREEK);
			break;
		case KBD_REPEAT:
			break;
		case KBD_ALT_LOCK:
			mods |= CADET_ALLUP_ALTLOCK;
			break;
		case KBD_HYPER:
			mods |= CADET_ALLUP_HYPER;
			break;
		case KBD_SUPER:
			mods |= CADET_ALLUP_SUPER;
			break;
		default:
			WARNING(TRACE_KBD, "kbd (cadet): unknown bucky key: 0%o\n", modifier_map[i]);
			/* Hack: ignore modifier key which isn't bound */
//			if (i >= SDLK_NUMLOCK && i <= SDLK_COMPOSE)
//				break;
			allup = false;
			break;
		}
	}
	if (allup == true) {
		DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
		cadet_shifts = shifts;
		cadet_allup_event(mods);
	}
	return allup;







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







217
218
219
220
221
222
223
224











































225
226
227
228
229
230
231
	for (int i = 0; allup && i < statesize; i++) {
		int bucky;

		if (state[i] != 1)
			continue;
		bucky = modifier_map[i];
		DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
		cadet_press_bucky(bucky, &mods, &shifts);











































	}
	if (allup == true) {
		DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
		cadet_shifts = shifts;
		cadet_allup_event(mods);
	}
	return allup;
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
	for (int i = 0; allup && i < statesize; i++) {
		int bucky;

		if (state[i] != 1)
			continue;
		bucky = modifier_map[i];
		DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
		switch (bucky) {
		case KBD_SHIFT:
			mods |= CADET_ALLUP_SHIFT;
			shifts |= (1 << CADET_IX_SHIFT);
			break;
		case KBD_TOP:
			mods |= CADET_ALLUP_TOP;
			shifts |= (1 << CADET_IX_TOP);
			break;
		case KBD_CONTROL:
			mods |= CADET_ALLUP_CONTROL;
			break;
		case KBD_META:
			mods |= CADET_ALLUP_META;
			break;
		case KBD_SHIFT_LOCK:
			mods |= CADET_ALLUP_CAPS_LOCK;
			break;
		case KBD_MODE_LOCK:
			mods |= CADET_ALLUP_MODELOCK;
			break;
		case KBD_GREEK:
			mods |= CADET_ALLUP_GREEK;
			shifts |= (1 << CADET_IX_GREEK);
			break;
		case KBD_REPEAT:
			break;
		case KBD_ALT_LOCK:
			mods |= CADET_ALLUP_ALTLOCK;
			break;
		case KBD_HYPER:
			mods |= CADET_ALLUP_HYPER;
			break;
		case KBD_SUPER:
			mods |= CADET_ALLUP_SUPER;
			break;
		default:
			WARNING(TRACE_KBD, "kbd (cadet): unknown bucky key: 0%o\n", modifier_map[i]);
			/* Hack: ignore modifier key which isn't bound */
//			if (i >= SDLK_NUMLOCK && i <= SDLK_COMPOSE)
//				break;
			allup = false;
			break;
		}
	}
	if (allup == true) {
		DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
		cadet_shifts = shifts;
		cadet_allup_event(mods);
	}
	return allup;







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







249
250
251
252
253
254
255
256











































257
258
259
260
261
262
263
	for (int i = 0; allup && i < statesize; i++) {
		int bucky;

		if (state[i] != 1)
			continue;
		bucky = modifier_map[i];
		DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
		cadet_press_bucky(bucky, &mods, &shifts);











































	}
	if (allup == true) {
		DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
		cadet_shifts = shifts;
		cadet_allup_event(mods);
	}
	return allup;

Changes to sdl1.c.

255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
sdl1_beep(int v)
{
}

void
sdl1_init(void)
{
	NOTICE(TRACE_USIM, "tv: using SDL backend for monitor and keyboard\n");

	Foreground = 0xff; // White
	Background = 0x00; // Black

	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE)) {
		fprintf(stderr, "SDL_Init(): %s", SDL_GetError());
		exit(1);







|







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
sdl1_beep(int v)
{
}

void
sdl1_init(void)
{
	NOTICE(TRACE_USIM, "tv: using SDL1 backend for monitor and keyboard\n");

	Foreground = 0xff; // White
	Background = 0x00; // Black

	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE)) {
		fprintf(stderr, "SDL_Init(): %s", SDL_GetError());
		exit(1);

Changes to sdl2.c.

328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
	int duration = DTP_FIX_VAL(mmem[22]);//M-1 M-MEM 22
	xbeep(wavelength, duration);
}

void
sdl2_init(void)
{
	NOTICE(TRACE_USIM, "tv: using SDL backend for monitor and keyboard\n");

	Foreground = 0xffffff; // White
	Background = 0x000000; // Black

	xbeep_audio_init();
	SDL_CreateWindowAndRenderer(tv_width, tv_height, SDL_WINDOW_OPENGL, &window, &renderer);
	SDL_ShowCursor(0);	/* Invisible cursor. */







|







328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
	int duration = DTP_FIX_VAL(mmem[22]);//M-1 M-MEM 22
	xbeep(wavelength, duration);
}

void
sdl2_init(void)
{
	NOTICE(TRACE_USIM, "tv: using SDL2 backend for monitor and keyboard\n");

	Foreground = 0xffffff; // White
	Background = 0x000000; // Black

	xbeep_audio_init();
	SDL_CreateWindowAndRenderer(tv_width, tv_height, SDL_WINDOW_OPENGL, &window, &renderer);
	SDL_ShowCursor(0);	/* Invisible cursor. */