/* Copyright 2016-2020 Arisotura This file is part of melonDS. melonDS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. melonDS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with melonDS. If not, see http://www.gnu.org/licenses/. */ #include #include #include "Input.h" #include "PlatformConfig.h" namespace Input { int JoystickID; SDL_Joystick* Joystick = nullptr; u32 KeyInputMask, JoyInputMask; u32 KeyHotkeyMask, JoyHotkeyMask; u32 HotkeyMask, LastHotkeyMask; u32 HotkeyPress, HotkeyRelease; void OpenJoystick() { if (Joystick) SDL_JoystickClose(Joystick); int num = SDL_NumJoysticks(); if (num < 1) { Joystick = nullptr; return; } if (JoystickID >= num) JoystickID = 0; Joystick = SDL_JoystickOpen(JoystickID); } void CloseJoystick() { if (Joystick) { SDL_JoystickClose(Joystick); Joystick = nullptr; } } void Process() { SDL_JoystickUpdate(); if (Joystick) { if (!SDL_JoystickGetAttached(Joystick)) { SDL_JoystickClose(Joystick); Joystick = NULL; } } if (!Joystick && (SDL_NumJoysticks() > 0)) { JoystickID = Config::JoystickID; OpenJoystick(); } /*JoyInputMask = 0xFFF; for (int i = 0; i < 12; i++) if (JoystickButtonDown(Config::JoyMapping[i])) JoyInputMask &= ~(1<nativeScanCode(); return (scan == 0x11D || scan == 0x138 || scan == 0x36); } #else bool IsRightModKey(QKeyEvent* event) { quint32 scan = event->nativeScanCode(); return (scan == 0x69 || scan == 0x6C || scan == 0x3E); } #endif }