OSDN Git Service

d64edfaef4a6899846de88cc3c999c658c65eaad
[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, USING_FLAGS *using_flags) : 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(using_flags, 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
34         if(p_wid == NULL) this->setWindowIcon(QIcon(":/icon_gamepad.png"));
35         this->setLayout(layout);
36         this->show();
37 }
38
39 CSP_DropDownJoysticks::~CSP_DropDownJoysticks()
40 {
41 }
42
43 void CSP_DropDownJoysticks::do_set_js_button(int jsnum, int button_num, int assigned_value)
44 {
45         if((button_num < 0) || (button_num >= 16)) return;
46         if((jsnum < 0) || (jsnum >= 4)) return;
47         //printf("Select: %d %d %d\n", jsnum, button_num, assigned_value);
48         config.joy_buttons[jsnum][button_num] = assigned_value;
49 }
50
51 void CSP_DropDownJoysticks::do_set_js_button_idx(int jsnum, int button_num, int assigned_value)
52 {
53         if((button_num < 0) || (button_num >= 16)) return;
54         if((jsnum < 0) || (jsnum >= 4)) return;
55         //printf("Select_Idx: %d %d %d\n", jsnum, button_num, assigned_value);
56         config.joy_buttons[jsnum][button_num] = assigned_value;
57 }
58