ps2: checkpatch fixes

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Helge Deller <deller@gmx.de>
Message-Id: <20220624134109.881989-2-mark.cave-ayland@ilande.co.uk>
This commit is contained in:
Mark Cave-Ayland 2022-06-24 14:40:16 +01:00
parent 40d5224907
commit 545e5cf817

View File

@ -436,8 +436,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
}
}
} else {
if (qcode < qemu_input_map_qcode_to_atset1_len)
if (qcode < qemu_input_map_qcode_to_atset1_len) {
keycode = qemu_input_map_qcode_to_atset1[qcode];
}
if (keycode) {
if (keycode & 0xff00) {
ps2_put_keycode(s, keycode >> 8);
@ -530,8 +531,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
}
}
} else {
if (qcode < qemu_input_map_qcode_to_atset2_len)
if (qcode < qemu_input_map_qcode_to_atset2_len) {
keycode = qemu_input_map_qcode_to_atset2[qcode];
}
if (keycode) {
if (keycode & 0xff00) {
ps2_put_keycode(s, keycode >> 8);
@ -546,8 +548,9 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
}
}
} else if (s->scancode_set == 3) {
if (qcode < qemu_input_map_qcode_to_atset3_len)
if (qcode < qemu_input_map_qcode_to_atset3_len) {
keycode = qemu_input_map_qcode_to_atset3[qcode];
}
if (keycode) {
/* FIXME: break code should be configured on a key by key basis */
if (!key->down) {
@ -569,8 +572,10 @@ uint32_t ps2_read_data(PS2State *s)
trace_ps2_read_data(s);
q = &s->queue;
if (q->count == 0) {
/* NOTE: if no data left, we return the last keyboard one
(needed for EMM386) */
/*
* NOTE: if no data left, we return the last keyboard one
* (needed for EMM386)
*/
/* XXX: need a timer to do things correctly */
index = q->rptr - 1;
if (index < 0) {
@ -700,9 +705,11 @@ void ps2_write_keyboard(void *opaque, int val)
}
}
/* Set the scancode translation mode.
0 = raw scancodes.
1 = translated scancodes (used by qemu internally). */
/*
* Set the scancode translation mode.
* 0 = raw scancodes.
* 1 = translated scancodes (used by qemu internally).
*/
void ps2_keyboard_set_translation(void *opaque, int mode)
{
@ -727,14 +734,16 @@ static int ps2_mouse_send_packet(PS2MouseState *s)
dz1 = s->mouse_dz;
dw1 = s->mouse_dw;
/* XXX: increase range to 8 bits ? */
if (dx1 > 127)
if (dx1 > 127) {
dx1 = 127;
else if (dx1 < -127)
} else if (dx1 < -127) {
dx1 = -127;
if (dy1 > 127)
}
if (dy1 > 127) {
dy1 = 127;
else if (dy1 < -127)
} else if (dy1 < -127) {
dy1 = -127;
}
b = 0x08 | ((dx1 < 0) << 4) | ((dy1 < 0) << 5) | (s->mouse_buttons & 0x07);
ps2_queue_noirq(&s->common, b);
ps2_queue_noirq(&s->common, dx1 & 0xff);
@ -747,10 +756,11 @@ static int ps2_mouse_send_packet(PS2MouseState *s)
s->mouse_dw = 0;
break;
case 3:
if (dz1 > 127)
if (dz1 > 127) {
dz1 = 127;
else if (dz1 < -127)
} else if (dz1 < -127) {
dz1 = -127;
}
ps2_queue_noirq(&s->common, dz1 & 0xff);
s->mouse_dz -= dz1;
s->mouse_dw = 0;
@ -816,8 +826,9 @@ static void ps2_mouse_event(DeviceState *dev, QemuConsole *src,
InputBtnEvent *btn;
/* check if deltas are recorded when disabled */
if (!(s->mouse_status & MOUSE_STATUS_ENABLED))
if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) {
return;
}
switch (evt->type) {
case INPUT_EVENT_KIND_REL:
@ -868,8 +879,10 @@ static void ps2_mouse_sync(DeviceState *dev)
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
}
if (!(s->mouse_status & MOUSE_STATUS_REMOTE)) {
/* if not remote, send event. Multiple events are sent if
too big deltas */
/*
* if not remote, send event. Multiple events are sent if
* too big deltas
*/
while (ps2_mouse_send_packet(s)) {
if (s->mouse_dx == 0 && s->mouse_dy == 0
&& s->mouse_dz == 0 && s->mouse_dw == 0) {
@ -983,25 +996,29 @@ void ps2_write_mouse(void *opaque, int val)
switch (s->mouse_detect_state) {
default:
case 0:
if (val == 200)
if (val == 200) {
s->mouse_detect_state = 1;
}
break;
case 1:
if (val == 100)
if (val == 100) {
s->mouse_detect_state = 2;
else if (val == 200)
} else if (val == 200) {
s->mouse_detect_state = 3;
else
} else {
s->mouse_detect_state = 0;
}
break;
case 2:
if (val == 80)
if (val == 80) {
s->mouse_type = 3; /* IMPS/2 */
}
s->mouse_detect_state = 0;
break;
case 3:
if (val == 80)
if (val == 80) {
s->mouse_type = 4; /* IMEX */
}
s->mouse_detect_state = 0;
break;
}
@ -1159,8 +1176,9 @@ static int ps2_kbd_post_load(void* opaque, int version_id)
PS2KbdState *s = (PS2KbdState *)opaque;
PS2State *ps2 = &s->common;
if (version_id == 2)
if (version_id == 2) {
s->scancode_set = 2;
}
ps2_common_post_load(ps2);