Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved joystick handling for Game OSD #12366

Merged
merged 11 commits into from Jul 5, 2017
1 change: 1 addition & 0 deletions cmake/treedata/common/subdirs.txt
Expand Up @@ -16,6 +16,7 @@ xbmc/input input
xbmc/input/joysticks input/joysticks
xbmc/input/joysticks/dialogs input/joysticks/dialogs
xbmc/input/joysticks/generic input/joysticks/generic
xbmc/input/joysticks/keymaps input/joysticks/keymaps
xbmc/input/keyboard input/keyboard
xbmc/input/keyboard/generic input/keyboard/generic
xbmc/input/mouse input/mouse
Expand Down
158 changes: 110 additions & 48 deletions system/keymaps/joystick.xml
@@ -1,34 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains the mapping of keys to actions within Kodi. -->
<!-- -->
<!-- The format is: -->
<!-- <window> -->
<!-- <device> -->
<!-- <button>action</button> -->
<!-- </device> -->
<!-- </window> -->
<!-- -->
<!-- The <global> section is a fall through - they will only be used if the button is -->
<!-- not used in the current window's section. -->
<!-- -->
<!-- Actions can be built-in functions. -->
<!-- eg <B>ActivateWindow(Music)</B> -->
<!-- would automatically go to Music on the press of the B button. -->
<!-- -->
<!-- -->
<!-- An empty action removes the corresponding mapping from default and parent keymaps. -->
<!-- This is different from a "noop" action, which disables a button. -->
<!-- -->
<!-- More documentation on keymaps can be found on http://kodi.wiki/view/keymaps -->
<!-- This file contains the mapping of joystick buttons to actions within -->
<!-- Kodi. -->
<!-- -->
<!-- The format is: -->
<!-- <window> -->
<!-- <joystick profile="game.controller.default"> -->
<!-- <button>action</button> -->
<!-- </joystick> -->
<!-- </window> -->
<!-- -->
<!-- The <global> section is a fall through - they will only be used if the -->
<!-- button is not used in the current window's section. -->
<!-- -->
<!-- The "profile" attribute specifies the controller profile whose buttons -->
<!-- are being mapped. Currently, the default controller profile is used for -->
<!-- every controller. In the future it may be possible to specify mappings -->
<!-- for the controller profile most similar to the user's physical -->
<!-- controller. -->
<!-- -->
<!-- Actions can be built-in functions. -->
<!-- eg <b>ActivateWindow(Music)</b> -->
<!-- would automatically go to Music on the press of the B button. -->
<!-- -->
<!-- Buttons can be overloaded with hold durations, in miliseconds: -->
<!-- <joystick profile="game.controller.default"> -->
<!-- <a>Select</a> -->
<!-- <a holdtime="500">ContextMenu</a> -->
<!-- </joystick> -->
<!-- -->
<!-- Buttons can be also require hotkeys to be pressed: -->
<!-- <joystick profile="game.controller.default"> -->
<!-- <start hotkey="back">Stop</start> -->
<!-- </joystick> -->
<!-- -->
<!-- Due to limitations in the button mapper, buttons can be overloaded with -->
<!-- different hold durations, but not different hotkeys for the same -->
<!-- duration. -->
<!-- -->
<!-- More documentation on keymaps can be found on -->
<!-- http://kodi.wiki/view/keymaps -->
<!-- -->
<keymap>
<global>
<joystick profile="game.controller.default">
<a>Select</a>
<a holdtime="500">ContextMenu</a>
<b>Back</b>
<x>ContextMenu</x>
<y>FullScreen</y>
<start>ActivateWindow(PlayerControls)</start>
<back>PreviousMenu</back>
<guide>ActivateWindow(Home)</guide>
<up>Up</up>
<down>Down</down>
Expand All @@ -40,14 +60,14 @@
<righttrigger>ScrollDown</righttrigger>
<leftbumper>ScrollUp</leftbumper>
<rightbumper>ScrollDown</rightbumper>
<leftstickleft>Left</leftstickleft>
<leftstickright>Right</leftstickright>
<leftstickup>Up</leftstickup>
<leftstickdown>Down</leftstickdown>
<rightstickleft>VolumeDown</rightstickleft>
<rightstickright>VolumeUp</rightstickright>
<rightstickup>VolumeUp</rightstickup>
<rightstickdown>VolumeDown</rightstickdown>
<leftstick direction="left">Left</leftstick>
<leftstick direction="right">Right</leftstick>
<leftstick direction="up">Up</leftstick>
<leftstick direction="down">Down</leftstick>
<rightstick direction="left">VolumeDown</rightstick>
<rightstick direction="right">VolumeUp</rightstick>
<rightstick direction="up">VolumeUp</rightstick>
<rightstick direction="down">VolumeDown</rightstick>
</joystick>
</global>
<FileManager>
Expand All @@ -69,8 +89,8 @@
<x>OSD</x>
<y>FullScreen</y>
<start>Info</start>
<back>Seek(-7)</back>
<guide>ActivateWindow(Home)</guide>
<back>OSD</back>
<guide>OSD</guide>
<up>ChapterOrBigStepForward</up>
<down>ChapterOrBigStepBack</down>
<right>StepForward</right>
Expand All @@ -81,25 +101,63 @@
<righttrigger>AnalogFastForward</righttrigger>
<leftbumper>AnalogRewind</leftbumper>
<rightbumper>AnalogFastForward</rightbumper>
<leftstickleft>AnalogSeekBack</leftstickleft>
<leftstickright>AnalogSeekForward</leftstickright>
<leftstickup>AnalogSeekForward</leftstickup>
<leftstickdown>AnalogSeekBack</leftstickdown>
<rightstickleft>VolumeDown</rightstickleft>
<rightstickright>VolumeUp</rightstickright>
<rightstickup>VolumeUp</rightstickup>
<rightstickdown>VolumeDown</rightstickdown>
<leftstick direction="left">AnalogSeekBack</leftstick>
<leftstick direction="right">AnalogSeekForward</leftstick>
<leftstick direction="up">noop</leftstick>
<leftstick direction="down">noop</leftstick>
</joystick>
</FullscreenVideo>
<FullscreenGame>
<joystick profile="game.controller.default">
<start holdtime="1000">OSD</start>
<back holdtime="1000">OSD</back>
<guide holdtime="1000">OSD</guide>
<guide>OSD</guide>
<!-- Give games access to volume controls -->
<rightstick direction="left" hotkey="back">VolumeDown</rightstick>
<rightstick direction="right" hotkey="back">VolumeUp</rightstick>
<rightstick direction="up" hotkey="back">VolumeUp</rightstick>
<rightstick direction="down" hotkey="back">VolumeDown</rightstick>
<!-- RetroPie hotkeys, ref: https://github.com/RetroPie/RetroPie-Setup/wiki/RetroArch-Configuration -->
<!--
<b hotkey="back">Player.Reset</b>
<x hotkey="back">OSD</x>
<start hotkey="back">Stop</start>
<rightbumper hotkey="back">Save</rightbumper>
<leftbumper hotkey="back">Load</leftbumper>
<righttrigger hotkey="back">AnalogFastForward</righttrigger>
<lefttrigger hotkey="back">AnalogRewind</lefttrigger>
<right hotkey="back">SaveSlotIncrease</right>
<left hotkey="back">SaveSlotDecrease</left>
-->
<!-- Hotkeys courtesy Julipo -->
<!--
<a hotkey="back">Screenshot</a>
<x hotkey="back">FullScreen</x>
<y hotkey="back">OSD</y>
<start hotkey="back">OSD</start>
<rightbumper hotkey="back">Save</rightbumper>
<leftbumper hotkey="back">Load</leftbumper>
<leftstick direction="left" hotkey="back">SaveSlotDecrease</leftstick>
<leftstick direction="right" hotkey="back">SaveSlotIncrease</leftstick>
-->
<!-- Merged -->
<a hotkey="back">Screenshot</a>
<b hotkey="back">PlayerControl(Reset)</b>
<x hotkey="back">OSD</x>
<y hotkey="back">FullScreen</y>
<start hotkey="back">Stop</start>
<rightbumper hotkey="back">Save</rightbumper>
<leftbumper hotkey="back">Load</leftbumper>
<righttrigger hotkey="back">AnalogFastForward</righttrigger>
<lefttrigger hotkey="back">AnalogRewind</lefttrigger>
<right hotkey="back">SaveSlotIncrease</right>
<left hotkey="back">SaveSlotDecrease</left>
<leftstick direction="left" hotkey="back">SaveSlotDecrease</leftstick>
<leftstick direction="right" hotkey="back">SaveSlotIncrease</leftstick>
</joystick>
</FullscreenGame>
<FullscreenLiveTV>
<joystick profile="game.controller.default">
<guide>OSD</guide>
<up>ChannelUp</up>
<down>ChannelDown</down>
<left>StepBack</left>
Expand All @@ -108,6 +166,7 @@
</FullscreenLiveTV>
<FullscreenRadio>
<joystick profile="game.controller.default">
<guide>OSD</guide>
<up>ChannelUp</up>
<down>ChannelDown</down>
<left>StepBack</left>
Expand Down Expand Up @@ -148,8 +207,10 @@
<righttrigger>AnalogFastForward</righttrigger>
<leftbumper>AnalogRewind</leftbumper>
<rightbumper>AnalogFastForward</rightbumper>
<leftstickleft>PreviousPreset</leftstickleft>
<leftstickright>NextPreset</leftstickright>
<leftstick direction="left">PreviousPreset</leftstick>
<leftstick direction="right">NextPreset</leftstick>
<leftstick direction="up">noop</leftstick>
<leftstick direction="down">noop</leftstick>
</joystick>
</Visualisation>
<MusicOSD>
Expand All @@ -174,10 +235,10 @@
<down>ZoomOut</down>
<left>PreviousPicture</left>
<right>NextPicture</right>
<leftstickleft>AnalogMoveX</leftstickleft>
<leftstickright>AnalogMoveX</leftstickright>
<leftstickup>AnalogMoveY</leftstickup>
<leftstickdown>AnalogMoveY</leftstickdown>
<leftstick direction="left">AnalogMoveX</leftstick>
<leftstick direction="right">AnalogMoveX</leftstick>
<leftstick direction="up">AnalogMoveY</leftstick>
<leftstick direction="down">AnalogMoveY</leftstick>
<lefttrigger>ZoomOut</lefttrigger>
<righttrigger>ZoomIn</righttrigger>
</joystick>
Expand Down Expand Up @@ -235,6 +296,7 @@
</VideoPlaylist>
<VirtualKeyboard>
<joystick profile="game.controller.default">
<a>Shift</a>
<b>BackSpace</b>
<y>Symbols</y>
<leftbumper>Shift</leftbumper>
Expand Down
4 changes: 2 additions & 2 deletions xbmc/AppParamParser.cpp
Expand Up @@ -56,13 +56,13 @@ void CAppParamParser::Parse(const char* const* argv, int nArgs)
{
if ((argv[next][0] != '-') && (argv[next][0] == '/'))
{
CInputManager::GetInstance().SetRemoteControlName(argv[next]);
CServiceBroker::GetInputManager().SetRemoteControlName(argv[next]);
i++;
}
}
}
else if (strnicmp(argv[i], "-n", 2) == 0 || strnicmp(argv[i], "--nolirc", 8) == 0)
CInputManager::GetInstance().DisableRemoteControl();
CServiceBroker::GetInputManager().DisableRemoteControl();

