From f75ba32fa983b1f3e72b87c4547fbf394600d2b7 Mon Sep 17 00:00:00 2001 From: "Christoph \"baka0815\" Schwerdtfeger" Date: Mon, 13 Aug 2018 13:00:24 +0200 Subject: [PATCH] evdev/maple: Set devices via config --- core/hw/maple/maple_cfg.cpp | 22 ++++++++++++------- core/hw/maple/maple_cfg.h | 7 +++++-- core/linux-dist/main.cpp | 42 ++++++++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp index a705fd639..cf6adde3c 100644 --- a/core/hw/maple/maple_cfg.cpp +++ b/core/hw/maple/maple_cfg.cpp @@ -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 diff --git a/core/hw/maple/maple_cfg.h b/core/hw/maple/maple_cfg.h index 6b7d9efb6..86ac18528 100644 --- a/core/hw/maple/maple_cfg.h +++ b/core/hw/maple/maple_cfg.h @@ -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(); \ No newline at end of file +void mcfg_DestroyDevices(); diff --git a/core/linux-dist/main.cpp b/core/linux-dist/main.cpp index c75f0da85..b6b465523 100755 --- a/core/linux-dist/main.cpp +++ b/core/linux-dist/main.cpp @@ -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))