• R/O
  • SSH
  • HTTPS

chnosproject: コミット


コミットメタ情報

リビジョン320 (tree)
日時2012-04-08 16:50:45
作者hikarupsp

ログメッセージ

一応マウス対応。マウスカーソルが動くようになり、MouseInfoウィンドウに情報が表示される。
スクロールマウスにも対応しており、数字の増減だけ一応反応するが、VirtualPC2007での動作が不安定なので、解決する必要がある。

変更サマリ

差分

--- beta/tolset_chn_000/chnos_010/chnos/system.c (revision 319)
+++ beta/tolset_chn_000/chnos_010/chnos/system.c (revision 320)
@@ -451,6 +451,11 @@
451451 return sended_tasks;
452452 }
453453
454+uint System_Sheet_SetParentToVRAM(UI_Sheet *sheet)
455+{
456+ return Sheet_SetParent(sheet, System.Controller.Display->vramsheet);
457+}
458+
454459 //
455460 void System_Check_Memory(void)
456461 {
--- beta/tolset_chn_000/chnos_010/chnos/core.h (revision 319)
+++ beta/tolset_chn_000/chnos_010/chnos/core.h (revision 320)
@@ -212,13 +212,15 @@
212212 uint Memory_Get_FreeSize(IO_MemoryControl ctrl);
213213
214214 /*mouse.c マウス関連*/
215-void Initialise_Mouse(void);
215+IO_MouseControl *Initialise_Mouse(void);
216216 void InterruptHandler2c(uint *esp);
217+void Mouse_Set_ReceiveFIFO(DATA_FIFO32 *fifo, uint data0);
217218 void Mouse_SendCommand(uint cmd);
218219 UI_MouseCursor *MouseCursor_Initialise(UI_Sheet *parent);
219220 uint MouseCursor_Show(UI_MouseCursor *mcursor);
220221 uint MouseCursor_Move_Relative(UI_MouseCursor *mcursor, int rpx, int rpy);
221222 uint MouseCursor_Move_Absolute(UI_MouseCursor *mcursor, int apx, int apy);
223+bool Mouse_Decode(IO_MouseControl *mctrl, uint data);
222224
223225 /*mtask.c マルチタスク関連*/
224226 UI_TaskControl *Initialise_MultiTask_Control(IO_MemoryControl sysmemctrl);
@@ -342,6 +344,7 @@
342344 IO_DisplayControl *System_Display_Get_Controller(void);
343345 uint System_Memory_Get_FreeSize(void);
344346 uint System_TaskControlMessage_Send_AllTask(uint message);
347+uint System_Sheet_SetParentToVRAM(UI_Sheet *sheet);
345348
346349 /*timer.c タイマー関連*/
347350 UI_TimerControl *Initialise_ProgrammableIntervalTimer(void);
--- beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 319)
+++ beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 320)
@@ -8,7 +8,7 @@
88 UI_Task *mytask;
99 uint i;
1010 IO_DisplayControl *disp_ctrl;
11- UI_Sheet *vramsheet, *testsheet, *testsheet2, *sheet_desktop;
11+ UI_Sheet *vramsheet, *testsheet, *sheet_desktop;
1212 UI_Sheet *sheet08, *sheet16, *sheet32;
1313 int x, y;
1414 UI_Timer *timer1, *timer2, *timer3;
@@ -84,18 +84,6 @@
8484 Drawing_Draw_Circle(disp_ctrl->vram, disp_ctrl->xsize, 100, 250, 0xc6c6c6, i);
8585 }
8686
87- testsheet2 = Sheet_Initialise();
88- Sheet_SetBuffer(testsheet2, Null, 128, 64, 8);
89- for(y = 0; y < testsheet2->size.y; y++){
90- for(x = 0; x < testsheet2->size.x; x++){
91- ((uchar *)testsheet2->vram)[y * testsheet2->size.x + x] = y * 2 + x;
92- }
93- }
94- Drawing08_Fill_Rectangle(testsheet2->vram, testsheet2->size.x, 0xc6c6c6, 4, 24, testsheet2->size.x - 4 - 1, testsheet2->size.y - 4 - 1);
95- Drawing08_Put_String(testsheet2->vram, testsheet2->size.x, 4, 4, 0xffffff, "TestSheet2");
96- Sheet_SetParent(testsheet2, vramsheet);
97- Sheet_Show(testsheet2, 2, 80, 80);
98-
9987 testsheet = Sheet_Initialise();
10088 sheet_desktop = Sheet_Initialise();
10189 sheet08 = Sheet_Initialise();
@@ -146,16 +134,16 @@
146134 Sheet_Show(sheet_desktop, 0, 0, 0);
147135
148136 Sheet_SetParent(sheet08, vramsheet);
149- Sheet_Show(sheet08, 3, 20, vramsheet->size.y >> 1);
137+ Sheet_Show(sheet08, 1, 20, vramsheet->size.y >> 1);
150138
151139 Sheet_SetParent(sheet16, vramsheet);
152- Sheet_Show(sheet16, 2, 220, vramsheet->size.y >> 1);
140+ Sheet_Show(sheet16, 1, 220, vramsheet->size.y >> 1);
153141
154142 Sheet_SetParent(sheet32, vramsheet);
155- Sheet_Show(sheet32, 2, 420, vramsheet->size.y >> 1);
143+ Sheet_Show(sheet32, 1, 420, vramsheet->size.y >> 1);
156144
157145 Sheet_SetParent(testsheet, vramsheet);
158- Sheet_Show(testsheet, 4, 10, 10);
146+ Sheet_Show(testsheet, 6, 10, 10);
159147
160148 timer1 = Timer_Initialise();
161149 Timer_Config(timer1, 50, mytask->fifo, 11, True);
@@ -277,9 +265,13 @@
277265 {
278266 UI_Task *mytask;
279267 uint data;
280- DATA_FIFO32 *mfifo;
268+ IO_MouseControl *mctrl;
269+ UI_Sheet *mouseinfosheet;
270+ uchar s[16];
271+ int scroll;
281272
282273 data = 0;
274+ scroll = 0;
283275
284276 mytask = System_MultiTask_GetNowTask();
285277
@@ -287,15 +279,24 @@
287279 debug("MCT:MouseControlTask Start Running.\nMCT:UI_Task=0x%X\n", mytask);
288280 #endif
289281
290- Initialise_Mouse();
282+ mouseinfosheet = Sheet_Initialise();
283+ Sheet_SetBuffer(mouseinfosheet, Null, (4 * 2) + (8 * 16), 4 + 16 + (4 * 2) + (16 * 4), 8);
284+ System_Sheet_SetParentToVRAM(mouseinfosheet);
285+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0x99cc33, 0, 0, mouseinfosheet->size.x - 1, mouseinfosheet->size.y - 1);
286+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24, mouseinfosheet->size.x - 1 - 4, mouseinfosheet->size.y - 1 - 4);
287+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 4, 0xffffff, "MouseInfo");
291288
289+ mctrl = Initialise_Mouse();
290+
292291 #ifdef CHNOSPROJECT_DEBUG_MCT
293292 debug("MCT:Mouse Initialized.\n");
294293 #endif
295294
296295 MouseCursor_Show(mcursor);
297-// Mouse_Set_ReceiveFIFO(mytask->fifo, 0x100);
296+ Mouse_Set_ReceiveFIFO(mytask->fifo, 0x100);
298297
298+ Mouse_Decode(mctrl, 0x00); //Decode start.
299+
299300 for(;;){
300301 if(FIFO32_MyTaskFIFO_Status() == 0){
301302 System_MultiTask_Task_Sleep(mytask);
@@ -305,9 +306,40 @@
305306 debug("MCT:Receive data from FIFO(data:0x%X).\n", data);
306307 #endif
307308 if(0x100 <= data && data <= 0x1ff){
309+ if(Mouse_Decode(mctrl, data - 0x100)){
310+ MouseCursor_Move_Relative(mcursor, mctrl->move.x, mctrl->move.y);
311+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 0) + 15);
312+ snprintf(s, sizeof(s), "X:%d", mcursor->cursor_sheet->location.x);
313+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 0), 0x000000, s);
314+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 1), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 1) + 15);
315+ snprintf(s, sizeof(s), "Y:%d", mcursor->cursor_sheet->location.y);
316+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 1), 0x000000, s);
317+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 2), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 2) + 15);
318+ snprintf(s, sizeof(s), "Button:lrc");
319+ if(mctrl->button.bit.L){
320+ s[7] -= 0x20;
321+ }
322+ if(mctrl->button.bit.R){
323+ s[8] -= 0x20;
324+ }
325+ if(mctrl->button.bit.C){
326+ s[9] -= 0x20;
327+ }
328+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 2), 0x000000, s);
329+ if(mctrl->flags.scroll){
330+ scroll += mctrl->scroll;
331+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 3), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 3) + 15);
332+ snprintf(s, sizeof(s), "Scroll:%d", scroll);
333+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 3), 0x000000, s);
308334
335+ Sheet_RefreshSheet(mouseinfosheet, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 3) + 15);
336+ } else{
337+ Sheet_RefreshSheet(mouseinfosheet, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 2) + 15);
338+ }
339+ }
309340 } else if(data == TCM_INFO_DISPLAY_UPDATE_RESOLUTION){
310341 MouseCursor_Move_Absolute(mcursor, mcursor->cursor_sheet->parent->size.x >> 1, mcursor->cursor_sheet->parent->size.y >> 1);
342+ Sheet_Show(mouseinfosheet, 2, 200, 200);
311343 }
312344 }
313345 }
--- beta/tolset_chn_000/chnos_010/chnos/mouse.c (revision 319)
+++ beta/tolset_chn_000/chnos_010/chnos/mouse.c (revision 320)
@@ -32,19 +32,22 @@
3232 "***.....................",
3333 };
3434
35-void Initialise_Mouse(void)
35+IO_MouseControl *Initialise_Mouse(void)
3636 {
37+ IO_MouseControl *mctrl;
38+
3739 mouse_data0 = 0;
3840 mouse_fifo = Null;
41+ mouse_retv = 0;
3942
43+ mctrl = (IO_MouseControl *)System_Memory_Allocate(sizeof(IO_MouseControl));
44+
4045 IO_CLI();
4146 System_GateDescriptor_Set(0x2c, (uint)asm_InterruptHandler2c, 0x02, AR_INTGATE32);
4247 ProgrammableInterruptController_InterruptMask_Clear(0x0c);
4348 IO_STI();
4449
45- Mouse_SendCommand(MOUSECMD_ENABLE);
46-
47- return;
50+ return mctrl;
4851 }
4952
5053 void InterruptHandler2c(uint *esp)
@@ -63,6 +66,10 @@
6366 mouse_retv = data;
6467 }
6568
69+ #ifdef CHNOSPROJECT_DEBUG_MOUSE
70+ debug("InterruptHandler2c:IRQ12:0x%02X\n", data);
71+ #endif
72+
6673 return;
6774 }
6875
@@ -200,3 +207,150 @@
200207
201208 return 0;
202209 }
210+
211+bool Mouse_Decode(IO_MouseControl *mctrl, uint data)
212+{
213+ switch(mctrl->decode_phase){
214+//マウス初期化及びスクロールマウス識別
215+ case 0:
216+ Mouse_SendCommand(MOUSECMD_RESET);
217+ mctrl->decode_phase++;
218+ break;
219+ case 1:
220+ if(data == KEYDATA_ACK){
221+ mctrl->decode_phase++;
222+ }
223+ break;
224+ case 2:
225+ if(data == KEYDATA_TEST_SUCCEEDED){
226+ Mouse_SendCommand(MOUSECMD_SET_SAMPLE_RATE);
227+ mctrl->decode_phase++;
228+ }
229+ break;
230+ case 3:
231+ if(data == KEYDATA_ACK){
232+ Mouse_SendCommand(200);
233+ mctrl->decode_phase++;
234+ }
235+ break;
236+ case 4:
237+ if(data == KEYDATA_ACK){
238+ Mouse_SendCommand(MOUSECMD_SET_SAMPLE_RATE);
239+ mctrl->decode_phase++;
240+ }
241+ break;
242+ case 5:
243+ if(data == KEYDATA_ACK){
244+ Mouse_SendCommand(100);
245+ mctrl->decode_phase++;
246+ }
247+ break;
248+ case 6:
249+ if(data == KEYDATA_ACK){
250+ Mouse_SendCommand(MOUSECMD_SET_SAMPLE_RATE);
251+ mctrl->decode_phase++;
252+ }
253+ break;
254+ case 7:
255+ if(data == KEYDATA_ACK){
256+ Mouse_SendCommand(80);
257+ mctrl->decode_phase++;
258+ }
259+ break;
260+ case 8:
261+ if(data == KEYDATA_ACK){
262+ Mouse_SendCommand(MOUSECMD_GET_DEVICE_ID);
263+ mctrl->decode_phase++;
264+ }
265+ break;
266+ case 9:
267+ if(data == KEYDATA_ACK){
268+ mctrl->decode_phase++;
269+ }
270+ break;
271+ case 10:
272+ if(data == MOUSE_TYPE_3BUTTON){
273+ mctrl->decode_phase = 20;
274+ Mouse_SendCommand(MOUSECMD_ENABLE_DATA_REPORTING);
275+ } else if(data == MOUSE_TYPE_3BUTTON_SCROLL){
276+ mctrl->flags.scroll = True;
277+ mctrl->decode_phase = 30;
278+ Mouse_SendCommand(MOUSECMD_ENABLE_DATA_REPORTING);
279+ }
280+ break;
281+//3ボタンマウス解析
282+ case 20:
283+ if(data == KEYDATA_ACK){
284+ mctrl->decode_phase++;
285+ }
286+ break;
287+ case 21:
288+ //1バイト目が、00XY1CRLの形式になっているかどうかチェック
289+ //0xc8=11001000なので、ANDすると必ず00001000になるはずである
290+ if((data & 0xc8) == 0x08){ //1バイト目が、00xx1xxxの形式になっているかどうかチェック 0xc8=11001000なので、ANDすると必ず00001000になるはずである
291+ mctrl->decode_buf[0] = data;
292+ mctrl->decode_phase++;
293+ }
294+ break;
295+ case 22:
296+ mctrl->decode_buf[1] = data;
297+ mctrl->decode_phase++;
298+ break;
299+ case 23:
300+ mctrl->decode_buf[2] = data;
301+ mctrl->decode_phase = 21;
302+ mctrl->button.button = mctrl->decode_buf[0] & 0x07;
303+ mctrl->move.x = mctrl->decode_buf[1];
304+ mctrl->move.y = mctrl->decode_buf[2];
305+ if(mctrl->decode_buf[0] & 0x10){
306+ mctrl->move.x |= 0xffffff00;
307+ }
308+ if(mctrl->decode_buf[0] & 0x20){
309+ mctrl->move.y |= 0xffffff00;
310+ }
311+ mctrl->move.y = -mctrl->move.y;
312+ return True;
313+//3ボタンスクロールマウス解析
314+ case 30:
315+ if(data == KEYDATA_ACK){
316+ mctrl->decode_phase++;
317+ }
318+ break;
319+ case 31:
320+ //1バイト目が、00XY1CRLの形式になっているかどうかチェック
321+ //0xc8=11001000なので、ANDすると必ず00001000になるはずである
322+ if((data & 0xc8) == 0x08){ //1バイト目が、00xx1xxxの形式になっているかどうかチェック 0xc8=11001000なので、ANDすると必ず00001000になるはずである
323+ mctrl->decode_buf[0] = data;
324+ mctrl->decode_phase++;
325+ }
326+ break;
327+ case 32:
328+ mctrl->decode_buf[1] = data;
329+ mctrl->decode_phase++;
330+ break;
331+ case 33:
332+ mctrl->decode_buf[2] = data;
333+ mctrl->button.button = mctrl->decode_buf[0] & 0x07;
334+ mctrl->move.x = mctrl->decode_buf[1];
335+ mctrl->move.y = mctrl->decode_buf[2];
336+ if(mctrl->decode_buf[0] & 0x10){
337+ mctrl->move.x |= 0xffffff00;
338+ }
339+ if(mctrl->decode_buf[0] & 0x20){
340+ mctrl->move.y |= 0xffffff00;
341+ }
342+ mctrl->move.y = -mctrl->move.y;
343+ mctrl->decode_phase++;
344+ break;
345+ case 34:
346+ mctrl->decode_buf[3] = data;
347+ mctrl->decode_phase = 31;
348+ mctrl->scroll = mctrl->decode_buf[3] & 0x0f;
349+ if(mctrl->scroll & 0x08){
350+ mctrl->scroll |= 0xfffffff0;
351+ }
352+ return True;
353+ }
354+
355+ return False;
356+}
--- beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 319)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 320)
@@ -12,7 +12,7 @@
1212 //#define CHNOSPROJECT_DEBUG_CALLBIOS
1313 //#define CHNOSPROJECT_DEBUG_FIFO
1414 //#define CHNOSPROJECT_DEBUG_KBCT
15- //#define CHNOSPROJECT_DEBUG_MCT
15+ #define CHNOSPROJECT_DEBUG_MCT
1616 #define CHNOSPROJECT_DEBUG_MOUSE
1717 //#define CHNOSPROJECT_DEBUG_DISPLAY
1818 //#define CHNOSPROJECT_DEBUG_DRAWING
@@ -209,16 +209,27 @@
209209 /*KBD io port*/
210210 #define PORT_KEYDATA 0x0060
211211 #define PORT_KEYSTA 0x0064
212+#define PORT_KEYCMD 0x0064
213+#define KBC_MODE 0x47 //Keyboard and Mouse Interrupt Enable.
212214 #define KEYSTA_SEND_NOTREADY 0x02
215+#define KEYDATA_ACK 0xfa
216+#define KEYDATA_RESEND 0xfe
217+#define KEYDATA_TEST_SUCCEEDED 0xaa
218+#define KEYDATA_TEST_FAILED 0xfc
213219 #define KEYCMD_WRITE_8042_MODE_REG 0x60
214-#define KBC_MODE 0x47 //Keyboard and Mouse Interrupt Enable.
215-#define PORT_KEYCMD 0x0064
216220 #define KEYCMD_SENDTO_MOUSE 0xd4
217221 #define KEYCMD_LED 0xed
218-#define KEYDATA_ACK 0xfa
219-#define KEYDATA_RESEND 0xfe
220-#define MOUSECMD_ENABLE 0xf4
221222
223+/*Mouse*/
224+#define MOUSECMD_RESET 0xff
225+//#define MOUSECMD_SET_DEFAULTS 0xf6
226+//#define MOUSECMD_DISABLE_DATA_REPORTING 0xf5
227+#define MOUSECMD_ENABLE_DATA_REPORTING 0xf4
228+#define MOUSECMD_SET_SAMPLE_RATE 0xf3
229+#define MOUSECMD_GET_DEVICE_ID 0xf2
230+#define MOUSE_TYPE_3BUTTON 0x00
231+#define MOUSE_TYPE_3BUTTON_SCROLL 0x03
232+
222233 /*COM1 io port*/
223234 #define COM1_RX 0x03f8
224235 #define COM1_TX 0x03f8
--- beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 319)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 320)
@@ -524,6 +524,24 @@
524524
525525 /*mouse*/
526526
527+typedef struct IO_MOUSE_CONTROL {
528+ uint decode_phase;
529+ uchar decode_buf[4];
530+ DATA_Location2D move;
531+ int scroll;
532+ struct IO_MOUSE_CONTROL_FLAGS {
533+ unsigned scroll : 1;
534+ } flags;
535+ union IO_MOUSE_CONTROL_BUTTON {
536+ uchar button;
537+ struct IO_MOUSE_CONTROL_BUTTON_BIT {
538+ unsigned L : 1;
539+ unsigned R : 1;
540+ unsigned C : 1;
541+ } bit;
542+ } button;
543+} IO_MouseControl;
544+
527545 typedef struct UI_MOUSE_CURSOR {
528546 UI_Sheet *cursor_sheet;
529547 struct UI_MOUSE_CURSOR_FLAGS {
旧リポジトリブラウザで表示