-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcursorpos.c
More file actions
67 lines (61 loc) · 1.48 KB
/
cursorpos.c
File metadata and controls
67 lines (61 loc) · 1.48 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "cursorpos.h"
int cursorpos_copy(CursorPos* prDest, CursorPos* prSrc) {
if (prDest == NULL || prSrc == NULL) {
return CURSORPOS_NULLPTR;
}
prDest->x = prSrc->x;
prDest->y = prSrc->y;
return CURSORPOS_SUCCESS;
}
int cursorpos_init(CursorPos* prPos) {
if (prPos == NULL) {
return CURSORPOS_NULLPTR;
}
prPos->x = 0;
prPos->y = 0;
return CURSORPOS_SUCCESS;
}
int cursorpos_read(CursorPos* prPos, SceUID fd) {
int r = 0;
if (prPos == NULL) {
return CURSORPOS_NULLPTR;
}
if (fd < 0) {
return CURSORPOS_IOERROR;
}
r = sceIoRead(fd, &prPos->x, sizeof(int));
if (r != sizeof(int)) {
return CURSORPOS_IOERROR;
}
r = sceIoRead(fd, &prPos->y, sizeof(int));
if (r != sizeof(int)) {
return CURSORPOS_IOERROR;
}
return CURSORPOS_SUCCESS;
}
int cursorpos_set(CursorPos* prPos, int x, int y) {
if (prPos == NULL) {
return CURSORPOS_NULLPTR;
}
prPos->x = x;
prPos->y = y;
return CURSORPOS_SUCCESS;
}
int cursorpos_write(CursorPos* prPos, SceUID fd) {
int r = 0;
if (prPos == NULL) {
return CURSORPOS_NULLPTR;
}
if (fd < 0) {
return CURSORPOS_IOERROR;
}
r = sceIoWrite(fd, &prPos->x, sizeof(int));
if (r != sizeof(int)) {
return CURSORPOS_IOERROR;
}
r = sceIoWrite(fd, &prPos->y, sizeof(int));
if (r != sizeof(int)) {
return CURSORPOS_IOERROR;
}
return CURSORPOS_SUCCESS;
}