mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-05-03 14:59:36 +00:00
added reporting of additional virtual joystick buttons (X, Y, L, R, L2, R2, L3,R3).
This commit is contained in:
42
menu.c
42
menu.c
@@ -248,19 +248,28 @@ void siprintbinary(char* buffer, size_t const size, void const * const ptr)
|
||||
void get_joystick_state( char *joy_string, char *joy_string2, unsigned int joy_num ) {
|
||||
// helper to get joystick status (both USB or DB9)
|
||||
unsigned char joy;
|
||||
uint16_t vjoy;
|
||||
memset(joy_string, '\0', sizeof(joy_string));
|
||||
memset(joy_string2, '\0', sizeof(joy_string2));
|
||||
if (joy_num==0)
|
||||
if (joy_num==0) {
|
||||
joy = OsdJoyGet();
|
||||
else
|
||||
vjoy = joy;
|
||||
vjoy |= OsdJoyGetExtra() << 8;
|
||||
} else {
|
||||
joy = OsdJoyGet2();
|
||||
if (joy==0) {
|
||||
vjoy = joy;
|
||||
vjoy |= OsdJoyGetExtra2() << 8;
|
||||
}
|
||||
if (vjoy==0) {
|
||||
strcpy(joy_string2, JOY_NO_INPUT);
|
||||
return;
|
||||
}
|
||||
strcat(joy_string, " ");
|
||||
strcat(joy_string2, " " );
|
||||
if(joy & JOY_UP) strcat(joy_string, "\x12");
|
||||
|
||||
if(joy & JOY_UP) strcat(joy_string, "\x12 ");
|
||||
else strcat(joy_string, " ");
|
||||
|
||||
if(joy & JOY_LEFT) {
|
||||
if(joy & JOY_DOWN)
|
||||
strcat(joy_string2, "< \x13 ");
|
||||
@@ -284,6 +293,29 @@ void get_joystick_state( char *joy_string, char *joy_string2, unsigned int joy_n
|
||||
if(joy & JOY_SELECT) strcat(joy_string2, "Sel ");
|
||||
else strcat(joy_string2, " ");
|
||||
if(joy & JOY_START) strcat(joy_string2, "Sta");
|
||||
|
||||
if(vjoy & JOY_X) strcat(joy_string, "X ");
|
||||
else strcat(joy_string, " ");
|
||||
|
||||
if(vjoy & JOY_Y) strcat(joy_string, "Y ");
|
||||
else strcat(joy_string, " ");
|
||||
|
||||
if(vjoy & JOY_L) strcat(joy_string, "L ");
|
||||
else strcat(joy_string, " ");
|
||||
|
||||
if(vjoy & JOY_R) strcat(joy_string, "R ");
|
||||
else strcat(joy_string, " ");
|
||||
|
||||
if(vjoy & JOY_L2) strcat(joy_string, "L2 ");
|
||||
else strcat(joy_string, " ");
|
||||
|
||||
if(vjoy & JOY_R2) strcat(joy_string, "R2 ");
|
||||
else strcat(joy_string, " ");
|
||||
|
||||
if(vjoy & JOY_L3) strcat(joy_string, "L3");
|
||||
// switch to string2 because we run out of space
|
||||
if(vjoy & JOY_L3) strcat(joy_string2, "R3 ");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -378,7 +410,7 @@ void HandleUI(void)
|
||||
static char helpstate=0;
|
||||
|
||||
/* check joystick status */
|
||||
char joy_string[16];
|
||||
char joy_string[32];
|
||||
char joy_string2[32];
|
||||
char usb_id[64];
|
||||
|
||||
|
||||
15
osd.c
15
osd.c
@@ -735,23 +735,36 @@ unsigned char OsdNumJoysticksSet(unsigned char num) {
|
||||
|
||||
/* latest joystick state */
|
||||
static unsigned char osd_joy;
|
||||
static unsigned char osd_joy_extra;
|
||||
void OsdJoySet(unsigned char c) {
|
||||
//iprintf("OSD joy: %x\n", c);
|
||||
osd_joy = c;
|
||||
}
|
||||
void OsdJoySetExtra(unsigned char c) {
|
||||
osd_joy_extra = c;
|
||||
}
|
||||
unsigned char OsdJoyGet() {
|
||||
return osd_joy;
|
||||
}
|
||||
unsigned char OsdJoyGetExtra() {
|
||||
return osd_joy_extra;
|
||||
}
|
||||
/* latest joystick state */
|
||||
static unsigned char osd_joy2;
|
||||
static unsigned char osd_joy_extra2;
|
||||
void OsdJoySet2(unsigned char c) {
|
||||
//iprintf("OSD joy 2: %x\n", c);
|
||||
osd_joy2 = c;
|
||||
}
|
||||
void OsdJoySetExtra2(unsigned char c) {
|
||||
osd_joy_extra2 = c;
|
||||
}
|
||||
unsigned char OsdJoyGet2() {
|
||||
return osd_joy2;
|
||||
}
|
||||
|
||||
unsigned char OsdJoyGetExtra2() {
|
||||
return osd_joy_extra2;
|
||||
}
|
||||
|
||||
static uint8_t raw_usb_joy; // four directions and 4 buttons
|
||||
static uint8_t raw_usb_joy_extra; // eight extra buttons
|
||||
|
||||
2
osd.h
2
osd.h
@@ -145,6 +145,8 @@ unsigned char OsdJoyGetExtra();
|
||||
// State of second (virtual) joystisk
|
||||
void OsdJoySet2(unsigned char);
|
||||
unsigned char OsdJoyGet2();
|
||||
void OsdJoySetExtra2(unsigned char);
|
||||
unsigned char OsdJoyGetExtra2();
|
||||
|
||||
// Keep track of connected sticks
|
||||
unsigned char OsdNumJoysticks();
|
||||
|
||||
@@ -757,6 +757,13 @@ static void usb_process_iface (usb_hid_iface_info_t *iface,
|
||||
|
||||
//if (jmap != 0) iprintf("JMAP post map:%d\n", jmap);
|
||||
|
||||
// report joystick 1 to OSD
|
||||
if ( iface->jindex==0) {
|
||||
OsdJoySetExtra( btn_extra );
|
||||
} else if (iface->jindex==1) {
|
||||
OsdJoySetExtra2( btn_extra );
|
||||
}
|
||||
|
||||
// swap joystick 0 and 1 since 1 is the one
|
||||
// used primarily on most systems
|
||||
idx = iface->jindex;
|
||||
|
||||
Reference in New Issue
Block a user