demux-ts: fix TS files with MP4 ES AAC descriptor
[mplayer/glamo.git] / osdep / getch2-os2.c
blob27ebfaa354a5af95369f7340a193e9b7c296c6e7
1 /*
2 * OS/2 TermIO
4 * Copyright (c) 2007 KO Myung-Hun (komh@chollian.net)
6 * This file is part of MPlayer.
8 * MPlayer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * MPlayer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #define INCL_KBD
24 #define INCL_VIO
25 #define INCL_DOS
26 #include <os2.h>
28 #include <stdio.h>
29 #include <string.h>
31 #include "config.h"
32 #include "keycodes.h"
33 #include "input/input.h"
34 #include "mp_fifo.h"
35 #include "getch2.h"
37 #if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV)
38 #include <locale.h>
39 #include <langinfo.h>
40 #endif
42 int mp_input_slave_cmd_func( int fd, char *dest, int size )
44 PPIB ppib;
45 CHAR szPipeName[ 100 ];
46 HFILE hpipe;
47 ULONG ulAction;
48 ULONG cbActual;
49 ULONG rc;
51 DosGetInfoBlocks( NULL, &ppib );
53 sprintf( szPipeName, "\\PIPE\\MPLAYER\\%lx", ppib->pib_ulpid );
55 rc = DosOpen( szPipeName, &hpipe, &ulAction, 0, FILE_NORMAL,
56 OPEN_ACTION_OPEN_IF_EXISTS,
57 OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE,
58 NULL );
59 if( rc )
60 return MP_INPUT_NOTHING;
62 rc = DosRead( hpipe, dest, size, &cbActual );
63 if( rc )
64 return MP_INPUT_NOTHING;
66 rc = cbActual;
68 // Send ACK
69 DosWrite( hpipe, &rc, sizeof( ULONG ), &cbActual );
71 DosClose( hpipe );
73 return rc;
77 int screen_width = 80;
78 int screen_height = 24;
79 char *erase_to_end_of_line = NULL;
81 void get_screen_size( void )
83 VIOMODEINFO vmi;
85 vmi.cb = sizeof( VIOMODEINFO );
87 VioGetMode( &vmi, 0 );
89 screen_width = vmi.col;
90 screen_height = vmi.row;
93 static int getch2_status = 0;
95 static int getch2_internal( void )
97 KBDKEYINFO kki;
99 if( !getch2_status )
100 return -1;
102 if( KbdCharIn( &kki, IO_NOWAIT, 0 ))
103 return -1;
105 // key pressed ?
106 if( kki.fbStatus )
108 // extended key ?
109 if(( kki.chChar == 0x00 ) || ( kki.chChar == 0xE0 ))
111 switch( kki.chScan )
113 case 0x4B : // Left
114 return KEY_LEFT;
116 case 0x48 : // Up
117 return KEY_UP;
119 case 0x4D : // Right
120 return KEY_RIGHT;
122 case 0x50 : // Down
123 return KEY_DOWN;
125 case 0x53 : // Delete
126 return KEY_DELETE;
128 case 0x52 : // Insert
129 return KEY_INSERT;
131 case 0x47 : // Home
132 return KEY_HOME;
134 case 0x4F : // End
135 return KEY_END;
137 case 0x49 : // Page Up
138 return KEY_PAGE_UP;
140 case 0x51 : // Page Down
141 return KEY_PAGE_DOWN;
144 else
146 switch( kki.chChar )
148 case 0x08 : // Backspace
149 return KEY_BS;
151 case 0x1B : // Esc
152 return KEY_ESC;
154 case 0x0D : // Enter
155 // Keypad Enter ?
156 if( kki.chScan == 0xE0 )
157 return KEY_KPENTER;
158 break;
161 return kki.chChar;
165 return -1;
168 void getch2(struct mp_fifo *fifo)
170 int key;
172 key = getch2_internal();
173 if( key != -1 )
174 mplayer_put_key(fifo, key);
177 void getch2_enable( void )
179 getch2_status = 1;
182 void getch2_disable( void )
184 getch2_status = 0;
187 #ifdef CONFIG_ICONV
188 char *get_term_charset( void )
190 char *charset = NULL;
192 #ifdef HAVE_LANGINFO
193 setlocale( LC_CTYPE, "");
194 charset = strdup( nl_langinfo( CODESET ));
195 setlocale( LC_CTYPE, "C");
196 #endif
198 return charset;
200 #endif