mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-02-02 06:21:16 +00:00
added joystick aliases for sticks known by the firmware
This commit is contained in:
38
menu.c
38
menu.c
@@ -323,6 +323,7 @@ void get_joystick_state_usb( char *s, unsigned char joy_num ) {
|
||||
/* USB specific - current "raw" state
|
||||
(in reverse binary format to correspont to MIST.INI mapping entries)
|
||||
*/
|
||||
char buffer[5];
|
||||
if (OsdNumJoysticks()==0 || (joy_num==1 && OsdNumJoysticks()<2))
|
||||
{
|
||||
strcpy( s, " ");
|
||||
@@ -336,8 +337,18 @@ void get_joystick_state_usb( char *s, unsigned char joy_num ) {
|
||||
joy = OsdUsbJoyGetB();
|
||||
siprintf(s, " USB: ");
|
||||
siprintbinary(binary_string, sizeof(joy), &joy);
|
||||
strcat(s, binary_string);
|
||||
binary_string[0]=binary_string[0]=='1'?'>':'-';
|
||||
binary_string[1]=binary_string[1]=='1'?'<':'-';
|
||||
binary_string[2]=binary_string[2]=='1'?'\x13':'-';
|
||||
binary_string[3]=binary_string[3]=='1'?'\x12':'-';
|
||||
|
||||
memcpy( buffer, &binary_string[0], 4 );
|
||||
buffer[4]='\0';
|
||||
strcat(s, buffer );
|
||||
strcat(s, " ");
|
||||
memcpy( buffer, &binary_string[4], 4 );
|
||||
buffer[4]='\0';
|
||||
strcat(s, buffer );
|
||||
if(joy_num==0)
|
||||
joy = OsdUsbJoyGetExtra();
|
||||
else
|
||||
@@ -352,10 +363,11 @@ void get_joystick_id ( char *usb_id, unsigned char joy_num ) {
|
||||
Builds a string containing the USB VID/PID information of a joystick
|
||||
*/
|
||||
unsigned int i;
|
||||
unsigned int usb_vid = OsdUsbVidGet();
|
||||
unsigned int usb_pid = OsdUsbPidGet();
|
||||
unsigned int usb_vid;
|
||||
unsigned int usb_pid;
|
||||
char vid[5] = " ";
|
||||
char pid[5] = " ";
|
||||
char buffer[32];
|
||||
|
||||
if (OsdNumJoysticks()==0 || (joy_num==1 && OsdNumJoysticks()<2))
|
||||
{
|
||||
@@ -367,10 +379,24 @@ void get_joystick_id ( char *usb_id, unsigned char joy_num ) {
|
||||
if (joy_num==1) {
|
||||
usb_vid = OsdUsbVidGetB();
|
||||
usb_pid = OsdUsbPidGetB();
|
||||
} else {
|
||||
usb_vid = OsdUsbVidGet();
|
||||
usb_pid = OsdUsbPidGet();
|
||||
}
|
||||
memset(usb_id, '\0', sizeof(usb_id));
|
||||
strcpy(usb_id, " ");
|
||||
|
||||
if (usb_vid>0) {
|
||||
|
||||
strcpy(usb_id, get_joystick_alias( usb_vid, usb_pid ));
|
||||
if(strlen(usb_id)>0) {
|
||||
siprintf(buffer, "%*s", (28-strlen(usb_id))/2, " ");
|
||||
strcat(buffer, usb_id);
|
||||
strcpy(usb_id, buffer);
|
||||
return; //exit, we got an alias for the stick
|
||||
}
|
||||
|
||||
memset(usb_id, '\0', sizeof(usb_id));
|
||||
strcpy(usb_id, " ");
|
||||
|
||||
itoa(usb_vid, vid, 16);
|
||||
itoa(usb_pid, pid, 16);
|
||||
if(strlen(vid)<4) {
|
||||
@@ -2936,8 +2962,6 @@ void HandleUI(void)
|
||||
OsdWrite(3, "", 0, 0);
|
||||
|
||||
if(strlen(OsdCoreName())<26) {
|
||||
//strcpy(s, " core: ");
|
||||
//strcat(s, OsdCoreName());
|
||||
siprintf(s, "%*s%s", (28-strlen(OsdCoreName()))/2, " ", OsdCoreName());
|
||||
}
|
||||
else strcpy(s, OsdCoreName());
|
||||
|
||||
@@ -12,6 +12,7 @@ This file defines how to handle mapping in the MiST controllers in various ways:
|
||||
|
||||
#include "timer.h"
|
||||
#include "debug.h"
|
||||
#include "joymapping.h"
|
||||
#include "../user_io.h"
|
||||
#include "../mist_cfg.h"
|
||||
|
||||
@@ -115,6 +116,36 @@ void virtual_joystick_remap(char *s) {
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char* get_joystick_alias( uint16_t vid, uint16_t pid ) {
|
||||
|
||||
if(vid==0x0F30 && pid==0x1012)
|
||||
return JOYSTICK_ALIAS_QANBA_Q4RAF;
|
||||
|
||||
if(vid==0x081F && pid==0xE401)
|
||||
return JOYSTICK_ALIAS_CHEAP_SNES;
|
||||
|
||||
if(vid==0x0583 && pid==0x2060)
|
||||
return JOYSTICK_ALIAS_IBUFALLO_SNES;
|
||||
|
||||
if(vid==0x0411 && pid==0x00C6)
|
||||
return JOYSTICK_ALIAS_IBUFALLO_SNES;
|
||||
|
||||
if (vid==0x0079 && pid==0x0006)
|
||||
return JOYSTICK_ALIAS_RETROLINK_GC;
|
||||
|
||||
if(vid==0x1F4F && pid==0x0003)
|
||||
return JOYSTICK_ALIAS_ROYDS_EX;
|
||||
|
||||
if(vid==0x04D8 && pid==0xF421)
|
||||
return JOYSTICK_ALIAS_NEOGEO_DAPTOR;
|
||||
|
||||
if(vid==0x1345 && pid==0x1030)
|
||||
return JOYSTICK_ALIAS_RETRO_FREAK;
|
||||
|
||||
return JOYSTICK_ALIAS_NONE;
|
||||
|
||||
}
|
||||
|
||||
/* Translates USB input into internal virtual joystick,
|
||||
with some default handling for common/known gampads */
|
||||
|
||||
@@ -321,7 +352,7 @@ void joystick_key_map(char *s) {
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void virtual_joystick_keyboard ( uint16_t vjoy, uint8_t keyb_hit ) {
|
||||
void virtual_joystick_keyboard ( uint16_t vjoy ) {
|
||||
|
||||
// ignore if globally switched off
|
||||
if(mist_cfg.joystick_disable_shortcuts)
|
||||
|
||||
@@ -9,6 +9,18 @@
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
#define JOYSTICK_ALIAS_NONE ""
|
||||
#define JOYSTICK_ALIAS_QANBA_Q4RAF "Qanba Q4RAF"
|
||||
#define JOYSTICK_ALIAS_CHEAP_SNES "SNES Generic Pad"
|
||||
#define JOYSTICK_ALIAS_IBUFALLO_SNES "iBuffalo SFC BSGP801"
|
||||
#define JOYSTICK_ALIAS_IBUFALLO_NES "iBuffalo FC BGCFC801"
|
||||
#define JOYSTICK_ALIAS_RETROLINK_GC "Retrolink N64/GC"
|
||||
#define JOYSTICK_ALIAS_ROYDS_EX "ROYDS Stick.EX"
|
||||
#define JOYSTICK_ALIAS_NEOGEO_DAPTOR "NEOGEO-daptor"
|
||||
#define JOYSTICK_ALIAS_RETRO_FREAK "Retro Freak gamepad"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
// INI parsing
|
||||
@@ -18,6 +30,9 @@ void virtual_joystick_remap(char *);
|
||||
// runtime mapping
|
||||
uint16_t virtual_joystick_mapping (uint16_t vid, uint16_t pid, uint16_t joy_input);
|
||||
|
||||
// name known joysticks
|
||||
char* get_joystick_alias( uint16_t vid, uint16_t pid );
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
// INI parsing
|
||||
|
||||
Reference in New Issue
Block a user