Mercurial > mplayer.hg
annotate osdep/getch2-os2.c @ 36379:847bc950322a
Support HEVC in native mpeg-ts demuxer.
author | cehoyos |
---|---|
date | Thu, 17 Oct 2013 09:55:57 +0000 |
parents | 160052767c65 |
children |
rev | line source |
---|---|
26016 | 1 /* |
28924
d5d66bff938a
cosmetics: Remove file names from file header, it only causes trouble.
diego
parents:
27393
diff
changeset
|
2 * OS/2 TermIO |
26016 | 3 * |
4 * Copyright (c) 2007 KO Myung-Hun (komh@chollian.net) | |
5 * | |
6 * This file is part of MPlayer. | |
7 * | |
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. | |
12 * | |
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. | |
17 * | |
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. | |
21 */ | |
22 | |
23 #define INCL_KBD | |
24 #define INCL_VIO | |
25 #define INCL_DOS | |
26 #include <os2.h> | |
27 | |
28 #include <stdio.h> | |
29290
ef46d5a66bb2
Use a malloced string for the get_term_charset return value.
reimar
parents:
28924
diff
changeset
|
29 #include <string.h> |
26016 | 30 |
31 #include "config.h" | |
32 #include "keycodes.h" | |
33 #include "input/input.h" | |
34 #include "mp_fifo.h" | |
31199
160052767c65
getch2-os2.c: Add #include for the header that declares the public functions.
diego
parents:
30633
diff
changeset
|
35 #include "getch2.h" |
26016 | 36 |
27393 | 37 #if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV) |
26016 | 38 #include <locale.h> |
39 #include <langinfo.h> | |
40 #endif | |
41 | |
42 int mp_input_slave_cmd_func( int fd, char *dest, int size ) | |
43 { | |
44 PPIB ppib; | |
45 CHAR szPipeName[ 100 ]; | |
46 HFILE hpipe; | |
47 ULONG ulAction; | |
48 ULONG cbActual; | |
49 ULONG rc; | |
50 | |
51 DosGetInfoBlocks( NULL, &ppib ); | |
52 | |
53 sprintf( szPipeName, "\\PIPE\\MPLAYER\\%lx", ppib->pib_ulpid ); | |
54 | |
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; | |
61 | |
62 rc = DosRead( hpipe, dest, size, &cbActual ); | |
63 if( rc ) | |
64 return MP_INPUT_NOTHING; | |
65 | |
66 rc = cbActual; | |
67 | |
68 // Send ACK | |
69 DosWrite( hpipe, &rc, sizeof( ULONG ), &cbActual ); | |
70 | |
71 DosClose( hpipe ); | |
72 | |
73 return rc; | |
74 } | |
75 | |
76 | |
77 int screen_width = 80; | |
78 int screen_height = 24; | |
79 char *erase_to_end_of_line = NULL; | |
80 | |
81 void get_screen_size( void ) | |
82 { | |
83 VIOMODEINFO vmi; | |
84 | |
85 vmi.cb = sizeof( VIOMODEINFO ); | |
86 | |
87 VioGetMode( &vmi, 0 ); | |
88 | |
89 screen_width = vmi.col; | |
90 screen_height = vmi.row; | |
91 } | |
92 | |
93 static int getch2_status = 0; | |
94 | |
95 static int getch2_internal( void ) | |
96 { | |
97 KBDKEYINFO kki; | |
98 | |
99 if( !getch2_status ) | |
100 return -1; | |
101 | |
102 if( KbdCharIn( &kki, IO_NOWAIT, 0 )) | |
103 return -1; | |
104 | |
105 // key pressed ? | |
106 if( kki.fbStatus ) | |
107 { | |
108 // extended key ? | |
109 if(( kki.chChar == 0x00 ) || ( kki.chChar == 0xE0 )) | |
110 { | |
111 switch( kki.chScan ) | |
112 { | |
113 case 0x4B : // Left | |
114 return KEY_LEFT; | |
115 | |
116 case 0x48 : // Up | |
117 return KEY_UP; | |
118 | |
119 case 0x4D : // Right | |
120 return KEY_RIGHT; | |
121 | |
122 case 0x50 : // Down | |
123 return KEY_DOWN; | |
124 | |
125 case 0x53 : // Delete | |
126 return KEY_DELETE; | |
127 | |
128 case 0x52 : // Insert | |
129 return KEY_INSERT; | |
130 | |
131 case 0x47 : // Home | |
132 return KEY_HOME; | |
133 | |
134 case 0x4F : // End | |
135 return KEY_END; | |
136 | |
137 case 0x49 : // Page Up | |
138 return KEY_PAGE_UP; | |
139 | |
140 case 0x51 : // Page Down | |
141 return KEY_PAGE_DOWN; | |
142 } | |
143 } | |
144 else | |
145 { | |
146 switch( kki.chChar ) | |
147 { | |
148 case 0x08 : // Backspace | |
149 return KEY_BS; | |
150 | |
151 case 0x1B : // Esc | |
152 return KEY_ESC; | |
153 | |
154 case 0x0D : // Enter | |
155 // Keypad Enter ? | |
156 if( kki.chScan == 0xE0 ) | |
157 return KEY_KPENTER; | |
158 break; | |
159 } | |
160 | |
161 return kki.chChar; | |
162 } | |
163 } | |
164 | |
165 return -1; | |
166 } | |
167 | |
168 void getch2( void ) | |
169 { | |
170 int key; | |
171 | |
172 key = getch2_internal(); | |
173 if( key != -1 ) | |
174 mplayer_put_key( key ); | |
175 } | |
176 | |
177 void getch2_enable( void ) | |
178 { | |
179 getch2_status = 1; | |
180 } | |
181 | |
182 void getch2_disable( void ) | |
183 { | |
184 getch2_status = 0; | |
185 } | |
186 | |
27393 | 187 #ifdef CONFIG_ICONV |
26016 | 188 char *get_term_charset( void ) |
189 { | |
190 char *charset = NULL; | |
191 | |
27359
d788e177a35e
Rename some preprocessor directives from CONFIG_* to HAVE_* where appropriate;
diego
parents:
27341
diff
changeset
|
192 #ifdef HAVE_LANGINFO |
26016 | 193 setlocale( LC_CTYPE, ""); |
29290
ef46d5a66bb2
Use a malloced string for the get_term_charset return value.
reimar
parents:
28924
diff
changeset
|
194 charset = strdup( nl_langinfo( CODESET )); |
26016 | 195 setlocale( LC_CTYPE, "C"); |
196 #endif | |
197 | |
198 return charset; | |
199 } | |
200 #endif |