Skip to content

Commit

Permalink
Misc tweaks and fixes
Browse files Browse the repository at this point in the history
* Imagine: Make Input::Device into an std::variant and remove virtual functions
* Imagine: Use float for MotionEvent coordinates
* Imagine: Add support for passing joystick axis events in MotionEvent
* Imagine: Move input configuration variables into config/defs.hh and simplify inputDefs.hh
* Imagine: Map analog trigger axes to L2/R2 by default
* Imagine: Update joystick axis mappings to match between Linux evdev and Android APIs
* EmuFramework: Use mode key to open system actions in default generic gamepad profiles and also to dismiss menu
* EmuFramework: Always write out key config name length when saving InputDeviceConfig, fixes issue where device config gets corrupted when reading back 0 length name
* C64.emu: Catch and display errors from setSystemFilesPath()
* C64.emu: Handle URIs in archiveHasDirectory()
* NES.emu: Update core to FCEUX GIT e806a5a (2023.12.09)
  • Loading branch information
Robert Broglia committed Dec 13, 2023
1 parent 285d4ee commit f8a5e36
Show file tree
Hide file tree
Showing 81 changed files with 1,745 additions and 1,516 deletions.
18 changes: 9 additions & 9 deletions 2600.emu/src/main/input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ std::span<const KeyConfigDesc> A2600App::defaultKeyConfigs()

static constexpr std::array wiimoteMap
{
KeyMapping{::Event::LeftJoystickUp, Wiimote::UP},
KeyMapping{::Event::LeftJoystickRight, Wiimote::RIGHT},
KeyMapping{::Event::LeftJoystickDown, Wiimote::DOWN},
KeyMapping{::Event::LeftJoystickLeft, Wiimote::LEFT},
KeyMapping{::Event::LeftJoystickFire, Wiimote::_1},
KeyMapping{::Event::LeftJoystickFire5, Wiimote::_2},
KeyMapping{::Event::ConsoleSelect, Wiimote::MINUS},
KeyMapping{::Event::ConsoleReset, Wiimote::PLUS},
KeyMapping{::Event::ConsoleLeftDiffToggle, Wiimote::A},
KeyMapping{::Event::LeftJoystickUp, WiimoteKey::UP},
KeyMapping{::Event::LeftJoystickRight, WiimoteKey::RIGHT},
KeyMapping{::Event::LeftJoystickDown, WiimoteKey::DOWN},
KeyMapping{::Event::LeftJoystickLeft, WiimoteKey::LEFT},
KeyMapping{::Event::LeftJoystickFire, WiimoteKey::_1},
KeyMapping{::Event::LeftJoystickFire5, WiimoteKey::_2},
KeyMapping{::Event::ConsoleSelect, WiimoteKey::MINUS},
KeyMapping{::Event::ConsoleReset, WiimoteKey::PLUS},
KeyMapping{::Event::ConsoleLeftDiffToggle, WiimoteKey::A},
};

