Revision f255c38f

View differences:

MatrixScan.c
36 36
	// push initial 1
37 37
	pushBit(1);
38 38
	pushBit(0); // to get the 1 on the first output
39
	// set afterglow before we miss it later in case of ghosting
40
	ReportData->Modifier |= modAfterglow;
41
	modAfterglow = 0;
39 42
	// scan matrix
40 43
	uint8_t pressedKeys = 0;
41 44
	for(uint8_t i = 0; i < 19; i++){
......
44 47
		pushBit(0);
45 48
	}
46 49
	// check for ghosting
47
	uint8_t pacman = 0; // he'll eat the ghost
48
	for(uint8_t i = 0; i < 19; i++){
50
	for(uint8_t i = 0; i < 19-1; i++){
49 51
		if(matrixState[i] != 0){
50
			if(matrixState[i] == pacman &&
51
				((pacman == (1<<0)) ||
52
				 (pacman == (1<<1)) ||
53
				 (pacman == (1<<2)) ||
54
				 (pacman == (1<<3)) ||
55
				 (pacman == (1<<4)) ||
56
				 (pacman == (1<<5)) ||
57
				 (pacman == (1<<6)) ||
58
				 (pacman == (1<<7)))){
59
				 continue;
60
			}
61
			if(((matrixState[i] & pacman) != 0)){
62
					return; // ghost found
52
			for(uint8_t j = i+1; j < 19; j++){
53
				if(matrixState[i] == matrixState[j] && !((matrixState[i] == (1<<0)) ||
54
				 (matrixState[i] == (1<<1)) ||
55
				 (matrixState[i] == (1<<2)) ||
56
				 (matrixState[i] == (1<<3)) ||
57
				 (matrixState[i] == (1<<4)) ||
58
				 (matrixState[i] == (1<<5)) ||
59
				 (matrixState[i] == (1<<6)) ||
60
				 (matrixState[i] == (1<<7)))){
61
				 return; // ghosting found
62
				}
63 63
			}
64
			pacman |= matrixState[i];
65 64
		}
66 65
	}
67 66
	// check for mods
......
114 113
		}
115 114
	}
116 115
	// build report
117
	ReportData->Modifier |= modAfterglow;
118
	modAfterglow = 0;
119 116
	for(uint8_t i = 0; i < 19; i++){
120 117
		if(matrixState[i] != 0){
121 118
			for(uint8_t bit = 0; bit < 8; bit++){

Also available in: Unified diff