1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-01-13 15:17:43 +00:00

Added built-in mapping for 8BitDo SFC30

Added Inputs menu (contains tests)
Added simple keyboard test menu.
Added display to show raw VID/PID data of controllers.
This commit is contained in:
Newsdee 2016-06-10 23:47:24 +08:00
parent e2e8c66927
commit 5514b98c62
7 changed files with 288 additions and 104 deletions

254
menu.c
View File

@ -215,7 +215,8 @@ static void substrcpy(char *d, char *s, char idx) {
*d = 0; *d = 0;
} }
#define STD_EXIT " exit" #define STD_EXIT " exit"
#define STD_SPACE_EXIT " SPACE to exit"
#define JOY_NO_INPUT " \x14" // center of joystick arrows #define JOY_NO_INPUT " \x14" // center of joystick arrows
#define JOY_VID "VID:" #define JOY_VID "VID:"
@ -314,7 +315,7 @@ void get_joystick_state( char *joy_string, char *joy_string2, unsigned int joy_n
if(vjoy & JOY_L3) strcat(joy_string, "L3"); if(vjoy & JOY_L3) strcat(joy_string, "L3");
// switch to string2 because we run out of space // switch to string2 because we run out of space
if(vjoy & JOY_L3) strcat(joy_string2, "R3 "); if(vjoy & JOY_R3) strcat(joy_string2, "R3 ");
return; return;
} }
@ -358,22 +359,51 @@ void get_joystick_state_usb( char *s, unsigned char joy_num ) {
return; return;
} }
void get_joystick_id ( char *usb_id, unsigned char joy_num ) { void append_joystick_usbid ( char *usb_id, unsigned int usb_vid, unsigned int usb_pid ) {
/*
appends a string with VID and PID numbers.
Make sure to provide long enough string in usb_id
*/
unsigned short i;
char vid[5] = " ";
char pid[5] = " ";
itoa(usb_vid, vid, 16);
itoa(usb_pid, pid, 16);
if(strlen(vid)<4) {
for(i=5;i>0;i--) {
vid[i]=vid[i-1];
}
vid[0]='0';
}
if(strlen(pid)<4) {
for(i=5;i>0;i--) {
pid[i]=pid[i-1];
}
pid[0]='0';
}
strcat( usb_id, JOY_VID);
strcat( usb_id, vid);
strcat( usb_id, " ");
strcat( usb_id, JOY_PID);
strcat( usb_id, pid);
return;
}
void get_joystick_id ( char *usb_id, unsigned char joy_num, short raw_id ) {
/* /*
Builds a string containing the USB VID/PID information of a joystick Builds a string containing the USB VID/PID information of a joystick
*/ */
unsigned int i;
unsigned int usb_vid; unsigned int usb_vid;
unsigned int usb_pid; unsigned int usb_pid;
char vid[5] = " ";
char pid[5] = " ";
char buffer[32]; char buffer[32];
if (OsdNumJoysticks()==0 || (joy_num==1 && OsdNumJoysticks()<2)) if (raw_id==0) {
{ if (OsdNumJoysticks()==0 || (joy_num==1 && OsdNumJoysticks()<2))
strcpy( usb_id, " "); {
strcat( usb_id, "Atari DB9 Joystick"); strcpy( usb_id, " ");
return; strcat( usb_id, "Atari DB9 Joystick");
return;
}
} }
if (joy_num==1) { if (joy_num==1) {
@ -386,36 +416,19 @@ void get_joystick_id ( char *usb_id, unsigned char joy_num ) {
if (usb_vid>0) { if (usb_vid>0) {
strcpy(usb_id, get_joystick_alias( usb_vid, usb_pid )); if (raw_id ==0) {
if(strlen(usb_id)>0) { strcpy(usb_id, get_joystick_alias( usb_vid, usb_pid ));
siprintf(buffer, "%*s", (28-strlen(usb_id))/2, " "); if(strlen(usb_id)>0) {
strcat(buffer, usb_id); siprintf(buffer, "%*s", (28-strlen(usb_id))/2, " ");
strcpy(usb_id, buffer); strcat(buffer, usb_id);
return; //exit, we got an alias for the stick strcpy(usb_id, buffer);
return; //exit, we got an alias for the stick
}
} }
memset(usb_id, '\0', sizeof(usb_id)); memset(usb_id, '\0', sizeof(usb_id));
strcpy(usb_id, " "); strcpy(usb_id, " ");
append_joystick_usbid( usb_id, usb_vid, usb_pid );
itoa(usb_vid, vid, 16);
itoa(usb_pid, pid, 16);
if(strlen(vid)<4) {
for(i=5;i>0;i--) {
vid[i]=vid[i-1];
}
vid[0]='0';
}
if(strlen(pid)<4) {
for(i=5;i>0;i--) {
pid[i]=pid[i-1];
}
pid[0]='0';
}
strcat( usb_id, JOY_VID);
strcat( usb_id, vid);
strcat( usb_id, " ");
strcat( usb_id, JOY_PID);
strcat( usb_id, pid);
} else { } else {
strcat(usb_id, "Atari DB9 Joystick"); strcat(usb_id, "Atari DB9 Joystick");
} }
@ -434,6 +447,7 @@ void HandleUI(void)
static long helptext_timer; static long helptext_timer;
static const char *helptext; static const char *helptext;
static char helpstate=0; static char helpstate=0;
unsigned char keys[6] = {0,0,0,0,0,0};
/* check joystick status */ /* check joystick status */
char joy_string[32]; char joy_string[32];
@ -870,18 +884,18 @@ void HandleUI(void)
case MENU_8BIT_SYSTEM1: case MENU_8BIT_SYSTEM1:
helptext=helptexts[HELPTEXT_MAIN]; helptext=helptexts[HELPTEXT_MAIN];
menumask=0x3f; // 5 selections + Exit menumask=0x1f; // 5 selections + Exit
OsdSetTitle("System", OSD_ARROW_LEFT); OsdSetTitle("System", OSD_ARROW_LEFT);
menustate = MENU_8BIT_SYSTEM2; menustate = MENU_8BIT_SYSTEM2;
parentstate = MENU_8BIT_SYSTEM1; parentstate = MENU_8BIT_SYSTEM1;
OsdWrite(0, "", 0,0); OsdWrite(0, "", 0,0);
OsdWrite(1, " Firmware & Core \x16", menusub == 0,0); OsdWrite(1, " Firmware & Core \x16", menusub == 0,0);
OsdWrite(2, " Joystick 1 Test \x16", menusub == 1,0); OsdWrite(2, " Input Devices \x16", menusub == 1,0);
OsdWrite(3, " Joystick 2 Test \x16", menusub == 2,0); OsdWrite(3, " Save settings \x16", menusub == 2,0);
OsdWrite(4, " Save settings", menusub == 3,0); OsdWrite(4, "", 0,0);
OsdWrite(5, " About", menusub == 4,0); OsdWrite(5, " About", menusub == 3,0);
OsdWrite(6, "", 0,0); OsdWrite(6, "", 0,0);
OsdWrite(7, STD_EXIT, menusub == 5, 0); OsdWrite(7, STD_EXIT, menusub == 4, 0);
break; break;
case MENU_8BIT_SYSTEM2 : case MENU_8BIT_SYSTEM2 :
@ -897,15 +911,10 @@ void HandleUI(void)
break; break;
case 1: case 1:
// Joystick1 test // Joystick1 test
menustate = MENU_8BIT_TEST1; menustate = MENU_8BIT_CONTROLLERS1;
menusub = 0; menusub = 0;
break; break;
case 2: case 2:
// Joystick2 test
menustate = MENU_8BIT_JOYTEST_B1;
menusub = 0;
break;
case 3:
// Save settings // Save settings
user_io_create_config_name(s); user_io_create_config_name(s);
iprintf("Saving config to %s\n", s); iprintf("Saving config to %s\n", s);
@ -916,12 +925,12 @@ void HandleUI(void)
iprintf("Settings for %s written\n", s); iprintf("Settings for %s written\n", s);
} }
break; break;
case 4: case 3:
// About logo // About logo
menustate = MENU_8BIT_ABOUT1; menustate = MENU_8BIT_ABOUT1;
menusub = 0; menusub = 0;
break; break;
case 5: case 4:
// Exit // Exit
menustate=MENU_NONE1; menustate=MENU_NONE1;
menusub = 0; menusub = 0;
@ -982,26 +991,143 @@ void HandleUI(void)
} }
break; break;
case MENU_8BIT_TEST1: case MENU_8BIT_CONTROLLERS1:
helptext = helptexts[HELPTEXT_NONE];
menumask=0x1f;
OsdSetTitle("Inputs", 0);
menustate = MENU_8BIT_CONTROLLERS2;
parentstate=MENU_8BIT_CONTROLLERS1;
OsdWrite(0, "", 0, 0);
OsdWrite(1, " Joystick 1 Test \x16", menusub==0, 0);
OsdWrite(2, " Joystick 2 Test \x16", menusub==1, 0);
OsdWrite(3, " Keyboard Test \x16", menusub==2, 0);
OsdWrite(4, " USB status \x16", menusub==3, 0);
OsdWrite(5, "", 0, 0);
OsdWrite(6, "", 0, 0);
OsdWrite(7, STD_EXIT, menusub==4, 0);
break;
case MENU_8BIT_CONTROLLERS2:
// menu key closes menu
if (menu)
menustate = MENU_NONE1;
if(select) {
switch (menusub) {
case 0:
// Joystick1 Test
menustate = MENU_8BIT_JOYTEST_A1;
menusub = 0;
break;
case 1:
// Joystick2 test
menustate = MENU_8BIT_JOYTEST_B1;
menusub = 0;
break;
case 2:
// Keyboard test
menustate = MENU_8BIT_KEYTEST1;
menusub = 0;
break;
case 3:
// USB status
menustate=MENU_8BIT_USB1;
menusub = 0;
break;
case 4:
// Exit
menustate=MENU_NONE1;
menusub = 0;
break;
}
}
break;
case MENU_8BIT_KEYTEST1:
helptext = helptexts[HELPTEXT_NONE]; helptext = helptexts[HELPTEXT_NONE];
menumask=1; menumask=1;
get_joystick_id( usb_id, 0 ); OsdSetTitle("Keyboard", 0);
menustate = MENU_8BIT_KEYTEST2;
parentstate=MENU_8BIT_KEYTEST1;
OsdKeyboardPressed(keys);
siprintf(s, "%2x %2x %2x %2x %2x %2x", keys[0], keys[1], keys[2], keys[3], keys[4], keys[5]);
OsdWrite(0, "", 0, 0);
OsdWrite(1, s, 0,0);
OsdWrite(2, "", 0, 0);
OsdWrite(3, "", 0, 0);
OsdWrite(4, "", 0, 0);
OsdWrite(5, "", 0, 0);
OsdWrite(6, " ", 0, 0);
OsdWrite(7, STD_SPACE_EXIT, menusub==0, 0);
break;
case MENU_8BIT_KEYTEST2:
OsdKeyboardPressed(keys);
siprintf(s, "%2x %2x %2x %2x %2x %2x", keys[0], keys[1], keys[2], keys[3], keys[4], keys[5]);
OsdWrite(1, s, 0,0);
// allow allow exit when hitting space
if(c==KEY_SPACE) {
menustate = MENU_8BIT_CONTROLLERS1;
menusub = 0;
}
break;
case MENU_8BIT_USB1:
helptext = helptexts[HELPTEXT_NONE];
menumask=1;
OsdSetTitle("USB", 0);
menustate = MENU_8BIT_USB2;
parentstate=MENU_8BIT_USB1;
get_joystick_id( usb_id, 0, 1);
OsdWrite(0, " Joy1:", 0, 0);
OsdWrite(1, usb_id, 0, 0);
strcpy(usb_id, " ");
get_joystick_id( usb_id, 1, 1);
OsdWrite(2, " Joy2:", 0, 0);
OsdWrite(3, usb_id, 0, 0);
OsdWrite(4, "", 0, 0);
OsdWrite(5, "", 0, 0);
OsdWrite(6, " ", 0, 0);
OsdWrite(7, STD_SPACE_EXIT, menusub==0, 0);
break;
case MENU_8BIT_USB2:
menumask=1;
OsdSetTitle("USB", 0);
get_joystick_id( usb_id, 0, 1);
OsdWrite(0, " Joy1:", 0, 0);
OsdWrite(1, usb_id, 0, 0);
strcpy(usb_id, " ");
get_joystick_id( usb_id, 1, 1);
OsdWrite(2, " Joy2:", 0, 0);
OsdWrite(3, usb_id, 0, 0);
OsdWrite(7, STD_SPACE_EXIT, menusub==0, 0);
// allow allow exit when hitting space
if(c==KEY_SPACE) {
menustate = MENU_8BIT_CONTROLLERS1;
menusub = 0;
}
break;
case MENU_8BIT_JOYTEST_A1:
helptext = helptexts[HELPTEXT_NONE];
menumask=1;
get_joystick_id( usb_id, 0, 0);
OsdSetTitle("Joy1", 0); OsdSetTitle("Joy1", 0);
menustate = MENU_8BIT_TEST2; menustate = MENU_8BIT_JOYTEST_A2;
parentstate=MENU_8BIT_TEST1; parentstate=MENU_8BIT_JOYTEST_A1;
OsdWrite(0, " Test Joystick 1", 0, 0); OsdWrite(0, " Test Joystick 1", 0, 0);
OsdWrite(1, usb_id, 0, 0); OsdWrite(1, usb_id, 0, 0);
OsdWrite(2, "", 0, 0); OsdWrite(2, "", 0, 0);
OsdWrite(3, "", 0, 0); OsdWrite(3, "", 0, 0);
OsdWrite(4, "", 0, 0); OsdWrite(4, "", 0, 0);
OsdWrite(5, "", 0, 0); OsdWrite(5, "", 0, 0);
OsdWrite(6, " ", 0, 0); OsdWrite(6, " ", 0, 0);
OsdWrite(7, " SPACE to exit", menusub==0, 0); OsdWrite(7, STD_SPACE_EXIT, menusub==0, 0);
break; break;
case MENU_8BIT_TEST2: case MENU_8BIT_JOYTEST_A2:
get_joystick_state( joy_string, joy_string2, 0 ); //grab state of joy 0 get_joystick_state( joy_string, joy_string2, 0 ); //grab state of joy 0
get_joystick_id( usb_id, 0 ); get_joystick_id( usb_id, 0, 0 );
OsdWrite(1, usb_id, 0, 0); OsdWrite(1, usb_id, 0, 0);
OsdWrite(3, joy_string, 0, 0); OsdWrite(3, joy_string, 0, 0);
OsdWrite(4, joy_string2, 0, 0); OsdWrite(4, joy_string2, 0, 0);
@ -1011,7 +1137,7 @@ void HandleUI(void)
OsdWrite(6, s, 0,0); OsdWrite(6, s, 0,0);
// allow allow exit when hitting space // allow allow exit when hitting space
if(c==KEY_SPACE) { if(c==KEY_SPACE) {
menustate = MENU_8BIT_SYSTEM1; menustate = MENU_8BIT_CONTROLLERS1;
menusub = 0; menusub = 0;
} }
break; break;
@ -1019,7 +1145,7 @@ void HandleUI(void)
case MENU_8BIT_JOYTEST_B1: case MENU_8BIT_JOYTEST_B1:
helptext = helptexts[HELPTEXT_NONE]; helptext = helptexts[HELPTEXT_NONE];
menumask=1; menumask=1;
get_joystick_id( usb_id, 1 ); get_joystick_id( usb_id, 1, 0);
OsdSetTitle("Joy2", 0); OsdSetTitle("Joy2", 0);
menustate = MENU_8BIT_JOYTEST_B2; menustate = MENU_8BIT_JOYTEST_B2;
parentstate=MENU_8BIT_JOYTEST_B1; parentstate=MENU_8BIT_JOYTEST_B1;
@ -1030,12 +1156,12 @@ void HandleUI(void)
OsdWrite(4, "", 0, 0); OsdWrite(4, "", 0, 0);
OsdWrite(5, "", 0, 0); OsdWrite(5, "", 0, 0);
OsdWrite(6, " ", 0, 0); OsdWrite(6, " ", 0, 0);
OsdWrite(7, " SPACE to exit", menusub==0, 0); OsdWrite(7, STD_SPACE_EXIT, menusub==0, 0);
break; break;
case MENU_8BIT_JOYTEST_B2: case MENU_8BIT_JOYTEST_B2:
get_joystick_state( joy_string, joy_string2, 1 ); get_joystick_state( joy_string, joy_string2, 1 );
get_joystick_id( usb_id, 1 ); get_joystick_id( usb_id, 1, 0);
OsdWrite(1, usb_id, 0, 0); OsdWrite(1, usb_id, 0, 0);
OsdWrite(3, joy_string, 0, 0); OsdWrite(3, joy_string, 0, 0);
OsdWrite(4, joy_string2, 0, 0); OsdWrite(4, joy_string2, 0, 0);
@ -1045,7 +1171,7 @@ void HandleUI(void)
OsdWrite(6, s, 0,0); OsdWrite(6, s, 0,0);
// allow allow exit when hitting space // allow allow exit when hitting space
if(c==KEY_SPACE) { if(c==KEY_SPACE) {
menustate = MENU_8BIT_SYSTEM1; menustate = MENU_8BIT_CONTROLLERS1;
menusub = 0; menusub = 0;
} }
break; break;

12
menu.h
View File

@ -99,10 +99,16 @@ enum MENU
MENU_8BIT_SYSTEM2, MENU_8BIT_SYSTEM2,
MENU_8BIT_ABOUT1, MENU_8BIT_ABOUT1,
MENU_8BIT_ABOUT2, MENU_8BIT_ABOUT2,
MENU_8BIT_TEST1, MENU_8BIT_CONTROLLERS1,
MENU_8BIT_TEST2, MENU_8BIT_CONTROLLERS2,
MENU_8BIT_JOYTEST_A1,
MENU_8BIT_JOYTEST_A2,
MENU_8BIT_JOYTEST_B1, MENU_8BIT_JOYTEST_B1,
MENU_8BIT_JOYTEST_B2 MENU_8BIT_JOYTEST_B2,
MENU_8BIT_KEYTEST1,
MENU_8BIT_KEYTEST2,
MENU_8BIT_USB1,
MENU_8BIT_USB2
}; };
// UI strings, used by boot messages // UI strings, used by boot messages

