📄 joystickconfig.cc
字号:
//// Copyright (c) 2004 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// This program 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 2 of the License, or// (at your option) any later version.//// This program 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 this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//------------------------------------------------------------------------------#include "JoystickConfig.h"//------------------------------------------------------------------------------const char* JoystickConfig::jsPrefix = "js.";//------------------------------------------------------------------------------void JoystickConfig::setCommand(commands_t& commands, size_t index, const char* command){ while(commands.size()<=index) { commands.push_back(0); } delete commands[index]; commands[index] = strdup(command);}//------------------------------------------------------------------------------void JoystickConfig::setCommand(commands_t& commands, const char* key, const char* command){ int index = atoi(key); if (index>=0 && index<256) { setCommand(commands, index, command); }}//------------------------------------------------------------------------------const char* JoystickConfig::getCommand(const commands_t& commands, size_t index){ if (index<commands.size()) return commands[index]; else return 0;}//------------------------------------------------------------------------------JoystickConfig::~JoystickConfig(){ for(commands_t::iterator i = buttonCommands.begin(); i!=buttonCommands.end(); ++i) { delete *i; } for(commands_t::iterator i = leftCommands.begin(); i!=leftCommands.end(); ++i) { delete *i; } for(commands_t::iterator i = rightCommands.begin(); i!=rightCommands.end(); ++i) { delete *i; }}//------------------------------------------------------------------------------void JoystickConfig::process(const char* key, const char* value){ static const char* buttonPrefix = "js.button"; static const size_t buttonPrefixLength = strlen(buttonPrefix); static const char* leftPrefix1 = "js.left"; static const size_t leftPrefix1Length = strlen(leftPrefix1); static const char* leftPrefix2 = "js.down"; static const size_t leftPrefix2Length = strlen(leftPrefix2); static const char* rightPrefix1 = "js.right"; static const size_t rightPrefix1Length = strlen(rightPrefix1); static const char* rightPrefix2 = "js.up"; static const size_t rightPrefix2Length = strlen(rightPrefix2); if (strncmp(key, buttonPrefix, buttonPrefixLength)==0) { setCommand(buttonCommands, key+buttonPrefixLength, value); } else if (strncmp(key, leftPrefix1, leftPrefix1Length)==0) { setCommand(leftCommands, key+leftPrefix1Length, value); } else if (strncmp(key, leftPrefix2, leftPrefix2Length)==0) { setCommand(leftCommands, key+leftPrefix2Length, value); } else if (strncmp(key, rightPrefix1, rightPrefix1Length)==0) { setCommand(rightCommands, key+rightPrefix1Length, value); } else if (strncmp(key, rightPrefix2, rightPrefix2Length)==0) { setCommand(rightCommands, key+rightPrefix2Length, value); }}//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -