OSDN Git Service

[UI][Qt] Add key codes setting dialog.
[csp-qt/common_source_project-fm7.git] / source / src / qt / gui / dropdown_joystick.cpp
1 /*
2  * Common Source Project/ Qt
3  * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
4  *  Qt: Menu->Emulator->Define Strings
5  *  History: Feb 23, 2016 : Initial
6  */
7
8 #include "osd.h"
9 #include "config.h"
10
11 #include "dropdown_keyset.h"
12 #include "dropdown_jsbutton.h"
13 #include "dropdown_jspage.h"
14 #include "dropdown_joystick.h"
15
16 CSP_DropDownJoysticks::CSP_DropDownJoysticks(QWidget *parent, QStringList *lst) : QWidget(parent)
17 {
18         p_wid = parent;
19
20         layout = new QHBoxLayout(this);
21         int i;
22
23         tabBox = new QTabWidget(this);
24         for(i = 0; i < 4; i++) {
25                 QString tmps;
26                 QString ns;
27                 pages[i] = new CSP_DropDownJSPage(this, lst, i);
28                 ns.setNum(i + 1);
29                 tmps = QString::fromUtf8("Joystick") + ns;
30                 tabBox->addTab(pages[i], tmps);
31         }
32         layout->addWidget(tabBox);
33         this->setLayout(layout);
34         this->show();
35 }
36
37 CSP_DropDownJoysticks::~CSP_DropDownJoysticks()
38 {
39 }
40
41 void CSP_DropDownJoysticks::do_set_js_button(int jsnum, int button_num, int assigned_value)
42 {
43         if((button_num < 0) || (button_num >= 16)) return;
44         if((jsnum < 0) || (jsnum >= 4)) return;
45         //printf("Select: %d %d %d\n", jsnum, button_num, assigned_value);
46         config.joy_buttons[jsnum][button_num] = assigned_value;
47 }
48
49 void CSP_DropDownJoysticks::do_set_js_button_idx(int jsnum, int button_num, int assigned_value)
50 {
51         if((button_num < 0) || (button_num >= 16)) return;
52         if((jsnum < 0) || (jsnum >= 4)) return;
53         //printf("Select_Idx: %d %d %d\n", jsnum, button_num, assigned_value);
54         config.joy_buttons[jsnum][button_num] = assigned_value;
55 }
56