Make SwScaler recognize RGB48 BE/LE colourspaces (not support though).
[mplayer/glamo.git] / osdep / getch2-os2.c
blobabb7f2e6acc56a42557debc8a23688c3e4d91adf
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>
30 #include "config.h"
31 #include "keycodes.h"
32 #include "input/input.h"
33 #include "mp_fifo.h"
35 #if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV)
36 #include <locale.h>
37 #include <langinfo.h>
38 #endif
40 int mp_input_slave_cmd_func( int fd, char *dest, int size )
42 PPIB ppib;
43 CHAR szPipeName[ 100 ];
44 HFILE hpipe;
45 ULONG ulAction;
46 ULONG cbActual;
47 ULONG rc;
49 DosGetInfoBlocks( NULL, &ppib );
51 sprintf( szPipeName, "\\PIPE\\MPLAYER\\%lx", ppib->pib_ulpid );
53 rc = DosOpen( szPipeName, &hpipe, &ulAction, 0, FILE_NORMAL,
54 OPEN_ACTION_OPEN_IF_EXISTS,
55 OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE,
56 NULL );
57 if( rc )
58 return MP_INPUT_NOTHING;
60 rc = DosRead( hpipe, dest, size, &cbActual );
61 if( rc )
62 return MP_INPUT_NOTHING;
64 rc = cbActual;
66 // Send ACK
67 DosWrite( hpipe, &rc, sizeof( ULONG ), &cbActual );
69 DosClose( hpipe );
71 return rc;
75 int screen_width = 80;
76 int screen_height = 24;
77 char *erase_to_end_of_line = NULL;
79 void get_screen_size( void )
81 VIOMODEINFO vmi;
83 vmi.cb = sizeof( VIOMODEINFO );
85 VioGetMode( &vmi, 0 );
87 screen_width = vmi.col;
88 screen_height = vmi.row;
91 static int getch2_status = 0;
93 static int getch2_internal( void )
95 KBDKEYINFO kki;
97 if( !getch2_status )
98 return -1;
100 if( KbdCharIn( &kki, IO_NOWAIT, 0 ))
101 return -1;
103 // key pressed ?
104 if( kki.fbStatus )
106 // extended key ?
107 if(( kki.chChar == 0x00 ) || ( kki.chChar == 0xE0 ))
109 switch( kki.chScan )
111 case 0x4B : // Left
112 return KEY_LEFT;
114 case 0x48 : // Up
115 return KEY_UP;
117 case 0x4D : // Right
118 return KEY_RIGHT;
120 case 0x50 : // Down
121 return KEY_DOWN;
123 case 0x53 : // Delete
124 return KEY_DELETE;
126 case 0x52 : // Insert
127 return KEY_INSERT;
129 case 0x47 : // Home
130 return KEY_HOME;
132 case 0x4F : // End
133 return KEY_END;
135 case 0x49 : // Page Up
136 return KEY_PAGE_UP;
138 case 0x51 : // Page Down
139 return KEY_PAGE_DOWN;
142 else
144 switch( kki.chChar )
146 case 0x08 : // Backspace
147 return KEY_BS;
149 case 0x1B : // Esc
150 return KEY_ESC;
152 case 0x0D : // Enter
153 // Keypad Enter ?
154 if( kki.chScan == 0xE0 )
155 return KEY_KPENTER;
156 break;
159 return kki.chChar;
163 return -1;
166 void getch2( void )
168 int key;
170 key = getch2_internal();
171 if( key != -1 )
172 mplayer_put_key( key );
175 void getch2_enable( void )
177 getch2_status = 1;
180 void getch2_disable( void )
182 getch2_status = 0;
185 #ifdef CONFIG_ICONV
186 char *get_term_charset( void )
188 char *charset = NULL;
190 #ifdef HAVE_LANGINFO
191 setlocale( LC_CTYPE, "");
192 charset = nl_langinfo( CODESET );
193 setlocale( LC_CTYPE, "C");
194 #endif
196 return charset;
198 #endif