Skip to content

Commit

Permalink
完了, 有bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hua-zhi-wan committed Dec 23, 2020
1 parent 009a0ab commit 04a7113
Show file tree
Hide file tree
Showing 15 changed files with 1,366 additions and 1,214 deletions.
13 changes: 6 additions & 7 deletions GamepadPlusGUI/GamepadPlusGUI.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2020-12-20T21:44:11. -->
<!-- Written by QtCreator 4.11.0, 2020-12-23T13:53:50. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -67,7 +67,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.9.9 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.9.9 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.599.win64_msvc2017_64_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
Expand Down Expand Up @@ -119,7 +119,7 @@
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/GitHub/GamepadPlusGUI/debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/GitHub/GamepadPlus/withGUI/GamepadPlus/build-GamepadPlusGUI-Desktop_Qt_5_9_9_MSVC2017_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
Expand Down Expand Up @@ -287,9 +287,8 @@
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">GamepadPlusGUI2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/GitHub/GamepadPlusGUI/GamepadPlusGUI/GamepadPlusGUI.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">D:/GitHub/GamepadPlusGUI/GamepadPlusGUI/GamepadPlusGUI.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/GitHub/GamepadPlus/withGUI/GamepadPlus/GamepadPlusGUI/GamepadPlusGUI.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">D:/GitHub/GamepadPlus/withGUI/GamepadPlus/GamepadPlusGUI/GamepadPlusGUI.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
Expand All @@ -300,7 +299,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/GitHub/GamepadPlusGUI/build-GamepadPlusGUI-Desktop_Qt_5_9_9_MSVC2017_64bit-Debug</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/GitHub/GamepadPlus/withGUI/GamepadPlus/build-GamepadPlusGUI-Desktop_Qt_5_9_9_MSVC2017_64bit-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
Expand Down
35 changes: 34 additions & 1 deletion GamepadPlusGUI/widget.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "widget.h"

#include "globalconfig.h"
#include <QDebug.h>
#include <QPainter>
#include <cmath>

Expand Down Expand Up @@ -266,6 +265,40 @@ int Widget::keyboardStep()
}

// Reset
if(state != 0) {
switch (state) {
case 4:{
if(!Gamepad.getDPad(GamepadDpadEX::left)) {
Keyboard.keyboardPress(keyDirection/40 % 26 + 'A');
state = 0;
}
break;
}
case 2:{
if(!Gamepad.getDPad(GamepadDpadEX::down)) {
Keyboard.keyboardPress(DOWN_KEY_CODE[keyDirection/80 % 4]);
state = 0;
}
break;
}
case 6:{
if(!Gamepad.getDPad(GamepadDpadEX::right)) {
Keyboard.keyboardPress(RIGHT_KEY_CODE[keyDirection/40 % 15]);
state = 0;
}
break;
}
case 8:{
if(!Gamepad.getDPad(GamepadDpadEX::up)) {
Keyboard.keyboardPress(UP_KEY_CODE[keyDirection/60 % 8]);
state = 0;
}
break;
}
}
}

return 0;
}

int Widget::xyToDirection(int x, int y)
Expand Down
Loading

0 comments on commit 04a7113

Please sign in to comment.