mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-01-13 15:17:43 +00:00
Added OSD reporting for Joystick 2
This commit is contained in:
parent
5ac081e365
commit
0b41f47263
4
menu.h
4
menu.h
@ -100,7 +100,9 @@ enum MENU
|
||||
MENU_8BIT_ABOUT1,
|
||||
MENU_8BIT_ABOUT2,
|
||||
MENU_8BIT_TEST1,
|
||||
MENU_8BIT_TEST2
|
||||
MENU_8BIT_TEST2,
|
||||
MENU_8BIT_JOYTEST_B1,
|
||||
MENU_8BIT_JOYTEST_B2
|
||||
};
|
||||
|
||||
// UI strings, used by boot messages
|
||||
|
||||
48
osd.c
48
osd.c
@ -724,6 +724,15 @@ unsigned char OsdKeyGet() {
|
||||
return osd_key;
|
||||
}
|
||||
|
||||
// Keep track of connected sticks
|
||||
static unsigned char joysticks;
|
||||
unsigned char OsdNumJoysticks() {
|
||||
return joysticks;
|
||||
}
|
||||
unsigned char OsdNumJoysticksSet(unsigned char num) {
|
||||
joysticks = num;
|
||||
}
|
||||
|
||||
/* latest joystick state */
|
||||
static unsigned char osd_joy;
|
||||
void OsdJoySet(unsigned char c) {
|
||||
@ -733,6 +742,16 @@ void OsdJoySet(unsigned char c) {
|
||||
unsigned char OsdJoyGet() {
|
||||
return osd_joy;
|
||||
}
|
||||
/* latest joystick state */
|
||||
static unsigned char osd_joy2;
|
||||
void OsdJoySet2(unsigned char c) {
|
||||
//iprintf("OSD joy 2: %x\n", c);
|
||||
osd_joy2 = c;
|
||||
}
|
||||
unsigned char OsdJoyGet2() {
|
||||
return osd_joy2;
|
||||
}
|
||||
|
||||
|
||||
static uint8_t raw_usb_joy; // four directions and 4 buttons
|
||||
static uint8_t raw_usb_joy_extra; // eight extra buttons
|
||||
@ -747,10 +766,22 @@ uint8_t OsdUsbJoyGetExtra() {
|
||||
return raw_usb_joy_extra;
|
||||
}
|
||||
|
||||
static uint8_t raw_usb_joy_b; // four directions and 4 buttons
|
||||
static uint8_t raw_usb_joy_extra_b; // eight extra buttons
|
||||
void OsdUsbJoySetB(uint8_t usbjoy, uint8_t usbextra) {
|
||||
raw_usb_joy_b = usbjoy;
|
||||
raw_usb_joy_extra_b = usbextra;
|
||||
}
|
||||
uint8_t OsdUsbJoyGetB() {
|
||||
return raw_usb_joy_b;
|
||||
}
|
||||
uint8_t OsdUsbJoyGetExtraB() {
|
||||
return raw_usb_joy_extra_b;
|
||||
}
|
||||
|
||||
/* connected HID information */
|
||||
static unsigned int usb_vid;
|
||||
static unsigned int usb_pid;
|
||||
|
||||
void OsdUsbIdSet(unsigned int vid, unsigned int pid) {
|
||||
usb_vid=vid;
|
||||
usb_pid=pid;
|
||||
@ -762,6 +793,21 @@ unsigned int OsdUsbPidGet() {
|
||||
return usb_pid;
|
||||
}
|
||||
|
||||
/* connected HID information - joy 2*/
|
||||
static unsigned int usb_vid_b;
|
||||
static unsigned int usb_pid_b;
|
||||
void OsdUsbIdSetB(unsigned int vid, unsigned int pid) {
|
||||
usb_vid_b=vid;
|
||||
usb_pid_b=pid;
|
||||
}
|
||||
unsigned int OsdUsbVidGetB() {
|
||||
return usb_vid_b;
|
||||
}
|
||||
unsigned int OsdUsbPidGetB() {
|
||||
return usb_pid_b;
|
||||
}
|
||||
|
||||
|
||||
/* core currently loaded */
|
||||
static char lastcorename[261+10] = "CORE";
|
||||
void OsdCoreNameSet(const char* str) {
|
||||
|
||||
16
osd.h
16
osd.h
@ -134,15 +134,29 @@ unsigned char OsdKeyGet();
|
||||
|
||||
void OsdJoySet(unsigned char);
|
||||
unsigned char OsdJoyGet();
|
||||
void OsdJoySet2(unsigned char); //second joystick
|
||||
unsigned char OsdJoyGet2();
|
||||
|
||||
// Keep track of connected sticks
|
||||
unsigned char OsdNumJoysticks();
|
||||
unsigned char OsdNumJoysticksSet(unsigned char num);
|
||||
|
||||
// USB raw data for joystick 1
|
||||
void OsdUsbJoySet(uint8_t usbjoy, uint8_t usbextra);
|
||||
uint8_t OsdUsbJoyGet();
|
||||
uint8_t OsdUsbJoyGetExtra();
|
||||
|
||||
void OsdUsbIdSet(unsigned int vid, unsigned int pid);
|
||||
unsigned int OsdUsbVidGet();
|
||||
unsigned int OsdUsbPidGet();
|
||||
|
||||
// USB raw data for joystick 2
|
||||
void OsdUsbJoySetB(uint8_t usbjoy, uint8_t usbextra);
|
||||
uint8_t OsdUsbJoyGetB();
|
||||
uint8_t OsdUsbJoyGetExtraB();
|
||||
void OsdUsbIdSetB(unsigned int vid, unsigned int pid);
|
||||
unsigned int OsdUsbVidGetB();
|
||||
unsigned int OsdUsbPidGetB();
|
||||
|
||||
// get/set core currently loaded
|
||||
void OsdCoreNameSet(const char* str);
|
||||
char* OsdCoreName();
|
||||
|
||||
43
usb/hid.c
43
usb/hid.c
@ -91,16 +91,16 @@ static uint8_t hid_get_report_descr(usb_device_t *dev, uint8_t i, uint16_t size)
|
||||
// we got a report descriptor. Try to parse it
|
||||
if(parse_report_descriptor(buf, size, &(info->iface[i].conf))) {
|
||||
if(info->iface[i].conf.type == REPORT_TYPE_JOYSTICK) {
|
||||
hid_debugf("Detected USB joystick #%d", joysticks);
|
||||
|
||||
info->iface[i].device_type = HID_DEVICE_JOYSTICK;
|
||||
info->iface[i].jindex = joysticks++;
|
||||
hid_debugf("Detected USB joystick #%d", joysticks);
|
||||
info->iface[i].device_type = HID_DEVICE_JOYSTICK;
|
||||
info->iface[i].jindex = joysticks++;
|
||||
OsdNumJoysticksSet(joysticks);
|
||||
}
|
||||
} else {
|
||||
// parsing failed. Fall back to boot mode for mice
|
||||
if(info->iface[i].conf.type == REPORT_TYPE_MOUSE) {
|
||||
hid_debugf("Failed to parse mouse, try using boot mode");
|
||||
info->iface[i].ignore_boot_mode = false;
|
||||
hid_debugf("Failed to parse mouse, try using boot mode");
|
||||
info->iface[i].ignore_boot_mode = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -324,6 +324,7 @@ static uint8_t usb_hid_init(usb_device_t *dev) {
|
||||
|
||||
// process all supported interfaces
|
||||
for(i=0; i<info->bNumIfaces; i++) {
|
||||
|
||||
// no boot mode, try to parse HID report descriptor
|
||||
// when running archie core force the usage of the HID descriptor as
|
||||
// boot mode only supports two buttons and the archie wants three
|
||||
@ -452,22 +453,23 @@ static uint8_t usb_hid_release(usb_device_t *dev) {
|
||||
usb_device_t *dev = usb_get_devices();
|
||||
uint8_t j;
|
||||
for(j=0;j<USB_NUMDEVICES;j++) {
|
||||
if(dev[j].bAddress && (dev[j].class == &usb_hid_class)) {
|
||||
// search for joystick interfaces
|
||||
uint8_t k;
|
||||
for(k=0;k<MAX_IFACES;k++) {
|
||||
if(dev[j].hid_info.iface[k].device_type == HID_DEVICE_JOYSTICK) {
|
||||
if(dev[j].hid_info.iface[k].jindex > c_jindex) {
|
||||
hid_debugf("decreasing jindex of dev #%d from %d to %d", j,
|
||||
dev[j].hid_info.iface[k].jindex, dev[j].hid_info.iface[k].jindex-1);
|
||||
dev[j].hid_info.iface[k].jindex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(dev[j].bAddress && (dev[j].class == &usb_hid_class)) {
|
||||
// search for joystick interfaces
|
||||
uint8_t k;
|
||||
for(k=0;k<MAX_IFACES;k++) {
|
||||
if(dev[j].hid_info.iface[k].device_type == HID_DEVICE_JOYSTICK) {
|
||||
if(dev[j].hid_info.iface[k].jindex > c_jindex) {
|
||||
hid_debugf("decreasing jindex of dev #%d from %d to %d", j,
|
||||
dev[j].hid_info.iface[k].jindex, dev[j].hid_info.iface[k].jindex-1);
|
||||
dev[j].hid_info.iface[k].jindex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// one less joystick in the system ...
|
||||
joysticks--;
|
||||
OsdNumJoysticksSet(joysticks);
|
||||
}
|
||||
}
|
||||
|
||||
@ -737,6 +739,9 @@ static void usb_process_iface (usb_hid_iface_info_t *iface,
|
||||
if ( iface->jindex==0) {
|
||||
OsdUsbIdSet( conf->joystick_mouse.vid, conf->joystick_mouse.pid );
|
||||
OsdUsbJoySet( jmap, btn_extra );
|
||||
} else if (iface->jindex==1) {
|
||||
OsdUsbIdSetB( conf->joystick_mouse.vid, conf->joystick_mouse.pid );
|
||||
OsdUsbJoySetB( jmap, btn_extra );
|
||||
}
|
||||
// map virtual joypad
|
||||
uint16_t vjoy = jmap;
|
||||
|
||||
26
user_io.c
26
user_io.c
@ -56,13 +56,6 @@ static char caps_lock_toggle = 0;
|
||||
// avoid multiple keyboard/controllers to interfere
|
||||
static uint8_t latest_keyb_priority = 0; // keyboard=0, joypad with key mappings=1
|
||||
|
||||
// track for debug/display
|
||||
static unsigned char latest_joy0 = 0;
|
||||
static unsigned char latest_joy1 = 0;
|
||||
|
||||
unsigned char user_io_state_joy0() { return latest_joy0; }
|
||||
unsigned char user_io_state_joy1() { return latest_joy1; }
|
||||
|
||||
// mouse position storage for ps2 and minimig rate limitation
|
||||
#define X 0
|
||||
#define Y 1
|
||||
@ -307,12 +300,19 @@ void user_io_digital_joystick(unsigned char joystick, unsigned char map) {
|
||||
static const uint8_t joy2kbd[] = {
|
||||
OSDCTRLMENU, OSDCTRLMENU, OSDCTRLMENU, OSDCTRLSELECT,
|
||||
OSDCTRLUP, OSDCTRLDOWN, OSDCTRLLEFT, OSDCTRLRIGHT };
|
||||
static uint8_t last_map = 0;
|
||||
|
||||
if (joystick==0) latest_joy0 = map;
|
||||
else latest_joy1 = map;
|
||||
|
||||
OsdJoySet(map);
|
||||
|
||||
// the physical joysticks (db9 ports at the right device side)
|
||||
// as well as the joystick emulation are renumbered if usb joysticks
|
||||
// are present in the system. The USB joystick(s) replace joystick 1
|
||||
// and 0 and the physical joysticks are "shifted up".
|
||||
// Since the primary joystick is in port 1 the first usb joystick
|
||||
// becomes joystick 1 and only the second one becomes joystick 0
|
||||
// (mouse port)
|
||||
|
||||
if (joystick==1)
|
||||
OsdJoySet(map);
|
||||
else if (joystick==0) // WARNING: 0 is the second joystick, either USB or DB9
|
||||
OsdJoySet2(map);
|
||||
|
||||
// iprintf("joy to osd\n");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user