mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-11-28 02:54:15 +01:00
Automatic virtual keyboard
This commit is contained in:
parent
bf5151a527
commit
923b73786a
@ -116,7 +116,7 @@ void draw()
|
||||
}
|
||||
|
||||
|
||||
struct virtkey *get_key_internal()
|
||||
struct virtkey *get_key_internal(int vk)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
@ -132,7 +132,7 @@ struct virtkey *get_key_internal()
|
||||
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
|
||||
k = menu_wait_key_press();
|
||||
k = menu_wait_key_press(vk);
|
||||
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
@ -170,7 +170,7 @@ struct virtkey *get_key_internal()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct virtkey* get_key()
|
||||
struct virtkey* get_key(int vk)
|
||||
{
|
||||
virtkey_t *key;
|
||||
|
||||
@ -179,7 +179,7 @@ struct virtkey* get_key()
|
||||
keys[3 * KEY_COLS + 0 ].is_on = 0; //Caps Shit
|
||||
keys[3 * KEY_COLS + 8 ].is_on = 0; //Sym Shift
|
||||
|
||||
key = get_key_internal();
|
||||
key = get_key_internal(vk);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ struct Virtual_Keyboard
|
||||
} VirtualKeyboard;
|
||||
|
||||
void VirtualKeyboard_init(SDL_Surface *screen);
|
||||
struct virtkey* get_key();
|
||||
struct virtkey* get_key_internal();
|
||||
struct virtkey* get_key(int vk);
|
||||
struct virtkey* get_key_internal(int vk);
|
||||
void draw();
|
||||
void select_next_kb(int dx, int dy);
|
||||
void toggle_shift();
|
||||
|
@ -106,6 +106,7 @@ void computer_init () { //Called only on start-up
|
||||
ordenador.videosystem = 0; //PAL
|
||||
ordenador.joystick[0] = 1; //Kemposton
|
||||
ordenador.joystick[1] = 0; // Cursor
|
||||
ordenador.vk_auto = 0; //Vk called by +
|
||||
ordenador.rumble[0] = 0;
|
||||
ordenador.rumble[1] = 0;
|
||||
ordenador.turbo = 0;
|
||||
@ -1057,6 +1058,8 @@ inline void read_keyboard () {
|
||||
fire_on[0]=0;
|
||||
fire_on[1]=0;
|
||||
|
||||
static int countdown_kb;
|
||||
|
||||
ordenador.k8 = ordenador.k9 = ordenador.k10 = ordenador.k11 =
|
||||
ordenador.k12 = ordenador.k13 = ordenador.k14 =
|
||||
ordenador.k15 = 0;
|
||||
@ -1072,6 +1075,22 @@ inline void read_keyboard () {
|
||||
|
||||
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
if (ordenador.vk_auto)
|
||||
{
|
||||
if (countdown_kb>0) countdown_kb--;
|
||||
|
||||
#ifdef GEKKO
|
||||
WPADData *wd;
|
||||
wd = WPAD_Data(0);
|
||||
if ((wd->ir.valid)&&(!countdown_kb)) {virtual_keyboard();countdown_kb=30;}
|
||||
#else
|
||||
int x=0,y=0 ;
|
||||
SDL_GetRelativeMouseState(&x,&y);
|
||||
if ((x||y)&&(!countdown_kb)) {virtual_keyboard();countdown_kb=30;}
|
||||
#endif
|
||||
}
|
||||
|
||||
for(joy_n=0;joy_n<ordenador.joystick_number;joy_n++)
|
||||
{
|
||||
joy_axis_x[joy_n] = SDL_JoystickGetAxis(ordenador.joystick_sdl[joy_n], 0);
|
||||
@ -1080,8 +1099,9 @@ inline void read_keyboard () {
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 6) ||
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 19)) main_menu(); //Wii button "Home"
|
||||
|
||||
if (SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 5) ||
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 18)) virtual_keyboard(); //Wii button "+"
|
||||
|
||||
if ((!ordenador.vk_auto) &&(SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 5) ||
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 18))) virtual_keyboard(); //Wii button "+"
|
||||
|
||||
if (joy_axis_x[joy_n] > 16384) ordenador.joy_axis_x_state[joy_n] = JOY_RIGHT;
|
||||
else if (joy_axis_x[joy_n] < -16384) ordenador.joy_axis_x_state[joy_n] = JOY_LEFT;
|
||||
@ -1102,6 +1122,14 @@ inline void read_keyboard () {
|
||||
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][joybutton_n])] =
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], joybutton_n);
|
||||
}
|
||||
|
||||
if (ordenador.vk_auto) { //Check if it is possible to put in the loop
|
||||
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][5])] =
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 5);
|
||||
joybutton_matrix[joy_n][(ordenador.joybuttonkey[joy_n][18])] =
|
||||
SDL_JoystickGetButton(ordenador.joystick_sdl[joy_n], 18);
|
||||
}
|
||||
|
||||
//JOY HAT
|
||||
status_hat[joy_n] = SDL_JoystickGetHat(ordenador.joystick_sdl[joy_n], 0);
|
||||
if(!ordenador.joypad_as_joystick[joy_n])
|
||||
@ -1487,8 +1515,8 @@ void ResetComputer () {
|
||||
ordenador.s15|=0x1F;
|
||||
ordenador.js=0;
|
||||
|
||||
ordenador.updown=0;
|
||||
ordenador.leftright=0;
|
||||
//ordenador.updown=0;
|
||||
//ordenador.leftright=0;
|
||||
|
||||
ordenador.wr=0;
|
||||
ordenador.r_fetch = 0;
|
||||
|
@ -105,8 +105,8 @@ struct computer {
|
||||
|
||||
// Linux joystick private global variables
|
||||
|
||||
unsigned char use_js;
|
||||
unsigned char updown,leftright;
|
||||
//unsigned char use_js;
|
||||
//unsigned char updown,leftright;
|
||||
|
||||
// sound global variables
|
||||
|
||||
@ -231,6 +231,7 @@ struct computer {
|
||||
unsigned int joybuttonkey[2][22];
|
||||
unsigned char joypad_as_joystick[2];
|
||||
unsigned char rumble[2];
|
||||
unsigned char vk_auto;
|
||||
unsigned char port; //SD, USB, SMB or FTP
|
||||
unsigned char smb_enable;
|
||||
unsigned char SmbUser[32];
|
||||
|
@ -486,11 +486,11 @@ int retorno, bucle;
|
||||
}
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
|
||||
ordenador.use_js=0;
|
||||
//ordenador.use_js=0;
|
||||
printf("Can't initialize JoyStick subsystem\n");
|
||||
} else {
|
||||
printf("JoyStick subsystem initialized\n");
|
||||
ordenador.use_js=1;
|
||||
//ordenador.use_js=1;
|
||||
if(SDL_NumJoysticks()>0){
|
||||
// Open joystick
|
||||
ordenador.joystick_number = SDL_NumJoysticks();
|
||||
@ -663,6 +663,7 @@ int save_config(struct computer *object, char *filename) {
|
||||
fprintf(fconfig,"port=%c%c",48+object->port,10);
|
||||
fprintf(fconfig,"autoconf=%c%c",48+object->autoconf,10);
|
||||
fprintf(fconfig,"turbo=%c%c",48+object->turbo,10);
|
||||
fprintf(fconfig,"vk_auto=%c%c",48+object->vk_auto,10);
|
||||
|
||||
|
||||
for (joy_n=0; joy_n<2; joy_n++)
|
||||
@ -831,7 +832,7 @@ int load_config(struct computer *object, char *filename) {
|
||||
FILE *fconfig;
|
||||
unsigned char volume=255,mode128k=255,issue=255,ntsc=255, joystick1=255,joystick2=255,ay_emul=255,mdr_active=255,
|
||||
dblscan=255,framerate =255, screen =255, text=255, precision=255, bw=255, tap_fast=255, audio_mode=255,
|
||||
joypad1=255, joypad2=255, rumble1=255, rumble2=255, joy_n=255, key_n=255, port=255, autoconf=255, turbo=225;
|
||||
joypad1=255, joypad2=255, rumble1=255, rumble2=255, joy_n=255, key_n=255, port=255, autoconf=255, turbo=225, vk_auto=255;
|
||||
|
||||
if (filename) strcpy(config_path,filename);
|
||||
else return -2;
|
||||
@ -957,6 +958,10 @@ int load_config(struct computer *object, char *filename) {
|
||||
turbo=line[6]-'0';
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(line,"vk_auto=",8)) {
|
||||
vk_auto=line[8]-'0';
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(line,"joybutton_",10)) {
|
||||
sscanf(line, "joybutton_%c_%c=%3d",&joy_n ,&key_n, &key_sdl);
|
||||
if ((joy_n<50) && (joy_n>47) && (key_n<119) && (key_n>96))
|
||||
@ -1035,6 +1040,9 @@ int load_config(struct computer *object, char *filename) {
|
||||
if (turbo<2) {
|
||||
object->turbo=turbo;
|
||||
}
|
||||
if (vk_auto<2) {
|
||||
object->vk_auto=vk_auto;
|
||||
}
|
||||
|
||||
fclose(fconfig);
|
||||
return 0;
|
||||
|
@ -119,11 +119,11 @@ static const char *input_messages[] = {
|
||||
/*00*/ "Joystick type",
|
||||
/*01*/ "^|Cursor|Kempston|Sinclair1|Sinclair2",
|
||||
/*02*/ "Bind key to Wiimote",
|
||||
/*03*/ "^|A|B|1|2|-",
|
||||
/*03*/ "^|A|B|1|2|-|+",
|
||||
/*04*/ "Bind key to Nunchuk",
|
||||
/*05*/ "^|Z|C",
|
||||
/*06*/ "Bind key to Classic",
|
||||
/*07*/ "^|a|b|x|y|L|R|Zl|Zr|-",
|
||||
/*07*/ "^|a|b|x|y|L|R|Zl|Zr|-|+",
|
||||
/*08*/ "Bind key to Pad",
|
||||
/*09*/ "^|Up|Down|Left|Right",
|
||||
/*10*/ "Use Joypad as Joystick",
|
||||
@ -156,7 +156,10 @@ static const char *tools_messages[] = {
|
||||
/*07*/ "Port",
|
||||
/*08*/ "^|sd|usb|smb|ftp",
|
||||
/*09*/ " ",
|
||||
/*10*/ "Help",
|
||||
/*10*/ "Auto virtual keyboard",
|
||||
/*11*/ "^|on|off",
|
||||
/*12*/ " ",
|
||||
/*13*/ "Help",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -674,9 +677,9 @@ static void setup_joystick(int joy, unsigned int sdl_key, int joy_key)
|
||||
|
||||
static void input_options(int joy)
|
||||
{
|
||||
const unsigned int wiimote_to_sdl[] = {0, 1, 2, 3, 4};
|
||||
const unsigned int wiimote_to_sdl[] = {0, 1, 2, 3, 4,5};
|
||||
const unsigned int nunchuk_to_sdl[] = {7, 8};
|
||||
const unsigned int classic_to_sdl[] = {9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
const unsigned int classic_to_sdl[] = {9, 10, 11, 12, 13, 14, 15, 16, 17,18};
|
||||
const unsigned int pad_to_sdl[] = {18, 19, 20, 21};
|
||||
int joy_key = 1;
|
||||
unsigned int sdl_key;
|
||||
@ -707,7 +710,7 @@ static void input_options(int joy)
|
||||
VirtualKeyboard.sel_x = 64;
|
||||
VirtualKeyboard.sel_y = 90;
|
||||
|
||||
virtualkey = get_key();
|
||||
virtualkey = get_key(0);
|
||||
if (virtualkey == NULL)
|
||||
return;
|
||||
sdl_key = virtualkey->sdl_code;
|
||||
@ -1290,7 +1293,7 @@ int parse_poke (const char *filename)
|
||||
k=0;
|
||||
|
||||
while (!((k & KEY_ESCAPE)||(k & KEY_SELECT)))
|
||||
{k = menu_wait_key_press();}
|
||||
{k = menu_wait_key_press(0);}
|
||||
|
||||
banner.y=y;
|
||||
|
||||
@ -1361,7 +1364,7 @@ int parse_poke (const char *filename)
|
||||
k=0;
|
||||
|
||||
while (!(k & KEY_ESCAPE)&&(ritorno==0))
|
||||
{k = menu_wait_key_press();}
|
||||
{k = menu_wait_key_press(0);}
|
||||
|
||||
fclose(fpoke);
|
||||
if (ritorno==0) strcpy(ordenador.last_selected_poke_file,filename);
|
||||
@ -1439,7 +1442,7 @@ switch (which)
|
||||
static int tools()
|
||||
{
|
||||
int opt , retorno;
|
||||
int submenus[2];
|
||||
int submenus[3];
|
||||
|
||||
memset(submenus, 0, sizeof(submenus));
|
||||
|
||||
@ -1447,6 +1450,7 @@ static int tools()
|
||||
retorno=-1; //Exit from menu as default
|
||||
|
||||
submenus[1] = ordenador.port;
|
||||
submenus[2] = !ordenador.vk_auto;
|
||||
|
||||
opt = menu_select_title("Tools menu",
|
||||
tools_messages, submenus);
|
||||
@ -1454,6 +1458,7 @@ static int tools()
|
||||
return 0;
|
||||
|
||||
set_port(submenus[1]);
|
||||
ordenador.vk_auto = !submenus[2];
|
||||
|
||||
switch(opt)
|
||||
{
|
||||
@ -1466,7 +1471,7 @@ static int tools()
|
||||
case 5: // Load poke file
|
||||
retorno = load_poke_file();
|
||||
break;
|
||||
case 10:
|
||||
case 13:
|
||||
help();
|
||||
retorno = -1;
|
||||
break;
|
||||
@ -1485,7 +1490,7 @@ void virtual_keyboard(void)
|
||||
VirtualKeyboard.sel_x = 64;
|
||||
VirtualKeyboard.sel_y = 90;
|
||||
|
||||
virtkey_t *key =get_key();
|
||||
virtkey_t *key =get_key(1);
|
||||
if (key) {key_code = key->sdl_code;} else return;
|
||||
|
||||
ordenador.kbd_buffer_pointer=1;
|
||||
|
@ -42,6 +42,10 @@
|
||||
|
||||
#include "minizip/unzip.h"
|
||||
|
||||
#if defined(GEKKO)
|
||||
# include <wiiuse/wpad.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
extern FILE *fdebug;
|
||||
#define printf(...) fprintf(fdebug,__VA_ARGS__)
|
||||
@ -138,7 +142,7 @@ int msgInfo(char *text, int duration, SDL_Rect *irc)
|
||||
SDL_FillRect(real_screen, &brc, SDL_MapRGB(real_screen->format, 0x00, 0x80, 0x00));
|
||||
menu_print_font(real_screen, 0,0,0, FULL_DISPLAY_X/2-12/RATIO, Y+42/RATIO, "OK",20);
|
||||
SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w, brc.h);
|
||||
while (!(KEY_SELECT & menu_wait_key_press())) {}
|
||||
while (!(KEY_SELECT & menu_wait_key_press(0))) {}
|
||||
|
||||
}
|
||||
|
||||
@ -212,7 +216,7 @@ int msgYesNo(char *text, int default_opt, int x, int y)
|
||||
SDL_UpdateRect(real_screen, brc.x, brc.y, brc.w,brc.h);
|
||||
|
||||
//SDL_Flip(real_screen);
|
||||
key = menu_wait_key_press();
|
||||
key = menu_wait_key_press(0);
|
||||
if (key & KEY_SELECT)
|
||||
{
|
||||
return default_opt;
|
||||
@ -915,7 +919,7 @@ static void menu_fini(menu_t *p_menu)
|
||||
free(p_menu->p_submenus);
|
||||
}
|
||||
|
||||
uint32_t menu_wait_key_press(void)
|
||||
uint32_t menu_wait_key_press(int vk)
|
||||
{
|
||||
SDL_Event ev;
|
||||
uint32_t keys = 0;
|
||||
@ -928,6 +932,20 @@ uint32_t menu_wait_key_press(void)
|
||||
static int joy_keys_last;
|
||||
static int joy_bottons_last[2][8];
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
if (ordenador.vk_auto)
|
||||
{
|
||||
#ifdef GEKKO
|
||||
WPADData *wd;
|
||||
wd = WPAD_Data(0);
|
||||
if (vk&&!(wd->ir.valid)) return KEY_ESCAPE;
|
||||
#else
|
||||
int x=0,y=0 ;
|
||||
SDL_GetRelativeMouseState(&x,&y);
|
||||
if ((x<20||y<20||(x>FULL_DISPLAY_X-20)||y>FULL_DISPLAY_Y-20)) return KEY_ESCAPE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Wii-specific, sorry */
|
||||
for (nr = 0; nr < ordenador.joystick_number; nr++) {
|
||||
joy = ordenador.joystick_sdl[nr];
|
||||
@ -1069,7 +1087,7 @@ static int menu_select_internal(SDL_Surface *screen,
|
||||
menu_draw(screen, p_menu, 0, font_size, draw_scr);
|
||||
SDL_Flip(screen);
|
||||
|
||||
keys = menu_wait_key_press();
|
||||
keys = menu_wait_key_press(0);
|
||||
|
||||
if (keys & KEY_UP)
|
||||
select_next(p_menu, 0, -1, 1);
|
||||
@ -1424,7 +1442,7 @@ int ask_value_sdl(int *final_value,int y_coord,int max_value) {
|
||||
VirtualKeyboard.sel_x = 64;
|
||||
VirtualKeyboard.sel_y = 155;
|
||||
|
||||
virtualkey = get_key();
|
||||
virtualkey = get_key(0);
|
||||
if (virtualkey == NULL) return(0);
|
||||
if (virtualkey->sdl_code==1) break; //done, retorno -1
|
||||
sdl_key = virtualkey->sdl_code;
|
||||
@ -1553,7 +1571,7 @@ int ask_filename_sdl(char *nombre_final,int y_coord,char *extension, char *path,
|
||||
VirtualKeyboard.sel_x = 64;
|
||||
VirtualKeyboard.sel_y = 155;
|
||||
|
||||
virtualkey = get_key();
|
||||
virtualkey = get_key(0);
|
||||
if (virtualkey == NULL) return(2);
|
||||
sdl_key = virtualkey->sdl_code;
|
||||
|
||||
|
@ -54,7 +54,7 @@ int menu_select(const char **pp_msgs, int *p_submenus);
|
||||
const char *menu_select_file(const char *dir_path,const char *selected_file, int draw_scr);
|
||||
|
||||
|
||||
uint32_t menu_wait_key_press(void);
|
||||
uint32_t menu_wait_key_press(int vk);
|
||||
|
||||
void msgKill(SDL_Rect *rc);
|
||||
int msgInfo(char *text, int duration, SDL_Rect *rc);
|
||||
|
Loading…
Reference in New Issue
Block a user