Merge remote-tracking branch 'tmk/master'

This commit is contained in:
Mark Sikora 2023-03-06 11:04:30 -05:00
commit 8435c70fef
13 changed files with 3723 additions and 3818 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -132,9 +132,11 @@ int16_t IBMPCConverter::read_wait(uint16_t wait_ms)
* Keyboard ID
*
* 0000: IBM 84-key keyboard
* FFFF: XT keyobard
* FFFF: No keyboard or XT
* FFFE: Broken AT or PS/2 keyboard?
* FFFD: Zenith Z-150 AT
* FFFC: IBM XT
* FFFB: Clone XT
* AB83: AT or PS/2 keyboard
* BFBF: IBM Terminal keyboard
* 00FF: Mouse
@ -149,17 +151,21 @@ uint16_t IBMPCConverter::read_keyboard_id(void)
// https://deskthority.net/viewtopic.php?p=495196#p495196
if (ibmpc.protocol == IBMPC_PROTOCOL_AT_Z150) return 0xFFFD;
// XT doesn't response
if (ibmpc.protocol == IBMPC_PROTOCOL_XT_IBM) return 0xFFFC;
if (ibmpc.protocol == IBMPC_PROTOCOL_XT_CLONE) return 0xFFFB;
// Disable
//code = ibmpc_host_send(0xF5);
// Read ID
code = ibmpc.host_send(0xF2);
if (code == -1) { id = 0xFFFF; goto DONE; } // XT or No keyboard
if (code == -1) { id = 0xFFFF; goto DONE; } // No keyboard or XT
if (code != 0xFA) { id = 0xFFFE; goto DONE; } // Broken PS/2?
// ID takes 500ms max TechRef [8] 4-41
code = read_wait(500);
if (code == -1) { id = 0x0000; goto DONE; } // AT
if (code == -1) { id = 0x0000; goto DONE; } // AT IBM 84-key
id = (code & 0xFF)<<8;
// Mouse responds with one-byte 00, this returns 00FF [y] p.14
@ -322,12 +328,16 @@ uint8_t IBMPCConverter::process_interface(void)
if (0x0000 == keyboard_id) { // CodeSet2 AT(IBM PC AT 84-key)
keyboard_kind = PC_AT;
} else if (0xFFFF == keyboard_id) { // CodeSet1 XT
} else if (0xFFFF == keyboard_id) { // No keyboard or XT
keyboard_kind = PC_XT;
} else if (0xFFFE == keyboard_id) { // CodeSet2 PS/2 fails to response?
keyboard_kind = PC_AT;
} else if (0xFFFD == keyboard_id) { // Zenith Z-150 AT
keyboard_kind = PC_AT;
} else if (0xFFFC == keyboard_id) { // IBM XT
keyboard_kind = PC_XT;
} else if (0xFFFB == keyboard_id) { // Clone XT
keyboard_kind = PC_XT;
} else if (0x00FF == keyboard_id) { // Mouse is not supported
keyboard_kind = PC_MOUSE;
} else if (0xAB85 == keyboard_id || // IBM 122-key Model M, NCD N-97
@ -904,6 +914,7 @@ uint8_t IBMPCConverter::cs2_e0code(uint8_t code) {
case 0x72: return 0x3F; // cursor down
case 0x74: return 0x47; // cursor right
case 0x75: return 0x4F; // cursor up
case 0x77: return 0x00; // Unicomp New Model M Pause/Break key fix
case 0x7A: return 0x56; // page down
case 0x7D: return 0x5E; // page up
case 0x7C: return 0x7F; // Print Screen

View file

@ -16,10 +16,13 @@ typedef enum { NONE, PC_XT, PC_AT, PC_TERMINAL, PC_MOUSE } keyboard_kind_t;
kind == PC_MOUSE ? "MOUSE" : \
"NONE")
#define ID_STR(id) (id == 0xFFFE ? "_????" : \
#define ID_STR(id) (id == 0xFFFF ? "_NONE" : \
(id == 0xFFFE ? "_ERROR" : \
(id == 0xFFFD ? "_Z150" : \
(id == 0x0000 ? "_AT84" : \
"")))
(id == 0xFFFC ? "_IBM" : \
(id == 0xFFFB ? "_CLONE" : \
(id == 0x0000 ? "_IBM84" : \
""))))))
#define ROW(code) ((code>>4)&0x07)
#define COL(code) (code&0x0F)