if (stricmp(argv[i], "-d") == 0)
{
Expand Down
24 changes: 9 additions & 15 deletions xbmc/Application.cpp
Expand Up @@ -94,6 +94,7 @@
#include "utils/CPUInfo.h"
#include "utils/log.h"
#include "utils/SeekHandler.h"
#include "ServiceBroker.h"

#include "input/KeyboardLayoutManager.h"

Expand Down Expand Up @@ -350,7 +351,7 @@ bool CApplication::OnEvent(XBMC_Event& newEvent)
g_application.OnAction(CAction(ACTION_MOUSE_MOVE, 0, static_cast<float>(newEvent.focus.x), static_cast<float>(newEvent.focus.y), 0, 0));
break;
default:
return CInputManager::GetInstance().OnEvent(newEvent);
return CServiceBroker::GetInputManager().OnEvent(newEvent);
}
return true;
}
Expand Down Expand Up @@ -644,9 +645,6 @@ bool CApplication::Create()
m_replayGainSettings.iNoGainPreAmp = m_ServiceManager->GetSettings().GetInt(CSettings::SETTING_MUSICPLAYER_REPLAYGAINNOGAINPREAMP);
m_replayGainSettings.bAvoidClipping = m_ServiceManager->GetSettings().GetBool(CSettings::SETTING_MUSICPLAYER_REPLAYGAINAVOIDCLIPPING);

