[go: up one dir, main page]

File: mouse.cpp

package info (click to toggle)
fbzx 3.1.0-1
  • links: PTS, VCS
  • area: contrib
  • in suites: bullseye, buster, stretch
  • size: 2,152 kB
  • ctags: 861
  • sloc: cpp: 10,495; ansic: 8,663; python: 1,116; makefile: 123; xml: 28; sh: 3
file content (45 lines) | stat: -rw-r--r-- 815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "mouse.hh"
#include "computer.hh"
#include "emulator.hh"
#include "keyboard.hh"
#include "osd.hh"

#include <stdio.h>

class Mouse *mouse;

void Mouse::reset() {
  
  this->posx = keyboard->mouse_x;
  this->posy = keyboard->mouse_y;
  this->x = 0;
  this->y = 0;
  this->button = 255;
  
}

Mouse::Mouse() {
  this->enabled = false;
  this->reset();
}

void Mouse::emulate(int tstates) {

  uint8_t diffx = (keyboard->mouse_x - this->posx)/2;
  uint8_t diffy = (keyboard->mouse_y - this->posy)/2;
  this->posx = keyboard->mouse_x;
  this->posy = keyboard->mouse_y;
  
  this->x += diffx;
  this->y -= diffy;
  this->button = 255;
  if (keyboard->mouse_right) {
    this->button -= 1;
  }
  if (keyboard->mouse_left) {
    this->button -= 2;
  }
  if (keyboard->mouse_center) {
    this->button -= 4;
  }
}