void c64ui_set_keyarr(int status) { keyboard_set_keyarr(1, 7, status); }
void cbm2ui_set_keyarr(int status) { keyboard_set_keyarr(8, 4, status); }
void vic20ui_set_keyarr(int status) { keyboard_set_keyarr(1, 3, status); }
void gp2x_poll_input(void) { static int stats_button; static int prefs_button; static int vkeyb_button; static int joy_time = 0; static unsigned int a_held = 0; static unsigned int x_held = 0; unsigned int i; unsigned int joy_state = gp2x_joystick_read(0); /* start */ if (joy_state&GP2X_START) { input_start = 1; } /* prefs */ if (!(joy_state & GP2X_SELECT)) { prefs_button = 0; } if (joy_state & GP2X_SELECT && !prefs_button) { prefs_open = ~prefs_open; prefs_button = 1; } /* vkeyb */ if (!(joy_state & GP2X_L)) { vkeyb_button = 0; } if (joy_state & GP2X_L && !vkeyb_button) { vkeyb_open = ~vkeyb_open; vkeyb_button = 1; } if (prefs_open || vkeyb_open) { int rrate; resources_get_int("RefreshRate", &rrate); if (!rrate) { rrate++; } if (joy_state & (GP2X_UP | GP2X_DOWN | GP2X_LEFT | GP2X_RIGHT)) { joy_time += rrate; } else { joy_time = 0; } if (joy_time == rrate || (joy_time > 6)) { if (joy_time > 4) { joy_time = rrate; } input_up = joy_state & GP2X_UP; input_down = joy_state & GP2X_DOWN; input_select = joy_state & GP2X_SELECT; input_left = joy_state & GP2X_LEFT; input_right = joy_state & GP2X_RIGHT; } /* B button */ if ((joy_state & (GP2X_B | GP2X_PUSH)) != input_b_last) { input_b = joy_state & (GP2X_B | GP2X_PUSH); input_b_last = input_b; } /* A button */ if ((joy_state & GP2X_A) != input_a_last) { input_a = joy_state & GP2X_A; input_a_last = input_a; } /* X button */ if ((joy_state & GP2X_X) != input_x_last) { input_x = joy_state & GP2X_X; input_x_last = input_x; } /* Y button */ if (!(joy_state & GP2X_Y)) { input_y = 0; } if ((joy_state & GP2X_Y) && !input_y) { input_y = 1; } } /* stats */ if (!(joy_state & GP2X_R)) { stats_button = 0; } if (joy_state & GP2X_R && !stats_button) { stats_open = ~stats_open; stats_button = 1; } /* A */ if (mapped_key_a) { if ((joy_state & GP2X_A) && (!a_held)) { a_held = 1; keyboard_set_keyarr(mapped_key_a_row, mapped_key_a_col, 1); } else if (a_held && (!(joy_state & GP2X_A))) { a_held = 0; keyboard_set_keyarr(mapped_key_a_row, mapped_key_a_col, 0); } } /* X */ if (mapped_key_x) { if ((joy_state & GP2X_X) && (!x_held)) { x_held = 1; keyboard_set_keyarr(mapped_key_x_row, mapped_key_x_col, 1); } else if (x_held && (!(joy_state & GP2X_X))) { x_held = 0; keyboard_set_keyarr(mapped_key_x_row, mapped_key_x_col, 0); } } //volume if (gp2x_joystick_read(0) & GP2X_VOL_UP) { volume_up(); } else if (gp2x_joystick_read(0) & GP2X_VOL_DOWN) { volume_down(); } if (prefs_open || vkeyb_open) { return; } //gp2x joystick BYTE j = joystick_value[cur_port]; if (joy_state & GP2X_UP) { j |= 0x01; } else { j &= ~0x01; } if (joy_state & GP2X_DOWN) { j |= 0x02; } else { j &= ~0x02; } if (joy_state & GP2X_LEFT) { j |= 0x04; } else { j &=~ 0x04; } if (joy_state & GP2X_RIGHT) { j |= 0x08; } else { j &= ~0x08; } if (joy_state & (GP2X_B | GP2X_PUSH)) { j |= 0x10; } else { j &= ~0x10; } joystick_value[cur_port] = j; //mapped if (mapped_up) { if (joy_state & mapped_up) { j |= 0x01; joystick_value[cur_port] = j; } } if (mapped_down) { if (joy_state & mapped_down) { j |= 0x02; joystick_value[cur_port] = j; } } if (mapped_left) { if (joy_state & mapped_left) { j |= 0x04; joystick_value[cur_port] = j; } } if (mapped_right) { if (joy_state&mapped_right) { j |= 0x08; joystick_value[cur_port] = j; } } gp2x_poll_usb_input(); }
void draw_vkeyb(unsigned char *screen) { unsigned int i; /* keyboard */ for (i = 0; keyb[i]; i++) { draw_ascii_string(screen, display_width, vkeyb_x, vkeyb_y + (i * 8), keyb[i], kb_fg, kb_bg); } /* cursor */ draw_ascii_string(screen, display_width, 8 * cursor_x, 8 * cursor_y, "+", cursor_fg, cursor_bg); if (input_down) { input_down = 0; if (input_b && cursor_y == vkeyb_y / 8) { if (vkeyb_y + (kb_height * 8) < 240) { vkeyb_y += 8; cursor_y++; } } else { if (cursor_y<(240 / 8) - 1) { cursor_y++; } } } else if (input_up) { input_up = 0; if (input_b && cursor_y == vkeyb_y / 8) { if (vkeyb_y > 0) { vkeyb_y -= 8; cursor_y--; } } else { if (cursor_y > 0) { cursor_y--; } } } if (input_left) { input_left = 0; if (input_b && cursor_y == vkeyb_y / 8) { if (vkeyb_x > 0) { vkeyb_x -= 8; cursor_x--; } } else { if (cursor_x > 0) { cursor_x--; } } } else if (input_right) { input_right = 0; if (input_b && cursor_y == vkeyb_y / 8) { if (vkeyb_x + (kb_width * 8) < display_width) { vkeyb_x += 8; cursor_x++; } } else { if (cursor_x < (display_width / 8) - 1) { cursor_x++; } } } /* b=normal keypress */ if (!input_b) { button_deselected = 1; } if (!input_b && gotkeypress) { gotkeypress = 0; vkey_pressed = 0; vkey_released = 1; } else if (input_b && button_deselected) { button_deselected = 0; for (i = 0; keytable[i]; i += 4) { if ((cursor_x - (vkeyb_x / 8) == keytable[i]) && (cursor_y - (vkeyb_y / 8) == keytable[i + 1])) { vkey_row = keytable[i + 2]; vkey_column = keytable[i + 3]; vkey_pressed = 1; gotkeypress = 1; break; } } } if (vkey_pressed) { vkey_pressed = 0; keyboard_set_keyarr(vkey_row, vkey_column, 1); } else if (vkey_released) { vkey_released = 0; keyboard_set_keyarr(vkey_row, vkey_column, 0); } /* y=shifted keypress */ if (!input_y) { shift_button_deselected = 1; } if (!input_y && shift_gotkeypress) { shift_gotkeypress = 0; shift_vkey_pressed = 0; shift_vkey_released = 1; } else if (input_y && shift_button_deselected) { shift_button_deselected = 0; for (i = 0; keytable[i]; i += 4) { if ((cursor_x - (vkeyb_x / 8) == keytable[i]) && (cursor_y - (vkeyb_y / 8) == keytable[i + 1])) { shift_vkey_row = keytable[i + 2]; shift_vkey_column = keytable[i + 3]; shift_vkey_pressed = 1; shift_gotkeypress = 1; break; } } } if (shift_vkey_pressed) { shift_vkey_pressed = 0; ui_set_keyarr(1); keyboard_set_keyarr(shift_vkey_row, shift_vkey_column, 1); } else if (shift_vkey_released) { shift_vkey_released = 0; keyboard_set_keyarr(shift_vkey_row, shift_vkey_column, 0); ui_set_keyarr(0); } //mapping A if (input_a) { input_a = 0; if (mapped_key_a) { /* if already mapped & pressed, rls key */ keyboard_set_keyarr (mapped_key_a_row, mapped_key_a_col, 0); mapped_key_a = 0; } for (i = 0; keytable[i]; i += 4) { if ((cursor_x - (vkeyb_x / 8) == keytable[i]) && (cursor_y - (vkeyb_y / 8) == keytable[i + 1])) { vkey_row = keytable[i + 2]; vkey_column = keytable[i + 3]; mapped_key_a = 1; mapped_key_a_row = vkey_row; mapped_key_a_col = vkey_column; break; } } } //mapping X if (input_x) { input_x = 0; if (mapped_key_x) { /* if already mapped & pressed, rls key */ keyboard_set_keyarr(mapped_key_x_row, mapped_key_x_col, 0); mapped_key_x = 0; } for (i = 0; keytable[i]; i += 4) { if ((cursor_x - (vkeyb_x / 8) == keytable[i]) && (cursor_y - (vkeyb_y / 8) == keytable[i + 1])) { vkey_row = keytable[i + 2]; vkey_column = keytable[i + 3]; mapped_key_x = 1; mapped_key_x_row = vkey_row; mapped_key_x_col = vkey_column; break; } } } }