View file

@ -95,6 +95,17 @@ SRC += next_kbd.c
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)
# Suspend mode:
# Mode Power consumption RemoteWakeup Replug during suspend
# -----------------------------------------------------------------------------------
# STANDBY 10mA NG OK
# POWER_DOWN 10mA OK OK
# IDLE 23mA OK OK
# NOPOWERSAVE 23mA OK OK
# NO_POWER_DOWN 23mA OK OK
# RemoteWakeup does not work with STANDBY due to NeXT query&response protocol.
# Use Power Down mode(default).
#OPT_DEFS += -DSUSPEND_MODE_STANDBY
include $(TMK_DIR)/protocol.mk
include $(TMK_DIR)/protocol/lufa.mk

View file

@ -1,4 +1,9 @@
TARGET = next_usb_unimap
UNIMAP_ENABLE = yes
KEYMAP_SECTION_ENABLE = yes
# LUFA debug print enabled temporarily for this issue:
# https://github.com/tmk/tmk_keyboard/issues/753
TMK_LUFA_DEBUG = yes
include Makefile

File diff suppressed because it is too large Load diff

View file

@ -76,8 +76,6 @@ static bool is_modified = false;
#define NEXT_KBD_PWR_READ (NEXT_KBD_PWR_PIN&(1<<NEXT_KBD_PWR_BIT))
static bool power_state = false;
/* intialize matrix for scanning. should be called once. */
void matrix_init(void)
{
@ -94,10 +92,7 @@ void matrix_init(void)
NEXT_KBD_LED1_ON;
NEXT_KBD_PWR_DDR &= ~(1<<NEXT_KBD_PWR_BIT); // Power Button pin to input
NEXT_KBD_PWR_PIN |= (1<<NEXT_KBD_PWR_BIT); // KBD_PWR pull up
power_state = NEXT_KBD_PWR_READ ? false : true;
dprintf("Initial power button state: %b\n", power_state);
NEXT_KBD_PWR_PORT |= (1<<NEXT_KBD_PWR_BIT); // KBD_PWR pull up
next_kbd_init();
@ -155,20 +150,8 @@ uint8_t matrix_scan(void)
if (!NEXT_KBD_PWR_READ) {
matrix_make(NEXT_KBD_PWR_KEYCODE);
power_state = 1;
if (is_modified)
{
dprintf("Power state 1\n");
}
} else {
matrix_break(NEXT_KBD_PWR_KEYCODE);
power_state = 0;
if (is_modified)
{
dprintf("Power state 0\n");
}
}
uint32_t resp = (next_kbd_recv());
@ -187,6 +170,7 @@ uint8_t matrix_scan(void)
);
#endif
/*
dprintf("[ r=%04lX keycode=%02X pressed=%X CTRL=%X SHIFT_LEFT=%X SHIFT_RGHT=%X CMD_LEFT=%X CMD_RGHT=%X ALT_LEFT=%X ALT_RGHT=%X ]\n", \
resp, \
NEXT_KBD_KEYCODE(resp), \
@ -199,6 +183,7 @@ uint8_t matrix_scan(void)
NEXT_KBD_PRESSED_ALT_LEFT(resp), \
NEXT_KBD_PRESSED_ALT_RGHT(resp) \
);
*/
// Modifier keys don't return keycode; have to check the upper bits
NEXT_KBD_MAKE_OR_BREAK(ALT_RGHT, 0x51);
@ -226,6 +211,7 @@ static void matrix_make(uint8_t code)
if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= 1<<COL(code);
is_modified = true;
dprintf("%02X ", code);
}
}
@ -235,5 +221,6 @@ static void matrix_break(uint8_t code)
if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
dprintf("%02X ", code | 0x80);
}
}

