Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Suggestion
02-19-2014, 09:03 AM (This post was last modified: 02-19-2014 09:29 AM by Young.)
Post: #1
Code Suggestion
void PSPDpad::ProcessTouch(float x, float y, bool down) in GamepadEmu.cpp

.
.
.
bool fourWay = g_Config.bDisableDpadDiagonals || rad < 0.7f;
if (down) {
if (fourWay) {
/*int direction = (int)(floorf((atan2f(dy, dx) / (2 * M_PI) * 4) + 0.5f)) & 3;
switch (direction) {
case 0: ctrlMask |= CTRL_RIGHT; break;
case 1: ctrlMask |= CTRL_DOWN; break;
case 2: ctrlMask |= CTRL_LEFT; break;
case 3: ctrlMask |= CTRL_UP; break;
}*/

int maskL1Flag = CTRL_DOWN | CTRL_LEFT;
int maskL2Flag = CTRL_RIGHT | CTRL_DOWN;

if (dy < dx) maskL1Flag = CTRL_RIGHT | CTRL_UP;
if (dy < -dx) maskL2Flag = CTRL_LEFT | CTRL_UP;

ctrlMask = maskL1Flag & maskL2Flag;

// 4 way pad
} else {
// 8 way pad
/*int direction = (int)(floorf((atan2f(dy, dx) / (2 * M_PI) * 8) + 0.5f)) & 7;
switch (direction) {
case 0: ctrlMask |= CTRL_RIGHT; break;
case 1: ctrlMask |= CTRL_RIGHT | CTRL_DOWN; break;
case 2: ctrlMask |= CTRL_DOWN; break;
case 3: ctrlMask |= CTRL_DOWN | CTRL_LEFT; break;
case 4: ctrlMask |= CTRL_LEFT; break;
case 5: ctrlMask |= CTRL_UP | CTRL_LEFT; break;
case 6: ctrlMask |= CTRL_UP; break;
case 7: ctrlMask |= CTRL_UP | CTRL_RIGHT; break;
}*/

int maskL1Flag = CTRL_DOWN;
int maskL2Flag = CTRL_RIGHT;
int maskL3Flag = CTRL_LEFT;
int maskL4Flag = CTRL_DOWN;

if (dy < -dx * 0.41421356f) maskL1Flag = CTRL_UP; //tan 22.5(degree) = 0.4142135623730950488016887242097
if (dy < -dx * 2.41421436f) maskL2Flag = CTRL_LEFT; //tan 67.5(degree) = 2.4142135623730950488016887242097
if (dy < dx * 2.41421436f) maskL3Flag = CTRL_RIGHT;
if (dy < dx * 0.41421356f) maskL4Flag = CTRL_UP;

ctrlMask = (maskL1Flag & maskL4Flag) + (maskL2Flag & maskL3Flag);

}
}
.
.
.
i don't know how to use 'git' thing cuz i'm not a programmer
i'm just a math teacher
Find all posts by this user
Quote this message in a reply
02-19-2014, 09:46 AM
Post: #2
RE: Code Suggestion
Maybe this post might be helpfull:

http://forums.ppsspp.org/showthread.php?...=Compiling

Compiling is much easier with MVSE2013... you can use it to test if it will work with emu.

also you can request a pull if its successfull at github

o.o Oh Hi XD
P.S: Wanted to go to Japan so badly

AOD270
Windows 7 Home Basic (32bit)
Intel Atom N2800 (Quad-core) 1.86GHz
Intel Graphic Media Accelerator 3600 series
Find all posts by this user
Quote this message in a reply
02-19-2014, 06:27 PM (This post was last modified: 02-27-2014 06:43 AM by Young.)
Post: #3
RE: Code Suggestion
Thanks for your repling, Raimoo

That post is exactly what I need to know
Find all posts by this user
Quote this message in a reply
02-20-2014, 07:26 PM
Post: #4
RE: Code Suggestion
Mathmatically that may be more efficient and it will probably run faster but honstly this is not a bottleneck and the old code seems way more readable to me from a programmer perspective. But of course Herik can decide whether he likes your code better than what we have.
Find all posts by this user
Quote this message in a reply
02-25-2014, 06:24 PM
Post: #5
RE: Code Suggestion
If you want to suggest this to the Developers, it would be better to create an account on github.com and create a new issue here:

https://github.com/hrydgard/ppsspp/issue...state=open
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: