Forgotten updates

This commit is contained in:
Aki Goto
2013-12-23 03:06:53 +09:00
parent 2d60c783df
commit 082e47dcec
3 changed files with 34 additions and 2 deletions

View File

@@ -221,11 +221,36 @@ static int handle_idle_pointer(struct PadKey *this, struct js_event *event)
static int cursorY = 0;
if (this->pointer.vx != 0 || this->pointer.vy != 0) {
int dx = this->pointer.vx / 4096;
int dy = this->pointer.vy / 4096;
int dx;
int dy;
int v;
this->pointer.charge++;
if (this->pointer.charge < 96) {
v = this->pointer.charge / 3;
} else {
v = 32;
}
if (this->pointer.vx < 0) {
dx = -v;
} else if (this->pointer.vx == 0) {
dx = 0;
} else {
dx = v;
}
if (this->pointer.vy < 0) {
dy = -v;
} else if (this->pointer.vy == 0) {
dy = 0;
} else {
dy = v;
}
XTestFakeRelativeMotionEvent(this->display, dx, dy, 0);
XFlush(this->display);
} else {
this->pointer.charge = 0;
}
return 0;
@@ -244,6 +269,7 @@ int PadKey_handle(struct PadKey *this)
FD_ZERO(&rfds);
FD_SET(this->fd, &rfds);
#if 1
if (this->pointer.vx != 0 || this->pointer.vy != 0) {
tv.tv_sec = 0;
tv.tv_usec = 20000;
@@ -251,6 +277,10 @@ int PadKey_handle(struct PadKey *this)
tv.tv_sec = 0;
tv.tv_usec = 100000;
}
#else
tv.tv_sec = 0;
tv.tv_usec = 20000;
#endif
retval = select(this->fd + 1, &rfds, NULL, NULL, &tv);
if (retval == -1) {

View File

@@ -11,6 +11,7 @@ void Pointer_initialize(struct Pointer *this)
this->yNumber = 1;
this->vx = 0;
this->vy = 0;
this->charge = 0;
this->leftNumber = 0;
this->centerNumber = 1;
this->rightNumber = 3;

View File

@@ -13,6 +13,7 @@ struct Pointer {
int yNumber;
int vx;
int vy;
int charge;
int leftNumber;
int centerNumber;
int rightNumber;