View file

@ -449,6 +449,11 @@ void register_code(uint8_t code)
else if IS_CONSUMER(code) {
host_consumer_send(KEYCODE2CONSUMER(code));
}
else if (code == KC_BOOTLOADER) {
clear_keyboard();
wait_ms(50);
bootloader_jump();
}
}
void unregister_code(uint8_t code)

View file

@ -142,9 +142,11 @@ RETRY:
#ifdef SIEMENS_PCD_SUPPORT
// inhibit - https://github.com/tmk/tmk_keyboard/issues/747
wait_us(15);
clock_lo();
wait_us(150);
if (protocol & IBMPC_PROTOCOL_AT) {
wait_us(15);
clock_lo();
wait_us(150);
}
#endif
// clear buffer to get response correctly
@ -369,9 +371,11 @@ void IBMPC::isr(void)
DONE:
#ifdef SIEMENS_PCD_SUPPORT
// inhibit - https://github.com/tmk/tmk_keyboard/issues/747
clock_lo();
wait_us(150);
clock_hi();
if (protocol & IBMPC_PROTOCOL_AT) {
clock_lo();
wait_us(150);
clock_hi();
}
#endif
// store data

View file

@ -51,7 +51,7 @@ TMK_LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_E
TMK_LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8
TMK_LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1
# Remote wakeup fix for ATmega32U2 https://github.com/tmk/tmk_keyboard/issues/361
ifeq ($(MCU),atmega32u2)
ifeq (atmega32u2,$(strip $(MCU)))
TMK_LUFA_OPTS += -DNO_LIMITED_CONTROLLER_CONNECT
endif

View file

@ -442,7 +442,7 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearOUT();
Endpoint_ClearStatusStage();
#ifdef TMK_LUFA_DEBUG
xprintf("[L%d]", USB_ControlRequest.wIndex);
xprintf("[L%d %02X]", USB_ControlRequest.wIndex, keyboard_led_stats);
#endif
break;
#endif
@ -488,9 +488,8 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearStatusStage();
keyboard_protocol = (USB_ControlRequest.wValue & 0xFF);
clear_keyboard();
#ifdef TMK_LUFA_DEBUG
print("[P]");
xprintf("[P%d %04X]", USB_ControlRequest.wIndex, USB_ControlRequest.wValue);
#endif
}
#endif
@ -500,7 +499,9 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearStatusStage();
mouse_protocol = (USB_ControlRequest.wValue & 0xFF);
clear_keyboard();
#ifdef TMK_LUFA_DEBUG
xprintf("[P%d %04X]", USB_ControlRequest.wIndex, USB_ControlRequest.wValue);
#endif
}
#endif
}
@ -515,7 +516,7 @@ void EVENT_USB_Device_ControlRequest(void)
keyboard_idle = ((USB_ControlRequest.wValue & 0xFF00) >> 8);
#ifdef TMK_LUFA_DEBUG
xprintf("[I%d]%d", USB_ControlRequest.wIndex, (USB_ControlRequest.wValue & 0xFF00) >> 8);
xprintf("[I%d %04X]", USB_ControlRequest.wIndex, USB_ControlRequest.wValue);
#endif
#endif
}
@ -632,6 +633,12 @@ static void send_system(uint16_t data)
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
#ifdef MOUSE_ENABLE
// Not send while mouse is set to Boot Protocol
if (mouse_protocol == 0)
return;
#endif
report_extra_t r = { .report_id = REPORT_ID_SYSTEM };
if (data < SYSTEM_POWER_DOWN) {
r.usage = 0;
@ -657,6 +664,12 @@ static void send_consumer(uint16_t data)
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
#ifdef MOUSE_ENABLE
// Not send while mouse is set to Boot Protocol
if (mouse_protocol == 0)
return;
#endif
report_extra_t r = {
.report_id = REPORT_ID_CONSUMER,
.usage = data