// Create the Mouse, Keyboard and Remote
CInputManager::GetInstance().InitializeInputs();

// load the keyboard layouts
if (!CKeyboardLayoutManager::GetInstance().Load())
{
Expand Down Expand Up @@ -736,7 +734,7 @@ bool CApplication::CreateGUI()

// The key mappings may already have been loaded by a peripheral
CLog::Log(LOGINFO, "load keymapping");
if (!CButtonTranslator::GetInstance().Load())
if (!CServiceBroker::GetInputManager().LoadKeymaps())
return false;

RESOLUTION_INFO info = g_graphicsContext.GetResInfo();
Expand Down Expand Up @@ -1923,7 +1921,7 @@ bool CApplication::OnAppCommand(const CAction &action)
uint32_t appcmd = action.GetID();
CKey key(appcmd | KEY_APPCOMMAND, (unsigned int) 0);
int iWin = g_windowManager.GetActiveWindow() & WINDOW_ID_MASK;
CAction appcmdaction = CButtonTranslator::GetInstance().GetAction(iWin, key);
CAction appcmdaction = CServiceBroker::GetInputManager().GetAction(iWin, key);

// If we couldn't find an action return false to indicate we have not
// handled this appcommand
Expand Down Expand Up @@ -1962,8 +1960,7 @@ bool CApplication::OnAction(const CAction &action)
}

