annotate osdep/getch2-os2.c @ 33585:1f6ff1848bd3

Remove left-over code from icon/cursor handling that is now done by w32_common.c
author reimar
date Sun, 19 Jun 2011 18:43:07 +0000
parents 160052767c65
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26016
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
1 /*
28924
d5d66bff938a cosmetics: Remove file names from file header, it only causes trouble.
diego
parents: 27393
diff changeset
2 * OS/2 TermIO
26016
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
3 *
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
4 * Copyright (c) 2007 KO Myung-Hun (komh@chollian.net)
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
5 *
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
6 * This file is part of MPlayer.
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
7 *
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
11 * (at your option) any later version.
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
12 *
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
16 * GNU General Public License for more details.
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
17 *
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License along
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
21 */
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
22
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
23 #define INCL_KBD
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
24 #define INCL_VIO
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
25 #define INCL_DOS
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
26 #include <os2.h>
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
27
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
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
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
30
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
31 #include "config.h"
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
32 #include "keycodes.h"
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
33 #include "input/input.h"
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
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
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
36
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27359
diff changeset
37 #if defined(HAVE_LANGINFO) && defined(CONFIG_ICONV)
26016
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
38 #include <locale.h>
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
39 #include <langinfo.h>
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
40 #endif
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
41
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
42 int mp_input_slave_cmd_func( int fd, char *dest, int size )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
43 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
44 PPIB ppib;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
45 CHAR szPipeName[ 100 ];
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
46 HFILE hpipe;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
47 ULONG ulAction;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
48 ULONG cbActual;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
49 ULONG rc;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
50
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
51 DosGetInfoBlocks( NULL, &ppib );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
52
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
53 sprintf( szPipeName, "\\PIPE\\MPLAYER\\%lx", ppib->pib_ulpid );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
54
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
55 rc = DosOpen( szPipeName, &hpipe, &ulAction, 0, FILE_NORMAL,
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
56 OPEN_ACTION_OPEN_IF_EXISTS,
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
57 OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE,
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
58 NULL );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
59 if( rc )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
60 return MP_INPUT_NOTHING;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
61
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
62 rc = DosRead( hpipe, dest, size, &cbActual );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
63 if( rc )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
64 return MP_INPUT_NOTHING;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
65
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
66 rc = cbActual;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
67
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
68 // Send ACK
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
69 DosWrite( hpipe, &rc, sizeof( ULONG ), &cbActual );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
70
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
71 DosClose( hpipe );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
72
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
73 return rc;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
74 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
75
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
76
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
77 int screen_width = 80;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
78 int screen_height = 24;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
79 char *erase_to_end_of_line = NULL;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
80
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
81 void get_screen_size( void )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
82 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
83 VIOMODEINFO vmi;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
84
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
85 vmi.cb = sizeof( VIOMODEINFO );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
86
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
87 VioGetMode( &vmi, 0 );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
88
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
89 screen_width = vmi.col;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
90 screen_height = vmi.row;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
91 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
92
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
93 static int getch2_status = 0;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
94
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
95 static int getch2_internal( void )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
96 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
97 KBDKEYINFO kki;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
98
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
99 if( !getch2_status )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
100 return -1;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
101
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
102 if( KbdCharIn( &kki, IO_NOWAIT, 0 ))
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
103 return -1;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
104
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
105 // key pressed ?
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
106 if( kki.fbStatus )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
107 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
108 // extended key ?
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
109 if(( kki.chChar == 0x00 ) || ( kki.chChar == 0xE0 ))
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
110 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
111 switch( kki.chScan )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
112 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
113 case 0x4B : // Left
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
114 return KEY_LEFT;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
115
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
116 case 0x48 : // Up
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
117 return KEY_UP;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
118
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
119 case 0x4D : // Right
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
120 return KEY_RIGHT;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
121
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
122 case 0x50 : // Down
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
123 return KEY_DOWN;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
124
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
125 case 0x53 : // Delete
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
126 return KEY_DELETE;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
127
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
128 case 0x52 : // Insert
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
129 return KEY_INSERT;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
130
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
131 case 0x47 : // Home
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
132 return KEY_HOME;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
133
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
134 case 0x4F : // End
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
135 return KEY_END;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
136
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
137 case 0x49 : // Page Up
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
138 return KEY_PAGE_UP;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
139
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
140 case 0x51 : // Page Down
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
141 return KEY_PAGE_DOWN;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
142 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
143 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
144 else
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
145 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
146 switch( kki.chChar )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
147 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
148 case 0x08 : // Backspace
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
149 return KEY_BS;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
150
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
151 case 0x1B : // Esc
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
152 return KEY_ESC;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
153
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
154 case 0x0D : // Enter
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
155 // Keypad Enter ?
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
156 if( kki.chScan == 0xE0 )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
157 return KEY_KPENTER;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
158 break;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
159 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
160
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
161 return kki.chChar;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
162 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
163 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
164
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
165 return -1;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
166 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
167
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
168 void getch2( void )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
169 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
170 int key;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
171
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
172 key = getch2_internal();
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
173 if( key != -1 )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
174 mplayer_put_key( key );
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
175 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
176
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
177 void getch2_enable( void )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
178 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
179 getch2_status = 1;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
180 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
181
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
182 void getch2_disable( void )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
183 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
184 getch2_status = 0;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
185 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
186
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27359
diff changeset
187 #ifdef CONFIG_ICONV
26016
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
188 char *get_term_charset( void )
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
189 {
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
190 char *charset = NULL;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
191
27359
d788e177a35e Rename some preprocessor directives from CONFIG_* to HAVE_* where appropriate;
diego
parents: 27341
diff changeset
192 #ifdef HAVE_LANGINFO
26016
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
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
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
195 setlocale( LC_CTYPE, "C");
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
196 #endif
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
197
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
198 return charset;
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
199 }
528bdf17dd8a OS/2 getch2() support
diego
parents:
diff changeset
200 #endif