39static int mouse_init = 0;
46 printf(
"PS2Mouse Library already initialised\n");
50 mouseif.server = NULL;
53 if (SifBindRpc(&mouseif, PS2MOUSE_BIND_RPC_ID, 0) < 0) {
57 }
while(!mouseif.server);
67 u8* uncached = UNCACHED_SEG(buffer.buffer);
74 if (SifCallRpc(&mouseif, PS2MOUSE_READ, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
87 buffer.mode = readMode;
88 if (SifCallRpc(&mouseif, PS2MOUSE_SETREADMODE, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
97 u32 *uncached = (u32 *) UNCACHED_SEG(&buffer.mode);
99 if (SifCallRpc(&mouseif, PS2MOUSE_GETREADMODE, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
105int PS2MouseSetThres(u32 thres)
108 buffer.thres = thres;
109 if (SifCallRpc(&mouseif, PS2MOUSE_SETTHRES, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
115u32 PS2MouseGetThres()
118 u32* uncached = (u32 *) UNCACHED_SEG(&buffer.thres);
119 if (SifCallRpc(&mouseif, PS2MOUSE_GETTHRES, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
125int PS2MouseSetAccel(
float accel)
130 if(accel < 0)
return -1;
132 accel_fixed = (u32) (accel * 65536.0);
133 buffer.accel = accel_fixed;
134 if (SifCallRpc(&mouseif, PS2MOUSE_SETACCEL, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
140float PS2MouseGetAccel()
143 u32* uncached = (u32 *) UNCACHED_SEG(&buffer.accel);
146 if (SifCallRpc(&mouseif, PS2MOUSE_GETACCEL, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
149 accel_fixed = uncached[0];
151 return ((
float) accel_fixed) / 65536.0 ;
154int PS2MouseSetBoundary(
int minx,
int maxx,
int miny,
int maxy)
157 buffer.bounds.minx = minx;
158 buffer.bounds.maxx = maxx;
159 buffer.bounds.miny = miny;
160 buffer.bounds.maxy = maxy;
162 if (SifCallRpc(&mouseif, PS2MOUSE_SETBOUNDARY, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
168int PS2MouseGetBoundary(
int *minx,
int *maxx,
int *miny,
int *maxy)
171 struct mbounds* uncached = (
struct mbounds *) UNCACHED_SEG(&buffer.bounds);
173 if (SifCallRpc(&mouseif, PS2MOUSE_GETBOUNDARY, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
176 *minx = uncached->minx;
177 *maxx = uncached->maxx;
178 *miny = uncached->miny;
179 *maxy = uncached->maxy;
184int PS2MouseSetPosition(
int x,
int y)
190 if (SifCallRpc(&mouseif, PS2MOUSE_SETPOSITION, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
199 if (SifCallRpc(&mouseif, PS2MOUSE_RESET, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
208 u32* uncached = (u32 *) UNCACHED_SEG(&buffer.data);
210 if (SifCallRpc(&mouseif, PS2MOUSE_ENUM, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
216u32 PS2MouseGetVersion()
219 u32* uncached = (u32 *) UNCACHED_SEG(&buffer.data);
221 if (SifCallRpc(&mouseif, PS2MOUSE_GETVERSION, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
227int PS2MouseSetDblClickTime(u32 msec)
232 if (SifCallRpc(&mouseif, PS2MOUSE_SETDBLCLICKTIME, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
238u32 PS2MouseGetDblClickTIme()
241 u32* uncached = (u32 *) UNCACHED_SEG(&buffer.time);
243 if (SifCallRpc(&mouseif, PS2MOUSE_GETDBLCLICKTIME, 0, &buffer, 128, &buffer, 128, NULL, NULL) < 0)
int PS2MouseRead(PS2MouseData *data)
int PS2MouseSetReadMode(u32 readMode)
u32 PS2MouseGetReadMode()