1 #include "touchscreen.h"
2 #include <exec/types.h>
3 #include <exec/semaphores.h>
4 #include <exec/interrupts.h>
5 #include <exec/execbase.h>
6 #include <asm/registers.h>
7 #include <aros/libcall.h>
8 #include <aros/asmcall.h>
11 #include <aros/debug.h>
15 * Interrupt handler for the touchscreen
17 void touchscreen_int(HIDDT_IRQ_Handler
* irq
, HIDDT_IRQ_HwInfo
*hw
)
19 struct ExecBase
* SysBase
= *(struct ExecBase
**)0x04;
20 struct mouse_data
*data
=(struct mouse_data
*)irq
->h_Data
;
21 struct pHidd_Mouse_Event
*e
= &data
->me
;
23 * Try to read the coordinates
25 WREG_B(PFDATA
) = (RREG_B(PFDATA
) & 0xf0) | 0x06;
26 WREG_W(SPICONT2
) = (SPI_ENABLE_F
|SPI_XCH_F
|SPI_IRQEN_F
);
28 e
->x
= RREG_W(SPIDATA2
);
30 WREG_B(PFDATA
) = (RREG_B(PFDATA
) & 0xf0) | 0x09;
31 WREG_W(SPICONT2
) = (SPI_ENABLE_F
|SPI_XCH_F
|SPI_IRQEN_F
);
33 e
->y
= RREG_W(SPIDATA2
);
35 e
->x
= -(e
->x
/2-0xff);
36 e
->y
= -(e
->y
/2-0xff);
38 if (STATE_IDLE
== data
->state
) {
39 e
->button
= vHidd_Mouse_NoButton
;
40 e
->type
= vHidd_Mouse_Motion
;
41 D(bug("---------------- Motion! callback=%p\n",data
->mouse_callback
));
42 data
->mouse_callback(data
->callbackdata
, e
);
44 e
->button
= vHidd_Mouse_Button1
;
45 e
->type
= vHidd_Mouse_Press
;
46 D(bug("------------- Press!\n"));
47 data
->mouse_callback(data
->callbackdata
, e
);
49 if ((e
->x
!= data
->lastx
) &&
50 (e
->y
!= data
->lasty
)) {
51 e
->button
= vHidd_Mouse_Button1
;
52 e
->type
= vHidd_Mouse_Motion
;
53 D(bug("---------------- Motion! callback=%p\n",data
->mouse_callback
));
54 data
->mouse_callback(data
->callbackdata
, e
);
60 data
->state
= STATE_PEN_DOWN
;
67 AROS_UFH4(ULONG
, tsVBlank
,
68 AROS_UFHA(ULONG
, dummy
, A0
),
69 AROS_UFHA(void *, _data
, A1
),
70 AROS_UFHA(ULONG
, dummy2
, A5
),
71 AROS_UFHA(struct ExecBase
*, SysBase
, A6
))
74 struct mouse_data
*data
=(struct mouse_data
*)_data
;
75 if (STATE_PEN_DOWN
== data
->state
) {
77 if (2 == data
->idlectr
) {
78 struct pHidd_Mouse_Event
*e
= &data
->me
;
81 e
->button
= vHidd_Mouse_Button1
;
82 e
->type
= vHidd_Mouse_Release
;
83 data
->mouse_callback(data
->callbackdata
, e
);
84 data
->state
= STATE_IDLE
;