evdev/maple: Set devices via config

This commit is contained in:
Christoph "baka0815" Schwerdtfeger 2018-08-13 13:00:24 +02:00 committed by Ender's Games
parent 17d9159b82
commit f75ba32fa9
3 changed files with 60 additions and 11 deletions

View File

@ -14,7 +14,7 @@ Plugins:
KeyMap -- translated chars ( no re-mapping possible)
Output
Image
*/
/*
MapleConfig:
@ -64,19 +64,20 @@ struct MapleConfigMap : IMapleConfigMap
}
};
void mcfg_Create(MapleDeviceType type,u32 bus,u32 port)
void mcfg_Create(MapleDeviceType type, u32 bus, u32 port)
{
maple_device* dev=maple_Create(type);
dev->Setup(maple_GetAddress(bus,port));
maple_device* dev = maple_Create(type);
dev->Setup(maple_GetAddress(bus, port));
dev->config = new MapleConfigMap(dev);
dev->OnSetup();
MapleDevices[bus][port]=dev;
MapleDevices[bus][port] = dev;
}
void mcfg_CreateDevices()
{
int numberOfControl = cfgLoadInt("players", "nb", 1);
#if DC_PLATFORM == DC_PLATFORM_DREAMCAST
int numberOfControl = cfgLoadInt("players", "nb", 1);
if (numberOfControl <= 0)
numberOfControl = 1;
if (numberOfControl > 4)
@ -84,10 +85,15 @@ int numberOfControl = cfgLoadInt("players", "nb", 1);
for (int i = 0; i < numberOfControl; i++){
mcfg_Create(MDT_SegaController, i, 5);
// mcfg_Create(MDT_PurupuruPack, i, 1);
}
mcfg_Create(MDT_SegaVMU,0,0);
mcfg_Create(MDT_SegaVMU,0,1);
// if using evdev they will be created later on
#if !defined(USE_EVDEV)
mcfg_Create(MDT_SegaVMU, 0, 0);
mcfg_Create(MDT_SegaVMU, 0, 1);
#endif
#else
mcfg_Create(MDT_NaomiJamma, 0, 5);
#endif

View File

@ -1,5 +1,6 @@
#pragma once
#include "types.h"
#include "maple_devs.h"
enum PlainJoystickButtonId
{
@ -42,7 +43,7 @@ struct PlainJoystickState
joy[0]=joy[1]=joy[2]=joy[3]=0x80;
trigger[0]=trigger[1]=0;
}
static const u32 ButtonMask = PJBI_B | PJBI_A | PJBI_START | PJBI_DPAD_UP |
static const u32 ButtonMask = PJBI_B | PJBI_A | PJBI_START | PJBI_DPAD_UP |
PJBI_DPAD_DOWN | PJBI_DPAD_LEFT | PJBI_DPAD_RIGHT | PJBI_Y | PJBI_X;
static const u32 AxisMask = PJAI_X1 | PJAI_Y1;
@ -63,9 +64,11 @@ struct IMapleConfigMap
virtual ~IMapleConfigMap() {}
};
void mcfg_Create(MapleDeviceType type, u32 bus, u32 port);
#ifndef _ANDROID
void mcfg_CreateDevices();
#else
void mcfg_CreateDevices();
#endif
void mcfg_DestroyDevices();
void mcfg_DestroyDevices();

View File

@ -37,6 +37,8 @@
#if defined(USE_EVDEV)
#include "linux-dist/evdev.h"
#include "hw/maple/maple_cfg.h"
#include "hw/maple/maple_devs.h"
#endif
#if defined(USE_JOYSTICK)
@ -154,6 +156,44 @@ void SetupInput()
}
}
}
switch (evdev_controllers[port].mapping->Maple_Device1)
{
case 1:
printf("Maple Device 1: VMU\n");
mcfg_Create(MDT_SegaVMU, port, 0);
break;
case 2:
printf("Maple Device 1: Microphone\n");
mcfg_Create(MDT_Microphone, port, 0);
break;
case 3:
printf("Maple Device 1: PuruPuruPack\n");
mcfg_Create(MDT_PurupuruPack, port, 0);
break;
default:
printf("Unsupported configuration for Maple Device 1 (using VMU): %d\n", evdev_controllers[port].mapping->Maple_Device1);
mcfg_Create(MDT_SegaVMU, port, 0);
}
switch (evdev_controllers[port].mapping->Maple_Device2)
{
case 1:
printf("Maple Device 2: VMU\n");
mcfg_Create(MDT_SegaVMU, port, 1);
break;
case 2:
printf("Maple Device 2: Microphone\n");
mcfg_Create(MDT_Microphone, port, 1);
break;
case 3:
printf("Maple Device 2: PuruPuruPack\n");
mcfg_Create(MDT_PurupuruPack, port, 1);
break;
default:
printf("Unsupported configuration for Maple Device 2 (using VMU): %d\n", evdev_controllers[port].mapping->Maple_Device2);
mcfg_Create(MDT_SegaVMU, port, 1);
}
}
}
#endif
@ -364,7 +404,7 @@ string find_user_data_dir()
// If XDG_DATA_HOME is set explicitly, we'll use that instead of $HOME/.config
data = (string)getenv("XDG_DATA_HOME") + "/reicast";
}
if(!data.empty())
{
if((stat(data.c_str(), &info) != 0) || !(info.st_mode & S_IFDIR))