Correction of the up and down error after reload...

This commit is contained in:
Edouard Dupin 2012-02-14 12:09:47 +01:00
parent 7797b52d36
commit 00568fc30f

90
main.c
View File

@ -215,15 +215,48 @@ int main (int argc, char**argv)
{ {
int32_t inputValue; int32_t inputValue;
inputValue = getc(stdin); inputValue = getc(stdin);
if (inputValue == 0x1b) { switch(inputValue)
// mose event : {
int32_t val2 = getc(stdin); case 'q':
int32_t val3 = getc(stdin); case 'Q':
int32_t val4 = getc(stdin); goto exit_programme;
int32_t val5 = getc(stdin); break;
int32_t val6 = getc(stdin); //case 0x1B:
case '\e':
inputValue = getc (stdin);
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
// [ == 0x5B
if (inputValue == '[')
{
inputValue = getc (stdin);
char charValue = inputValue;
// printf("\n get data : 0x%08x ..... : \\e[%c\n", (unsigned int)inputValue, charValue);
if ( charValue == 'A' //0x41 ==> UP
|| charValue == 'B' //0x42 ==> DOWN
|| charValue == 'C' //0x43 ==> RIGHT
|| charValue == 'D' //0x44 ==> LEFT
)
{
//printf("\n get data :\\e[%c ==> MoveKey \n", charValue);
if (charValue == 'A') {
upDownOfsetFile(-5);
} else if ( charValue == 'B') {
upDownOfsetFile(5);
} else if ( charValue == 'C') {
upDownOfsetFile((GetNumberOfRaw()-NB_HEARDER_RAW));
} else if ( charValue == 'D') {
upDownOfsetFile(-(GetNumberOfRaw()-NB_HEARDER_RAW));
}
} else if (charValue == 'M' ) { //0x4d ==> mouse
//printf("\n get data :\\e[%c ==> Mouse \n", charValue);
int32_t button = getc(stdin);
int32_t xPos = getc(stdin);
xPos -= 0x20;
int32_t yPos = getc(stdin);
yPos -= 0x20;
int32_t bt=0; int32_t bt=0;
switch (val4) { switch (button) {
case 97: case 97:
bt = 4; bt = 4;
break; break;
@ -237,51 +270,16 @@ int main (int argc, char**argv)
bt = 3; bt = 3;
break; break;
} }
//printf("\n mouse event : %d, %d, %d, %d=%d x=%d y=%d\n", inputValue, val2, val3, val4, bt, val5-33, val6-33); //printf(" bt=%#x=%d \n", button, bt);
(void)val2; //printf(" x=%d y=%d\n", xPos, yPos);
(void)val3;
(void)val4;
(void)val5;
(void)val6;
if (bt == 4) { if (bt == 4) {
upDownOfsetFile(5); upDownOfsetFile(5);
} else if (bt == 5) { } else if (bt == 5) {
upDownOfsetFile(-5); upDownOfsetFile(-5);
} }
inputValue = 0;
} else {
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
}
switch(inputValue)
{
case 'q':
case 'Q':
goto exit_programme;
break;
//case 0x1B:
case '\e':
inputValue = getc (stdin);
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
if (inputValue == 0x5B)
{
inputValue = getc (stdin);
//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
if ( inputValue == 0x41
|| inputValue == 0x42
|| inputValue == 0x43
|| inputValue == 0x44)
{
if (inputValue == 0x41) {
upDownOfsetFile(-5);
} else if ( inputValue == 0x42) {
upDownOfsetFile(5);
} else if ( inputValue == 0x43) {
upDownOfsetFile((GetNumberOfRaw()-NB_HEARDER_RAW));
} else if ( inputValue == 0x44) {
upDownOfsetFile(-(GetNumberOfRaw()-NB_HEARDER_RAW));
}
} }
} }
break; break;
// change the type of interpretation the file // change the type of interpretation the file
case 't': case 't':