Mercurial > mplayer.hg
annotate osdep/getch2-os2.c @ 30620:d6f2e0515ad3
Print all 64 bits of seek position.
author | reimar |
---|---|
date | Sat, 20 Feb 2010 11:21:51 +0000 |
parents | ef46d5a66bb2 |
children | 32725ca88fed |
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" | |
35 | |
27393 | 36 #if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV) |
26016 | 37 #include <locale.h> |
38 #include <langinfo.h> | |
39 #endif | |
40 | |
41 int mp_input_slave_cmd_func( int fd, char *dest, int size ) | |
42 { | |
43 PPIB ppib; | |
44 CHAR szPipeName[ 100 ]; | |
45 HFILE hpipe; | |
46 ULONG ulAction; | |
47 ULONG cbActual; | |
48 ULONG rc; | |
49 | |
50 DosGetInfoBlocks( NULL, &ppib ); | |
51 | |
52 sprintf( szPipeName, "\\PIPE\\MPLAYER\\%lx", ppib->pib_ulpid ); | |
53 | |
54 rc = DosOpen( szPipeName, &hpipe, &ulAction, 0, FILE_NORMAL, | |
55 OPEN_ACTION_OPEN_IF_EXISTS, | |
56 OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE, | |
57 NULL ); | |
58 if( rc ) | |
59 return MP_INPUT_NOTHING; | |
60 | |
61 rc = DosRead( hpipe, dest, size, &cbActual ); | |
62 if( rc ) | |
63 return MP_INPUT_NOTHING; | |
64 | |
65 rc = cbActual; | |
66 | |
67 // Send ACK | |
68 DosWrite( hpipe, &rc, sizeof( ULONG ), &cbActual ); | |
69 | |
70 DosClose( hpipe ); | |
71 | |
72 return rc; | |
73 } | |
74 | |
75 | |
76 int screen_width = 80; | |
77 int screen_height = 24; | |
78 char *erase_to_end_of_line = NULL; | |
79 | |
80 void get_screen_size( void ) | |
81 { | |
82 VIOMODEINFO vmi; | |
83 | |
84 vmi.cb = sizeof( VIOMODEINFO ); | |
85 | |
86 VioGetMode( &vmi, 0 ); | |
87 | |
88 screen_width = vmi.col; | |
89 screen_height = vmi.row; | |
90 } | |
91 | |
92 static int getch2_status = 0; | |
93 | |
94 static int getch2_internal( void ) | |
95 { | |
96 KBDKEYINFO kki; | |
97 | |
98 if( !getch2_status ) | |
99 return -1; | |
100 | |
101 if( KbdCharIn( &kki, IO_NOWAIT, 0 )) | |
102 return -1; | |
103 | |
104 // key pressed ? | |
105 if( kki.fbStatus ) | |
106 { | |
107 // extended key ? | |
108 if(( kki.chChar == 0x00 ) || ( kki.chChar == 0xE0 )) | |
109 { | |
110 switch( kki.chScan ) | |
111 { | |
112 case 0x4B : // Left | |
113 return KEY_LEFT; | |
114 | |
115 case 0x48 : // Up | |
116 return KEY_UP; | |
117 | |
118 case 0x4D : // Right | |
119 return KEY_RIGHT; | |
120 | |
121 case 0x50 : // Down | |
122 return KEY_DOWN; | |
123 | |
124 case 0x53 : // Delete | |
125 return KEY_DELETE; | |
126 | |
127 case 0x52 : // Insert | |
128 return KEY_INSERT; | |
129 | |
130 case 0x47 : // Home | |
131 return KEY_HOME; | |
132 | |
133 case 0x4F : // End | |
134 return KEY_END; | |
135 | |
136 case 0x49 : // Page Up | |
137 return KEY_PAGE_UP; | |
138 | |
139 case 0x51 : // Page Down | |
140 return KEY_PAGE_DOWN; | |
141 } | |
142 } | |
143 else | |
144 { | |
145 switch( kki.chChar ) | |
146 { | |
147 case 0x08 : // Backspace | |
148 return KEY_BS; | |
149 | |
150 case 0x1B : // Esc | |
151 return KEY_ESC; | |
152 | |
153 case 0x0D : // Enter | |
154 // Keypad Enter ? | |
155 if( kki.chScan == 0xE0 ) | |
156 return KEY_KPENTER; | |
157 break; | |
158 } | |
159 | |
160 return kki.chChar; | |
161 } | |
162 } | |
163 | |
164 return -1; | |
165 } | |
166 | |
167 void getch2( void ) | |
168 { | |
169 int key; | |
170 | |
171 key = getch2_internal(); | |
172 if( key != -1 ) | |
173 mplayer_put_key( key ); | |
174 } | |
175 | |
176 void getch2_enable( void ) | |
177 { | |
178 getch2_status = 1; | |
179 } | |
180 | |
181 void getch2_disable( void ) | |
182 { | |
183 getch2_status = 0; | |
184 } | |
185 | |
27393 | 186 #ifdef CONFIG_ICONV |
26016 | 187 char *get_term_charset( void ) |
188 { | |
189 char *charset = NULL; | |
190 | |
27359
d788e177a35e
Rename some preprocessor directives from CONFIG_* to HAVE_* where appropriate;
diego
parents:
27341
diff
changeset
|
191 #ifdef HAVE_LANGINFO |
26016 | 192 setlocale( LC_CTYPE, ""); |
29290
ef46d5a66bb2
Use a malloced string for the get_term_charset return value.
reimar
parents:
28924
diff
changeset
|
193 charset = strdup( nl_langinfo( CODESET )); |
26016 | 194 setlocale( LC_CTYPE, "C"); |
195 #endif | |
196 | |
197 return charset; | |
198 } | |
199 #endif | |
200 |