Skip to content

Commit fc9a3bc

Browse files
mouse test
1 parent 865622d commit fc9a3bc

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

os/programs/drivers/ps2mouse.rrbasic

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ PROCmouse_send(&FF)
1818
PROCmouse_send(&F6)
1919
PROCmouse_send(&F4)
2020

21-
x = 0
22-
y = 0
21+
x = GRAPHICS_WIDTH / 2
22+
y = GRAPHICS_HEIGHT / 2
2323
buttons = 0
24+
25+
MAXX = GRAPHICS_WIDTH - 1
26+
MAXY = GRAPHICS_HEIGHT - 1
27+
2428
DIM pkt,3
2529
idx = 0
2630

@@ -53,6 +57,11 @@ REPEAT
5357
x = x + dx
5458
y = y - dy
5559

60+
IF x < 0 THEN x = 0
61+
IF x > MAXX THEN x = MAXX
62+
IF y < 0 THEN y = 0
63+
IF y > MAXY THEN y = MAXY
64+
5665
buttons = BITAND(b0, 7)
5766

5867
idx = 0

os/programs/mousetest.rrbasic

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CLS
2+
UDPBIND "127.0.0.1", 9999
3+
X = GRAPHICS_WIDTH / 2
4+
Y = GRAPHICS_HEIGHT / 2
5+
GCOL RGB(255,255,0)
6+
POINT X, Y
7+
REPEAT
8+
CURSOR 0, 0
9+
UDPWRITE "127.0.0.1", 9999, 14501, "GET"
10+
PACKET$ = UDPREAD$(9999)
11+
IF PACKET$ <> "" THEN
12+
PRINT PACKET$
13+
X$ = TOKENIZE$(PACKET$, " ")
14+
Y$ = TOKENIZE$(PACKET$, " ")
15+
M$ = TOKENIZE$(PACKET$, " ")
16+
NEW_X = VAL(X$)
17+
NEW_Y = VAL(Y$)
18+
IF NEW_X <> X OR NEW_Y <> Y THEN
19+
GCOL 0
20+
POINT X, Y
21+
M = VAL(M$)
22+
GCOL RGB(255,255,0)
23+
X = NEW_X
24+
Y = NEW_Y
25+
POINT X, Y
26+
ENDIF
27+
ENDIF
28+
UNTIL INKEY$ <> ""
29+
UDPUNBIND "127.0.0.1", 9999

src/basic/sockets.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ static void basic_udp_handle_packet(uint32_t src_ip, uint16_t src_port, uint16_t
258258
packet->data = buddy_strdup(ctx->allocator, data);
259259
packet->ip = buddy_strdup(ctx->allocator, ip);
260260
packet->source_port = src_port;
261-
dprintf("UDPREAD handle packet from %s TO PORT %d SOURCE %d\n", ip, dst_port, src_port);
262261
packet->next = NULL;
263262
uint64_t flags;
264263
lock_spinlock_irq(&udp_read_lock, &flags);
@@ -290,7 +289,6 @@ void udpwrite_statement(struct basic_ctx* ctx) {
290289
tokenizer_error_print(ctx, "Invalid UDP packet length");
291290
}
292291
uint32_t dest = htonl(str_to_ip(dest_ip));
293-
dprintf("UDPWRITE to %08x ON PORT %ld\n", dest, dest_port);
294292
udp_send_packet((uint8_t*)&dest, source_port, dest_port, (void*)data, strlen(data) + 1); // including the NULL terminator
295293
}
296294

@@ -360,6 +358,11 @@ char* basic_udpread(struct basic_ctx* ctx) {
360358
udp_packets[port]->prev = NULL;
361359
}
362360
buddy_free(ctx->allocator, queue);
361+
} else {
362+
ctx->last_packet.ip = buddy_strdup(ctx->allocator, "0.0.0.0");
363+
ctx->last_packet.data = buddy_strdup(ctx->allocator, "");
364+
ctx->last_packet.length = 0;
365+
ctx->last_packet.source_port = 0;
363366
}
364367

365368
unlock_spinlock_irq(&udp_read_lock, flags);

0 commit comments

Comments
 (0)