Index: embios/trunk/button.c |
— | — | @@ -76,6 +76,7 @@ |
77 | 77 |
|
78 | 78 | void button_send_event(enum button_event eventtype, int which, int value)
|
79 | 79 | {
|
| 80 | + DEBUGF("Sending button event: %d, %02X, %02X", eventtype, which, value);
|
80 | 81 | int i;
|
81 | 82 | for (i = 0; i < BUTTON_MAX_HOOKS; i++)
|
82 | 83 | if (button_hooks[i].owner != NULL)
|
Index: embios/trunk/target/ipodnano2g/clickwheel.c |
— | — | @@ -49,9 +49,11 @@ |
50 | 50 | while (true)
|
51 | 51 | {
|
52 | 52 | wakeup_wait(&clickwheel_wakeup, TIMEOUT_BLOCK);
|
| 53 | + DEBUGF("Got clickwheel packet");
|
53 | 54 | uint32_t mode = enter_critical_section();
|
54 | 55 | uint32_t data = clickwheel_packet;
|
55 | 56 | leave_critical_section(mode);
|
| 57 | + DEBUGF("Acquired clickwheel packet: %08X", data);
|
56 | 58 | if ((data & 0x800000FF) == 0x8000001A)
|
57 | 59 | {
|
58 | 60 | int newbuttons = (data >> 8) & 0x1f;
|
— | — | @@ -58,7 +60,10 @@ |
59 | 61 | int newpos = (data >> 16) & 0xff;
|
60 | 62 | bool newtouched = (data & 0x40000000) ? true : false;
|
61 | 63 |
|
| 64 | + DEBUGF("This is a change packet, button state: %02X, position: %02d, touched: %d",
|
| 65 | + newbuttons, newpos, newtouched);
|
62 | 66 | int buttonschanged = oldbuttons ^ newbuttons;
|
| 67 | + DEBUGF("Changed buttons: %02X", buttonschanged);
|
63 | 68 | for (i = 0; i < 5; i++)
|
64 | 69 | if ((buttonschanged >> i) & 1)
|
65 | 70 | {
|
— | — | @@ -71,21 +76,35 @@ |
72 | 77 | if (!oldtouched) button_send_event(WHEEL_TOUCH, 0, newpos);
|
73 | 78 | button_send_event(WHEEL_POSITION, 0, newpos);
|
74 | 79 | int distance = newpos - oldpos;
|
75 | | - if (TIMEOUT_EXPIRED(lastpacket, 200000) || lastdiff * distance < 0) packets = 10;
|
| 80 | + DEBUGF("Time since last packet: %d microseconds", USEC_TIMER - lastpacket);
|
| 81 | + if (TIMEOUT_EXPIRED(lastpacket, 200000))
|
| 82 | + {
|
| 83 | + DEBUGF("Resetting accel due to timeout");
|
| 84 | + packets = 10;
|
| 85 | + }
|
| 86 | + else if (lastdiff * distance < 0)
|
| 87 | + {
|
| 88 | + DEBUGF("Resetting accel due to direction change");
|
| 89 | + packets = 10;
|
| 90 | + }
|
76 | 91 | else packets++;
|
77 | 92 | lastdiff = distance;
|
78 | 93 | if (packets > 200) packets = 200;
|
79 | 94 | if (distance < -48) distance += 96;
|
80 | 95 | else if (distance > 48) distance -= 96;
|
| 96 | + DEBUGF("Wheel moved %d units without accel", distance);
|
| 97 | + DEBUGF("Wheel moved %d units with accel", distance * packets);
|
| 98 | + button_send_event(WHEEL_MOVED, 0, distance);
|
81 | 99 | collect += distance * packets;
|
82 | | - button_send_event(WHEEL_MOVED, 0, distance);
|
83 | 100 | enum button_event e = collect > 0 ? WHEEL_FORWARD : WHEEL_BACKWARD;
|
84 | 101 | int data = (collect > 0 ? collect : -collect) / 128;
|
85 | 102 | if (data) button_send_event(e, 0, data);
|
86 | 103 | collect %= 128;
|
| 104 | + DEBUGF("Wheel moved %d steps (%d left)", data, collect);
|
87 | 105 | }
|
88 | 106 | else if (oldtouched)
|
89 | 107 | {
|
| 108 | + DEBUGF("Wheel was untouched");
|
90 | 109 | button_send_event(WHEEL_POSITION, 0, newpos);
|
91 | 110 | button_send_event(WHEEL_UNTOUCH, 0, newpos);
|
92 | 111 | collect = 0;
|
— | — | @@ -98,8 +117,11 @@ |
99 | 118 | oldtouched = newtouched;
|
100 | 119 | lastpacket = USEC_TIMER;
|
101 | 120 | }
|
102 | | - else if ((data & 0x8000FFFF) == 0x8000023A && (data & 0x1F0000))
|
103 | | - oldbuttons = (data >> 16) & 0x1F;
|
| 121 | + else if ((data & 0x8000FFFF) == 0x8000023A)
|
| 122 | + {
|
| 123 | + if (data & 0x1F0000) oldbuttons = (data >> 16) & 0x1F;
|
| 124 | + DEBUGF("This is an init packet, button state: %02X", oldbuttons);
|
| 125 | + }
|
104 | 126 | }
|
105 | 127 | }
|
106 | 128 |
|