if (action.IsMouse())
CInputManager::GetInstance().SetMouseActive(true);

CServiceBroker::GetInputManager().SetMouseActive(true);

if (action.GetID() == ACTION_CREATE_EPISODE_BOOKMARK)
{
Expand Down Expand Up @@ -2023,10 +2020,7 @@ bool CApplication::OnAction(const CAction &action)

// reload keymaps
if (action.GetID() == ACTION_RELOAD_KEYMAPS)
{
CButtonTranslator::GetInstance().Clear();
CButtonTranslator::GetInstance().Load();
}
CServiceBroker::GetInputManager().ReloadKeymaps();

// show info : Shows the current video or song information
if (action.GetID() == ACTION_SHOW_INFO)
Expand Down Expand Up @@ -2671,7 +2665,7 @@ void CApplication::FrameMove(bool processEvents, bool processGUI)
}
CWinEvents::MessagePump();

CInputManager::GetInstance().Process(g_windowManager.GetActiveWindowID(), frameTime);
CServiceBroker::GetInputManager().Process(g_windowManager.GetActiveWindowID(), frameTime);

if (processGUI && m_renderGUI)
{
Expand Down Expand Up @@ -2765,7 +2759,7 @@ bool CApplication::Cleanup()
g_LangCodeExpander.Clear();
g_charsetConverter.clear();
g_directoryCache.Clear();
CButtonTranslator::GetInstance().Clear();
//CServiceBroker::GetInputManager().ClearKeymaps(); //! @todo
#ifdef HAS_EVENT_SERVER
CEventServer::RemoveInstance();
#endif
Expand Down Expand Up @@ -2905,7 +2899,7 @@ void CApplication::Stop(int exitCode)
m_ServiceManager->DestroyAudioEngine();

CLog::Log(LOGNOTICE, "closing down remote control service");
CInputManager::GetInstance().DisableRemoteControl();
CServiceBroker::GetInputManager().DisableRemoteControl();

// unregister ffmpeg lock manager call back
av_lockmgr_register(NULL);
Expand Down
5 changes: 5 additions & 0 deletions xbmc/ServiceBroker.cpp
Expand Up @@ -105,6 +105,11 @@ ADDON::CServiceAddonManager& CServiceBroker::GetServiceAddons()
return g_application.m_ServiceManager->GetServiceAddons();
}

CInputManager& CServiceBroker::GetInputManager()
{
return g_application.m_ServiceManager->GetInputManager();
}

bool CServiceBroker::IsBinaryAddonCacheUp()
{
return g_application.m_ServiceManager->init_level > 1;
Expand Down
2 changes: 2 additions & 0 deletions xbmc/ServiceBroker.h
Expand Up @@ -53,6 +53,7 @@ class CDataCacheCore;
class CSettings;
class IAE;
class CFavouritesService;
class CInputManager;

namespace KODI
{
Expand Down Expand Up @@ -86,5 +87,6 @@ class CServiceBroker
static PERIPHERALS::CPeripherals& GetPeripherals();
static CFavouritesService& GetFavouritesService();
static ADDON::CServiceAddonManager& GetServiceAddons();
static CInputManager& GetInputManager();
static bool IsBinaryAddonCacheUp();
};