onepad: move KeyName in the dialog and remove the now useless dialog.h

Note: use C++ construct to avoid C buffer.
This commit is contained in:
Gregory Hainaut 2017-05-03 16:40:35 +02:00
parent a71a549fa3
commit ecd7107ccb
6 changed files with 25 additions and 63 deletions

View File

@ -75,7 +75,6 @@ set(onepadLinuxSources
# onepad Linux headers # onepad Linux headers
set(onepadLinuxHeaders set(onepadLinuxHeaders
${linux_headers}/linux.h
${linux_headers}/opPanel.h ${linux_headers}/opPanel.h
${linux_headers}/GamepadConfiguration.h ${linux_headers}/GamepadConfiguration.h
${linux_headers}/JoystickConfiguration.h) ${linux_headers}/JoystickConfiguration.h)

View File

@ -19,6 +19,30 @@
#include "dialog.h" #include "dialog.h"
static std::string KeyName(int pad, int key, int keysym)
{
if (!keysym)
return "";
// Mouse
if (keysym < 10) {
switch (keysym) {
case 0:
return "";
case 1:
return "Mouse Left";
case 2:
return "Mouse Middle";
case 3:
return "Mouse Right";
default: // Use only number for extra button
return "Mouse " + std::to_string(keysym);
}
}
return std::string(XKeysymToString(keysym));
}
// Construtor of Dialog // Construtor of Dialog
Dialog::Dialog() Dialog::Dialog()
: wxDialog(NULL, // Parent : wxDialog(NULL, // Parent

View File

@ -24,42 +24,9 @@
#include "GamePad.h" #include "GamePad.h"
#include "keyboard.h" #include "keyboard.h"
#include "onepad.h" #include "onepad.h"
#include "linux.h"
extern std::string s_strIniPath; extern std::string s_strIniPath;
string KeyName(int pad, int key, int keysym)
{
string tmp;
tmp.resize(28);
if (keysym) {
if (keysym < 10) {
// mouse
switch (keysym) {
case 1:
sprintf(&tmp[0], "Mouse Left");
break;
case 2:
sprintf(&tmp[0], "Mouse Middle");
break;
case 3:
sprintf(&tmp[0], "Mouse Right");
break;
default: // Use only number for extra button
sprintf(&tmp[0], "Mouse %d", keysym);
}
} else {
// keyboard
char *pstr = XKeysymToString(keysym);
if (pstr != NULL)
tmp = pstr;
}
}
return tmp;
}
void DefaultKeyboardValues() void DefaultKeyboardValues()
{ {
set_keyboard_key(0, XK_a, PAD_L2); set_keyboard_key(0, XK_a, PAD_L2);

View File

@ -26,7 +26,7 @@
#include <string.h> #include <string.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "linux.h" #include "dialog.h"
Display *GSdsp; Display *GSdsp;
Window GSwin; Window GSwin;

View File

@ -1,26 +0,0 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __LINUX_H__
#define __LINUX_H__
extern void DisplayDialog();
extern string KeyName(int pad, int key, int keysym = 0);
#endif

View File

@ -26,8 +26,6 @@
#if defined(__unix__) #if defined(__unix__)
#include "Linux/linux.h"
extern Display *GSdsp; extern Display *GSdsp;
extern void PollForX11KeyboardInput(); extern void PollForX11KeyboardInput();
extern bool PollX11KeyboardMouseEvent(u32 &pkey); extern bool PollX11KeyboardMouseEvent(u32 &pkey);