23
osd.c
View File

@ -820,6 +820,29 @@ unsigned int OsdUsbPidGetB() {
return usb_pid_b; return usb_pid_b;
} }
/* keyboard data */
static unsigned char key_modifier = 0;
static unsigned char key_pressed[6] = { 0,0,0,0,0,0 };
void OsdKeyboardSet( unsigned char modifier, char* keycodes) {
unsigned i=0;
key_modifier = modifier;
for(i=0; i<6; i++) {
if((keycodes[i]&0xFF) != 0xFF )
key_pressed[i]=keycodes[i];
else
key_pressed[i]=0;
}
iprintf("keyodes: %x %x\n", key_pressed[0], key_pressed[1]);
}
unsigned char OsdKeyboardModifiers() {
return key_modifier;
}
void OsdKeyboardPressed(char *keycodes) {
unsigned i=0;
for(i=0; i<6; i++)
keycodes[i]=key_pressed[i];
}
/* core currently loaded */ /* core currently loaded */
static char lastcorename[261+10] = "CORE"; static char lastcorename[261+10] = "CORE";

5
osd.h
View File

@ -168,6 +168,11 @@ void OsdUsbIdSetB(unsigned int vid, unsigned int pid);
unsigned int OsdUsbVidGetB(); unsigned int OsdUsbVidGetB();
unsigned int OsdUsbPidGetB(); unsigned int OsdUsbPidGetB();
// keyboard status
void OsdKeyboardSet( unsigned char modifier, char* pressed);
unsigned char OsdKeyboardModifiers();
void OsdKeyboardPressed(char *pressed);
// get/set core currently loaded // get/set core currently loaded
void OsdCoreNameSet(const char* str); void OsdCoreNameSet(const char* str);
char* OsdCoreName(); char* OsdCoreName();

View File

@ -142,6 +142,9 @@ char* get_joystick_alias( uint16_t vid, uint16_t pid ) {
if(vid==0x1345 && pid==0x1030) if(vid==0x1345 && pid==0x1030)
return JOYSTICK_ALIAS_RETRO_FREAK; return JOYSTICK_ALIAS_RETRO_FREAK;
if(vid==0x1235 && pid==0xab21)
return JOYSTICK_ALIAS_8BITDO_SFC30;
return JOYSTICK_ALIAS_NONE; return JOYSTICK_ALIAS_NONE;
} }
@ -255,6 +258,22 @@ uint16_t virtual_joystick_mapping (uint16_t vid, uint16_t pid, uint16_t joy_inpu
use_default=0; use_default=0;
} }
//mapping for 8bitdo SFC30
if(vid==0x1235 && pid==0xab21) {
mapping[btn_off+1] = JOY_A;
mapping[btn_off+2] = JOY_B;
//mapping[btn_off+3] // not used
mapping[btn_off+4] = JOY_X;
mapping[btn_off+5] = JOY_Y;
//mapping[btn_off+6] // not used
mapping[btn_off+7] = JOY_L | JOY_L2; // also bind to buttons for flippers
mapping[btn_off+8] = JOY_R | JOY_R2; // also bind to buttons for flippers
//9 and 10 not used
mapping[btn_off+11] = JOY_SELECT;
mapping[btn_off+12] = JOY_START;
use_default=0;
}
// apply remap information from mist.ini if present // apply remap information from mist.ini if present
uint8_t j; uint8_t j;
for(j=0;j<MAX_VIRTUAL_JOYSTICK_REMAP;j++) { for(j=0;j<MAX_VIRTUAL_JOYSTICK_REMAP;j++) {
@ -387,7 +406,7 @@ void virtual_joystick_keyboard ( uint16_t vjoy ) {
// shortcuts mapped if start is pressed (take priority) // shortcuts mapped if start is pressed (take priority)
if (vjoy & JOY_START) { if (vjoy & JOY_START) {
iprintf("joy2key START is pressed\n"); //iprintf("joy2key START is pressed\n");
int idx = 0; int idx = 0;
if(vjoy & JOY_A) buf[idx++] = 0x28; // ENTER if(vjoy & JOY_A) buf[idx++] = 0x28; // ENTER
if(vjoy & JOY_B) buf[idx++] = 0x2C; // SPACE if(vjoy & JOY_B) buf[idx++] = 0x2C; // SPACE
@ -427,7 +446,7 @@ void virtual_joystick_keyboard ( uint16_t vjoy ) {
if (joy_key_map[i].modifier) { if (joy_key_map[i].modifier) {
modifier |= joy_key_map[i].modifier; modifier |= joy_key_map[i].modifier;
mapped_hit=1; mapped_hit=1;
iprintf("joy2key hit (modifier):%d\n", joy_key_map[i].modifier); //iprintf("joy2key hit (modifier):%d\n", joy_key_map[i].modifier);
} }
// only override up to 6 keys, // only override up to 6 keys,
// and preserve overrides from further up this function // and preserve overrides from further up this function
@ -440,7 +459,7 @@ void virtual_joystick_keyboard ( uint16_t vjoy ) {
if (joy_key_map[i].keys[j]) { if (joy_key_map[i].keys[j]) {
buf[k++] = joy_key_map[i].keys[j]; buf[k++] = joy_key_map[i].keys[j];
mapped_hit=1; mapped_hit=1;
iprintf("joy2key hit:%d\n", joy_key_map[i].keys[j]); //iprintf("joy2key hit:%d\n", joy_key_map[i].keys[j]);
} }
} }
} }

View File

@ -19,7 +19,7 @@
#define JOYSTICK_ALIAS_ROYDS_EX "ROYDS Stick.EX" #define JOYSTICK_ALIAS_ROYDS_EX "ROYDS Stick.EX"
#define JOYSTICK_ALIAS_NEOGEO_DAPTOR "NEOGEO-daptor" #define JOYSTICK_ALIAS_NEOGEO_DAPTOR "NEOGEO-daptor"
#define JOYSTICK_ALIAS_RETRO_FREAK "Retro Freak gamepad" #define JOYSTICK_ALIAS_RETRO_FREAK "Retro Freak gamepad"
#define JOYSTICK_ALIAS_8BITDO_SFC30 "8BitDo SFC30"
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1108,8 +1108,8 @@ void user_io_poll() {
ps2_mouse[2] = mouse_pos[Y]; ps2_mouse[2] = mouse_pos[Y];
// collect movement info and send at predefined rate // collect movement info and send at predefined rate
iprintf("PS2 MOUSE: %x %d %d\n", if(!(ps2_mouse[0]==0x08 && ps2_mouse[1]==0 && ps2_mouse[2]==0))
ps2_mouse[0], ps2_mouse[1], ps2_mouse[2]); iprintf("PS2 MOUSE: %x %d %d\n", ps2_mouse[0], ps2_mouse[1], ps2_mouse[2]);
spi_uio_cmd_cont(UIO_MOUSE); spi_uio_cmd_cont(UIO_MOUSE);
spi8(ps2_mouse[0]); spi8(ps2_mouse[0]);
@ -1251,18 +1251,17 @@ static void send_keycode(unsigned short code) {
// pause does not have a break code // pause does not have a break code
if(!(code & BREAK)) { if(!(code & BREAK)) {
// Pause key sends E11477E1F014E077
// Pause key sends E11477E1F014E077 static const unsigned char c[] = {
static const unsigned char c[] = { 0xe1, 0x14, 0x77, 0xe1, 0xf0, 0x14, 0xf0, 0x77, 0x00 };
0xe1, 0x14, 0x77, 0xe1, 0xf0, 0x14, 0xf0, 0x77, 0x00 }; const unsigned char *p = c;
const unsigned char *p = c;
iprintf("PS2 KBD ");
iprintf("PS2 KBD "); while(*p) {
while(*p) { iprintf("%x ", *p);
iprintf("%x ", *p); spi8(*p++);
spi8(*p++); }
} iprintf("\n");
iprintf("\n");
} }
} else { } else {
iprintf("PS2 KBD "); iprintf("PS2 KBD ");
@ -1431,12 +1430,14 @@ void user_io_kbd(unsigned char m, unsigned char *k, uint8_t priority) {
(core_type == CORE_TYPE_ARCHIE) || (core_type == CORE_TYPE_ARCHIE) ||
(core_type == CORE_TYPE_8BIT)) { (core_type == CORE_TYPE_8BIT)) {
// iprintf("KBD: %d\n", m); // iprintf("KBD: %d\n", m);
// hexdump(k, 6, 0); // hexdump(k, 6, 0);
static unsigned char modifier = 0, pressed[6] = { 0,0,0,0,0,0 }; static unsigned char modifier = 0, pressed[6] = { 0,0,0,0,0,0 };
char keycodes[6] = { 0,0,0,0,0,0 };
char i, j; char i, j;
// remap keycodes if requested // remap keycodes if requested
for(i=0;(i<6) && k[i];i++) { for(i=0;(i<6) && k[i];i++) {
for(j=0;j<MAX_REMAP;j++) { for(j=0;j<MAX_REMAP;j++) {
@ -1446,25 +1447,25 @@ void user_io_kbd(unsigned char m, unsigned char *k, uint8_t priority) {
} }
} }
} }
// remap modifiers to each other if requested // remap modifiers to each other if requested
// bit 0 1 2 3 4 5 6 7 // bit 0 1 2 3 4 5 6 7
// key LCTRL LSHIFT LALT LGUI RCTRL RSHIFT RALT RGUI // key LCTRL LSHIFT LALT LGUI RCTRL RSHIFT RALT RGUI
if (false) { // (disabled until we configure it via INI) if (false) { // (disabled until we configure it via INI)
uint8_t default_mod_mapping [8] = { uint8_t default_mod_mapping [8] = {
0x1, 0x1,
0x2, 0x2,
0x4, 0x4,
0x8, 0x8,
0x10, 0x10,
0x20, 0x20,
0x40, 0x40,
0x80 0x80
}; };
uint8_t modifiers = 0; uint8_t modifiers = 0;
for(i=0; i<8; i++) for(i=0; i<8; i++)
if (m & (0x01<<i)) modifiers |= default_mod_mapping[i]; if (m & (0x01<<i)) modifiers |= default_mod_mapping[i];
m = modifiers; m = modifiers;
} }
// modifier keys are used as buttons in emu mode // modifier keys are used as buttons in emu mode
if(emu_mode != EMU_NONE) { if(emu_mode != EMU_NONE) {
@ -1642,8 +1643,12 @@ void user_io_kbd(unsigned char m, unsigned char *k, uint8_t priority) {
} }
} }
for(i=0;i<6;i++) for(i=0;i<6;i++) {
pressed[i] = k[i]; pressed[i] = k[i];
keycodes[i] = keycode(pressed[i]);
}
OsdKeyboardSet(m, keycodes);
} }
} }