My problem seems to be a weird one, for I can't find it anywhere on the web. My problem is that I am trying to make it
so the mouse loops to the opposite side of the display when it reaches the edge of said display. For example,
if the mouse cursor was supposed to reach a Y position of -1, I want the mouse to loop to the other side of the display, in this case,
the bottom. I also need this to be translated as a linear movement, in other words, I don't the cursor movement to be translated as
up then INSTANT down then up again. I want a smooth up motion. I can make the linear movement, I just need the looping part. I have realized that this problem might also be with the OS, and my OS is Xubuntu 12.04 LTS I am also using QT 4.8 if that means anything.
An example of my problem is when you move your mouse cursor to the edge of your display, it stops right? I want to make it so the mouse continues to move that direction but is loops to the opposite side of the display.
For instance: If you move your mouse cursor left to right, when you hit the right-edge I want the cursor to "loop" to the left edge then continue to move left-to-right. I want this to happen indefinitely.
class CMainWindow : public QMainWindow
// Re-implemented QT virtual functions.
void paintEvent(QPaintEvent *);
void resizeEvent(QResizeEvent *r);
void keyPressEvent(QKeyEvent *k);
void keyReleaseEvent(QKeyEvent *);
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *m);
void mouseReleaseEvent(QMouseEvent *);
void ChangeMouse(int aValue);
void ChangeSpeed(int aValue);
bool PointInQuad(float aX, float aY, SQuad aQuad);
// Native C/C++ member types ;; NO CLASSES.
float mnMouseSpeed; // This variable is used to keep track of the mouse speed.
bool mbMouseClick; // This bit is set when the mouse button has been clicked.
float mnBallSpeed; // This variable directly varies with the mouse speed.
int miPrevMouseY; // The previous Y-position of the mouse cursor
int miMouseY; // The current Y-position of the mouse cursor
// Vectors of dynamic objects objects.
// Native QT member types ;; CLASSES.
QWidget *mpWid; // This is the Client Area Widget.
QVBoxLayout *mpLay; // This is the game layout.
QTimer *mpFrameTimer; // At each timeout() game is updated.
// These objects are for the settings/pause screen.
QVBoxLayout *mpPauseLayout; // This object describes the layout of the pause screen.
QSlider *mpMouseSpeed; // This slider object is used to control the mouse speed.
#endif // MAINWINDOW_H
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
int main(int argc, char *argv)
// Seed the random number generator.
// Create the QApplication Object.
QApplication app(argc, argv);
//Create the MainWindow Object then show it.
//Run the QApplication object, then return it's error code (if any).
Sorry about the stoopid comment (I was in nine-year-old mode.)
In your example, you're saying that the cursor is moving upwards and is at position zero, the next value of y would be -1, and you want it to now be at the bottom of the screen, so y should be set to whatever the maximum value of y should be? Now I'm in 57-year-old-man mode and I don't understand the "smooth up motion" part, nor the "looping" part. Can you please explain that so an old man can understand?