PIN Definitions and scale definition
This commit is contained in:
		@@ -5,6 +5,23 @@
 | 
				
			|||||||
#include <hidboot.h>
 | 
					#include <hidboot.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define PIN_MOUSE_V    19 // LAN_TX0
 | 
				
			||||||
 | 
					#define PIN_MOUSE_VQ   26 // LAN_RX1
 | 
				
			||||||
 | 
					#define PIN_MOUSE_H    27 // LAN_CRS
 | 
				
			||||||
 | 
					#define PIN_MOUSE_HQ   23 // LAN_MDC
 | 
				
			||||||
 | 
					#define PIN_MOUSE_LBTN 21 // LAN_TXEN
 | 
				
			||||||
 | 
					#define PIN_MOUSE_MBTN 25 // LAN_RX0
 | 
				
			||||||
 | 
					#define PIN_MOUSE_RBTN 17 // LAN_CLK
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MOUSE_SCALE_MAX 63
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const byte mouseStates[4][2] = {
 | 
				
			||||||
 | 
					  {0, 0},
 | 
				
			||||||
 | 
					  {0, 1},
 | 
				
			||||||
 | 
					  {1, 1},
 | 
				
			||||||
 | 
					  {1, 0}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MouseRptParser : public MouseReportParser
 | 
					class MouseRptParser : public MouseReportParser
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  protected:
 | 
					  protected:
 | 
				
			||||||
@@ -14,41 +31,41 @@ class MouseRptParser : public MouseReportParser
 | 
				
			|||||||
    void OnLeftButtonDown  (MOUSEINFO *mi);
 | 
					    void OnLeftButtonDown  (MOUSEINFO *mi);
 | 
				
			||||||
    void OnLeftButtonUp  (MOUSEINFO *mi);
 | 
					    void OnLeftButtonUp  (MOUSEINFO *mi);
 | 
				
			||||||
    void OnMiddleButtonDown  (MOUSEINFO *mi);
 | 
					    void OnMiddleButtonDown  (MOUSEINFO *mi);
 | 
				
			||||||
 | 
					    void OnMiddleButtonUp  (MOUSEINFO *mi);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MouseRptParser::OnRightButtonUp  (MOUSEINFO *mi)
 | 
					void MouseRptParser::OnRightButtonUp  (MOUSEINFO *mi)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  digitalWrite(PIN_MOUSE_RBTN, HIGH);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MouseRptParser::OnRightButtonDown  (MOUSEINFO *mi)
 | 
					void MouseRptParser::OnRightButtonDown  (MOUSEINFO *mi)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  digitalWrite(PIN_MOUSE_RBTN, LOW);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MouseRptParser::OnLeftButtonDown  (MOUSEINFO *mi)
 | 
					void MouseRptParser::OnLeftButtonDown  (MOUSEINFO *mi)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  digitalWrite(16, LOW);
 | 
					  digitalWrite(PIN_MOUSE_LBTN, LOW);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MouseRptParser::OnLeftButtonUp  (MOUSEINFO *mi)
 | 
					void MouseRptParser::OnLeftButtonUp  (MOUSEINFO *mi)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  digitalWrite(16, HIGH);
 | 
					  digitalWrite(PIN_MOUSE_LBTN, HIGH);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MouseRptParser::OnMiddleButtonDown  (MOUSEINFO *mi)
 | 
					void MouseRptParser::OnMiddleButtonDown  (MOUSEINFO *mi)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  digitalWrite(PIN_MOUSE_MBTN, LOW);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
byte mouseStates[4][2] = {
 | 
					void MouseRptParser::OnMiddleButtonUp  (MOUSEINFO *mi)
 | 
				
			||||||
  {0, 0},
 | 
					{
 | 
				
			||||||
  {0, 1},
 | 
					  digitalWrite(PIN_MOUSE_MBTN, HIGH);
 | 
				
			||||||
  {1, 1},
 | 
					 | 
				
			||||||
  {1, 0}
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool mouseYworking = false;
 | 
					bool mouseYworking = false;
 | 
				
			||||||
int mouseYTableIndex = 0;
 | 
					int mouseYTableIndex = 0;
 | 
				
			||||||
void amigaYpulse(int8_t count) {
 | 
					void amigaYpulse(int8_t count) {
 | 
				
			||||||
@@ -59,7 +76,7 @@ void amigaYpulse(int8_t count) {
 | 
				
			|||||||
    return; 
 | 
					    return; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  mouseYworking = true;
 | 
					  mouseYworking = true;
 | 
				
			||||||
  byte mapped = map(abs(count), 0, 127, 1, 63);
 | 
					  byte mapped = map(abs(count), 0, 127, 1, MOUSE_SCALE_MAX);
 | 
				
			||||||
  for (byte i = 0; i < mapped; i++)
 | 
					  for (byte i = 0; i < mapped; i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if (count < 0) {
 | 
					    if (count < 0) {
 | 
				
			||||||
@@ -90,7 +107,7 @@ void amigaXpulse(int8_t count) {
 | 
				
			|||||||
  if (count == 0)
 | 
					  if (count == 0)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (byte i = 0; i < map(abs(count), 0, 127, 1, 63); i++)
 | 
					  for (byte i = 0; i < map(abs(count), 0, 127, 1, MOUSE_SCALE_MAX); i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if (count < 0) {
 | 
					    if (count < 0) {
 | 
				
			||||||
      mouseXTableIndex++;
 | 
					      mouseXTableIndex++;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user