2012-04-29 14:55:59 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* Copyright (C) 2012, Fabio Olimpieri
|
|
|
|
* Copyright (C) 2009, Simon Kagstrom
|
|
|
|
*
|
|
|
|
* Filename: VirtualKeyboard.c
|
|
|
|
*
|
|
|
|
* Description: A virtual keyboard
|
|
|
|
*
|
|
|
|
* This file is part of FBZX Wii
|
|
|
|
*
|
|
|
|
* FBZX Wii is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FBZX Wii is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
#include <SDL/SDL.h>
|
|
|
|
#include <SDL/SDL_ttf.h>
|
|
|
|
|
|
|
|
#include "z80free/Z80free.h"
|
|
|
|
#include "computer.h"
|
|
|
|
#include "VirtualKeyboard.h"
|
|
|
|
#include "menu_sdl.h"
|
2013-04-07 09:12:12 +02:00
|
|
|
#include "emulator.h"
|
2012-12-30 18:52:21 +01:00
|
|
|
#include<SDL/SDL_image.h>
|
2012-04-29 14:55:59 +02:00
|
|
|
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifdef HW_RVL
|
SDL sound, compile against MINGW (VK, fopen binary files, menu key calls FBZX Wii menu, return key active on KEYUP), 2 bugs in 128k snap format, turbo N in line command, separated code for normal and precise emulation, toggle full screen in FBZX menu, removed snow effect in normal emulation, changed save tape routine, fixed 2 bugs in z80, changed SP call in z80
2013-04-06 16:45:45 +02:00
|
|
|
#include <wiiuse/wpad.h>
|
|
|
|
#endif
|
2012-04-29 14:55:59 +02:00
|
|
|
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifdef HW_DOL
|
|
|
|
#include <ogc/pad.h>
|
|
|
|
#endif
|
|
|
|
|
2012-04-29 14:55:59 +02:00
|
|
|
#define K(name, sdl_code) \
|
2012-05-06 12:37:14 +02:00
|
|
|
{ name, sdl_code, 0 ,0, 0}
|
2012-04-29 14:55:59 +02:00
|
|
|
#define KNL() \
|
2012-05-06 12:37:14 +02:00
|
|
|
{ NULL, 0, 0 ,0, 0}
|
2012-04-29 14:55:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
#define KEY_COLS 10
|
2012-12-30 18:52:21 +01:00
|
|
|
#define KEY_ROWS 5
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
extern FILE *fdebug;
|
|
|
|
#define printf(...) fprintf(fdebug,__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#ifdef GEKKO
|
|
|
|
#define printf(...)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
static SDL_Surface *image_kbd, *image_sym, *image_caps,*image_kbd_small, *image_sym_small, *image_caps_small, *tmp_surface ;
|
2012-12-30 18:52:21 +01:00
|
|
|
static int vkb_is_init;
|
2013-03-09 15:24:01 +01:00
|
|
|
static int key_code;
|
2014-01-11 08:35:16 +01:00
|
|
|
VirtualKeyboard_struct VirtualKeyboard;
|
2012-04-29 14:55:59 +02:00
|
|
|
|
2012-05-06 12:37:14 +02:00
|
|
|
extern struct computer ordenador;
|
|
|
|
void clean_screen();
|
2012-04-29 14:55:59 +02:00
|
|
|
|
|
|
|
static virtkey_t keys[KEY_COLS * KEY_ROWS] = {
|
2012-05-06 12:37:14 +02:00
|
|
|
K(" 1",SDLK_1),K(" 2",SDLK_2), K(" 3",SDLK_3), K(" 4",SDLK_4), K(" 5",SDLK_5), K(" 6",SDLK_6), K(" 7",SDLK_7), K(" 8",SDLK_8), K(" 9",SDLK_9), K(" 0",SDLK_0),
|
|
|
|
K(" Q",SDLK_q), K(" W",SDLK_w), K(" E",SDLK_e), K(" R",SDLK_r), K(" T",SDLK_t), K(" Y",SDLK_y), K(" U",SDLK_u), K(" I",SDLK_i), K(" O",SDLK_o), K(" P",SDLK_p),
|
|
|
|
K(" A",SDLK_a), K(" S",SDLK_s), K(" D",SDLK_d), K(" F",SDLK_f), K(" G",SDLK_g), K(" H",SDLK_h), K(" J",SDLK_j), K(" K",SDLK_k), K(" L",SDLK_l),K("Enter",SDLK_RETURN),
|
|
|
|
K("Caps",SDLK_LSHIFT),K(" Z",SDLK_z),K(" X",SDLK_x),K(" C",SDLK_c), K(" V",SDLK_v), K(" B",SDLK_b), K(" N",SDLK_n), K(" M",SDLK_m), K("Sym",SDLK_LCTRL),K("Space",SDLK_SPACE),
|
2012-12-30 18:52:21 +01:00
|
|
|
K("Ext",SDLK_TAB),K("Edit",SDLK_INSERT),K("Del",SDLK_BACKSPACE),K("None",0), K("Done",1), K("Fire",SDLK_LALT) ,K(" Up",SDLK_UP),K("Down",SDLK_DOWN), K("Left",SDLK_LEFT),K("Right",SDLK_RIGHT)};
|
2012-04-29 14:55:59 +02:00
|
|
|
|
2012-12-30 18:52:21 +01:00
|
|
|
void VirtualKeyboard_init(SDL_Surface *screen)
|
2012-04-29 14:55:59 +02:00
|
|
|
{
|
|
|
|
VirtualKeyboard.screen = screen;
|
2012-12-30 18:52:21 +01:00
|
|
|
VirtualKeyboard.sel_x = 64;
|
|
|
|
VirtualKeyboard.sel_y = 100;
|
|
|
|
vkb_is_init = -1;
|
2013-04-07 09:12:12 +02:00
|
|
|
char *image_path;
|
2012-12-30 18:52:21 +01:00
|
|
|
|
2013-04-07 09:12:12 +02:00
|
|
|
image_path=myfile("fbzx/Spectrum_keyboard.png");
|
|
|
|
tmp_surface=IMG_Load(image_path);
|
|
|
|
free(image_path);
|
2013-01-16 21:07:44 +01:00
|
|
|
if (tmp_surface == NULL) {printf("Impossible to load keyboard image\n"); return;}
|
|
|
|
image_kbd=SDL_DisplayFormat(tmp_surface);
|
|
|
|
SDL_FreeSurface (tmp_surface);
|
2012-12-30 18:52:21 +01:00
|
|
|
|
2013-04-07 09:12:12 +02:00
|
|
|
image_path=myfile("fbzx/symbol_shift.png");
|
|
|
|
tmp_surface=IMG_Load(image_path);
|
|
|
|
free(image_path);
|
2013-01-16 21:07:44 +01:00
|
|
|
if (tmp_surface == NULL) {printf("Impossible to load symbol shift image\n"); return;}
|
|
|
|
image_sym=SDL_DisplayFormat(tmp_surface);
|
|
|
|
SDL_FreeSurface (tmp_surface);
|
|
|
|
|
2013-04-07 09:12:12 +02:00
|
|
|
image_path=myfile("fbzx/caps_shift.png");
|
|
|
|
tmp_surface=IMG_Load(image_path);
|
|
|
|
free(image_path);
|
2013-01-16 21:07:44 +01:00
|
|
|
if (tmp_surface == NULL) {printf("Impossible to load caps shift image\n"); return;}
|
|
|
|
image_caps=SDL_DisplayFormat(tmp_surface);
|
|
|
|
SDL_FreeSurface (tmp_surface);
|
|
|
|
|
2013-04-07 09:12:12 +02:00
|
|
|
image_path=myfile("fbzx/Spectrum_keyboard_small.png");
|
|
|
|
tmp_surface=IMG_Load(image_path);
|
|
|
|
free(image_path);
|
2013-01-16 21:07:44 +01:00
|
|
|
if (tmp_surface == NULL) {printf("Impossible to load keyboard small image\n"); return;}
|
|
|
|
image_kbd_small=SDL_DisplayFormat(tmp_surface);
|
|
|
|
SDL_FreeSurface (tmp_surface);
|
|
|
|
|
2013-04-07 09:12:12 +02:00
|
|
|
image_path=myfile("fbzx/symbol_shift_small.png");
|
|
|
|
tmp_surface=IMG_Load(image_path);
|
|
|
|
free(image_path);
|
2013-01-16 21:07:44 +01:00
|
|
|
if (tmp_surface == NULL) {printf("Impossible to load symbol shift small image\n"); return;}
|
|
|
|
image_sym_small=SDL_DisplayFormat(tmp_surface);
|
|
|
|
SDL_FreeSurface (tmp_surface);
|
2012-12-30 18:52:21 +01:00
|
|
|
|
2013-04-07 09:12:12 +02:00
|
|
|
image_path=myfile("fbzx/caps_shift_small.png");
|
|
|
|
tmp_surface=IMG_Load(image_path);
|
|
|
|
free(image_path);
|
2013-01-16 21:07:44 +01:00
|
|
|
if (tmp_surface == NULL) {printf("Impossible to load caps shift small image\n"); return;}
|
|
|
|
image_caps_small=SDL_DisplayFormat(tmp_surface);
|
|
|
|
SDL_FreeSurface (tmp_surface);
|
2015-01-31 13:26:17 +01:00
|
|
|
|
2012-04-29 14:55:59 +02:00
|
|
|
|
|
|
|
memset(VirtualKeyboard.buf, 0, sizeof(VirtualKeyboard.buf));
|
2012-12-30 18:52:21 +01:00
|
|
|
vkb_is_init = 1;
|
2012-04-29 14:55:59 +02:00
|
|
|
}
|
|
|
|
|
2014-04-09 09:51:06 +02:00
|
|
|
void VirtualKeyboard_fini()
|
|
|
|
{
|
|
|
|
if (vkb_is_init != 1) return;
|
|
|
|
|
|
|
|
SDL_FreeSurface (image_kbd);
|
|
|
|
SDL_FreeSurface (image_sym);
|
|
|
|
SDL_FreeSurface (image_caps);
|
|
|
|
SDL_FreeSurface (image_kbd_small);
|
|
|
|
SDL_FreeSurface (image_sym_small);
|
|
|
|
SDL_FreeSurface (image_caps_small);
|
|
|
|
vkb_is_init = -1;
|
|
|
|
ordenador.vk_is_active=0;
|
|
|
|
}
|
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
void draw_vk()
|
2012-04-29 14:55:59 +02:00
|
|
|
{
|
2012-12-30 18:52:21 +01:00
|
|
|
|
|
|
|
SDL_Rect dst_rect = {VirtualKeyboard.sel_x/RATIO, VirtualKeyboard.sel_y/RATIO, 0, 0};
|
|
|
|
|
|
|
|
if (RATIO == 1) SDL_BlitSurface(image_kbd, NULL, ordenador.screen, &dst_rect);
|
|
|
|
else SDL_BlitSurface(image_kbd_small, NULL, ordenador.screen, &dst_rect);
|
|
|
|
|
|
|
|
dst_rect.x = (VirtualKeyboard.sel_x+10)/RATIO;
|
|
|
|
dst_rect.y = (VirtualKeyboard.sel_y+200)/RATIO;
|
|
|
|
if (keys[3 * KEY_COLS + 0 ].is_on)
|
|
|
|
{if (RATIO == 1) SDL_BlitSurface(image_caps, NULL, ordenador.screen, &dst_rect);
|
|
|
|
else SDL_BlitSurface(image_caps_small, NULL, ordenador.screen, &dst_rect);}
|
|
|
|
|
|
|
|
|
|
|
|
dst_rect.x = (VirtualKeyboard.sel_x+402)/RATIO;
|
|
|
|
dst_rect.y = (VirtualKeyboard.sel_y+200)/RATIO;
|
|
|
|
if (keys[3 * KEY_COLS + 8 ].is_on)
|
|
|
|
{if (RATIO == 1) SDL_BlitSurface(image_sym, NULL, ordenador.screen, &dst_rect);
|
|
|
|
else SDL_BlitSurface(image_sym_small, NULL, ordenador.screen, &dst_rect);}
|
2012-04-29 14:55:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
struct virtkey *get_key_internal()
|
2012-04-29 14:55:59 +02:00
|
|
|
{
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
uint32_t k;
|
2012-12-30 18:52:21 +01:00
|
|
|
int x,y,xm, ym, i=0;
|
|
|
|
int key_w = 50/RATIO;
|
|
|
|
int key_h = 64/RATIO;
|
|
|
|
int border_x = VirtualKeyboard.sel_x/RATIO;
|
|
|
|
int border_y = VirtualKeyboard.sel_y/RATIO;
|
2017-01-15 14:50:14 +01:00
|
|
|
int joy_n=0;
|
2012-04-29 14:55:59 +02:00
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
draw_vk();
|
2012-04-29 14:55:59 +02:00
|
|
|
SDL_Flip(VirtualKeyboard.screen);
|
2012-12-27 16:39:35 +01:00
|
|
|
|
|
|
|
SDL_ShowCursor(SDL_ENABLE);
|
2012-04-29 14:55:59 +02:00
|
|
|
|
2017-01-15 14:50:14 +01:00
|
|
|
k = menu_wait_key_press(&joy_n);
|
2012-12-27 16:39:35 +01:00
|
|
|
|
|
|
|
SDL_ShowCursor(SDL_DISABLE);
|
2012-04-29 14:55:59 +02:00
|
|
|
|
2012-12-30 18:52:21 +01:00
|
|
|
if (k & KEY_ESCAPE) return NULL;
|
2012-04-29 14:55:59 +02:00
|
|
|
else if (k & KEY_SELECT)
|
|
|
|
{
|
2012-12-30 18:52:21 +01:00
|
|
|
|
|
|
|
SDL_GetMouseState(&xm, &ym);
|
|
|
|
x = (xm-border_x);
|
|
|
|
y = (ym-border_y);
|
|
|
|
if ((x<0)||(x>= KEY_COLS*key_w)) continue;
|
|
|
|
if ((y<0)||(y>= KEY_ROWS*key_h)) continue;
|
|
|
|
|
|
|
|
i = y/key_h*KEY_COLS + x/key_w;
|
|
|
|
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifdef HW_RVL
|
2017-04-30 23:10:59 +02:00
|
|
|
if (ordenador.vk_rumble)
|
|
|
|
{
|
|
|
|
if (joy_n < 2)
|
|
|
|
{
|
|
|
|
WPAD_Rumble(joy_n, 1);
|
|
|
|
SDL_Delay(90);
|
|
|
|
WPAD_Rumble(joy_n, 0);
|
|
|
|
}
|
|
|
|
else if (joy_n > 3)//gamepad
|
|
|
|
{
|
|
|
|
PAD_ControlMotor(joy_n-4,PAD_MOTOR_RUMBLE);
|
|
|
|
SDL_Delay(90);
|
|
|
|
PAD_ControlMotor(joy_n-4,PAD_MOTOR_STOP);
|
|
|
|
}
|
|
|
|
}
|
2013-01-16 21:07:44 +01:00
|
|
|
#endif
|
2012-12-27 16:39:35 +01:00
|
|
|
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifdef HW_DOL
|
2017-04-30 23:10:59 +02:00
|
|
|
if (ordenador.vk_rumble)
|
|
|
|
{
|
|
|
|
PAD_ControlMotor(joy_n,PAD_MOTOR_RUMBLE);
|
|
|
|
SDL_Delay(90);
|
|
|
|
PAD_ControlMotor(joy_n,PAD_MOTOR_STOP);
|
|
|
|
}
|
2015-01-31 13:26:17 +01:00
|
|
|
#endif
|
|
|
|
|
2012-12-27 16:39:35 +01:00
|
|
|
virtkey_t *key = &keys[i];
|
2012-05-06 14:55:12 +02:00
|
|
|
|
2012-12-30 18:52:21 +01:00
|
|
|
if ((key->sdl_code == 304) && !keys[3 * KEY_COLS + 8 ].is_on)
|
|
|
|
keys[3 * KEY_COLS + 0 ].is_on = !keys[3 * KEY_COLS + 0 ].is_on; //Caps Shit
|
|
|
|
else if ((key->sdl_code == 306) && !keys[3 * KEY_COLS + 0 ].is_on)
|
|
|
|
keys[3 * KEY_COLS + 8 ].is_on = !keys[3 * KEY_COLS + 8 ].is_on; //Sym Shift
|
2012-04-29 14:55:59 +02:00
|
|
|
else {
|
2012-12-30 18:52:21 +01:00
|
|
|
key->caps_on = keys[3 * KEY_COLS + 0 ].is_on;
|
|
|
|
key->sym_on = keys[3 * KEY_COLS + 8 ].is_on;
|
2012-04-29 14:55:59 +02:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
struct virtkey* get_key()
|
2012-04-29 14:55:59 +02:00
|
|
|
{
|
|
|
|
virtkey_t *key;
|
|
|
|
|
2012-12-30 18:52:21 +01:00
|
|
|
if (vkb_is_init != 1) return NULL;
|
2012-04-29 14:55:59 +02:00
|
|
|
|
2012-12-30 18:52:21 +01:00
|
|
|
keys[3 * KEY_COLS + 0 ].is_on = 0; //Caps Shit
|
|
|
|
keys[3 * KEY_COLS + 8 ].is_on = 0; //Sym Shift
|
2012-05-06 12:37:14 +02:00
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
key = get_key_internal();
|
2012-04-29 14:55:59 +02:00
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
void virtkey_ir_run(void)
|
|
|
|
{
|
|
|
|
int x,y,xm, ym, i=0;
|
|
|
|
int key_w = 50/RATIO;
|
|
|
|
int key_h = 64/RATIO;
|
|
|
|
int border_x = VirtualKeyboard.sel_x/RATIO;
|
|
|
|
int border_y = VirtualKeyboard.sel_y/RATIO;
|
2013-02-19 09:50:27 +01:00
|
|
|
int key_sel = 0;
|
2017-01-15 14:50:14 +01:00
|
|
|
int joy_n;
|
2013-01-16 21:07:44 +01:00
|
|
|
SDL_Joystick *joy;
|
2017-04-30 23:10:59 +02:00
|
|
|
static int joy_bottons_last[6][5];
|
|
|
|
static char countdown_rumble[6];
|
2017-01-15 14:50:14 +01:00
|
|
|
|
|
|
|
for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++)
|
|
|
|
{
|
2017-04-30 23:10:59 +02:00
|
|
|
#ifdef HW_RVL
|
|
|
|
if ((joy_n == 2) || (joy_n == 3)) continue; // No wimote 3 and 4
|
|
|
|
#endif
|
2017-01-15 14:50:14 +01:00
|
|
|
key_sel = 0;
|
2013-01-16 21:07:44 +01:00
|
|
|
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifdef HW_RVL
|
2017-01-15 14:50:14 +01:00
|
|
|
if (countdown_rumble[joy_n] > 0) {countdown_rumble[joy_n]--; if ((countdown_rumble[joy_n]==0)&&(ordenador.vk_rumble)) WPAD_Rumble(joy_n, 0);}
|
2013-01-16 21:07:44 +01:00
|
|
|
#endif
|
2015-01-31 13:26:17 +01:00
|
|
|
|
|
|
|
#ifdef HW_DOL
|
2017-01-15 14:50:14 +01:00
|
|
|
if (countdown_rumble[joy_n] > 0) {countdown_rumble[joy_n]--; if ((countdown_rumble[joy_n]==0)&&(ordenador.vk_rumble)) PAD_ControlMotor(joy_n,PAD_MOTOR_STOP);}
|
2015-01-31 13:26:17 +01:00
|
|
|
#endif
|
|
|
|
|
2017-01-15 14:50:14 +01:00
|
|
|
joy = ordenador.joystick_sdl[joy_n];
|
2013-01-16 21:07:44 +01:00
|
|
|
|
2017-01-15 14:50:14 +01:00
|
|
|
if ((SDL_JoystickGetButton(joy, 0) && !joy_bottons_last[joy_n][0]) || /* A */
|
|
|
|
(SDL_JoystickGetButton(joy, 3) && !joy_bottons_last[joy_n][1]) || /* 2 */
|
|
|
|
(SDL_JoystickGetButton(joy, 9) && !joy_bottons_last[joy_n][2]) || /* CA */
|
|
|
|
(SDL_JoystickGetButton(joy, 10) && !joy_bottons_last[joy_n][3]) /* CB */
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifndef GEKKO //Win
|
2017-01-15 14:50:14 +01:00
|
|
|
||(!joy_n && (SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1))&& !joy_bottons_last[0][4])//mouse left button
|
SDL sound, compile against MINGW (VK, fopen binary files, menu key calls FBZX Wii menu, return key active on KEYUP), 2 bugs in 128k snap format, turbo N in line command, separated code for normal and precise emulation, toggle full screen in FBZX menu, removed snow effect in normal emulation, changed save tape routine, fixed 2 bugs in z80, changed SP call in z80
2013-04-06 16:45:45 +02:00
|
|
|
#endif
|
|
|
|
) key_sel = KEY_SELECT;
|
|
|
|
|
2013-03-09 15:24:01 +01:00
|
|
|
|
2017-01-15 14:50:14 +01:00
|
|
|
if ((!SDL_JoystickGetButton(joy, 0) && joy_bottons_last[joy_n][0]) || /* A */
|
|
|
|
(!SDL_JoystickGetButton(joy, 3) && joy_bottons_last[joy_n][1]) || /* 2 */
|
|
|
|
(!SDL_JoystickGetButton(joy, 9) && joy_bottons_last[joy_n][2]) || /* CA */
|
|
|
|
(!SDL_JoystickGetButton(joy, 10) && joy_bottons_last[joy_n][3]) /* CB */
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifndef GEKKO //Win
|
2017-01-15 14:50:14 +01:00
|
|
|
||(!joy_n && !(SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) && joy_bottons_last[0][4]) //mouse left button
|
SDL sound, compile against MINGW (VK, fopen binary files, menu key calls FBZX Wii menu, return key active on KEYUP), 2 bugs in 128k snap format, turbo N in line command, separated code for normal and precise emulation, toggle full screen in FBZX menu, removed snow effect in normal emulation, changed save tape routine, fixed 2 bugs in z80, changed SP call in z80
2013-04-06 16:45:45 +02:00
|
|
|
#endif
|
|
|
|
) key_sel = KEY_DESELECT;
|
|
|
|
|
2013-03-09 15:24:01 +01:00
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
|
2017-01-15 14:50:14 +01:00
|
|
|
joy_bottons_last[joy_n][0] =SDL_JoystickGetButton(joy, 0) ; /* A */
|
|
|
|
joy_bottons_last[joy_n][1] =SDL_JoystickGetButton(joy, 3) ; /* 2 */
|
|
|
|
joy_bottons_last[joy_n][2] =SDL_JoystickGetButton(joy, 9) ; /* CA */
|
|
|
|
joy_bottons_last[joy_n][3] =SDL_JoystickGetButton(joy, 10) ; /* CB */
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifndef GEKKO //Win
|
2017-01-15 14:50:14 +01:00
|
|
|
if (!joy_n) joy_bottons_last[0][4] =SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1); //mouse left button
|
SDL sound, compile against MINGW (VK, fopen binary files, menu key calls FBZX Wii menu, return key active on KEYUP), 2 bugs in 128k snap format, turbo N in line command, separated code for normal and precise emulation, toggle full screen in FBZX menu, removed snow effect in normal emulation, changed save tape routine, fixed 2 bugs in z80, changed SP call in z80
2013-04-06 16:45:45 +02:00
|
|
|
#endif
|
2013-01-16 21:07:44 +01:00
|
|
|
|
2013-02-19 09:50:27 +01:00
|
|
|
if (key_sel==KEY_SELECT)
|
2013-01-16 21:07:44 +01:00
|
|
|
{
|
|
|
|
SDL_GetMouseState(&xm, &ym);
|
|
|
|
x = (xm-border_x);
|
|
|
|
y = (ym-border_y);
|
|
|
|
if ((x>0)&&(x< KEY_COLS*key_w)&&(y>0)&&(y< KEY_ROWS*key_h))
|
|
|
|
{
|
2015-01-31 13:26:17 +01:00
|
|
|
#ifdef HW_RVL
|
2017-01-15 14:50:14 +01:00
|
|
|
if (ordenador.vk_rumble) WPAD_Rumble(joy_n, 1);
|
2013-01-16 21:07:44 +01:00
|
|
|
#endif
|
2015-01-31 13:26:17 +01:00
|
|
|
|
|
|
|
#ifdef HW_DOL
|
2017-01-15 14:50:14 +01:00
|
|
|
if (ordenador.vk_rumble) PAD_ControlMotor(joy_n,PAD_MOTOR_RUMBLE);
|
2015-01-31 13:26:17 +01:00
|
|
|
#endif
|
|
|
|
|
2017-01-15 14:50:14 +01:00
|
|
|
countdown_rumble[joy_n]=5;
|
2013-01-16 21:07:44 +01:00
|
|
|
|
|
|
|
i = y/key_h*KEY_COLS + x/key_w;
|
|
|
|
|
|
|
|
virtkey_t *key = &keys[i];
|
|
|
|
|
|
|
|
if ((key->sdl_code == SDLK_LSHIFT) && !keys[3 * KEY_COLS + 8 ].is_on)
|
2013-03-09 15:24:01 +01:00
|
|
|
keys[3 * KEY_COLS + 0 ].is_on = !keys[3 * KEY_COLS + 0 ].is_on; //Caps Shit
|
2013-01-16 21:07:44 +01:00
|
|
|
else if ((key->sdl_code == SDLK_LCTRL) && !keys[3 * KEY_COLS + 0 ].is_on)
|
2013-03-09 15:24:01 +01:00
|
|
|
keys[3 * KEY_COLS + 8 ].is_on = !keys[3 * KEY_COLS + 8 ].is_on; //Sym Shift
|
2013-01-16 21:07:44 +01:00
|
|
|
else {
|
2013-03-09 15:24:01 +01:00
|
|
|
key->caps_on = keys[3 * KEY_COLS + 0 ].is_on;
|
|
|
|
key->sym_on = keys[3 * KEY_COLS + 8 ].is_on;
|
2013-01-16 21:07:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
key_code = key->sdl_code;
|
|
|
|
|
2013-03-09 15:24:01 +01:00
|
|
|
if ((key_code!=SDLK_LSHIFT)&&(key_code!=SDLK_LCTRL))
|
|
|
|
{
|
|
|
|
if (key->caps_on) joybutton_matrix[0][SDLK_LSHIFT]=1;
|
|
|
|
else if (key->sym_on) joybutton_matrix[0][SDLK_LCTRL]=1;
|
|
|
|
joybutton_matrix[0][key_code]=1;
|
|
|
|
}
|
|
|
|
|
2013-01-16 21:07:44 +01:00
|
|
|
printf ("Push Event: keycode %d\n", key_code);
|
|
|
|
|
|
|
|
SDL_ShowCursor(SDL_DISABLE);
|
|
|
|
draw_vk();
|
|
|
|
SDL_ShowCursor(SDL_ENABLE);
|
2013-02-19 09:50:27 +01:00
|
|
|
}
|
2013-03-09 15:24:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (key_sel==KEY_DESELECT)
|
|
|
|
{
|
|
|
|
joybutton_matrix[0][key_code]=0;
|
|
|
|
joybutton_matrix[0][SDLK_LSHIFT]=0;
|
|
|
|
joybutton_matrix[0][SDLK_LCTRL]=0;
|
|
|
|
|
|
|
|
if ((key_code!=SDLK_LSHIFT)&&(key_code!=SDLK_LCTRL))
|
|
|
|
{
|
|
|
|
keys[3 * KEY_COLS + 0 ].is_on = 0; //Caps Shit
|
|
|
|
keys[3 * KEY_COLS + 8 ].is_on = 0; //Sym Shift
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_ShowCursor(SDL_DISABLE);
|
|
|
|
draw_vk();
|
|
|
|
SDL_ShowCursor(SDL_ENABLE);
|
|
|
|
|
|
|
|
key_code=0;
|
2013-01-16 21:07:44 +01:00
|
|
|
}
|
2017-01-15 14:50:14 +01:00
|
|
|
}
|
2013-01-16 21:07:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void virtkey_ir_activate(void)
|
|
|
|
{
|
|
|
|
ordenador.vk_is_active=1;
|
|
|
|
VirtualKeyboard.sel_x = 64;
|
|
|
|
VirtualKeyboard.sel_y = 90;
|
|
|
|
draw_vk();
|
|
|
|
SDL_ShowCursor(SDL_ENABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void virtkey_ir_deactivate(void)
|
|
|
|
{
|
|
|
|
ordenador.vk_is_active=0;
|
|
|
|
SDL_ShowCursor(SDL_DISABLE);
|
2013-03-09 15:24:01 +01:00
|
|
|
|
|
|
|
joybutton_matrix[0][key_code]=0;
|
|
|
|
joybutton_matrix[0][SDLK_LSHIFT]=0;
|
|
|
|
joybutton_matrix[0][SDLK_LCTRL]=0;
|
|
|
|
keys[3 * KEY_COLS + 0 ].is_on = 0; //Caps Shit
|
|
|
|
keys[3 * KEY_COLS + 8 ].is_on = 0; //Sym Shift
|
|
|
|
key_code=0;
|
2014-03-23 18:36:37 +01:00
|
|
|
clean_screen();
|
2013-01-16 21:07:44 +01:00
|
|
|
}
|