{"action":"created","comment":{"url":"https://api.github.com/repos/citra-emu/citra/pulls/comments/72681794","id":72681794,"diff_hunk":"@@ -0,0 +1,160 @@\n+﻿// Copyright 2016 Citra Emulator Project\n+// Licensed under GPLv2 or any later version\n+// Refer to the license.txt file included.\n+\n+#include <utility>\n+#include <QTimer>\n+\n+#include \"citra_qt/configure_input.h\"\n+\n+ConfigureInput::ConfigureInput(QWidget* parent) :\n+    QWidget(parent),\n+    ui(new Ui::ConfigureInput) {\n+    ui->setupUi(this);\n+\n+    // Initialize mapping of input enum to UI button.\n+    input_mapping = {\n+        { std::make_pair(Settings::NativeInput::Values::A, ui->btnFaceA) },\n+        { std::make_pair(Settings::NativeInput::Values::B, ui->btnFaceB) },\n+        { std::make_pair(Settings::NativeInput::Values::X, ui->btnFaceX) },\n+        { std::make_pair(Settings::NativeInput::Values::Y, ui->btnFaceY) },\n+        { std::make_pair(Settings::NativeInput::Values::L, ui->btnShdrL) },\n+        { std::make_pair(Settings::NativeInput::Values::R, ui->btnShdrR) },\n+        { std::make_pair(Settings::NativeInput::Values::ZL, ui->btnShdrZL) },\n+        { std::make_pair(Settings::NativeInput::Values::ZR, ui->btnShdrZR) },\n+        { std::make_pair(Settings::NativeInput::Values::START, ui->btnStart) },\n+        { std::make_pair(Settings::NativeInput::Values::SELECT, ui->btnSelect) },\n+        { std::make_pair(Settings::NativeInput::Values::HOME, ui->btnHome) },\n+        { std::make_pair(Settings::NativeInput::Values::DUP, ui->btnDirUp) },\n+        { std::make_pair(Settings::NativeInput::Values::DDOWN, ui->btnDirDown) },\n+        { std::make_pair(Settings::NativeInput::Values::DLEFT, ui->btnDirLeft) },\n+        { std::make_pair(Settings::NativeInput::Values::DRIGHT, ui->btnDirRight) },\n+        { std::make_pair(Settings::NativeInput::Values::CUP, ui->btnStickUp) },\n+        { std::make_pair(Settings::NativeInput::Values::CDOWN, ui->btnStickDown) },\n+        { std::make_pair(Settings::NativeInput::Values::CLEFT, ui->btnStickLeft) },\n+        { std::make_pair(Settings::NativeInput::Values::CRIGHT, ui->btnStickRight) },\n+        { std::make_pair(Settings::NativeInput::Values::CIRCLE_UP, ui->btnCircleUp) },\n+        { std::make_pair(Settings::NativeInput::Values::CIRCLE_DOWN, ui->btnCircleDown) },\n+        { std::make_pair(Settings::NativeInput::Values::CIRCLE_LEFT, ui->btnCircleLeft) },\n+        { std::make_pair(Settings::NativeInput::Values::CIRCLE_RIGHT, ui->btnCircleRight) },\n+        { std::make_pair(Settings::NativeInput::Values::CIRCLE_MODIFIER, ui->btnCircleMod) },\n+    };\n+\n+    // Attach handle click method to each button click.\n+    for (const auto& entry : input_mapping) {\n+        connect(entry.second, SIGNAL(released()), this, SLOT(handleClick()));\n+    }\n+    connect(ui->btnRestoreDefaults, SIGNAL(released()), this, SLOT(restoreDefaults()));\n+    setFocusPolicy(Qt::ClickFocus);\n+    timer = new QTimer(this);\n+    timer->setSingleShot(true);\n+    connect(timer, &QTimer::timeout, this, [&]() { key_pressed = Qt::Key_Escape; setKey(); });\n+    this->setConfiguration();\n+}\n+\n+ConfigureInput::~ConfigureInput() {\n+}\n+\n+/// Event handler for all button released() event.\n+void ConfigureInput::handleClick() {\n+    QPushButton* sender = qobject_cast<QPushButton*>(QObject::sender());\n+    previous_mapping = sender->text();\n+    sender->setText(tr(\"[waiting]\"));\n+    sender->setFocus();\n+    grabKeyboard();\n+    grabMouse();\n+    changing_button = sender;\n+    timer->start(5000); //Cancel after 5 seconds\n+}\n+\n+/// Save all button configurations to settings file\n+void ConfigureInput::applyConfiguration() {\n+    for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {\n+        int value = getKeyValue(input_mapping[Settings::NativeInput::Values(i)]->text());\n+        Settings::values.input_mappings[Settings::NativeInput::All[i]] = value;\n+    }\n+    Settings::Apply();\n+}\n+\n+/// Load configuration settings into button text\n+void ConfigureInput::setConfiguration() {\n+    for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {\n+        QString keyValue = getKeyName(Settings::values.input_mappings[i]);\n+        input_mapping[Settings::NativeInput::Values(i)]->setText(keyValue);\n+    }\n+}\n+\n+/// Handle key press event for input tab when a button is 'waiting'.\n+void ConfigureInput::keyPressEvent(QKeyEvent* event) {\n+    if (changing_button != nullptr && event->key() != Qt::Key_unknown) {\n+        key_pressed = event->key();\n+        timer->stop();\n+        setKey();\n+    }\n+}\n+\n+/// Set button text to name of key pressed.\n+void ConfigureInput::setKey() {\n+    QString key_value = getKeyName(key_pressed);\n+    if (key_pressed == Qt::Key_Escape)\n+        changing_button->setText(previous_mapping);\n+    else\n+        changing_button->setText(key_value);\n+    removeDuplicates(key_value);\n+    key_pressed = Qt::Key_unknown;\n+    releaseKeyboard();\n+    releaseMouse();\n+    changing_button = nullptr;\n+    previous_mapping = nullptr;\n+}\n+\n+/// Convert key ASCII value to its' letter/name","path":"src/citra_qt/configure_input.cpp","position":111,"original_position":111,"commit_id":"5232d382ef30621661357c616467cf64798e08b6","original_commit_id":"5232d382ef30621661357c616467cf64798e08b6","user":{"login":"bunnei","id":6956688,"avatar_url":"https://avatars.githubusercontent.com/u/6956688?v=3","gravatar_id":"","url":"https://api.github.com/users/bunnei","html_url":"https://github.com/bunnei","followers_url":"https://api.github.com/users/bunnei/followers","following_url":"https://api.github.com/users/bunnei/following{/other_user}","gists_url":"https://api.github.com/users/bunnei/gists{/gist_id}","starred_url":"https://api.github.com/users/bunnei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bunnei/subscriptions","organizations_url":"https://api.github.com/users/bunnei/orgs","repos_url":"https://api.github.com/users/bunnei/repos","events_url":"https://api.github.com/users/bunnei/events{/privacy}","received_events_url":"https://api.github.com/users/bunnei/received_events","type":"User","site_admin":false},"body":"Docstrings should appear in the header file, not in the .cpp","created_at":"2016-07-28T18:59:47Z","updated_at":"2016-07-28T18:59:47Z","html_url":"https://github.com/citra-emu/citra/pull/1900#discussion_r72681794","pull_request_url":"https://api.github.com/repos/citra-emu/citra/pulls/1900","_links":{"self":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/comments/72681794"},"html":{"href":"https://github.com/citra-emu/citra/pull/1900#discussion_r72681794"},"pull_request":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/1900"}}},"pull_request":{"url":"https://api.github.com/repos/citra-emu/citra/pulls/1900","id":73472658,"html_url":"https://github.com/citra-emu/citra/pull/1900","diff_url":"https://github.com/citra-emu/citra/pull/1900.diff","patch_url":"https://github.com/citra-emu/citra/pull/1900.patch","issue_url":"https://api.github.com/repos/citra-emu/citra/issues/1900","number":1900,"state":"open","locked":false,"title":"Input GUI: Add tab to remap controls","user":{"login":"makotech222","id":4389156,"avatar_url":"https://avatars.githubusercontent.com/u/4389156?v=3","gravatar_id":"","url":"https://api.github.com/users/makotech222","html_url":"https://github.com/makotech222","followers_url":"https://api.github.com/users/makotech222/followers","following_url":"https://api.github.com/users/makotech222/following{/other_user}","gists_url":"https://api.github.com/users/makotech222/gists{/gist_id}","starred_url":"https://api.github.com/users/makotech222/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makotech222/subscriptions","organizations_url":"https://api.github.com/users/makotech222/orgs","repos_url":"https://api.github.com/users/makotech222/repos","events_url":"https://api.github.com/users/makotech222/events{/privacy}","received_events_url":"https://api.github.com/users/makotech222/received_events","type":"User","site_admin":false},"body":"Screenshot:\r\n![2016-07-23 13_19_38-citra _ input-gui-rebase-5232d38](https://cloud.githubusercontent.com/assets/4389156/17079514/2eab93ea-50d8-11e6-972c-8a07e9ba41cb.png)\r\n\r\nUI based on #1119 \r\n\r\nFirst pull request to Citra! \r\n\r\nThis is a simple GUI for allowing user to assign keyboard keys to Citra buttons. It has been a long time since I've written C++ code (I do C# for a living) so please let me know if there are better ways to do anything.\r\n\r\nInput is changed by clicking on one of the available buttons. The text of the button will change to [waiting] and will block all mouse input. When user presses a key on keyboard, it will change the text to the newly pressed key. Press 'Escape' while in input waiting mode to cancel. Changes will save when user exits the menu.\r\n\r\nEdit: New screenshot posted, with new circle modifier button. Note that my next pull request will overhaul how input is handled. This GUI may be subject to an overhaul as well.","created_at":"2016-06-11T16:50:57Z","updated_at":"2016-07-28T18:59:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8d99597f4abe2a8e52b9076f5d98a0113a83b262","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/citra-emu/citra/pulls/1900/commits","review_comments_url":"https://api.github.com/repos/citra-emu/citra/pulls/1900/comments","review_comment_url":"https://api.github.com/repos/citra-emu/citra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/citra-emu/citra/issues/1900/comments","statuses_url":"https://api.github.com/repos/citra-emu/citra/statuses/5232d382ef30621661357c616467cf64798e08b6","head":{"label":"makotech222:input-gui-rebase","ref":"input-gui-rebase","sha":"5232d382ef30621661357c616467cf64798e08b6","user":{"login":"makotech222","id":4389156,"avatar_url":"https://avatars.githubusercontent.com/u/4389156?v=3","gravatar_id":"","url":"https://api.github.com/users/makotech222","html_url":"https://github.com/makotech222","followers_url":"https://api.github.com/users/makotech222/followers","following_url":"https://api.github.com/users/makotech222/following{/other_user}","gists_url":"https://api.github.com/users/makotech222/gists{/gist_id}","starred_url":"https://api.github.com/users/makotech222/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makotech222/subscriptions","organizations_url":"https://api.github.com/users/makotech222/orgs","repos_url":"https://api.github.com/users/makotech222/repos","events_url":"https://api.github.com/users/makotech222/events{/privacy}","received_events_url":"https://api.github.com/users/makotech222/received_events","type":"User","site_admin":false},"repo":{"id":57228456,"name":"citra","full_name":"makotech222/citra","owner":{"login":"makotech222","id":4389156,"avatar_url":"https://avatars.githubusercontent.com/u/4389156?v=3","gravatar_id":"","url":"https://api.github.com/users/makotech222","html_url":"https://github.com/makotech222","followers_url":"https://api.github.com/users/makotech222/followers","following_url":"https://api.github.com/users/makotech222/following{/other_user}","gists_url":"https://api.github.com/users/makotech222/gists{/gist_id}","starred_url":"https://api.github.com/users/makotech222/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makotech222/subscriptions","organizations_url":"https://api.github.com/users/makotech222/orgs","repos_url":"https://api.github.com/users/makotech222/repos","events_url":"https://api.github.com/users/makotech222/events{/privacy}","received_events_url":"https://api.github.com/users/makotech222/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/makotech222/citra","description":"Nintendo 3DS Emulator","fork":true,"url":"https://api.github.com/repos/makotech222/citra","forks_url":"https://api.github.com/repos/makotech222/citra/forks","keys_url":"https://api.github.com/repos/makotech222/citra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/makotech222/citra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/makotech222/citra/teams","hooks_url":"https://api.github.com/repos/makotech222/citra/hooks","issue_events_url":"https://api.github.com/repos/makotech222/citra/issues/events{/number}","events_url":"https://api.github.com/repos/makotech222/citra/events","assignees_url":"https://api.github.com/repos/makotech222/citra/assignees{/user}","branches_url":"https://api.github.com/repos/makotech222/citra/branches{/branch}","tags_url":"https://api.github.com/repos/makotech222/citra/tags","blobs_url":"https://api.github.com/repos/makotech222/citra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/makotech222/citra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/makotech222/citra/git/refs{/sha}","trees_url":"https://api.github.com/repos/makotech222/citra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/makotech222/citra/statuses/{sha}","languages_url":"https://api.github.com/repos/makotech222/citra/languages","stargazers_url":"https://api.github.com/repos/makotech222/citra/stargazers","contributors_url":"https://api.github.com/repos/makotech222/citra/contributors","subscribers_url":"https://api.github.com/repos/makotech222/citra/subscribers","subscription_url":"https://api.github.com/repos/makotech222/citra/subscription","commits_url":"https://api.github.com/repos/makotech222/citra/commits{/sha}","git_commits_url":"https://api.github.com/repos/makotech222/citra/git/commits{/sha}","comments_url":"https://api.github.com/repos/makotech222/citra/comments{/number}","issue_comment_url":"https://api.github.com/repos/makotech222/citra/issues/comments{/number}","contents_url":"https://api.github.com/repos/makotech222/citra/contents/{+path}","compare_url":"https://api.github.com/repos/makotech222/citra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/makotech222/citra/merges","archive_url":"https://api.github.com/repos/makotech222/citra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/makotech222/citra/downloads","issues_url":"https://api.github.com/repos/makotech222/citra/issues{/number}","pulls_url":"https://api.github.com/repos/makotech222/citra/pulls{/number}","milestones_url":"https://api.github.com/repos/makotech222/citra/milestones{/number}","notifications_url":"https://api.github.com/repos/makotech222/citra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/makotech222/citra/labels{/name}","releases_url":"https://api.github.com/repos/makotech222/citra/releases{/id}","deployments_url":"https://api.github.com/repos/makotech222/citra/deployments","created_at":"2016-04-27T16:23:43Z","updated_at":"2016-04-27T16:23:44Z","pushed_at":"2016-07-25T00:42:34Z","git_url":"git://github.com/makotech222/citra.git","ssh_url":"git@github.com:makotech222/citra.git","clone_url":"https://github.com/makotech222/citra.git","svn_url":"https://github.com/makotech222/citra","homepage":"https://citra-emu.org","size":13137,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"citra-emu:master","ref":"master","sha":"624cd9cd983e294cea77a337e8aed916f28ababe","user":{"login":"citra-emu","id":7605670,"avatar_url":"https://avatars.githubusercontent.com/u/7605670?v=3","gravatar_id":"","url":"https://api.github.com/users/citra-emu","html_url":"https://github.com/citra-emu","followers_url":"https://api.github.com/users/citra-emu/followers","following_url":"https://api.github.com/users/citra-emu/following{/other_user}","gists_url":"https://api.github.com/users/citra-emu/gists{/gist_id}","starred_url":"https://api.github.com/users/citra-emu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citra-emu/subscriptions","organizations_url":"https://api.github.com/users/citra-emu/orgs","repos_url":"https://api.github.com/users/citra-emu/repos","events_url":"https://api.github.com/users/citra-emu/events{/privacy}","received_events_url":"https://api.github.com/users/citra-emu/received_events","type":"Organization","site_admin":false},"repo":{"id":19866730,"name":"citra","full_name":"citra-emu/citra","owner":{"login":"citra-emu","id":7605670,"avatar_url":"https://avatars.githubusercontent.com/u/7605670?v=3","gravatar_id":"","url":"https://api.github.com/users/citra-emu","html_url":"https://github.com/citra-emu","followers_url":"https://api.github.com/users/citra-emu/followers","following_url":"https://api.github.com/users/citra-emu/following{/other_user}","gists_url":"https://api.github.com/users/citra-emu/gists{/gist_id}","starred_url":"https://api.github.com/users/citra-emu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/citra-emu/subscriptions","organizations_url":"https://api.github.com/users/citra-emu/orgs","repos_url":"https://api.github.com/users/citra-emu/repos","events_url":"https://api.github.com/users/citra-emu/events{/privacy}","received_events_url":"https://api.github.com/users/citra-emu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/citra-emu/citra","description":"Nintendo 3DS Emulator","fork":false,"url":"https://api.github.com/repos/citra-emu/citra","forks_url":"https://api.github.com/repos/citra-emu/citra/forks","keys_url":"https://api.github.com/repos/citra-emu/citra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/citra-emu/citra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/citra-emu/citra/teams","hooks_url":"https://api.github.com/repos/citra-emu/citra/hooks","issue_events_url":"https://api.github.com/repos/citra-emu/citra/issues/events{/number}","events_url":"https://api.github.com/repos/citra-emu/citra/events","assignees_url":"https://api.github.com/repos/citra-emu/citra/assignees{/user}","branches_url":"https://api.github.com/repos/citra-emu/citra/branches{/branch}","tags_url":"https://api.github.com/repos/citra-emu/citra/tags","blobs_url":"https://api.github.com/repos/citra-emu/citra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/citra-emu/citra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/citra-emu/citra/git/refs{/sha}","trees_url":"https://api.github.com/repos/citra-emu/citra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/citra-emu/citra/statuses/{sha}","languages_url":"https://api.github.com/repos/citra-emu/citra/languages","stargazers_url":"https://api.github.com/repos/citra-emu/citra/stargazers","contributors_url":"https://api.github.com/repos/citra-emu/citra/contributors","subscribers_url":"https://api.github.com/repos/citra-emu/citra/subscribers","subscription_url":"https://api.github.com/repos/citra-emu/citra/subscription","commits_url":"https://api.github.com/repos/citra-emu/citra/commits{/sha}","git_commits_url":"https://api.github.com/repos/citra-emu/citra/git/commits{/sha}","comments_url":"https://api.github.com/repos/citra-emu/citra/comments{/number}","issue_comment_url":"https://api.github.com/repos/citra-emu/citra/issues/comments{/number}","contents_url":"https://api.github.com/repos/citra-emu/citra/contents/{+path}","compare_url":"https://api.github.com/repos/citra-emu/citra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/citra-emu/citra/merges","archive_url":"https://api.github.com/repos/citra-emu/citra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/citra-emu/citra/downloads","issues_url":"https://api.github.com/repos/citra-emu/citra/issues{/number}","pulls_url":"https://api.github.com/repos/citra-emu/citra/pulls{/number}","milestones_url":"https://api.github.com/repos/citra-emu/citra/milestones{/number}","notifications_url":"https://api.github.com/repos/citra-emu/citra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/citra-emu/citra/labels{/name}","releases_url":"https://api.github.com/repos/citra-emu/citra/releases{/id}","deployments_url":"https://api.github.com/repos/citra-emu/citra/deployments","created_at":"2014-05-16T18:33:15Z","updated_at":"2016-07-28T14:16:13Z","pushed_at":"2016-07-28T17:29:31Z","git_url":"git://github.com/citra-emu/citra.git","ssh_url":"git@github.com:citra-emu/citra.git","clone_url":"https://github.com/citra-emu/citra.git","svn_url":"https://github.com/citra-emu/citra","homepage":"https://citra-emu.org","size":20973,"stargazers_count":2129,"watchers_count":2129,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":522,"mirror_url":null,"open_issues_count":199,"forks":522,"open_issues":199,"watchers":2129,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/1900"},"html":{"href":"https://github.com/citra-emu/citra/pull/1900"},"issue":{"href":"https://api.github.com/repos/citra-emu/citra/issues/1900"},"comments":{"href":"https://api.github.com/repos/citra-emu/citra/issues/1900/comments"},"review_comments":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/1900/comments"},"review_comment":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/citra-emu/citra/pulls/1900/commits"},"statuses":{"href":"https://api.github.com/repos/citra-emu/citra/statuses/5232d382ef30621661357c616467cf64798e08b6"}}}}
{"actor":{"display_login":"bunnei"}}