Subversion Repositories group.electronics

Rev

Rev 36 | Rev 39 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36 Rev 37
Line 39... Line 39...
39
volatile uint8_t pcIntMask[3] = {0,0,0};
39
volatile uint8_t pcIntMask[3] = {0,0,0};
40
 
40
 
41
// rotdata = [rot#][(stat|sent)]
41
// rotdata = [rot#][(stat|sent)]
42
volatile uint8_t rotdata[2][2] = { {0,0}, {0,0} };
42
volatile uint8_t rotdata[2][2] = { {0,0}, {0,0} };
43
 
43
 
44
uint8_t keyMap[] = { 	49, 50, 51,
44
uint8_t keyMap[] = { 	0x1E, 0x1F, 0x20,
45
			52, 53, 54,
45
			0x21, 0x22, 0x23,
46
			55, 56, 57,
46
			0x24, 0x25, 0x26,
47
			56, 48, 52 };
47
			0x20, 0x27, 0x25 };
48
 
48
 
49
struct {
49
struct {
50
	uint8_t report_id;
50
	uint8_t report_id;
51
	uint8_t modifier;
51
	uint8_t modifier;
-
 
52
	uint8_t reserved;
52
	uint8_t keycode;
53
	uint8_t keycode[6];
53
} reportKeyboard;
54
} reportKeyboard;
54
 
55
 
55
struct{
56
struct{
56
	uint8_t report_id;
57
	uint8_t report_id;
57
  union {
58
  union {
Line 151... Line 152...
151
  wdt_enable(WDTO_1S);
152
  wdt_enable(WDTO_1S);
152
  usbInit();
153
  usbInit();
153
  sei();
154
  sei();
154
 
155
 
155
	reportKeyboard.report_id = 1;
156
	reportKeyboard.report_id = 1;
-
 
157
	reportKeyboard.reserved = 0x00;
-
 
158
 
156
	reportJoystick.report_id = 2;
159
	reportJoystick.report_id = 2;
157
 
160
 
-
 
161
 
158
  for(;;) {
162
  for(;;) {
159
    wdt_reset();
163
    wdt_reset();
160
    usbPoll();
164
    usbPoll();
161
 
165
 
162
    if(usbInterruptIsReady()){
166
    if(usbInterruptIsReady()){
163
	reportJoystick.data1[0] = (-128 + analogRead(0));
167
	reportJoystick.data1[0] = (-128 + analogRead(0));
164
	reportJoystick.data1[1] = (-128 + analogRead(1));
168
	reportJoystick.data1[1] = (-128 + analogRead(1));
165
	reportJoystick.data2 = 0x0000;				// Clear all the buttons
169
	reportJoystick.data2 = 0x0000;				// Clear all the buttons
166
 
170
 
167
	reportKeyboard.keycode = 0x00;
-
 
168
	reportKeyboard.modifier = 0x00;
171
	reportKeyboard.modifier = 0x00;
-
 
172
	reportKeyboard.keycode[0] = 0x00;
169
 
173
 
170
	uint8_t key = getKey();
174
	uint8_t key = getKey();
171
	if (rbi(PINB, PB5)) {
175
	if (rbi(PINB, PB5)) {
172
		cbi(PORTD, PD4);
176
		cbi(PORTD, PD4);
173
		// Keypad is joystick
177
		// Keypad is joystick
Line 176... Line 180...
176
	} else {
180
	} else {
177
		sbi(PORTD, PD4);
181
		sbi(PORTD, PD4);
178
		// Keypad is keyboard
182
		// Keypad is keyboard
179
		if (key > 0) {
183
		if (key > 0) {
180
			key--;
184
			key--;
181
			//if (key==10 || key==12)
185
			//if (key==0x20 || key==0x25)
182
			//	reportKeyboard.modifier |= (1<<1);	//Left shif
186
			//	reportKeyboard.modifier |= (1<<1);	//Left shif
183
			//reportKeyboard.keycode = keyMap[key];
187
			//reportKeyboard.keycode = keyMap[key];
184
			reportKeyboard.keycode = 0x30;
188
			reportKeyboard.keycode[0] = 0x30;
185
 
189
 
186
		}
190
		}
187
	}
191
	}
188
 
192
 
189
	// Now work out what rotary to send, if any
193
	// Now work out what rotary to send, if any