return genericKeyConfigs<pcKeyboardMap, genericGamepadMap, wiimoteMap>();
Expand Down
8 changes: 6 additions & 2 deletions C64.emu/src/main/EmuMenuViews.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,13 @@ class CustomFilePathOptionView : public FilePathOptionView, public MainAppHelper
}
else
{
if(!system().setSystemFilesPath(appContext(), path, type))
try
{
app().postErrorMessage("Path is missing DRIVES folder");
system().setSystemFilesPath(appContext(), path, type);
}
catch(std::exception &err)
{
app().postErrorMessage(err.what());
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion C64.emu/src/main/MainSystem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public:
void setRuntimeReuSize(int size);
void resetCanvasSourcePixmap(struct video_canvas_s *c);
FS::ArchiveIterator &systemFilesArchiveIterator(ApplicationContext, std::string_view path) const;
bool setSystemFilesPath(ApplicationContext, CStringView path, FS::file_type);
void setSystemFilesPath(ApplicationContext, CStringView path, FS::file_type);
void execC64Frame();

// required API functions
Expand Down
12 changes: 6 additions & 6 deletions C64.emu/src/main/input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,12 @@ std::span<const KeyConfigDesc> C64App::defaultKeyConfigs()

static constexpr std::array wiimoteMap
{
KeyMapping{C64Key::Up, Wiimote::UP},
KeyMapping{C64Key::Right, Wiimote::RIGHT},
KeyMapping{C64Key::Down, Wiimote::DOWN},
KeyMapping{C64Key::Left, Wiimote::LEFT},
KeyMapping{C64Key::JSTrigger, Wiimote::_1},
KeyMapping{C64Key::KeyboardF1, Wiimote::PLUS},
KeyMapping{C64Key::Up, WiimoteKey::UP},
KeyMapping{C64Key::Right, WiimoteKey::RIGHT},
KeyMapping{C64Key::Down, WiimoteKey::DOWN},
KeyMapping{C64Key::Left, WiimoteKey::LEFT},
KeyMapping{C64Key::JSTrigger, WiimoteKey::_1},
KeyMapping{C64Key::KeyboardF1, WiimoteKey::PLUS},
};

return genericKeyConfigs<pcKeyboardMap, genericGamepadMap, wiimoteMap>();
Expand Down
11 changes: 5 additions & 6 deletions C64.emu/src/main/sysfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ FS::ArchiveIterator &C64System::systemFilesArchiveIterator(ApplicationContext ct
return viceSysFilesArchiveIt;
}

static bool archiveHasDirectory(CStringView path, std::string_view dirName)
static bool archiveHasDirectory(ApplicationContext ctx, CStringView path, std::string_view dirName)
{
for(auto &entry : FS::ArchiveIterator{path})
for(auto &entry : FS::ArchiveIterator{ctx.openFileUri(path)})
{
if(entry.type() == FS::file_type::directory &&
entry.name().ends_with(dirName))
Expand All @@ -150,17 +150,16 @@ static bool archiveHasDirectory(CStringView path, std::string_view dirName)
return false;
}

bool C64System::setSystemFilesPath(ApplicationContext ctx, CStringView path, FS::file_type type)
void C64System::setSystemFilesPath(ApplicationContext ctx, CStringView path, FS::file_type type)
{
log.info("set firmware path:{}", path);
if((type == FS::file_type::directory && !ctx.fileUriExists(FS::uriString(path, "DRIVES")))
|| (EmuApp::hasArchiveExtension(path) && !archiveHasDirectory(path, "DRIVES/")))
|| (EmuApp::hasArchiveExtension(path) && !archiveHasDirectory(ctx, path, "DRIVES/")))
{
return false;
throw std::runtime_error{"Path is missing DRIVES folder"};
}
sysFilePath[0] = path;
viceSysFilesArchiveIt = {};
return true;
}

std::vector<std::string> C64System::systemFilesWithExtension(const char *ext) const
Expand Down
10 changes: 5 additions & 5 deletions EmuFramework/include/emuframework/AppKeyCode.hh
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ constexpr KeyCategory appKeyCategory{"In-Emulation Actions", appKeys};

constexpr std::array genericGamepadAppKeyCodeMap
{
KeyMapping{appKeys.openSystemActions, Input::Keycode::MENU},
KeyMapping{appKeys.fastForward, Input::Keycode::JS_RTRIGGER_AXIS},
KeyMapping{appKeys.openSystemActions, Input::Keycode::GAME_MODE},
KeyMapping{appKeys.fastForward, Input::Keycode::GAME_R2},
KeyMapping{appKeys.openMenu, Input::Keycode::BACK},
};

constexpr std::array genericGamepadModifierAppKeyCodeMap
{
KeyMapping{appKeys.openSystemActions, Input::Keycode::MENU},
KeyMapping{appKeys.fastForward, {Input::Keycode::JS_RTRIGGER_AXIS, Input::Keycode::JS2_XAXIS_POS}},
KeyMapping{appKeys.openSystemActions, Input::Keycode::GAME_MODE},
KeyMapping{appKeys.fastForward, {Input::Keycode::GAME_R2, Input::Keycode::JS2_XAXIS_POS}},
KeyMapping{appKeys.openMenu, Input::Keycode::BACK},
};

constexpr std::array genericWiimoteAppKeyCodeMap
{
KeyMapping{appKeys.openSystemActions, Input::Wiimote::HOME},
KeyMapping{appKeys.openSystemActions, Input::WiimoteKey::HOME},
};

constexpr std::array genericKeyboardAppKeyCodeMap
Expand Down
1 change: 0 additions & 1 deletion EmuFramework/include/emuframework/ButtonConfigView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <imagine/gfx/Quads.hh>
#include <imagine/gui/TableView.hh>
#include <imagine/gui/MenuItem.hh>
#include <imagine/input/config.hh>
#include <string>
#include <string_view>

Expand Down
1 change: 0 additions & 1 deletion EmuFramework/include/emuframework/InputManagerView.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <imagine/gui/MenuItem.hh>
#include <imagine/gfx/GfxText.hh>
#include <imagine/gfx/Quads.hh>
#include <imagine/input/config.hh>
#include <imagine/util/container/ArrayList.hh>
#include <vector>
#include <array>
Expand Down
1 change: 0 additions & 1 deletion EmuFramework/include/emuframework/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
along with EmuFramework. If not, see <http://www.gnu.org/licenses/> */

#include <imagine/config/defs.hh>
#include <imagine/input/config.hh>
#include <imagine/bluetooth/config.hh>

#ifdef ENV_NOTE
Expand Down
102 changes: 51 additions & 51 deletions EmuFramework/include/emuframework/keyRemappingUtils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ constexpr Input::Key wiimoteKeycodeToZeemote(Input::Key k)
using namespace Input;
switch(k)
{
case Wiimote::UP: return Zeemote::UP;
case Wiimote::RIGHT: return Zeemote::RIGHT;
case Wiimote::DOWN: return Zeemote::DOWN;
case Wiimote::LEFT: return Zeemote::LEFT;
case Wiimote::_1: return Zeemote::A;
case Wiimote::_2: return Zeemote::B;
case Wiimote::A: return Zeemote::C;
case Wiimote::B: return Zeemote::POWER;
case WiimoteKey::UP: return ZeemoteKey::UP;
case WiimoteKey::RIGHT: return ZeemoteKey::RIGHT;
case WiimoteKey::DOWN: return ZeemoteKey::DOWN;
case WiimoteKey::LEFT: return ZeemoteKey::LEFT;
case WiimoteKey::_1: return ZeemoteKey::A;
case WiimoteKey::_2: return ZeemoteKey::B;
case WiimoteKey::A: return ZeemoteKey::C;
case WiimoteKey::B: return ZeemoteKey::POWER;
default: return 0;
}
}
Expand All @@ -132,21 +132,21 @@ constexpr Input::Key genericGamepadKeycodeToWiiCC(Input::Key k)
using namespace Input;
switch(k)
{
case Keycode::UP: return WiiCC::UP;
case Keycode::RIGHT: return WiiCC::RIGHT;
case Keycode::DOWN: return WiiCC::DOWN;
case Keycode::LEFT: return WiiCC::LEFT;
case Keycode::GAME_A: return WiiCC::B;
case Keycode::GAME_B: return WiiCC::A;
case Keycode::GAME_X: return WiiCC::Y;
case Keycode::GAME_Y: return WiiCC::X;
case Keycode::GAME_SELECT: return WiiCC::MINUS;
case Keycode::GAME_START: return WiiCC::PLUS;
case Keycode::GAME_L1: return WiiCC::L;
case Keycode::GAME_L2: return WiiCC::ZL;
case Keycode::GAME_R1: return WiiCC::R;
case Keycode::GAME_R2: return WiiCC::ZR;
case Keycode::MENU: return WiiCC::HOME;
case Keycode::UP: return WiiCCKey::UP;
case Keycode::RIGHT: return WiiCCKey::RIGHT;
case Keycode::DOWN: return WiiCCKey::DOWN;
case Keycode::LEFT: return WiiCCKey::LEFT;
case Keycode::GAME_A: return WiiCCKey::B;
case Keycode::GAME_B: return WiiCCKey::A;
case Keycode::GAME_X: return WiiCCKey::Y;
case Keycode::GAME_Y: return WiiCCKey::X;
case Keycode::GAME_SELECT: return WiiCCKey::MINUS;
case Keycode::GAME_START: return WiiCCKey::PLUS;
case Keycode::GAME_L1: return WiiCCKey::L;
case Keycode::GAME_L2: return WiiCCKey::ZL;
case Keycode::GAME_R1: return WiiCCKey::R;
case Keycode::GAME_R2: return WiiCCKey::ZR;
case Keycode::MENU: return WiiCCKey::HOME;
default: return 0;
}
}
Expand All @@ -156,18 +156,18 @@ constexpr Input::Key genericGamepadKeycodeToICP(Input::Key k)
using namespace Input;
switch(k)
{
case Keycode::UP: return iControlPad::UP;
case Keycode::RIGHT: return iControlPad::RIGHT;
case Keycode::DOWN: return iControlPad::DOWN;
case Keycode::LEFT: return iControlPad::LEFT;
case Keycode::GAME_A: return iControlPad::X;
case Keycode::GAME_B: return iControlPad::B;
case Keycode::GAME_X: return iControlPad::A;
case Keycode::GAME_Y: return iControlPad::Y;
case Keycode::GAME_SELECT: return iControlPad::SELECT;
case Keycode::GAME_START: return iControlPad::START;
case Keycode::GAME_L1: return iControlPad::L;
case Keycode::GAME_R1: return iControlPad::R;
case Keycode::UP: return iControlPadKey::UP;
case Keycode::RIGHT: return iControlPadKey::RIGHT;
case Keycode::DOWN: return iControlPadKey::DOWN;
case Keycode::LEFT: return iControlPadKey::LEFT;
case Keycode::GAME_A: return iControlPadKey::X;
case Keycode::GAME_B: return iControlPadKey::B;
case Keycode::GAME_X: return iControlPadKey::A;
case Keycode::GAME_Y: return iControlPadKey::Y;
case Keycode::GAME_SELECT: return iControlPadKey::SELECT;
case Keycode::GAME_START: return iControlPadKey::START;
case Keycode::GAME_L1: return iControlPadKey::L;
case Keycode::GAME_R1: return iControlPadKey::R;
default: return 0;
}
}
Expand All @@ -177,21 +177,21 @@ constexpr Input::Key genericGamepadKeycodeToPS3(Input::Key k)
using namespace Input;
switch(k)
{
case Keycode::UP: return PS3::UP;
case Keycode::RIGHT: return PS3::RIGHT;
case Keycode::DOWN: return PS3::DOWN;
case Keycode::LEFT: return PS3::LEFT;
case Keycode::GAME_A: return PS3::CROSS;
case Keycode::GAME_B: return PS3::CIRCLE;
case Keycode::GAME_X: return PS3::SQUARE;
case Keycode::GAME_Y: return PS3::TRIANGLE;
case Keycode::GAME_SELECT: return PS3::SELECT;
case Keycode::GAME_START: return PS3::START;
case Keycode::GAME_L1: return PS3::L1;
case Keycode::GAME_L2: return PS3::L2;
case Keycode::GAME_R1: return PS3::R1;
case Keycode::GAME_R2: return PS3::R2;
case Keycode::MENU: return PS3::PS;
case Keycode::UP: return PS3Key::UP;
case Keycode::RIGHT: return PS3Key::RIGHT;
case Keycode::DOWN: return PS3Key::DOWN;
case Keycode::LEFT: return PS3Key::LEFT;
case Keycode::GAME_A: return PS3Key::CROSS;
case Keycode::GAME_B: return PS3Key::CIRCLE;
case Keycode::GAME_X: return PS3Key::SQUARE;
case Keycode::GAME_Y: return PS3Key::TRIANGLE;
case Keycode::GAME_SELECT: return PS3Key::SELECT;
case Keycode::GAME_START: return PS3Key::START;
case Keycode::GAME_L1: return PS3Key::L1;
case Keycode::GAME_L2: return PS3Key::L2;
case Keycode::GAME_R1: return PS3Key::R1;
case Keycode::GAME_R2: return PS3Key::R2;
case Keycode::MENU: return PS3Key::PS;
default: return 0;
}
}
Expand Down Expand Up @@ -230,8 +230,8 @@ constexpr std::span<const KeyConfigDesc> genericKeyConfigs()

static constexpr auto pcKeyboardMap = concatToArrayNow<genericKeyboardAppKeyCodeMap, pcKeyboardBaseMap>;

#ifdef CONFIG_INPUT_GAMEPAD_DEVICES
static constexpr auto genericGamepadMap = concatToArrayNow<genericGamepadAppKeyCodeMap, genericGamepadBaseMap>;
#ifdef CONFIG_INPUT_GAMEPAD_DEVICES
static constexpr auto ps3GamepadMap = transformMappedKeys(genericGamepadMap, genericGamepadKeycodeToPS3HID);
static constexpr auto ouyaGamepadMap = transformMappedKeys(genericGamepadMap, genericGamepadKeycodeToOuya);
#endif
Expand Down
1 change: 0 additions & 1 deletion EmuFramework/src/ConfigFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <imagine/base/ApplicationContext.hh>
#include <imagine/io/FileIO.hh>
#include <imagine/fs/FS.hh>
#include <imagine/input/config.hh>
#include <imagine/bluetooth/sys.hh>
#include <imagine/util/ScopeGuard.hh>

Expand Down

0 comments on commit f8a5e36

Please sign in to comment.