a geicko-2 based round robin ranking system designed to test c++ battleship submissions battleship.dunkirk.sh
1//go:build windows 2// +build windows 3 4package coninput 5 6import ( 7 "strings" 8 9 "golang.org/x/sys/windows" 10) 11 12// AddInputModes returns the given mode with one or more additional modes enabled. 13func AddInputModes(mode uint32, enableModes ...uint32) uint32 { 14 for _, enableMode := range enableModes { 15 mode |= enableMode 16 } 17 18 return mode 19} 20 21// RemoveInputModes returns the given mode with one or more additional modes disabled. 22func RemoveInputModes(mode uint32, disableModes ...uint32) uint32 { 23 for _, disableMode := range disableModes { 24 mode &^= disableMode 25 } 26 27 return mode 28} 29 30// ToggleInputModes returns the given mode with one or more additional modes toggeled. 31func ToggleInputModes(mode uint32, toggleModes ...uint32) uint32 { 32 for _, toggeMode := range toggleModes { 33 mode ^= toggeMode 34 } 35 36 return mode 37} 38 39var inputModes = []struct { 40 mode uint32 41 name string 42}{ 43 {mode: windows.ENABLE_ECHO_INPUT, name: "ENABLE_ECHO_INPUT"}, 44 {mode: windows.ENABLE_INSERT_MODE, name: "ENABLE_INSERT_MODE"}, 45 {mode: windows.ENABLE_LINE_INPUT, name: "ENABLE_LINE_INPUT"}, 46 {mode: windows.ENABLE_MOUSE_INPUT, name: "ENABLE_MOUSE_INPUT"}, 47 {mode: windows.ENABLE_PROCESSED_INPUT, name: "ENABLE_PROCESSED_INPUT"}, 48 {mode: windows.ENABLE_QUICK_EDIT_MODE, name: "ENABLE_QUICK_EDIT_MODE"}, 49 {mode: windows.ENABLE_WINDOW_INPUT, name: "ENABLE_WINDOW_INPUT"}, 50 {mode: windows.ENABLE_VIRTUAL_TERMINAL_INPUT, name: "ENABLE_VIRTUAL_TERMINAL_INPUT"}, 51} 52 53// ListInputMode returnes the isolated enabled input modes as a list. 54func ListInputModes(mode uint32) []uint32 { 55 modes := []uint32{} 56 57 for _, inputMode := range inputModes { 58 if mode&inputMode.mode > 0 { 59 modes = append(modes, inputMode.mode) 60 } 61 } 62 63 return modes 64} 65 66// ListInputMode returnes the isolated enabled input mode names as a list. 67func ListInputModeNames(mode uint32) []string { 68 modes := []string{} 69 70 for _, inputMode := range inputModes { 71 if mode&inputMode.mode > 0 { 72 modes = append(modes, inputMode.name) 73 } 74 } 75 76 return modes 77} 78 79// DescribeInputMode returns a string containing the names of each enabled input mode. 80func DescribeInputMode(mode uint32) string { 81 return strings.Join(ListInputModeNames(mode), "|") 82}