Skip to content

Commit

Permalink
4th and 5th button now works correctly (newmouse.h needs additional d…
Browse files Browse the repository at this point in the history
…efs for 5th)
  • Loading branch information
sq7bti committed Oct 15, 2021
1 parent 795b083 commit 7a66592
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 37 deletions.
107 changes: 71 additions & 36 deletions mousedriver.c
Expand Up @@ -52,7 +52,7 @@ struct MsgPort *InputMP;
struct InputEvent *MouseEvent;
struct InputBase *InputBase;
BYTE intsignal;
int code, mbutton_state, prev_joy0dat;
int code, button_state, prev_joy0dat, temp;

int main(void)
{
Expand All @@ -77,46 +77,82 @@ int main(void)
if (signals & mousedata.sigbit)
{

temp = mousedata.joy0dat ^ ((mousedata.joy0dat & 0x0202) >> 1);
temp &= 0x0303;
temp |= (temp & 0x0300) >> 6;
temp &= 0x000F;
temp ^= 0x000F;
code = MM_NOTHING;
// if(prev_joy0dat != (mousedata.joy0dat & 0x0303))
// {
// printf("joy: %04x->%04x -> ", prev_joy0dat & 0x0303, mousedata.joy0dat & 0x0303);
// prev_joy0dat = mousedata.joy0dat & 0x0303;
// }
// if( (mousedata.joy0dat & 0x0303) != 0x0202)
// {
// printf("%1X -> ", temp);
// }
switch(mousedata.joy0dat & 0x0303)
{ // YQXQ
case 0x0000: // 1111 MMB pressed
code |= MM_MIDDLEMOUSE_DOWN;
// printf("1111 MMB down\n");
if(!(button_state & 0x01))
{
// printf("%1X 1111 MMB down\n", temp);
code |= MM_MIDDLEMOUSE_DOWN;
button_state |= 0x01;
}
break;
case 0x0001: // 1110 middle button up
code |= MM_MIDDLEMOUSE_UP;
// printf("1110 MMB up\n");
if(button_state & 0x01)
{
// printf("%1X 1110 MMB up\n", temp);
code |= MM_MIDDLEMOUSE_UP;
button_state &= ~0x01;
}
break;

case 0x0002: // 1100 4th down
code |= MM_FOURTH_DOWN;
printf("1100 4th down\n");
if(!(button_state & 0x02))
{
// printf("%1X 1100 4th down\n", temp);
code |= MM_FOURTH_DOWN;
button_state |= 0x02;
}
break;
case 0x003: // 1101 4th up
code |= MM_FOURTH_UP;
printf("1101 4th up\n");
if(button_state & 0x02)
{
// printf("%1X 1101 4th up\n", temp);
code |= MM_FOURTH_UP;
button_state &= ~0x02;
}
break;

case 0x0100: // 1011 5th down
code |= MM_FIVETH_DOWN;
printf("1011 5th down\n");
if(!(button_state & 0x04))
{
// printf("%1X 1011 5th down\n", temp);
code |= MM_FIVETH_DOWN;
button_state |= 0x04;
}
break;
case 0x0101: // 1010 5th up
code |= MM_FIVETH_UP;
printf("1010 5th up\n");
if(button_state & 0x04)
{
// printf("%1X 1010 5th up\n", temp);
code |= MM_FIVETH_UP;
button_state &= ~0x04;
}
break;
case 0x0102: // 1000 wheel right
code |= MM_WHEEL_RIGHT;
printf("1000 wheel right\n");
code |= MM_WHEEL_RIGHT;
break;
case 0x0103: // 1001 wheel left
code |= MM_WHEEL_LEFT;
printf("1001 wheel left\n");
break;

case 0x0200: // 0011 wheel up
code |= MM_WHEEL_UP;
// printf("0011 wheel up\n");
Expand All @@ -125,12 +161,17 @@ int main(void)
code |= MM_WHEEL_DOWN;
// printf("0010 wheel down\n");
break;

case 0x0202: // 1111 -> nothing
// printf("\n");
// printf("0x%02x\n", prev_joy0dat & 0x0303);
break;
default:
printf("unsupported code 0x%02x\n", prev_joy0dat & 0x0303);
printf("unsupported code 0x%02x -> 0x%02X", mousedata.joy0dat & 0x0303, temp);
// printf("1/Y %1d; ", (temp & 0x0008) >> 3);
// printf("2/X %1d; ", (temp & 0x0004) >> 2);
// printf("3YQ %1d; ", (temp & 0x0002) >> 1);
// printf("4XQ %1d\n", (temp & 0x0001) >> 0);
break;
}

Expand Down Expand Up @@ -186,7 +227,7 @@ int AllocResources()

void FreeResources()
{
if (InputIO)
if (InputIO)
{
CloseDevice((struct IORequest *)InputIO);
DeleteIORequest(InputIO);
Expand All @@ -197,7 +238,6 @@ void FreeResources()
RemIntServer(INTB_VERTB, &vertblankint);
}

int down=0;
void CreateMouseEvents(int t)
{
if (t == 0)
Expand All @@ -223,41 +263,37 @@ void CreateMouseEvents(int t)
case MM_WHEEL_RIGHT:
MouseEvent->ie_Code = NM_WHEEL_RIGHT;
break;
// case MM_FOURTH_DOWN:
// MouseEvent->ie_Code = NM_FOURTH_DOWN;
// break;
// case MM_FOURTH_UP
// MouseEvent->ie_Code = NM_FOURTH_UP;
// break;
// case MM_FIVETH_DOWN:
// MouseEvent->ie_Code = NM_???;
// break;
// case MM_FIVETH_UP
// MouseEvent->ie_Code = NM_???;
// break;
case MM_MIDDLEMOUSE_DOWN:
MouseEvent->ie_Code = IECODE_MBUTTON;
MouseEvent->ie_Class = IECLASS_RAWMOUSE;
MouseEvent->ie_Code = IECODE_MBUTTON;
MouseEvent->ie_Qualifier = IEQUALIFIER_MIDBUTTON | IEQUALIFIER_RELATIVEMOUSE;
MouseEvent->ie_X = 0;
MouseEvent->ie_Y = 0;
break;
case MM_MIDDLEMOUSE_UP:
MouseEvent->ie_Code = IECODE_MBUTTON | IECODE_UP_PREFIX;
MouseEvent->ie_Class = IECLASS_RAWMOUSE;
MouseEvent->ie_Code = IECODE_MBUTTON | IECODE_UP_PREFIX;
MouseEvent->ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE;
MouseEvent->ie_X = 0;
MouseEvent->ie_Y = 0;
break;
case MM_FOURTH_DOWN:
MouseEvent->ie_Code = NM_BUTTON_FOURTH;
// MouseEvent->ie_Class = IECLASS_RAWMOUSE;
MouseEvent->ie_Class = IECLASS_NEWMOUSE;
MouseEvent->ie_X = 0;
MouseEvent->ie_Y = 0;
break;
case MM_FOURTH_UP:
MouseEvent->ie_Code = NM_BUTTON_FOURTH | IECODE_UP_PREFIX;
// MouseEvent->ie_Class = IECLASS_RAWMOUSE;
MouseEvent->ie_Class = IECLASS_NEWMOUSE;
MouseEvent->ie_X = 0;
MouseEvent->ie_Y = 0;
break;
case MM_FIVETH_DOWN:
MouseEvent->ie_Code = NM_BUTTON_FIVETH;
MouseEvent->ie_X = 0;
MouseEvent->ie_Y = 0;
break;
case MM_FIVETH_UP:
MouseEvent->ie_Code = NM_BUTTON_FIVETH | IECODE_UP_PREFIX;
MouseEvent->ie_X = 0;
MouseEvent->ie_Y = 0;
break;
Expand All @@ -266,7 +302,6 @@ void CreateMouseEvents(int t)
InputIO->io_Data = (APTR)MouseEvent;
InputIO->io_Length = sizeof(struct InputEvent);
InputIO->io_Command = IND_WRITEEVENT;
// InputIO->io_Flags = IOF_QUICK;

DoIO((struct IORequest *)InputIO);
}
4 changes: 4 additions & 0 deletions newmouse.h
Expand Up @@ -34,4 +34,8 @@
#define NM_BUTTON_FOURTH (0x7E)
#endif

#ifndef NM_BUTTON_FIVETH
#define NM_BUTTON_FIVETH (0x7F)
#endif

#endif /* NEWMOUSE_H */
2 changes: 1 addition & 1 deletion vbrserver.s
Expand Up @@ -54,7 +54,7 @@ _VertBServer:
Delay:
; cocolino 36,
; ez-mouse 25
MOVEQ #25,D1 ; Needs testing on a slower Amiga!
MOVEQ #30,D1 ; Needs testing on a slower Amiga!
.wait1
MOVE.B vhposr+1(A0),D0 ; Bits 7-0 H8-H1 (horizontal position)
.wait2
Expand Down

0 comments on commit 7a66592

Please sign in to comment.