Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
input_devices.c
Go to the documentation of this file.
1 /* A work-in-progess MEGA65 (Commodore-65 clone origins) emulator
2  Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
3  Copyright (C)2016-2022 LGB (Gábor Lénárt) <lgblgblgb@gmail.com>
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18 
19 
20 #include "xemu/emutools.h"
21 #include "input_devices.h"
22 #include "xemu/emutools_hid.h"
23 #include "xemu/c64_kbd_mapping.h"
24 #include "mega65.h"
25 #include "io_mapper.h"
26 #include "xemu/cpu65.h"
27 #include "hypervisor.h"
28 #include "ui.h"
29 #include "matrix_mode.h"
30 
31 
32 #define DEBUGKBD(...) DEBUG(__VA_ARGS__)
33 #define DEBUGKBDHWA(...) DEBUG(__VA_ARGS__)
34 #define DEBUGKBDHWACOM(...) //DEBUGPRINT(__VA_ARGS__)
35 
36 
37 /* Note: M65 has a "hardware accelerated" keyboard scanner, it can provide you the
38  last pressed character as ASCII (!) without the need to actually scan/etc the
39  keyboard matrix */
40 
41 /* These values are from matrix_to_ascii.vhdl in mega65-core project */
42 /* Some explanation is at the comments of function hwa_kbd_convert_and_push() */
43 
44 // 64 possibility of C64 keys (ie, the 8*8 matrix) + 8 extra C65 keys = 72
45 #define MAT2ASC_TAB_SIZE 72
46 
47 static const Uint8 matrix_normal_to_ascii[MAT2ASC_TAB_SIZE] ={0x14,0x0D,0x1d,0xf7,0xf1,0xf3,0xf5,0x11,0x33,0x77,0x61,0x34,0x7a,0x73,0x65,0x00,0x35,0x72,0x64,0x36,0x63,0x66,0x74,0x78,0x37,0x79,0x67,0x38,0x62,0x68,0x75,0x76,0x39,0x69,0x6a,0x30,0x6d,0x6b,0x6f,0x6e,0x2b,0x70,0x6c,0x2d,0x2e,0x3a,0x40,0x2c,0xa3,0x2a,0x3b,0x13,0x00,0x3d,0xAF,0x2f,0x31,0x5f,0x00,0x32,0x20,0x00,0x71,0x03,0x00,0x09,0x00,0x1f,0xf9,0xfb,0xfd,0x1b};
48 static const Uint8 matrix_shift_to_ascii[MAT2ASC_TAB_SIZE] ={0x94,0x0D,0x9d,0xf8,0xf2,0xf4,0xf6,0x91,0x23,0x57,0x41,0x24,0x5a,0x53,0x45,0x00,0x25,0x52,0x44,0x26,0x43,0x46,0x54,0x58,0x27,0x59,0x47,0x28,0x42,0x48,0x55,0x56,0x29,0x49,0x4a,0x7b,0x4d,0x4b,0x4f,0x4e,0x00,0x50,0x4c,0x00,0x3e,0x5b,0x00,0x3c,0x00,0x00,0x5d,0x93,0x00,0x5f,0x00,0x3f,0x21,0x60,0x00,0x22,0x20,0x00,0x51,0xa3,0x00,0x0f,0x00,0x1f,0xfa,0xfc,0xfe,0x1b};
49 static const Uint8 matrix_control_to_ascii[MAT2ASC_TAB_SIZE]={0x94,0x0D,0x9d,0xf8,0xf2,0xf4,0xf6,0x91,0x1c,0x17,0x01,0x9f,0x1a,0x13,0x05,0x00,0x9c,0x12,0x04,0x1e,0x03,0x06,0x14,0x18,0x1f,0x19,0x07,0x9e,0x02,0x08,0x15,0x16,0x12,0x09,0x0a,0x00,0x0d,0x0b,0x0f,0x0e,0x2b,0x10,0x0c,0x2d,0x2e,0x3a,0x40,0x2c,0x00,0xEF,0x3b,0x93,0x00,0x3d,0x00,0x2f,0x90,0x60,0x00,0x05,0x20,0x00,0x11,0xa3,0x00,0x0f,0x00,0x1f,0xfa,0xfc,0xfe,0x1b};
50 static const Uint8 matrix_cbm_to_ascii[MAT2ASC_TAB_SIZE] ={0x94,0x0D,0xED,0xf8,0xf2,0xf4,0xf6,0xEE,0x96,0xd7,0xc1,0x97,0xda,0xd3,0xc5,0x00,0x98,0xd2,0xc4,0x99,0xc3,0xc6,0xd4,0xd8,0x9a,0xd9,0xc7,0x9b,0xc2,0xc8,0xd5,0xd6,0x92,0xc9,0xca,0x81,0xcd,0xcb,0xcf,0xce,0x2b,0xd0,0xcc,0x2d,0x7c,0x7b,0x40,0x7e,0x00,0x2A,0x7d,0x93,0x00,0x5f,0x00,0x5c,0x81,0x60,0x00,0x95,0x20,0x00,0xd1,0xa3,0x00,0xef,0x00,0x1f,0xfa,0xfc,0xfe,0x1b};
51 static const Uint8 matrix_alt_to_ascii[MAT2ASC_TAB_SIZE] ={0x7f,0x00,0xdf,0xde,0xB9,0xB2,0xB3,0x00,0xA4,0xAE,0xE5,0xA2,0xF7,0xA7,0xE6,0x00,0xB0,0xAE,0xF0,0xA5,0xE7,0x00,0xFE,0xD7,0xB4,0xFF,0xE8,0xE2,0xFA,0xFD,0xFC,0xd3,0xda,0xED,0xE9,0xdb,0xB5,0xE1,0xF8,0xF1,0xB1,0xB6,0xF3,0xAC,0xBB,0xE4,0xA8,0xAB,0xA3,0xB7,0xE4,0xDC,0xDD,0xA6,0xAF,0xBF,0xA1,0xB8,0x00,0xAA,0xa0,0x00,0xA9,0xBA,0x00,0xC0,0x00,0x1f,0xBC,0xBD,0xBE,0xDB};
52 
53 #define MODKEY_LSHIFT 0x01
54 #define MODKEY_RSHIFT 0x02
55 #define MODKEY_CTRL 0x04
56 #define MODKEY_CBM 0x08
57 #define MODKEY_ALT 0x10
58 #define MODKEY_SCRL 0x20
59 
60 // Decoding table based on modoifer keys (the index is the MODKEY stuffs, low 4 bits)
61 // Priority is CBM, ALT, SHIFT, CTRL
62 static const Uint8 *matrix_to_ascii_table_selector[32] = {
63  matrix_normal_to_ascii, matrix_shift_to_ascii, matrix_shift_to_ascii, matrix_shift_to_ascii,
64  matrix_control_to_ascii, matrix_control_to_ascii, matrix_control_to_ascii, matrix_control_to_ascii,
65  matrix_cbm_to_ascii, matrix_cbm_to_ascii, matrix_cbm_to_ascii, matrix_cbm_to_ascii, // CBM key has priority
66  matrix_cbm_to_ascii, matrix_cbm_to_ascii, matrix_cbm_to_ascii, matrix_cbm_to_ascii, // CBM key has priority
67  matrix_alt_to_ascii, matrix_alt_to_ascii, matrix_alt_to_ascii, matrix_alt_to_ascii,
68  matrix_alt_to_ascii, matrix_alt_to_ascii, matrix_alt_to_ascii, matrix_alt_to_ascii,
69  matrix_cbm_to_ascii, matrix_cbm_to_ascii, matrix_cbm_to_ascii, matrix_cbm_to_ascii,
70  matrix_cbm_to_ascii, matrix_cbm_to_ascii, matrix_cbm_to_ascii, matrix_cbm_to_ascii
71 };
72 
73 #define HWA_SINGLE_ITEM
74 
75 static struct {
80 } hwa_kbd;
81 
82 static int restore_is_held = 0;
83 static Uint8 virtkey_state[3] = { 0xFF, 0xFF, 0xFF };
84 
85 
86 void hwa_kbd_disable_selector ( int state )
87 {
88  state = !state;
89  if (state != hwa_kbd.active_selector) {
90  hwa_kbd.active_selector = state;
91  DEBUGPRINT("KBD: hardware accelerated keyboard scanner selector is now %s" NL, state ? "ENABLED" : "DISABLED");
92  }
93 }
94 
95 
97 {
98  hwa_kbd.next = 0;
99  hwa_kbd.last = k;
100 }
101 
102 
103 /* used by actual I/O function to read $D610 */
105 {
106  if (hwa_kbd.next && !hwa_kbd.last) {
107  hwa_kbd.last = hwa_kbd.next;
108  hwa_kbd.next = 0;
109  }
110  DEBUGKBDHWACOM("KBD: HWA: reading key @ PC=$%04X result = $%02X" NL, cpu65.pc, hwa_kbd.last);
111  return hwa_kbd.last;
112 }
113 
114 
115 /* used by actual I/O function to read $D611 */
117 {
118  const Uint8 result = hwa_kbd.modifiers | (hwa_kbd.active_selector ? 0 : 0x80);
119  DEBUGKBDHWACOM("KBD: HWA: reading key modifiers @ PC=$%04X result = $%02X" NL, cpu65.pc, result);
120  return result;
121 }
122 
123 
124 /* used by actual I/O function to write $D610, the written data itself is not used, only the fact of writing */
125 void hwa_kbd_move_next ( void )
126 {
127  DEBUGKBDHWACOM("KBD: HWA: moving to next key @ PC=$%04X previous queued key = $%02X" NL, cpu65.pc, hwa_kbd.last);
128  hwa_kbd.last = 0;
129 }
130 
131 
132 #define CHR_EQU(i) ((i >= 32 && i < 127) ? (char)i : '?')
133 
134 
135 /* basically the opposite as kbd_get_last() but this one used internally only
136  * This is called by emu_callback_key() which is called by emutools_hid.c on key events.
137  * Purpose: convert keypress into MEGA65 hardware accelerated keyboard scanner's ASCII
138  * (which is basically ASCII, though with "invented" codes for the non-printable char keys (like F1 or RUN/STOP).
139  * Notions of variable names:
140  * - pos: emutools_hid.c related "position" info (of the key), non-linear, see the comments at the fist "if" at its two branches
141  * - scan: MEGA65 "scan code" (also 'table index' to index within the matrix2ascii tables): 0-63 nornal "c64 keys" (64 possibilities, 8*8 matrix), 64-71 "c65 extra keys" (8 possibilities)
142  * - ascii: the result ASCII value (with the mentioned "invented" codes included)
143  */
144 static void hwa_kbd_convert_and_push ( int pos )
145 {
146  int scan;
147  if (pos >= (C65_KEYBOARD_EXTRA_POS) && pos < ((C65_KEYBOARD_EXTRA_POS) + 8)) {
148  // Ugly hack: this should fix the problem that Xemu has disjoint space for std C64 and extra C65 keys ...
149  scan = pos - (C65_KEYBOARD_EXTRA_POS) + 64;
150  DEBUGKBDHWA("KBD: HWA: PUSH: doing C65 extra key translation from kbd pos $%02X to table index $%02X ..." NL, pos, scan);
151  } else {
152  // this is the normal case (ie, no special extra C65 key, but among the regular C64 ones):
153  // Xemu has a design to have key positions stored in row/col as low/high nybble of a byte
154  // normalize this here, to have a linear index.
155  // Note, that "extra C65 keys" are kinda handled as a hack, see above.
156  scan = ((pos & 0xF0) >> 1) | (pos & 7);
157  if (scan > 63) {
158  DEBUGKBDHWA("KBD: HWA: PUSH: NOT storing key (outside of translation table) from kbd pos $%02X and table index $%02X at PC=$%04X" NL, pos, scan, cpu65.pc);
159  return;
160  }
161  }
162  // Now, convert scan code to MEGA65 ASCII value, using one of the conversion tables selected by the actual used modifier key(s)
163  // Size of conversion table is 72 (64+8, C64keys+C65keys). This is already checked above, so it must be ok to do so without any further boundary checks
164  const int ascii = matrix_to_ascii_table_selector[hwa_kbd.active_selector ? (hwa_kbd.modifiers & 0x1F) : 0][scan];
165  if (ascii) {
166  if (!hwa_kbd.next) {
167  DEBUGKBDHWA("KBD: HWA: PUSH: storing key $%02X '%c' from kbd pos $%02X and table index $%02X at PC=$%04X" NL, ascii, CHR_EQU(ascii), pos, scan, cpu65.pc);
168  hwa_kbd.next = ascii;
169  } else
170  DEBUGKBDHWA("KBD: HWA: PUSH: NOT storing key (already waiting) $%02X '%c' from kbd pos $%02X and table index $%02X at PC=$%04X" NL, ascii, CHR_EQU(ascii), pos, scan, cpu65.pc);
171  } else
172  DEBUGKBDHWA("KBD: HWA: PUSH: NOT storing key (zero in translation table) from kbd pos $%02X and table index $%02X at PC=$%04X" NL, pos, scan, cpu65.pc);
173 }
174 
175 
176 // MEGA65's own way to do keyboard matrix scan. The theory is very similar to the C64 style
177 // (via CIA ports) scan, however the differenced/benefits:
178 // * no joystick interference on the keyboard
179 // * C65 extra keys are part of the main matrix
180 // * row selection is a simple number not mask of rows (that can be a "con" too if you want to check multiple rows at once?)
182 {
183  if (row > 8) // FIXME: what happens in this case?
184  return 0xFF;
185  if (row == 8) // this is the "extra" row of the "C65 keys"
186  return kbd_matrix[(C65_KEYBOARD_EXTRA_POS) >> 4];
187  // Otherwise the normal "C64-style" matrix is used.
188  return kbd_matrix[row];
189 }
190 
191 
192 void clear_emu_events ( void )
193 {
194  DEBUGKBDHWA("KBD: HWA: reset" NL);
195  hid_reset_events(1);
196  hwa_kbd.modifiers = 0;
197  hwa_kbd.next = 0;
198  hwa_kbd.last = 0;
199  for (int a = 0; a < 3; a++) {
200  if (virtkey_state[0] != 0xFF) {
201  hid_sdl_synth_key_event(virtkey_state[a], 0);
202  virtkey_state[a] = 0xFF;
203  }
204 
205  }
206 }
207 
208 
209 void input_toggle_joy_emu ( void )
210 {
212  OSD(-1, -1, "Joystick emulation on port #%d", joystick_emu);
213 }
214 
215 
216 void virtkey ( Uint8 rno, Uint8 scancode )
217 {
218  // Convert scancode to "Xemu kind of scan code" ...
219  if (scancode >= MAT2ASC_TAB_SIZE)
220  scancode = 0xFF;
221  else if (scancode < 64)
222  scancode = ((scancode & (32 + 16 + 8)) << 1) | (scancode & 7);
223  else
224  scancode += C65_KEYBOARD_EXTRA_POS - 64;
225  if (virtkey_state[rno] == scancode)
226  return;
227  if (virtkey_state[rno] != 0xFF)
228  hid_sdl_synth_key_event(virtkey_state[rno], 0);
229  virtkey_state[rno] = scancode;
230  if (scancode != 0xFF)
231  hid_sdl_synth_key_event(scancode, 1);
232 }
233 
234 
235 Uint8 cia1_in_b ( void )
236 {
237 #ifdef FAKE_TYPING_SUPPORT
238  if (XEMU_UNLIKELY(c64_fake_typing_enabled) && (((cia1.PRA | (~cia1.DDRA)) & 0xFF) != 0xFF) && (((cia1.PRB | (~cia1.DDRB)) & 0xFF) == 0xFF))
239  c64_handle_fake_typing_internals(cia1.PRA | (~cia1.DDRA));
240 #endif
241  return c64_keyboard_read_on_CIA1_B(
242  cia1.PRA | (~cia1.DDRA),
243  cia1.PRB | (~cia1.DDRB),
244  joystick_emu == 1 ? c64_get_joy_state() : 0xFF,
245  port_d607 & 2
246  );
247 }
248 
249 
250 Uint8 cia1_in_a ( void )
251 {
252  return c64_keyboard_read_on_CIA1_A(
253  cia1.PRB | (~cia1.DDRB),
254  cia1.PRA | (~cia1.DDRA),
255  joystick_emu == 2 ? c64_get_joy_state() : 0xFF
256  );
257 }
258 
259 
261 {
262  if (XEMU_UNLIKELY(restore_is_held)) {
263  restore_is_held++;
264  if (restore_is_held >= 20) {
265  restore_is_held = 0;
266  if (!in_hypervisor) {
267  DEBUGPRINT("KBD: RESTORE trap has been triggered." NL);
270  } else
271  DEBUGPRINT("KBD: *IGNORING* RESTORE trap trigger, already in hypervisor mode!" NL);
272  }
273  }
274 }
275 
276 
277 static void kbd_trigger_alttab_trap ( void )
278 {
279  KBD_RELEASE_KEY(TAB_KEY_POS);
280  //KBD_RELEASE_KEY(ALT_KEY_POS);
281  //hwa_kbd.modifiers &= ~MODKEY_ALT;
283  // TODO: remove the #if 0 part, if we're sure:
284 #if 0
285  // It would trigger matrix-mode via hypervisor call, but it has the problem that
286  // it won't work if you're already in hypervisor mode. So I reverted back to the
287  // direct method above. If it does not cause problem on longer term, let's remove this
288  // section.
289  if (!in_hypervisor) {
290  DEBUGPRINT("KBD: MATRIX trap has been triggered." NL);
292  } else {
293  DEBUGPRINT("KBD: *IGNORING* MATRIX trap trigger, already in hypervisor mode!" NL);
294  }
295 #endif
296 }
297 
298 
299 /* BEGIN HACK */
300 // Super ugly way to implement key repeats with the hardware accelerated ASCII based keyboard scanner.
301 // Since rest of Xemu, the kbd-matrix emulation want to actually DISABLE any repeated key events to
302 // come ... For this trick, the emu_callback_key_raw_sdl() handler must be registered, which is done
303 // in input_init() function.
304 // TODO: this whole mess of the HID must be resolved some day in a much nicer way. Not only this
305 // problem but in general (like decoding 'hotkeys' of emulator here in this file and things
306 // like that ...)
307 static SDL_Scancode last_scancode_seen = SDL_SCANCODE_UNKNOWN;
308 static int last_poscode_seen = 0;
309 
310 static int emu_callback_key_raw_sdl ( SDL_KeyboardEvent *ev )
311 {
312  if (ev->repeat && ev->state == SDL_PRESSED && ev->keysym.scancode == last_scancode_seen) {
313  hwa_kbd_convert_and_push(last_poscode_seen);
314  }
315  return 1; // allow default handler to run, though
316 }
317 /* END HACK */
318 
319 // Called by emutools_hid!!! to handle special private keys assigned to this emulator
320 int emu_callback_key ( int pos, SDL_Scancode key, int pressed, int handled )
321 {
322  // Update status of modifier keys
323  hwa_kbd.modifiers =
328 #ifdef ALT_KEY_POS
329  | (IS_KEY_PRESSED(ALT_KEY_POS) ? MODKEY_ALT : 0)
330 #endif
331 #ifdef SCRL_KEY_POS
332  | (IS_KEY_PRESSED(SCRL_KEY_POS) ? MODKEY_SCRL : 0)
333 #endif
334  ;
335  DEBUGKBD("KBD: HWA: pos = %d sdl_key = %d, pressed = %d, handled = %d" NL, pos, key, pressed, handled);
336  static int old_joystick_emu_port; // used to remember emulated joy port, as with mouse grab, we need to switch to port-1, and we want to restore user's one on leaving grab mode
337  if (pressed) {
338  // check if we have the ALT-TAB trap triggered (TAB is pressed now, and ALT is hold)
339  if (pos == TAB_KEY_POS && (hwa_kbd.modifiers & MODKEY_ALT)) {
340  kbd_trigger_alttab_trap();
341  return 0;
342  }
343  // RESTORE triggered trap is different as it depends on timing (how long it's pressed)
344  // So we just flag this, and the main emulation loop need to increment the value to see if the long press event comes, and trigger the trap.
345  // This is done by main emulation loop calling kbd_trigger_restore_trap() function, see above in this very source.
346  // Please note about the pair of this condition below with the "else" branch of the "pressed" condition.
347  if (pos == RESTORE_KEY_POS)
348  restore_is_held = 1;
349  // Check to be sure, some special Xemu internal stuffs uses kbd matrix positions does not exist for real
350  if (pos >= 0 && pos < 0x100) {
351  hwa_kbd_convert_and_push(pos);
352  // See the "HACK" above about key repeating ...
353  last_scancode_seen = key;
354  last_poscode_seen = pos;
355  }
356  // Also check for special, emulator-related hot-keys
357  if (key == SDL_SCANCODE_F10) {
359  } else if (key == SDL_SCANCODE_KP_ENTER) {
361  } else if (((hwa_kbd.modifiers & (MODKEY_LSHIFT | MODKEY_RSHIFT)) == (MODKEY_LSHIFT | MODKEY_RSHIFT)) && set_mouse_grab(SDL_FALSE, 0)) {
362  DEBUGPRINT("UI: mouse grab cancelled" NL);
363  joystick_emu = old_joystick_emu_port;
364  }
365  } else {
366  if (pos == RESTORE_KEY_POS)
367  restore_is_held = 0;
368  if (pos == -2 && key == 0) { // special case pos = -2, key = 0, handled = mouse button (which?) and release event!
369  if ((handled == SDL_BUTTON_LEFT) && set_mouse_grab(SDL_TRUE, 0)) {
370  OSD(-1, -1, "Mouse grab activated. Press\nboth SHIFTs together to cancel.");
371  DEBUGPRINT("UI: mouse grab activated" NL);
372  old_joystick_emu_port = joystick_emu;
373  joystick_emu = 1;
374  }
375  if (handled == SDL_BUTTON_RIGHT) {
376  ui_enter();
377  }
378  }
379  }
380  return 0;
381 }
382 
383 
385 {
386  static Uint8 result = 0;
387  if (is_mouse_grab()) {
388  static int mouse_x = 0;
389  mouse_x = (mouse_x + (hid_read_mouse_rel_x(-23, 23) / 3)) & 0x3F;
390  DEBUG("MOUSE: X is %d, result byte is %d" NL, mouse_x, result);
391  result = mouse_x << 1;
392  }
393  return result;
394 }
395 
396 
398 {
399  static Uint8 result = 0;
400  if (is_mouse_grab()) {
401  static int mouse_y = 0;
402  mouse_y = (mouse_y - (hid_read_mouse_rel_y(-23, 23) / 3)) & 0x3F;
403  DEBUG("MOUSE: Y is %d, result byte is %d" NL, mouse_y, result);
404  result = mouse_y << 1;
405  }
406  return result;
407 }
408 
409 
410 void input_init ( void )
411 {
413  hwa_kbd.active_selector = 1;
414 }
RESTORE_KEY_POS
#define RESTORE_KEY_POS
Definition: c64_kbd_mapping.h:31
LSHIFT_KEY_POS
#define LSHIFT_KEY_POS
Definition: c64_kbd_mapping.h:24
CHR_EQU
#define CHR_EQU(i)
Definition: input_devices.c:132
MODKEY_CBM
#define MODKEY_CBM
Definition: input_devices.c:56
emutools.h
TRAP_FREEZER_RESTORE_PRESS
#define TRAP_FREEZER_RESTORE_PRESS
Definition: hypervisor.h:26
cia1_in_a
Uint8 cia1_in_a(void)
Definition: input_devices.c:250
port_d607
int port_d607
Definition: io_mapper.c:43
MODKEY_LSHIFT
#define MODKEY_LSHIFT
Definition: input_devices.c:53
input_devices.h
hid_read_mouse_rel_x
int hid_read_mouse_rel_x(int min, int max)
Definition: emutools_hid.c:485
active_selector
int active_selector
Definition: input_devices.c:79
modifiers
Uint8 modifiers
Definition: input_devices.c:76
hwa_kbd_disable_selector
void hwa_kbd_disable_selector(int state)
Definition: input_devices.c:86
joystick_emu
int joystick_emu
Definition: c64_kbd_mapping.c:137
is_mouse_grab
SDL_bool is_mouse_grab(void)
Definition: emutools.c:145
hid_read_mouse_rel_y
int hid_read_mouse_rel_y(int min, int max)
Definition: emutools_hid.c:497
get_mouse_x_via_sid
Uint8 get_mouse_x_via_sid(void)
Definition: input_devices.c:384
io_mapper.h
set_mouse_grab
int set_mouse_grab(SDL_bool state, int force_allow)
Definition: emutools.c:131
matrix_mode.h
mega65.h
kbd_trigger_restore_trap
void kbd_trigger_restore_trap(void)
Definition: input_devices.c:260
CBM_KEY_POS
#define CBM_KEY_POS
Definition: c64_kbd_mapping.h:26
hwa_kbd_fake_key
void hwa_kbd_fake_key(Uint8 k)
Definition: input_devices.c:96
hid_reset_events
void hid_reset_events(int burn)
Definition: emutools_hid.c:170
Uint8
uint8_t Uint8
Definition: fat32.c:51
hid_sdl_synth_key_event
void hid_sdl_synth_key_event(int matrix_pos, int is_press)
Definition: emutools_hid.c:145
c64_toggle_joy_emu
void c64_toggle_joy_emu(void)
Definition: c64_kbd_mapping.c:140
get_mouse_y_via_sid
Uint8 get_mouse_y_via_sid(void)
Definition: input_devices.c:397
cia1_in_b
Uint8 cia1_in_b(void)
Definition: input_devices.c:235
virtkey
void virtkey(Uint8 rno, Uint8 scancode)
Definition: input_devices.c:216
emu_callback_key
int emu_callback_key(int pos, SDL_Scancode key, int pressed, int handled)
Definition: input_devices.c:138
next
Uint8 next
Definition: input_devices.c:77
MODKEY_ALT
#define MODKEY_ALT
Definition: input_devices.c:57
DEBUGPRINT
#define DEBUGPRINT(...)
Definition: emutools_basicdefs.h:171
MODKEY_SCRL
#define MODKEY_SCRL
Definition: input_devices.c:58
clear_emu_events
void clear_emu_events(void)
Definition: input_devices.c:57
kbd_directscan_query
Uint8 kbd_directscan_query(Uint8 row)
Definition: input_devices.c:181
hwa_kbd_get_last
Uint8 hwa_kbd_get_last(void)
Definition: input_devices.c:104
c64_get_joy_state
Uint8 c64_get_joy_state(void)
Definition: c64_kbd_mapping.c:151
in_the_matrix
int in_the_matrix
Definition: matrix_mode.c:39
matrix_mode_toggle
void matrix_mode_toggle(int status)
Definition: matrix_mode.c:518
HID_CB_LEVEL_EMU
#define HID_CB_LEVEL_EMU
Definition: emutools_hid.h:73
TRAP_MATRIX
#define TRAP_MATRIX
Definition: hypervisor.h:27
DEBUGKBD
#define DEBUGKBD(...)
Definition: input_devices.c:32
NL
#define NL
Definition: fat32.c:37
hypervisor.h
cpu65.h
IS_KEY_PRESSED
#define IS_KEY_PRESSED(pos)
Definition: c64_kbd_mapping.h:29
DEBUGKBDHWACOM
#define DEBUGKBDHWACOM(...)
Definition: input_devices.c:34
CTRL_KEY_POS
#define CTRL_KEY_POS
Definition: c64_kbd_mapping.h:27
kbd_matrix
Uint8 kbd_matrix[16]
Definition: dave.c:30
KBD_RELEASE_KEY
#define KBD_RELEASE_KEY(a)
Definition: emutools_hid.h:47
reset_mega65_asked
int reset_mega65_asked(void)
Definition: mega65.c:537
OSD
#define OSD(...)
Definition: xep128.h:100
in_hypervisor
int in_hypervisor
Definition: hypervisor.c:40
input_toggle_joy_emu
void input_toggle_joy_emu(void)
Definition: input_devices.c:209
emutools_hid.h
hid_register_sdl_keyboard_event_callback
void hid_register_sdl_keyboard_event_callback(const unsigned int level, hid_sdl_keyboard_event_callback_t cb)
Definition: emutools_hid.c:621
hwa_kbd_move_next
void hwa_kbd_move_next(void)
Definition: input_devices.c:125
DEBUG
#define DEBUG(...)
Definition: emutools_basicdefs.h:167
hypervisor_enter
void hypervisor_enter(int trapno)
Definition: hypervisor.c:132
MAT2ASC_TAB_SIZE
#define MAT2ASC_TAB_SIZE
Definition: input_devices.c:45
ui_enter
void ui_enter(void)
Definition: ui.c:326
ui.h
hwa_kbd_get_modifiers
Uint8 hwa_kbd_get_modifiers(void)
Definition: input_devices.c:116
RSHIFT_KEY_POS
#define RSHIFT_KEY_POS
Definition: c64_kbd_mapping.h:25
input_init
void input_init(void)
Definition: input_devices.c:410
MODKEY_RSHIFT
#define MODKEY_RSHIFT
Definition: input_devices.c:54
XEMU_UNLIKELY
#define XEMU_UNLIKELY(__x__)
Definition: emutools_basicdefs.h:125
last
Uint8 last
Definition: input_devices.c:78
c64_kbd_mapping.h
MODKEY_CTRL
#define MODKEY_CTRL
Definition: input_devices.c:55
DEBUGKBDHWA
#define DEBUGKBDHWA(...)
Definition: input_devices.c:33